/* ===========================================================================
   Marwari Hospitals — Housekeeping Inspection System
   =========================================================================== */
:root {
    --brand: #0b6b53;
    --brand-accent: #12876a;
    --brand-dark: #0e2b26;
    --brand-dark-2: #123a33;

    --bg: #eef1f4;
    --surface: #ffffff;
    --surface-2: #f7f9fa;
    --border: #dbe1e6;
    --border-strong: #c4cdd4;

    --text: #1f2933;
    --text-soft: #3d4852;
    --muted: #66727d;

    --ok-bg: #e4f4ec; --ok-fg: #0a6b4f;
    --warn-bg: #fff2dc; --warn-fg: #8a5a06;
    --bad-bg: #fdeaea; --bad-fg: #9c1f1f;
    --info-bg: #e7f0fb; --info-fg: #1c5aa8;

    --radius: 10px;
    --radius-sm: 7px;
    --shadow-sm: 0 1px 2px rgba(16, 33, 40, .06), 0 1px 3px rgba(16, 33, 40, .05);
    --shadow-md: 0 2px 8px rgba(16, 33, 40, .08), 0 8px 24px rgba(16, 33, 40, .06);
    --sidebar-w: 258px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-text-size-adjust: 100%;
}

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

h1 { font-size: 1.45rem; font-weight: 650; letter-spacing: -.01em; margin: 0 0 .35rem; }
h2 { font-size: 1.12rem; font-weight: 650; margin: 1.75rem 0 .6rem; }
h3 { font-size: 1rem; font-weight: 650; margin: 1.25rem 0 .5rem; }
p  { margin: .35rem 0 .9rem; }
.muted { color: var(--muted); }
.page-intro { color: var(--muted); margin: -.1rem 0 1.25rem; max-width: 70ch; }

/* ---------- App shell (authenticated pages) ------------------------------- */
.nav-toggle-cb { position: absolute; opacity: 0; pointer-events: none; }

