:root {
    --bg: #f1f5f9;
    --panel: #ffffff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #1d4ed8;
    --brand-dark: #1e3a8a;
    --ok: #16a34a;
    --warn: #d97706;
    --error: #dc2626;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.45;
}

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

h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.hint { color: var(--muted); font-weight: 400; font-size: .8rem; }

/* ---------- Login ---------- */
.auth-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
    background: linear-gradient(135deg, #1e3a8a, #2563eb 55%, #0ea5e9);
}
.auth-card {
    width: 100%; max-width: 400px; background: #fff; border-radius: 16px;
    padding: 32px; box-shadow: 0 20px 45px rgba(2, 6, 23, .35);
}
.auth-card h1 { text-align: center; }
.auth-card .muted { text-align: center; margin-top: 0; }
.auth-logo { text-align: center; font-size: 2.4rem; }
.demo-box {
    margin-top: 18px; padding: 12px 14px; background: #f8fafc;
    border: 1px dashed var(--line); border-radius: 10px; font-size: .85rem;
}
.demo-box b { display: block; margin-bottom: 4px; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 5px; font-size: .85em; }

/* ---------- Layout ---------- */
.topbar { background: var(--brand-dark); color: #fff; box-shadow: var(--shadow); }
.topbar-inner {
    max-width: 1180px; margin: 0 auto; padding: 10px 18px;
    display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: .3px; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a { color: #c7d2fe; padding: 6px 10px; border-radius: 8px; font-size: .9rem; }
.nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; color: #fff; }
.nav a.on { background: #fff; color: var(--brand-dark); font-weight: 600; }
.nav .who { color: #e0e7ff; font-size: .85rem; padding: 0 6px; }
.nav .logout { color: #fecaca; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 18px 60px; }
.footer {
    max-width: 1180px; margin: 0 auto; padding: 0 18px 30px;
    display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem;
}

.page-head { margin-bottom: 18px; }
.page-head .actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px;
}
.card .num { font-size: 1.7rem; font-weight: 700; color: var(--brand); }
.card .lbl { color: var(--muted); font-size: .85rem; }

/* ---------- Panels ---------- */
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.panel {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .3px; }
.tbl tbody tr:hover { background: #f8fafc; }

/* ---------- Pills ---------- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.pill-ok { background: #dcfce7; color: #166534; }
.pill-warn { background: #fef3c7; color: #92400e; }
.pill-off { background: #e2e8f0; color: #475569; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block; padding: 8px 14px; border: 1px solid var(--line); background: #fff;
    color: var(--ink); border-radius: 9px; cursor: pointer; font-size: .88rem; font-weight: 500;
    text-decoration: none; line-height: 1.2;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--error); }
.btn-danger:hover { background: #fef2f2; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-xs { padding: 3px 8px; font-size: .75rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 10px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=number], input[type=file], select, textarea {
    width: 100%; padding: 9px 11px; margin-top: 5px; border: 1px solid var(--line);
    border-radius: 9px; font-size: .9rem; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; align-items: end; }
.form-grid .actions { grid-column: 1 / -1; }
.form-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=text] { width: auto; min-width: 220px; margin-top: 0; }
.filters select { width: auto; margin-top: 0; }
.inline-label { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 0; }
.inline-label select { width: auto; margin-top: 0; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input[type=checkbox] { width: auto; margin: 0; }

/* ---------- Alerts ---------- */
.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .88rem; border: 1px solid transparent; }
.alert-ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.install-log { margin: 8px 0 18px; padding-left: 20px; color: #334155; }

/* ---------- Kiosk / camera ---------- */
.kiosk-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
@media (max-width: 760px) { .kiosk-grid { grid-template-columns: 1fr; } }
.cam-wrap { position: relative; border-radius: 12px; overflow: hidden; background: #0f172a; aspect-ratio: 4 / 3; }
.cam-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cam-status {
    position: absolute; left: 10px; bottom: 10px; background: rgba(15,23,42,.7); color: #fff;
    padding: 5px 10px; border-radius: 8px; font-size: .8rem;
}
.kiosk-side { display: flex; flex-direction: column; gap: 10px; }
.match-box {
    padding: 14px; border-radius: 10px; background: #f8fafc; border: 1px solid var(--line);
    min-height: 62px; font-size: .95rem;
}
.log { max-height: 260px; overflow-y: auto; border-top: 1px solid var(--line); padding-top: 8px; }
.log-line { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .85rem; }
.log-line.ok { color: #166534; }
