:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --bg: #f4f6fb;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --sidebar-bg: #111827;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #2563eb;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { text-decoration: none; color: inherit; }

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
}
.login-box {
    background: #fff;
    width: 380px;
    max-width: 92vw;
    padding: 36px 32px;
    border-radius: var(--radius);
    box-shadow: 0 20px 45px rgba(0,0,0,.25);
}
.login-box h2 { margin: 0 0 4px; font-size: 22px; }
.login-box p.sub { margin: 0 0 24px; color: var(--text-muted); font-size: 14px; }
.login-box .form-group { margin-bottom: 16px; }

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
}
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
textarea { resize: vertical; min-height: 80px; }

.btn {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}
.btn:hover { background: var(--primary-dark); }
.btn.full { width: 100%; }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.warning { background: var(--warning); }
.btn.small { padding: 6px 12px; font-size: 12px; }
.btn.outline { background: #fff; border: 1px solid var(--border); color: var(--text); }

.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 20px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar .brand {
    padding: 0 20px 20px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid #1f2937;
    margin-bottom: 10px;
}
.sidebar .brand small { display: block; font-size: 11px; font-weight: 400; color: #9ca3af; }
.sidebar a.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    font-size: 14px;
    color: var(--sidebar-text);
    border-left: 3px solid transparent;
}
.sidebar a.nav-link:hover { background: #1f2937; color: #fff; }
.sidebar a.nav-link.active { background: #1f2937; color: #fff; border-left-color: var(--sidebar-active); }
.sidebar .logout-link { margin-top: 20px; border-top: 1px solid #1f2937; padding-top: 14px; }

.main { flex: 1; min-width: 0; }
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 14px 26px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.topbar h1 { font-size: 19px; margin: 0; }
.topbar .user-chip { font-size: 13px; color: var(--text-muted); }
.content { padding: 24px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 18px 20px; border: 1px solid var(--border); }
.stat-card .num { font-size: 26px; font-weight: 700; margin: 4px 0; }
.stat-card .label { font-size: 13px; color: var(--text-muted); }

.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card h3 { margin: 0 0 16px; font-size: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:hover td { background: #f8fafc; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.yellow { background: #fef3c7; color: #92400e; }
.badge.blue { background: #dbeafe; color: #1e40af; }
.badge.gray { background: #f1f5f9; color: #475569; }

.alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert.success { background: #dcfce7; color: #166534; }
.alert.error { background: #fee2e2; color: #991b1b; }

.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }
.form-group { margin-bottom: 14px; }

.face-box { position: relative; width: 320px; max-width: 100%; margin: 0 auto; }
.face-box video, .face-box canvas { width: 100%; border-radius: 12px; background: #000; }
.face-box canvas { position: absolute; top: 0; left: 0; }
.face-status { text-align: center; margin-top: 12px; font-size: 14px; font-weight: 600; }

@media (max-width: 900px) {
    .sidebar { position: fixed; left: -240px; z-index: 50; transition: left .2s; }
    .sidebar.open { left: 0; }
    .app { display: block; }
    .main { width: 100%; }
}