.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, var(--brand-dark) 0%, var(--brand-dark-2) 100%);
    color: #d7e5e0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.15rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .09);
    display: flex;
    gap: .7rem;
    align-items: center;
}
.sidebar-brand img { width: 34px; height: 34px; object-fit: contain; border-radius: 6px; background: #fff; }
.brand-org { font-weight: 700; font-size: .98rem; color: #fff; letter-spacing: .01em; line-height: 1.15; }
.brand-sys { font-size: .74rem; color: #9fc4b9; letter-spacing: .02em; text-transform: uppercase; }

.sidebar-nav { padding: .6rem 0; flex: 1 1 auto; }
.sidebar-nav .nav-group {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
    color: #7fa89c; padding: .9rem 1.25rem .35rem;
}
.sidebar-nav a {
    display: block;
    padding: .5rem 1.25rem;
    color: #cfe0da;
    font-size: .9rem;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.sidebar-nav a.active {
    background: rgba(255, 255, 255, .1);
    color: #fff;
    border-left-color: var(--brand-accent);
    font-weight: 600;
}

.sidebar-user {
    border-top: 1px solid rgba(255, 255, 255, .09);
    padding: .9rem 1.25rem;
    font-size: .82rem;
}
.sidebar-user .who { color: #fff; font-weight: 600; }
.sidebar-user .role { color: #9fc4b9; }
.sidebar-user form { margin-top: .5rem; }
.sidebar-user button {
    background: rgba(255, 255, 255, .1); color: #fff; border: 1px solid rgba(255, 255, 255, .18);
    border-radius: var(--radius-sm); padding: .4rem .7rem; font: inherit; font-size: .82rem; cursor: pointer;
}
.sidebar-user button:hover { background: rgba(255, 255, 255, .18); }

.content { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: none;
    align-items: center;
    gap: .75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .6rem .9rem;
    position: sticky; top: 0; z-index: 20;
}
.topbar .brand-org { color: var(--text); }
.topbar .brand-sys { color: var(--muted); }
.menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
}
.menu-btn span, .menu-btn span::before, .menu-btn span::after {
    content: ""; display: block; width: 18px; height: 2px; background: var(--text); position: relative;
}
.menu-btn span::before { position: absolute; top: -6px; }
.menu-btn span::after  { position: absolute; top: 6px; }

.app-main {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.6rem 1.75rem 3.5rem;
    flex: 1 1 auto;
}

.flash {
    background: var(--ok-bg); border: 1px solid #b6ddcb; color: var(--ok-fg);
    padding: .7rem .95rem; border-radius: var(--radius); margin-bottom: 1.25rem;
    font-size: .92rem;
}
.alert {
    background: var(--bad-bg); border: 1px solid #e6b4b4; color: var(--bad-fg);
    padding: .7rem .95rem; border-radius: var(--radius); margin: .5rem 0 1rem; font-size: .92rem;
}

/* ---------- Auth pages -------------------------------------------------- */
.auth-wrap {
    min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(11, 107, 83, .10), transparent 60%),
        var(--bg);
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 2rem 1.9rem 2.1rem;
    width: 100%;
    max-width: 400px;
}
.auth-logo { text-align: center; margin-bottom: 1rem; }
.auth-logo img { max-height: 64px; max-width: 200px; object-fit: contain; }
.auth-org { text-align: center; font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; }
.auth-sys { text-align: center; color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 1.4rem; }
.auth-title { font-size: 1.05rem; font-weight: 650; margin: 0 0 .1rem; }
.auth-subtitle { color: var(--muted); margin: 0 0 1rem; font-size: .9rem; }

/* ---------- Forms ------------------------------------------------------- */
form { display: block; }
.form-grid { display: flex; flex-direction: column; gap: .3rem; max-width: 560px; }
.form-grid > .actions { margin-top: 1.25rem; }

label {
    font-weight: 600; font-size: .85rem; color: var(--text-soft);
    margin-top: .85rem; display: block;
}
.form-grid > label:first-of-type, .auth-card label:first-of-type { margin-top: 0; }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=file], input:not([type]), select, textarea {
    width: 100%;
    padding: .62rem .7rem;
    font: inherit;
    font-size: .95rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(18, 135, 106, .15);
}
textarea { min-height: 64px; resize: vertical; }

.checkbox-row { display: flex; align-items: center; gap: .5rem; margin-top: 1rem; font-weight: 600; font-size: .9rem; }
.checkbox-row input { width: auto; }

.field-error { color: var(--bad-fg); font-size: .82rem; margin-top: .1rem; }
.hint { color: var(--muted); font-size: .82rem; margin: .2rem 0 0; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 1.1rem 0; padding: .5rem 1rem 1rem; }
legend { font-weight: 650; font-size: .9rem; padding: 0 .4rem; color: var(--text-soft); }

/* ---------- Buttons -------------------------------------------------------- */
.btn, button.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem .9rem;
    font: inherit; font-size: .88rem; font-weight: 600;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-accent); }
.btn.danger { color: var(--bad-fg); border-color: #e0a9a9; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { padding: .32rem .6rem; font-size: .8rem; }

.btn-primary {
    display: inline-flex; align-items: center; justify-content: center;
    width: 100%;
    margin-top: 1.35rem;
    padding: .72rem 1rem;
    font: inherit; font-size: .95rem; font-weight: 650;
    color: #fff; background: var(--brand); border: none; border-radius: var(--radius-sm);
    cursor: pointer; text-decoration: none;
}
.btn-primary:hover { background: var(--brand-accent); text-decoration: none; }

.btn-link { background: none; border: none; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }

.actions { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; margin: 1.1rem 0; }
form.inline { display: inline; }

/* ---------- Cards & KPIs ------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.1rem 1.2rem;
    margin-bottom: 1.25rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .9rem;
    margin: 1rem 0 1.75rem;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: .95rem 1.05rem;
}
.kpi-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi-label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; margin-top: .2rem; }
.kpi-card.accent .kpi-value { color: var(--brand); }
.kpi-card.warn   .kpi-value { color: var(--warn-fg); }
.kpi-card.bad    .kpi-value { color: var(--bad-fg); }

/* ---------- Tables ------------------------------------------------------ */
.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td {
    text-align: left;
    padding: .62rem .85rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    vertical-align: top;
}
table.data thead th {
    background: var(--surface-2);
    font-weight: 650;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    position: sticky; top: 0;
}
table.data tbody tr:hover { background: #f4f8f7; }
table.data tr:last-child td { border-bottom: none; }
table.data td.wrap { white-space: normal; min-width: 12rem; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.actions-cell { white-space: nowrap; }
table.data td.actions-cell .btn { margin-right: .3rem; }

/* key/value table (confirmation, detail) */
table.kv { border-collapse: collapse; width: 100%; max-width: 520px; font-size: .92rem; }
table.kv th { text-align: left; color: var(--muted); font-weight: 600; padding: .5rem .8rem .5rem 0; width: 40%; vertical-align: top; }
table.kv td { padding: .5rem 0; border-bottom: 1px solid var(--border); }
table.kv tr:last-child td, table.kv tr:last-child th { border-bottom: none; }

/* ---------- Badges ---------------------------------------------------------- */
.badge {
    display: inline-block; padding: .12rem .55rem; border-radius: 999px;
    font-size: .76rem; font-weight: 650; letter-spacing: .01em;
    background: var(--info-bg); color: var(--info-fg);
}
.badge.ok    { background: var(--ok-bg);   color: var(--ok-fg); }
.badge.warn  { background: var(--warn-bg); color: var(--warn-fg); }
.badge.bad   { background: var(--bad-bg);  color: var(--bad-fg); }
.badge.muted { background: #eceff1; color: #5b6670; }

/* ---------- Filters bar ------------------------------------------------- */
.filters {
    display: flex; flex-wrap: wrap; gap: .8rem 1rem; align-items: end;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 1rem 1.1rem; margin: 1rem 0 1.5rem;
}
.filters label { margin: 0; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.filters .field { display: flex; flex-direction: column; gap: .25rem; }
.filters input, .filters select { min-width: 150px; }
.filters .filters-actions { display: flex; gap: .5rem; }

/* ---------- Supervisor inspection ------------------------------------------ */
.washroom-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.15rem;
    margin-bottom: 1.15rem;
}
.washroom-card .code { color: var(--muted); font-size: .82rem; letter-spacing: .04em; text-transform: uppercase; }
.washroom-card h1 { margin: .1rem 0 .2rem; }

.gps-status {
    font-size: .88rem; padding: .55rem .75rem; border-radius: var(--radius-sm);
    background: var(--info-bg); color: var(--info-fg); margin-bottom: 1.1rem;
}
.gps-status.ok { background: var(--ok-bg); color: var(--ok-fg); }
.gps-status.warn { background: var(--warn-bg); color: var(--warn-fg); }

.cat-head {
    font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
    margin: 1.5rem 0 .35rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border);
}
.checklist-item { padding: .95rem 0; border-bottom: 1px solid var(--border); }
.checklist-item:last-of-type { border-bottom: none; }
.checklist-item .q { font-weight: 600; }
.checklist-item .remark { margin-top: .55rem; }

.yesno { display: flex; gap: .55rem; margin-top: .55rem; }
.yesno label {
    flex: 1; margin: 0; text-align: center; padding: .7rem;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    cursor: pointer; font-weight: 650; color: var(--text-soft);
}
.yesno input { position: absolute; opacity: 0; }
.yesno label:has(input:checked) { border-color: var(--brand); background: var(--ok-bg); color: var(--brand); box-shadow: 0 0 0 2px rgba(11,107,83,.12) inset; }

/* ---------- Supervisor home ------------------------------------------------- */
.sup-home { max-width: 560px; }
.cta {
    display: flex; align-items: center; gap: 1rem;
    width: 100%;
    margin: 1.25rem 0 2rem;
    padding: 1.15rem 1.25rem;
    background: var(--brand);
    color: #fff;
    border-radius: 14px;
    box-shadow: var(--shadow-md);
    text-decoration: none;
}
.cta:hover { background: var(--brand-accent); text-decoration: none; }
.cta-icon {
    font-size: 1.9rem; line-height: 1;
    width: 52px; height: 52px; flex: none;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .16); border-radius: 12px;
}
.cta-title { display: block; font-size: 1.15rem; font-weight: 700; }
.cta-sub { display: block; font-size: .85rem; color: rgba(255, 255, 255, .85); margin-top: .1rem; }

/* ---------- Supervisor QR scanner ------------------------------------------ */
.scan-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    max-width: 460px;
    margin: 0 auto 1.25rem;
}
#reader { width: 100% !important; border: none !important; }
#reader video { border-radius: var(--radius-sm); width: 100% !important; }
#reader img[alt="Info icon"] { display: none; }
#reader__dashboard_section_csr button,
#reader__dashboard_section_swaplink {
    font: inherit !important;
    font-size: .88rem !important;
    padding: .5rem .8rem !important;
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--brand) !important;
    background: var(--brand) !important;
    color: #fff !important;
    cursor: pointer;
    text-decoration: none !important;
    display: inline-block;
    margin: .35rem .35rem 0 0;
}
#reader__dashboard_section_swaplink { background: var(--surface) !important; color: var(--brand) !important; }
#reader select { margin-top: .4rem; }
#reader__status_span { display: none; }

