:root {
    --bg: #0f172a;
    --panel: #ffffff;
    --ink: #1e293b;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --danger: #dc2626;
    --ok: #16a34a;
    --radius: 10px;
}

* { box-sizing: border-box; }

/* Honor the HTML `hidden` attribute even when author rules set display on the element. */
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: #f1f5f9;
    line-height: 1.5;
}

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

/* ---- Top bar ---- */
.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    background: #0f172a;
    color: #e2e8f0;
    padding: 0 20px;
    height: 56px;
}
.topbar .brand { color: #fff; font-weight: 700; font-size: 18px; }
.topbar nav { display: flex; gap: 18px; flex: 1; }
.topbar nav a { color: #cbd5e1; font-size: 14px; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.whoami { font-size: 13px; color: #94a3b8; }

/* ---- Layout ---- */
.container { max-width: 960px; margin: 28px auto; padding: 0 20px; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 14px; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-head h1 { margin: 0; }

/* ---- Cards ---- */
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}
.cards { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.stat { display: block; min-width: 150px; text-align: center; transition: transform .06s; }
.stat:hover { text-decoration: none; transform: translateY(-2px); }
.stat-num { font-size: 34px; font-weight: 700; color: var(--brand); }
.stat-label { color: var(--muted); text-transform: uppercase; font-size: 12px; letter-spacing: .05em; }

/* ---- Forms ---- */
.form label, .subform label { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
.form input[type=text], .form input[type=email], .form input[type=password],
.form select, .auth-card input {
    width: 100%;
    margin-top: 6px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 400;
    background: #fff;
}
.form textarea {
    width: 100%;
    margin-top: 6px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 400;
    font-family: inherit;
    resize: vertical;
    min-height: 150px;
    line-height: 1.55;
}
.form input:focus, .form select:focus, .form textarea:focus, .auth-card input:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ---- Call Log form ---- */
.call-form { max-width: 760px; padding: 26px 28px; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.req { color: var(--danger); font-weight: 700; }

.field-block { margin-bottom: 22px; }
.field-block > .field-label {
    display: block; font-weight: 600; font-size: 14px; margin-bottom: 8px; color: var(--ink);
}

.call-section {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px 18px 6px;
    margin-bottom: 22px;
    background: #fbfcfe;
}
.call-section > .section-title {
    font-weight: 700; font-size: 14px; margin: 0 0 14px; color: var(--ink);
    display: flex; align-items: center; gap: 8px;
}
.call-section > .section-title::before {
    content: ""; width: 4px; height: 15px; border-radius: 2px; background: var(--brand);
}
.section-hint { font-weight: 400; font-size: 12px; color: var(--muted); }

/* Selectable option chips (checkboxes rendered as cards) */
.chip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 12px; }
.chip {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
    background: #fff; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--ink);
    transition: border-color .1s, background .1s, box-shadow .1s;
    user-select: none;
}
.chip:hover { border-color: #c7d2e0; background: #f8fafc; }
.chip input { width: auto; margin: 0; accent-color: var(--brand); flex-shrink: 0; }
.chip:has(input:checked) {
    border-color: var(--brand); background: #eff6ff; color: var(--brand-dark);
    box-shadow: inset 0 0 0 1px var(--brand);
}

.other-field { margin: 4px 0 12px; }
.call-form .actions { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 4px; }
.call-form .btn-primary { padding: 11px 28px; font-size: 15px; }
.form input:disabled { background: #f8fafc; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.subform { border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin: 6px 0 18px; }
.subform legend { font-weight: 700; font-size: 14px; padding: 0 6px; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.checks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.check { font-weight: 400 !important; display: flex; align-items: center; gap: 8px; margin: 0 !important; }
.check input { width: auto; margin: 0; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.btn:hover { text-decoration: none; background: #f8fafc; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: #cbd5e1; cursor: pointer; font-size: 14px; padding: 0; }
.btn-link:hover { color: #fff; text-decoration: underline; }
.inline { display: inline; margin: 0; }

/* ---- Table ---- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---- Pills ---- */
.pill {
    display: inline-block; padding: 2px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 600; background: #eff6ff; color: var(--brand-dark);
    margin: 2px 2px 2px 0;
}
.pill-admin { background: #fef3c7; color: #92400e; }
.pill-ok { background: #dcfce7; color: #166534; }
.pill-off { background: #f1f5f9; color: var(--muted); }

/* ---- Flash ---- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ---- Auth ---- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; margin: 0; }
.auth-title { text-align: center; margin: 0 0 4px; }
.auth-sub { text-align: center; color: var(--muted); margin: 0 0 22px; }
.auth-card label { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
.auth-card .btn { margin-top: 6px; }

.error-card { text-align: center; }
.error-card h1 { font-size: 56px; color: var(--brand); margin-bottom: 4px; }

@media (max-width: 600px) {
    .grid-2 { grid-template-columns: 1fr; }
    .topbar { gap: 12px; padding: 0 12px; }
    .topbar nav { gap: 12px; }
}
