* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #00d4ff;
    --brand-purple: #a855f7;
    --brand-gradient: linear-gradient(135deg, #a855f7 0%, #3b82f6 52%, #00d4ff 100%);
    --bg: #0b1120;
    --surface: #141c33;
    --surface-2: #1c2747;
    --border: rgba(168, 85, 247, 0.32);
    --text: #f8fafc;
    --muted: #94a3b8;
    --danger: #ef4444;
    --success: #22c55e;
}

.brand-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.brand-logo-login {
    width: min(260px, 85%);
    height: auto;
    display: block;
}

.brand-logo-topbar {
    height: 36px;
    width: auto;
    display: block;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
code {
    background: rgba(0, 212, 255, 0.12);
    color: var(--primary);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* Login */
.login-view {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    background: #060916;
}

.iot-bg-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.login-card {
    position: relative;
    z-index: 2;
    background: rgba(20, 28, 51, 0.86);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    width: min(400px, 100%);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.login-card h1 { font-size: 22px; color: var(--primary); margin-bottom: 6px; }
.subtitle { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

.login-footer {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    color: var(--muted);
}

.link { color: var(--primary); text-decoration: none; font-size: 14px; }
.link:hover { text-decoration: underline; }

/* Admin Layout */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar h1 { font-size: 18px; color: var(--primary); }

.badge {
    background: rgba(0, 212, 255, 0.15);
    color: var(--primary);
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.tabs {
    display: flex;
    gap: 8px;
    padding: 14px 24px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    overflow-x: auto;
}

.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-panel {
    padding: 24px;
    max-width: 1280px;
    margin: 0 auto;
}

.panel-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 20px;
}

.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.toolbar-select {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 8px 10px;
    font-size: 13px;
}

.company-logo-box {
    height: 64px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed rgba(255, 255, 255, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    overflow: hidden;
}

.company-logo-box img {
    max-height: 48px;
    max-width: 100%;
    object-fit: contain;
}

.logo-preview-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    background: #0d1426;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.logo-preview-wrap img {
    max-height: 48px;
    max-width: 180px;
    object-fit: contain;
}

/* Modal Enrolamiento Facial */
.face-video-wrap {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    border: 1.5px solid var(--border);
    margin-bottom: 12px;
}

.face-video-wrap video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.face-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.face-samples-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #0d1426;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 13px;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 16px;
}

.machine-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.machine-card.disabled { opacity: 0.55; }

.machine-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.machine-card h3 { font-size: 16px; color: var(--text); }
.machine-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.card-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.discover-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 18px;
}

/* Table */
.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.data-table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }

/* Forms & Buttons */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; flex: 1; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input, .field select {
    background: #0d1426;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 14px;
    width: 100%;
}

.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }

.checks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    padding: 10px;
    background: #0d1426;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}

.check input { width: auto; accent-color: var(--primary); }

.btn {
    padding: 9px 14px;
    border-radius: 8px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-primary { background: var(--brand-gradient); color: #ffffff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid rgba(255, 255, 255, 0.12); }
.btn-danger { background: rgba(239, 68, 68, 0.18); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.4); }
.full-width { width: 100%; }

.error-msg { color: #fca5a5; font-size: 13px; margin-bottom: 12px; }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
}

.modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
    width: min(640px, 100%);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-card.small { width: min(440px, 100%); }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 26px;
    cursor: pointer;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--surface-2);
    border: 1px solid var(--primary);
    color: var(--text);
    padding: 12px 18px;
    border-radius: 10px;
    z-index: 2000;
    font-size: 13px;
}

@media (max-width: 640px) {
    .topbar, .tab-panel { padding: 14px; }
    .form-row { flex-direction: column; gap: 0; }
}