.scan-result { margin-top: .75rem; font-size: .92rem; text-align: center; color: var(--muted); }
.scan-result.ok { color: var(--ok-fg); font-weight: 600; }
.scan-result.warn { color: var(--warn-fg); }

.scan-fallback {
    max-width: 460px; margin: 0 auto 2rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); padding: .5rem 1rem;
}
.scan-fallback summary { cursor: pointer; font-weight: 600; padding: .5rem 0; }
.scan-fallback[open] summary { border-bottom: 1px solid var(--border); margin-bottom: .75rem; }

/* ---------- QR block --------------------------------------------------- */
.qr-block {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); padding: 1.1rem; margin: 1rem 0; max-width: 440px;
}
.qr-block img { width: 200px; height: 200px; image-rendering: pixelated; display: block; }
.qr-block code { word-break: break-all; font-size: .8rem; color: var(--text-soft); }

/* ---------- Access-map matrix ---------------------------------------------- */
table.matrix td, table.matrix th { text-align: center; }
table.matrix th:first-child, table.matrix td:first-child { text-align: left; white-space: nowrap; }
table.matrix input { width: auto; }

/* ---------- Responsive ------------------------------------------------- */
@media (max-width: 860px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; inset: 0 auto 0 0;
        width: 82%; max-width: 300px; z-index: 40;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow-md);
    }
    .nav-toggle-cb:checked ~ .layout .sidebar { transform: translateX(0); }
    .nav-toggle-cb:checked ~ .layout .scrim {
        content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30;
    }
    .topbar { display: flex; }
    .app-main { padding: 1.1rem 1rem 3rem; }
    h1 { font-size: 1.3rem; }
    .filters { padding: .85rem; }
}

@media (min-width: 861px) {
    .scrim, label.menu-btn { display: none; }
}
