/* ─── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --brand:        #2563eb;
    --brand-dark:   #1d4ed8;
    --danger:       #dc2626;
    --success:      #16a34a;
    --warning:      #d97706;
    --gray-50:      #f9fafb;
    --gray-100:     #f3f4f6;
    --gray-200:     #e5e7eb;
    --gray-400:     #9ca3af;
    --gray-600:     #4b5563;
    --gray-800:     #1f2937;
    --sidebar-w:    240px;
    --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body { font-family: var(--font); font-size: 14px; color: var(--gray-800); background: var(--gray-50); }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: #111827;
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.main-content {
    margin-left: var(--sidebar-w);
    padding: 32px;
    flex: 1;
    min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────────────── */
.sidebar-brand {
    padding: 20px 16px;
    border-bottom: 1px solid #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-name { font-size: 16px; font-weight: 700; color: #fff; }
.brand-name   { font-size: 16px; font-weight: 700; color: #fff; }
.brand-badge  { font-size: 10px; background: var(--brand); color: #fff; padding: 2px 6px; border-radius: 4px; }
.sidebar-logo { max-height: 36px; max-width: 160px; object-fit: contain; }

.nav-links { list-style: none; padding: 12px 0; flex: 1; }
.nav-links li a {
    display: block;
    padding: 8px 16px;
    color: #9ca3af;
    font-size: 13px;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}
.nav-links li a:hover,
.nav-links li a.active {
    color: #fff;
    background: #1f2937;
    border-left-color: var(--brand);
    text-decoration: none;
}
.nav-divider  { height: 1px; background: #374151; margin: 8px 0; }
.nav-section  { padding: 8px 16px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #6b7280; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid #374151;
}
.sidebar-user { display: block; font-size: 12px; color: #9ca3af; margin-bottom: 8px; }

/* ─── Test Mode Banner ──────────────────────────────────────────────── */
.test-mode-banner {
    background: #fef3c7;
    border-bottom: 2px solid #f59e0b;
    color: #92400e;
    text-align: center;
    padding: 8px;
    font-size: 13px;
    font-weight: 600;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 200;
}
.test-mode-banner ~ .layout { margin-top: 38px; }
.test-mode-banner ~ .layout .sidebar { top: 38px; }

/* ─── Page Header ───────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 700; }

/* ─── Cards ─────────────────────────────────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-header h2 { margin-bottom: 0; }

/* ─── Stats Grid ────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 20px;
}
.stat-label { font-size: 12px; color: var(--gray-600); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--gray-800); }
.stat-sub   { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* ─── Dashboard Grid ────────────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

/* ─── Tables ────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--gray-100); }
.data-table th { font-weight: 600; color: var(--gray-600); background: var(--gray-50); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }
.data-table th:first-child, .data-table td:first-child { padding-left: 0; }

/* ─── Buttons ───────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-danger, .btn-logout {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-primary   { background: var(--brand); color: #fff; }
.btn-primary:hover  { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--gray-100); color: var(--gray-800); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); text-decoration: none; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; text-decoration: none; color: #fff; }
.btn-warning   { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; text-decoration: none; color: #fff; }
.btn-logout    { background: transparent; color: #9ca3af; padding: 6px 0; font-size: 12px; width: 100%; }
.btn-logout:hover { color: #fff; }
.btn-full      { width: 100%; justify-content: center; }
.btn-sm        { padding: 5px 10px; font-size: 12px; }

/* ─── Forms ─────────────────────────────────────────────────────────── */
.field        { margin-bottom: 16px; }
.field label  { display: block; font-size: 12px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em; }
.field input, .field select, .field textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.field small  { display: block; font-size: 11px; color: var(--gray-400); margin-top: 4px; }
.field-error  { color: var(--danger); font-size: 12px; margin-top: 4px; }

.field-inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.field-inline label { margin-bottom: 0; white-space: nowrap; }
.field-inline input { flex: 1; min-width: 0; }

.inline-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }

/* ─── Alerts ────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ─── Badges ────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red   { background: #fee2e2; color: #991b1b; }
.badge-gray  { background: var(--gray-100); color: var(--gray-600); }
.badge-blue  { background: #dbeafe; color: #1e40af; }
.badge-yellow { background: #fef3c7; color: #92400e; }

/* ─── Auth Pages ────────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--gray-50); }
.auth-card { background: #fff; border: 1px solid var(--gray-200); border-radius: 10px; padding: 40px; width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-sub { color: var(--gray-400); font-size: 13px; margin-bottom: 24px; }

/* ─── Master body ───────────────────────────────────────────────────── */
.master-body { background: #0f172a; }
.master-body .sidebar { background: #0f172a; }
.master-body .main-content { background: #1e293b; color: #e2e8f0; }
.master-body .card { background: #0f172a; border-color: #334155; color: #e2e8f0; }
.master-body .data-table th { background: #1e293b; color: #94a3b8; }
.master-body .data-table td { border-color: #334155; }
.master-body .stat-card { background: #0f172a; border-color: #334155; }
.master-body .stat-value { color: #f1f5f9; }
.master-body .auth-wrap { background: #0f172a; }
.master-body .auth-card { background: #1e293b; border-color: #334155; color: #e2e8f0; }

/* ─── License Page ──────────────────────────────────────────────────── */
.license-status { display: flex; align-items: center; gap: 12px; }
.license-key    { font-family: monospace; font-size: 13px; color: var(--gray-600); }
.key-list       { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.key-list li code { display: block; padding: 8px 12px; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 6px; font-size: 14px; }

/* ─── Utilities ─────────────────────────────────────────────────────── */
.mt-2  { margin-top: 8px; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.empty-state { color: var(--gray-400); font-style: italic; padding: 16px 0; }
code { font-family: monospace; font-size: 12px; background: var(--gray-100); padding: 2px 6px; border-radius: 4px; }
.action-links { display: flex; gap: 12px; flex-wrap: wrap; }
