/*
 * HEMIS 02 Light theme. NCHE colours only: gold, black, grey.
 * Green, amber and red appear only as small status cues next to an icon and a label.
 */
@import '@fontsource-variable/inter';
@import 'bootstrap/dist/css/bootstrap.min.css';
@import 'bootstrap-icons/font/bootstrap-icons.min.css';

:root {
    color-scheme: light;
    --bg: #f4f3ef;
    --surf: #ffffff;
    --text: #1a1a1a;
    --muted: #625f58;
    --border: #e7e4db;
    --accent: #b9912a;
    --accent-ink: #161616;
    --accent-text: #7a5e14;
    --accent2: #9a988f;
    --ok: #2f7d4a;
    --warn: #9a5f12;
    --danger: #b03224;
    --brandbg: #141414;
    --radius: 16px;
    --shadow: 0 10px 30px rgba(20, 20, 20, .07);
    --sidebar-w: 250px;

    /* Type scale: four sizes only */
    --fs-sm: 12.5px;
    --fs-base: 14px;
    --fs-lg: 16px;
    --fs-xl: 24px;

    --bs-body-font-family: 'Inter Variable', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-body-color: var(--text);
    --bs-body-bg: var(--bg);
    --bs-border-color: var(--border);
    --bs-link-color-rgb: 122, 94, 20;
    --bs-link-hover-color-rgb: 26, 26, 26;
    --bs-focus-ring-color: rgba(185, 145, 42, .35);
}

body { background: var(--bg); color: var(--text); letter-spacing: .1px; font-size: var(--fs-base); }
.small, small { font-size: var(--fs-sm) !important; }
h1, h2, h3 { font-size: var(--fs-lg); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--text); text-decoration: underline; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted) !important; }
.visually-hidden-focusable:focus { position: fixed !important; top: 8px; left: 8px; z-index: 100; background: var(--surf); padding: 8px 12px; border-radius: 8px; }

/* Cards */
.hcard { background: var(--surf); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.hcard-h { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hcard-h h2, .hcard-h h3 { font-size: var(--fs-base); font-weight: 700; margin: 0; }
.hcard-b { padding: 18px; }
.stat { padding: 18px; border-radius: var(--radius); background: var(--surf); border: 1px solid var(--border); box-shadow: var(--shadow); }
.stat .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: var(--fs-lg); background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-text); }
.stat .v { font-size: var(--fs-xl); font-weight: 800; line-height: 1.1; margin-top: 10px; }
.stat .l { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }

/* Status pills: always icon + label (WCAG: never colour alone) */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-sm); font-weight: 600; padding: 3px 9px; border-radius: 7px; line-height: 1.4; white-space: nowrap; border: 1px solid; }
.pill-ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 38%, transparent); }
.pill-warn { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 38%, transparent); }
.pill-danger { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 38%, transparent); }
.pill-info { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.pill-mut { background: color-mix(in srgb, var(--muted) 12%, transparent); color: var(--muted); border-color: color-mix(in srgb, var(--muted) 30%, transparent); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: #faf9f6; color: var(--text); }

/* Buttons */
.btn { border-radius: 10px; font-weight: 600; }
.btn-accent { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); }
.btn-accent:hover, .btn-accent:focus { background: #a8821f; border-color: #a8821f; color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }
.btn-dark-outline { background: transparent; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-dark-outline:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); color: var(--danger); }

/* Forms */
.form-label { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.form-control, .form-select { background: var(--surf); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 9px 12px; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.invalid-feedback { color: var(--danger); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger); }
.form-text { color: var(--muted); }
/* Mandatory fields: a small gold asterisk after the label (set by x-field, x-code-select and app.js). */
.req::after { content: " *"; color: var(--accent-text); font-weight: 700; }
.req-note { font-size: var(--fs-sm); color: var(--muted); margin-bottom: 10px; }
.req-note .req-mark { color: var(--accent-text); font-weight: 700; }

/* Tables */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl th { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: var(--fs-base); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
.table-wrap { overflow-x: auto; }
.avatar { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: var(--fs-sm); background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-text); flex: 0 0 auto; }

/* Page header */
.page-h { font-size: var(--fs-xl); font-weight: 800; margin: 0; }
.page-sub { color: var(--muted); font-size: var(--fs-base); margin-top: 3px; }
.dl-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-base); }
.dl-row:last-child { border-bottom: 0; }
.dl-row dt { width: 160px; flex: 0 0 auto; color: var(--muted); font-weight: 600; }
.dl-row dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Layout shell: white sidebar + white topbar */
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); background: var(--surf); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; z-index: 40; transition: transform .25s; }
.sidebar .brand { display: block; padding: 4px 8px 16px; }
.sidebar .brand img { width: 100%; max-width: 190px; height: auto; }
.navi a, .navi button { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; color: #333; font-weight: 600; font-size: var(--fs-base); margin-bottom: 3px; width: 100%; border: 0; background: transparent; text-align: left; }
.navi a i, .navi button i { font-size: var(--fs-lg); opacity: .9; }
.navi a:hover, .navi button:hover { background: color-mix(in srgb, #333 10%, transparent); color: var(--text); text-decoration: none; }
.navi a.active { background: var(--accent); color: var(--accent-ink); }
.navi .cap { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; padding: 14px 12px 6px; }
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; background: var(--surf); border-bottom: 1px solid var(--border); padding: 12px 26px; display: flex; align-items: center; gap: 16px; }
.content { padding: 26px; max-width: 1280px; width: 100%; }
.iconbtn, .hamb { width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--border); background: var(--surf); color: var(--text); display: grid; place-items: center; }
.hamb { display: none; }
.topbar .who { line-height: 1.2; }
.topbar .who b { font-size: var(--fs-base); display: block; }
.topbar .who small { color: var(--muted); font-size: var(--fs-sm); }

/* Sign-in pages */
.auth-wrap { display: flex; min-height: 100vh; }
.auth-aside { position: relative; overflow: hidden; color: var(--text); padding: 48px; width: 46%; display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--border);
    background: linear-gradient(165deg, #fdfaf2 0%, #f6edd4 55%, #efe2bc 100%); }
/* Faint sunburst rays, echoing the HEMIS mark */
.auth-aside::before { content: ''; position: absolute; left: 50%; top: -55%; width: 160%; aspect-ratio: 1; transform: translateX(-50%); pointer-events: none;
    background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(185, 145, 42, .10) 0deg 6deg, transparent 6deg 15deg);
    -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 0%, transparent 62%); mask-image: radial-gradient(circle at 50% 50%, #000 0%, transparent 62%); }
.auth-aside > * { position: relative; }
.auth-aside .auth-logo { width: 220px; height: auto; display: block; }
.auth-aside .auth-title { font-size: var(--fs-xl); font-weight: 800; line-height: 1.2; }
.auth-aside .auth-org { color: var(--muted); margin: 14px 0 24px; font-size: var(--fs-base); }
.auth-aside .auth-point { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: var(--fs-base); font-weight: 500; }
.auth-aside .tick { color: var(--accent-text); }
.auth-aside .auth-foot { color: var(--muted); font-size: var(--fs-sm); }
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .mobile-logo { width: 170px; height: auto; }
.otp-input { font-size: var(--fs-xl); letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.qr-box { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: inline-block; }
.qr-box svg { display: block; width: 180px; height: 180px; }
.codes { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-base); columns: 2; background: #faf9f6; border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; }

/* Role permission matrix */
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix .form-check-input { width: 1.15em; height: 1.15em; margin: 0; }

.pagination { --bs-pagination-color: var(--text); --bs-pagination-active-bg: var(--accent); --bs-pagination-active-border-color: var(--accent); --bs-pagination-active-color: var(--accent-ink); --bs-pagination-focus-box-shadow: 0 0 0 3px rgba(185, 145, 42, .3); margin: 0; }
.alert { border-radius: 12px; font-size: var(--fs-base); }
.alert-hemis { background: color-mix(in srgb, var(--accent) 10%, #fff); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); color: var(--text); }
.alert-hemis-ok { background: color-mix(in srgb, var(--ok) 8%, #fff); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); color: var(--text); }
.alert-hemis-ok .bi { color: var(--ok); }
.alert-hemis-warn { background: color-mix(in srgb, var(--warn) 9%, #fff); border: 1px solid color-mix(in srgb, var(--warn) 38%, transparent); color: var(--text); }
.alert-hemis-warn .bi { color: var(--warn); }
.alert-hemis-danger { background: color-mix(in srgb, var(--danger) 6%, #fff); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); color: var(--text); }
pre.json { background: #faf9f6; border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: var(--fs-sm); max-height: 360px; overflow: auto; margin: 0; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow); }
    .sidebar.open { transform: none; }
    .main { margin-left: 0; }
    .hamb { display: grid; }
    .topbar { padding: 10px 16px; }
    .content { padding: 18px 16px; }
    .auth-aside { display: none; }
    .topbar .who { display: none; }
}
[x-cloak] { display: none !important; }
code { color: var(--text); }
.btn-link { color: var(--accent-text); font-weight: 600; text-decoration: none; }
.btn-link:hover { color: var(--text); text-decoration: underline; }
.nav-pills .nav-link { border-radius: 10px; font-weight: 600; }

.secret-key { display: block; padding: 8px 10px; background: #faf9f6; border: 1px solid var(--border); border-radius: 8px; word-break: break-all; }
.count { background: var(--text); color: #fff; border-radius: 999px; font-size: var(--fs-sm); padding: 0 8px; line-height: 20px; }
.navi a.active .count { background: var(--accent-ink); }
.dot-count { position: absolute; top: -5px; right: -5px; background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: var(--fs-sm); font-weight: 700; min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 5px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 16px 24px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.timeline li.now::before { background: #fff; border: 2px solid var(--accent); }
.stage-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.stage-row:last-child { border-bottom: 0; }
.stage-no { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: color-mix(in srgb, var(--text) 8%, transparent); flex: 0 0 auto; }
.stage-row.on .stage-no { background: var(--accent); color: var(--accent-ink); }
.stage-row.done .stage-no { background: var(--text); color: #fff; }
.stage-sub { margin-left: 18px; padding-left: 14px; border-left: 2px solid var(--border); }
.stage-sub .stage-row { padding: 5px 0; font-size: var(--fs-sm); }
.stage-sub .stage-no { width: auto; min-width: 30px; height: 22px; border-radius: 11px; padding: 0 6px; font-size: .72rem; }
.editor-stage { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #fff; }
.btn, .btn-sm, .form-control-sm, .form-select-sm { font-size: var(--fs-base); }
.form-control, .form-select, .form-check-label, .nav-link, .alert, .tbl td, .tbl th, .dropdown-item { font-size: var(--fs-base); }
.tbl th { font-size: var(--fs-sm); }

/* Number tables (reports): right-aligned figures, compact rows, totals in bold */
.tbl-num th:not(:first-child), .tbl-num td:not(:first-child) { text-align: right; }
.tbl-num td { padding: 8px 14px; }
.tbl-num tr.total td { font-weight: 700; background: color-mix(in srgb, var(--muted) 6%, transparent); }

/* Collapsible menu groups */
.nav-group { margin-bottom: 2px; }
.nav-group > summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; cursor: pointer; color: #333; font-weight: 700; font-size: var(--fs-base); user-select: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary > i:first-child { font-size: var(--fs-lg); opacity: .9; }
.nav-group > summary:hover { background: color-mix(in srgb, #333 10%, transparent); }
.nav-group > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nav-group > summary .caret { margin-left: auto; font-size: var(--fs-sm); transition: transform .2s; }
.nav-group[open] > summary .caret { transform: rotate(180deg); }
.nav-group[data-active] > summary { color: var(--accent-text); }
.nav-group-items { padding-left: 14px; border-left: 2px solid var(--border); margin: 2px 0 6px 20px; }
.nav-group-items a { padding: 8px 10px; font-weight: 500; }
.nav-group-items a i { font-size: var(--fs-base); }

/* Statistics progress */
.stat-on { outline: 2px solid var(--accent); }
.stat .ico.ico-danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.progress { background: color-mix(in srgb, var(--muted) 16%, transparent); height: 10px; border-radius: 6px; }
.progress-sm { height: 6px; }
.bg-accent { background: var(--accent) !important; }
.search-options { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 4px; list-style: none; background: var(--surf); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-height: 280px; overflow: auto; }
.search-options li { padding: 6px 10px; border-radius: 7px; cursor: pointer; font-size: var(--fs-base); }
.search-options li:hover, .search-options li[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* Statistics: the uploaded values, with cells that have issues marked (the title holds the message). */
.tbl-data td { font-size: var(--fs-sm); }
.tbl-data td.cell-error { box-shadow: inset 3px 0 0 var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.tbl-data td.cell-warn { box-shadow: inset 3px 0 0 var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }

/* Document dialog on a case. */
.doc-dialog { width: min(1000px, calc(100vw - 32px)); height: min(88vh, 1100px); padding: 0; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.doc-dialog[open] { display: flex; flex-direction: column; }
.doc-dialog::backdrop { background: rgb(0 0 0 / .45); }
.doc-dialog-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.doc-dialog-h .min-w-0 { min-width: 0; flex: 1 1 200px; }
.doc-dialog-b { flex: 1; min-height: 0; background: #f4f3f0; display: grid; place-items: center; overflow: auto; }
.doc-dialog-b iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.doc-dialog-b img { max-width: 100%; max-height: 100%; }

/* Calendar month view. */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.cal-h { padding: 6px 8px; font-size: var(--fs-sm); font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--border); }
.cal-d { min-height: 104px; padding: 4px 6px 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-width: 0; }
.cal-d:nth-child(7n) { border-right: 0; }
.cal-d.out { background: color-mix(in srgb, var(--text) 3%, transparent); }
.cal-d.out .cal-n { color: var(--muted); }
.cal-d.today .cal-n { background: var(--accent); color: var(--accent-ink); border-radius: 50%; width: 24px; text-align: center; }
.cal-n { font-size: var(--fs-sm); font-weight: 700; margin-bottom: 2px; line-height: 24px; }
.cal-e, .cal-key { display: block; font-size: .72rem; line-height: 1.3; padding: 2px 5px; margin-bottom: 2px; border-radius: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-e { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); text-decoration: none; border-left: 3px solid var(--accent); }
.cal-e:hover { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.cal-e.visit { background: color-mix(in srgb, var(--text) 8%, transparent); border-left-color: var(--text); }
.cal-e.cancelled { text-decoration: line-through; opacity: .6; }
.cal-e .t { font-weight: 700; }
.cal-key { color: var(--muted); border: 1px dashed var(--border); }
@media (max-width: 767.98px) { .cal-d { min-height: 64px; padding: 2px; } .cal-e .t { display: none; } }
