:root {
    --brand: #2563eb;
    --sidebar: #0f172a;
    --sidebar-w: 256px;
    --bg: #f1f5f9;
    --card-border: #e2e8f0;
    --muted: #64748b;
}

html { font-size: 15px; }
body { background: var(--bg); color: #0f172a; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
a { color: var(--brand); }

.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: color-mix(in srgb, var(--brand) 85%, #000); border-color: color-mix(in srgb, var(--brand) 85%, #000); color: #fff; }
.btn-outline-brand { border-color: var(--brand); color: var(--brand); }
.btn-outline-brand:hover { background: var(--brand); color: #fff; }
.text-brand { color: var(--brand) !important; }
/* ASP.NET renders an empty validation summary when there are no errors; only show it once it has messages. */
.validation-summary-valid { display: none !important; }
.validation-summary-errors ul { margin-bottom: 0; padding-left: 1.1rem; }
.bg-brand-soft { background: color-mix(in srgb, var(--brand) 10%, #fff); }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--brand) 20%, transparent); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.pagination .page-item.active .page-link { background: var(--brand); border-color: var(--brand); }
.pagination .page-link { color: var(--brand); }

/* ---------- App shell ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--sidebar); color: #cbd5e1;
    overflow-y: auto; z-index: 1040; transition: transform .2s ease; padding-bottom: 2rem;
}
.sidebar .brand { display: flex; gap: .75rem; align-items: center; padding: 1.1rem 1.1rem 1rem; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand img { max-width: 44px; max-height: 44px; border-radius: 8px; background: #fff; padding: 2px; }
.brand-mark { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 1.25rem; flex: none; }
.brand-mark.lg { width: 60px; height: 60px; font-size: 1.8rem; border-radius: 16px; }
.brand-title { display: block; font-weight: 600; line-height: 1.2; }
.brand-sub { display: block; font-size: .78rem; color: #94a3b8; }
.sidebar .nav { padding: .5rem .6rem; }
.sidebar .nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 1rem .75rem .35rem; }
.sidebar .nav-link { color: #cbd5e1; border-radius: 8px; padding: .5rem .75rem; display: flex; align-items: center; gap: .7rem; font-size: .93rem; }
.sidebar .nav-link i { font-size: 1.05rem; opacity: .85; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active { background: var(--brand); color: #fff; }
.sidebar-backdrop { display: none; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; background: #fff; border-bottom: 1px solid var(--card-border); padding: .65rem 1.5rem; }
.page-title { font-size: 1.2rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { padding: 1.5rem; flex: 1; }
.app-footer { color: var(--muted); font-size: .8rem; padding: 1rem 1.5rem; border-top: 1px solid var(--card-border); }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .main { margin-left: 0; }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1030; }
    .content { padding: 1rem; }
    .topbar { padding: .6rem 1rem; }
}

/* ---------- Auth pages ---------- */
body.auth { background: radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--brand) 18%, #fff), var(--bg) 55%); min-height: 100vh; }
.auth-wrap { max-width: 460px; margin: 0 auto; padding: 3rem 1rem; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand img { max-height: 70px; }
.auth-card { background: #fff; border: 1px solid var(--card-border); border-radius: 16px; padding: 1.75rem; box-shadow: 0 10px 30px rgba(15,23,42,.06); }
.auth-card h1 { font-size: 1.4rem; }
@media (max-width: 575.98px) {
    .auth-wrap { padding: 1.75rem .9rem; }
    .auth-brand { margin-bottom: 1rem; }
    .auth-brand .brand-mark.lg { width: 52px; height: 52px; font-size: 1.5rem; }
    .auth-card { padding: 1.25rem; border-radius: 14px; }
}
.auth-card .col-md-4, .auth-card .col-md-6, .auth-card .col-md-offset-2 { width: 100%; flex: 0 0 100%; max-width: 100%; margin-left: 0; }
.auth-card .row > .col-md-6:not(:first-child) { display: none; } /* hide external-login column */

/* ---------- Components ---------- */
.card { border: 1px solid var(--card-border); border-radius: 14px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--card-border); font-weight: 600; border-radius: 14px 14px 0 0 !important; padding: .85rem 1.1rem; }
.stat { display: flex; gap: 1rem; align-items: center; }
.stat .icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; font-size: 1.35rem; flex: none; }
.stat .value { font-size: 1.65rem; font-weight: 700; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .85rem; }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #f8fafc; }
.table-hover tbody tr { cursor: default; }
.badge-status { font-weight: 600; }
.status-Submitted { background: #dbeafe; color: #1e40af; }
.status-UnderReview { background: #fef3c7; color: #92400e; }
.status-Acknowledged { background: #dcfce7; color: #166534; }
.status-Closed { background: #e2e8f0; color: #334155; }
.status-Void { background: #fee2e2; color: #991b1b; }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.bar-chart .bar { flex: 1; background: color-mix(in srgb, var(--brand) 75%, #fff); border-radius: 6px 6px 0 0; position: relative; min-height: 2px; }
.bar-chart .bar:hover { background: var(--brand); }
.bar-chart .bar span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: .7rem; color: var(--muted); }
.bar-labels { display: flex; gap: 6px; font-size: .68rem; color: var(--muted); }
.bar-labels div { flex: 1; text-align: center; }
.hbar { height: 8px; background: #e2e8f0; border-radius: 8px; overflow: hidden; }
.hbar > div { height: 100%; background: var(--brand); border-radius: 8px; }
.empty-state { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .6; }
.signature-preview { max-width: 320px; max-height: 140px; border-bottom: 1px solid #94a3b8; background: repeating-linear-gradient(0deg, #fff, #fff 22px, #f8fafc 22px, #f8fafc 23px); }
.kv dt { color: var(--muted); font-weight: 500; font-size: .85rem; }
.kv dd { margin-bottom: .6rem; }
.token-chip { font-family: Consolas, monospace; font-size: .78rem; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 6px; padding: 1px 6px; cursor: pointer; display: inline-block; margin: 2px; }
.token-chip:hover { background: color-mix(in srgb, var(--brand) 12%, #fff); }
.nav-pills .nav-link.active { background: var(--brand); }
.nav-pills .nav-link { color: #334155; }
.explanation { white-space: pre-wrap; background: #f8fafc; border-left: 4px solid var(--brand); padding: .8rem 1rem; border-radius: 0 8px 8px 0; }

/* ---------- Public (employee) pages ---------- */
body.public { background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 14%, #fff) 0, var(--bg) 280px); min-height: 100vh; }
.public-wrap { max-width: 640px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.public-header { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.public-header img { max-height: 46px; }
.public-card { background: #fff; border-radius: 18px; border: 1px solid var(--card-border); padding: 1.4rem; box-shadow: 0 10px 30px rgba(15,23,42,.06); }
.timer-pill { display: inline-flex; align-items: center; gap: .35rem; background: #fff7ed; color: #9a3412; border-radius: 999px; padding: .25rem .75rem; font-size: .85rem; font-weight: 600; }
.timer-pill.danger { background: #fee2e2; color: #991b1b; }
.sig-wrap { position: relative; border: 2px dashed #cbd5e1; border-radius: 12px; background: #fff; }
.sig-wrap canvas { width: 100%; height: 180px; display: block; touch-action: none; cursor: crosshair; }
.sig-wrap .sig-hint { position: absolute; inset: auto 0 10px 0; text-align: center; color: #94a3b8; font-size: .85rem; pointer-events: none; }
.sig-wrap.signed .sig-hint { display: none; }
.sig-wrap .sig-line { position: absolute; left: 8%; right: 8%; bottom: 38px; border-bottom: 1px solid #e2e8f0; pointer-events: none; }

/* ---------- Kiosk ---------- */
body.kiosk { background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--brand) 25%, #fff), #f8fafc 60%); min-height: 100vh; }
.kiosk-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; text-align: center; }
.kiosk-qr { background: #fff; padding: 18px; border-radius: 24px; box-shadow: 0 20px 50px rgba(15,23,42,.15); position: relative; }
.kiosk-qr img { width: min(62vh, 80vw); height: min(62vh, 80vw); image-rendering: pixelated; display: block; }
.kiosk-qr.inactive img { filter: blur(6px) grayscale(1); opacity: .35; }
.kiosk-qr .overlay { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; flex-direction: column; font-weight: 700; font-size: 1.5rem; }
.kiosk-qr.inactive .overlay { display: flex; }
.kiosk-headline { font-size: clamp(1.4rem, 3.2vw, 2.4rem); font-weight: 700; max-width: 900px; }
.kiosk-sub { color: var(--muted); font-size: clamp(.95rem, 1.6vw, 1.2rem); max-width: 760px; }
.kiosk-meta { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.kiosk-meta .pill { background: #fff; border: 1px solid var(--card-border); border-radius: 999px; padding: .4rem 1rem; font-weight: 600; }
.kiosk-toast { position: fixed; top: 1rem; right: 1rem; z-index: 2000; }
.kiosk-controls { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; gap: .5rem; opacity: .35; transition: opacity .2s; }
.kiosk-controls:hover { opacity: 1; }

/* ---------- Report rendering ---------- */
.report-page { position: relative; background: #fff; margin: 0 auto 24px; box-shadow: 0 6px 24px rgba(15,23,42,.12); overflow: hidden; }
.report-el { position: absolute; overflow: hidden; box-sizing: border-box; }
.report-el.text { padding: 2px 3px; white-space: pre-wrap; word-wrap: break-word; display: flex; flex-direction: column; }
.report-el img { width: 100%; height: 100%; object-fit: contain; display: block; }
.report-el .hline { position: absolute; left: 0; right: 0; top: 50%; }
.report-el .vline { position: absolute; top: 0; bottom: 0; left: 50%; }
.print-toolbar { position: sticky; top: 0; z-index: 10; background: #0f172a; color: #fff; padding: .6rem 1rem; display: flex; gap: .5rem; align-items: center; margin-bottom: 24px; }
@media print {
    @page { margin: 0; }
    body { background: #fff !important; }
    .print-toolbar, .no-print { display: none !important; }
    .report-page { box-shadow: none; margin: 0; page-break-after: always; }
    .report-page:last-child { page-break-after: auto; }
}
