/* FaceAttend - admin UI */
:root {
    --bg: #f4f6fa;
    --panel: #ffffff;
    --ink: #1d2433;
    --ink-2: #5b6578;
    --line: #e3e7ef;
    --brand: #4338ca;
    --brand-ink: #ffffff;
    --brand-soft: #eef0ff;
    --side: #111827;
    --side-ink: #cbd2de;
    --green: #15803d; --green-soft: #dcfce7;
    --red: #b91c1c;   --red-soft: #fee2e2;
    --amber: #b45309; --amber-soft: #fef3c7;
    --blue: #1d4ed8;  --blue-soft: #dbeafe;
    --grey: #4b5563;  --grey-soft: #eceff3;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink); background: var(--bg);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--grey-soft); padding: 1px 5px; border-radius: 4px; }
pre { background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: 8px; overflow-x: auto; line-height: 1.45; }
pre code { background: none; padding: 0; color: inherit; }
h1, h2, h3, h4 { margin: 0 0 .6em; line-height: 1.25; }
h2 { font-size: 18px; } h3 { font-size: 15px; } h4 { font-size: 14px; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.center { text-align: center; justify-content: center; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* ---------------- layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; flex: 0 0 250px; background: var(--side); color: var(--side-ink);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 14px; }
.brand-mark {
    width: 36px; height: 36px; border-radius: 9px; background: var(--brand); color: #fff;
    display: grid; place-items: center; font-weight: 700; letter-spacing: .5px;
}
.brand-name { color: #fff; font-weight: 600; }
.brand-sub { font-size: 12px; opacity: .75; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; }
.sidebar nav a {
    color: var(--side-ink); padding: 9px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center;
}
.sidebar nav a svg { width: 18px; height: 18px; fill: currentColor; opacity: .85; flex: none; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 11px; opacity: .5; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--panel);
    border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; }
.menu-toggle { display: none; }
.content { padding: 22px 24px 40px; max-width: 1400px; width: 100%; }

/* ---------------- dropdown */
.dropdown { position: relative; }
.user-chip { border: 1px solid var(--line); background: var(--panel); border-radius: 20px; padding: 6px 12px; cursor: pointer; font: inherit; }
.dropdown-menu {
    display: none; position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); min-width: 210px;
    border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 8px; z-index: 30;
}
.dropdown.open .dropdown-menu { display: flex; flex-direction: column; gap: 2px; }
.dropdown-menu a, .dropdown-menu span { padding: 7px 10px; border-radius: 6px; }
.dropdown-menu a { color: var(--ink); }
.dropdown-menu a:hover { background: var(--bg); text-decoration: none; }

/* ---------------- cards / grid */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; flex: 1; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--ink-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--ink-2); }
.chart-box { position: relative; height: 260px; }

/* ---------------- tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); background: #fafbfd; white-space: nowrap; }
.table tbody tr:hover { background: #fafbfd; }
.table td.actions { white-space: nowrap; text-align: right; }
.table .empty { text-align: center; color: var(--ink-2); padding: 28px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--grey-soft); display: inline-block; vertical-align: middle; }
.thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; }

/* ---------------- badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-grey { background: var(--grey-soft); color: var(--grey); }

/* ---------------- buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
    color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; line-height: 1.2;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: #1d4fd6; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn-link { border: 0; background: none; color: var(--brand); padding: 4px 6px; cursor: pointer; font: inherit; }
.btn-link.danger { color: var(--red); }
.icon-btn { border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--ink-2); padding: 4px 8px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------- forms */
.form { display: grid; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .hint { font-weight: 400; color: var(--ink-2); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url],
input[type=search], input:not([type]), select, textarea {
    font: inherit; padding: 8px 10px; border: 1px solid #cfd6e2; border-radius: 8px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[readonly] { background: var(--bg); }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 400 !important; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.filters input, .filters select { min-width: 150px; padding: 6px 9px; }
.preview-box { display: flex; gap: 8px; flex-wrap: wrap; }
.preview-box img { width: 70px; height: 70px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* ---------------- alerts */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: var(--green-soft); color: var(--green); border-color: #bbf7d0; }
.alert-error { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.alert-info { background: var(--blue-soft); color: var(--blue); border-color: #bfdbfe; }
.alert-warning { background: var(--amber-soft); color: var(--amber); border-color: #fde68a; }

/* ---------------- modal */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: none; align-items: flex-start; justify-content: center; padding: 50px 16px; z-index: 100; overflow-y: auto; }
.modal.open { display: flex; }
.modal-box { background: var(--panel); border-radius: 12px; width: 100%; max-width: 640px; padding: 20px 22px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-box.small { max-width: 440px; }
.modal-box.large { max-width: 860px; }
.modal-head { display: flex; align-items: center; margin-bottom: 12px; }
.modal-head h3 { flex: 1; margin: 0; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---------------- toasts */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #111827; color: #fff; padding: 11px 16px; border-radius: 8px; max-width: 380px; white-space: pre-line;
    box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: all .25s; }
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--red); }
.toast-success { background: #166534; }
.spinner { width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- pager */
.pager { display: flex; gap: 4px; align-items: center; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.pager .muted { margin-right: auto; }
.pager a { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--panel); }
.pager a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager a:hover { text-decoration: none; }

/* ---------------- tabs & docs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 9px 14px; cursor: pointer; font: inherit; color: var(--ink-2); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--brand); border-color: var(--brand); font-weight: 600; }
.doc h3 { margin-top: 22px; }
.doc ol, .doc ul { padding-left: 20px; }
.doc li { margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: 180px 1fr auto auto; gap: 8px 12px; align-items: center; }
.kv .k { color: var(--ink-2); font-size: 13px; }
.kv .v { font-family: var(--mono); word-break: break-all; background: var(--bg); padding: 6px 10px; border-radius: 6px; }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps > li { position: relative; padding-left: 44px; margin-bottom: 18px; }
.steps > li::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: -2px;
    width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }
.lcd { display: inline-block; background: #1e3a1e; color: #9eff9e; font-family: var(--mono); padding: 8px 12px; border-radius: 6px; line-height: 1.3; white-space: pre; letter-spacing: 1px; }
.photo-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-grid img { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* ---------------- auth */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 20px;
    background: radial-gradient(circle at 20% 20%, #dbe7ff, transparent 40%), var(--bg); }
.auth-card { background: var(--panel); width: 100%; max-width: 400px; padding: 30px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.auth-card.wide { max-width: 560px; }
.brand-title { text-align: center; font-size: 22px; margin: 10px 0 4px; }
.checklist { list-style: none; padding: 0; }
.checklist .ok { color: var(--green); } .checklist .bad { color: var(--red); }

/* ---------------- responsive */
@media (max-width: 1000px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .kv { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
    .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s; }
    .sidebar.open { left: 0; }
    .menu-toggle { display: inline-block; }
    .content { padding: 16px; }
    .form .row { grid-template-columns: 1fr; }
    .topbar { padding: 12px 16px; }
}

/* Auth server: serial numbers never wrap; long action lists wrap instead of widening the table */
.table td.mono { white-space: nowrap; }
.table td.actions.wrap { white-space: normal; min-width: 170px; max-width: 230px; text-align: left; line-height: 1.9; }
.table td.actions.wrap > * { margin-right: 8px; }
