/* SIMS - plain CSS, no framework. Colours and sizes are variables so a school can re-skin in one place. */

:root {
    --color-primary: #1f4e79;
    --color-primary-dark: #163a5a;
    --color-accent: #2a9d8f;
    --color-bg: #f3f5f8;
    --color-surface: #ffffff;
    --color-text: #1c2733;
    --color-muted: #64748b;
    --color-border: #d7dde5;
    --color-success: #1b7f4d;
    --color-success-bg: #e6f5ec;
    --color-error: #b3261e;
    --color-error-bg: #fdecea;
    --color-warning: #8a5a00;
    --color-warning-bg: #fff4d6;
    --color-info: #1f4e79;
    --color-info-bg: #e8f1fa;
    --sidebar-width: 15rem;
    --radius: 0.5rem;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
}

a { color: var(--color-primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.75rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--color-muted); }

/* ---------- Buttons ---------- */

.btn {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
}
.btn:hover { border-color: var(--color-primary); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid rgba(42, 157, 143, 0.55);
    outline-offset: 2px;
}
.btn-primary { color: #fff; background: var(--color-primary); border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-danger { color: #fff; background: var(--color-error); border-color: var(--color-error); }
.btn-ghost { background: transparent; }
.btn-small { padding: 0.3rem 0.7rem; font-size: 0.875rem; white-space: nowrap; }
.btn-block { display: block; width: 100%; }

/* ---------- Forms ---------- */

.form .field { margin-bottom: 1rem; }
.form label { display: block; margin-bottom: 0.3rem; font-weight: 600; }
.form input[type="text"], .form input[type="password"], .form input[type="email"], .form input[type="number"],
.form input[type="date"], .form select, .form textarea {
    width: 100%;
    padding: 0.6rem 0.7rem;
    font: inherit;
    color: inherit;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.form .hint { display: block; margin-top: 0.25rem; color: var(--color-muted); }
.form-note { margin: 1rem 0 0; font-size: 0.9rem; text-align: center; }
.inline-form { display: inline; margin: 0; }

/* ---------- Flash messages and notices ---------- */

.flash, .notice {
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
}
.flash-success { color: var(--color-success); background: var(--color-success-bg); border-color: #b9e2cb; }
.flash-error   { color: var(--color-error);   background: var(--color-error-bg);   border-color: #f3c1bd; }
.flash-warning, .notice { color: var(--color-warning); background: var(--color-warning-bg); border-color: #f0dc9c; }
.flash-info    { color: var(--color-info);    background: var(--color-info-bg);    border-color: #bcd6ee; }

/* ---------- Cards and lists ---------- */

.card {
    padding: 1.25rem 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card.narrow { max-width: 32rem; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.25rem; margin: 0 0 1rem; }
.facts dt { color: var(--color-muted); }
.facts dd { margin: 0; }

/* ---------- Guest layout (sign-in, errors) ---------- */

body.guest {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 1rem;
}
.auth-card {
    width: 100%;
    max-width: 26rem;
    padding: 2rem 1.75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand h1 { margin: 0.5rem 0 0.15rem; font-size: 1.25rem; }
.auth-brand p { margin: 0; color: var(--color-muted); font-size: 0.9rem; }
.auth-card h2 { font-size: 1.15rem; }
.error-card { text-align: center; }
.error-code { margin: 0; font-size: 3.5rem; font-weight: 700; color: var(--color-primary); }

/* ---------- App layout ---------- */

body.app { display: block; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: var(--sidebar-width);
    overflow-y: auto;
    color: #fff;
    background: var(--color-primary-dark);
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1rem;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
.brand-logo { border-radius: 0.35rem; background: #fff; }
.brand-name { font-weight: 700; line-height: 1.2; }
.nav ul { margin: 0; padding: 0.5rem 0; list-style: none; }
.nav a {
    display: block;
    padding: 0.65rem 1rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    border-left: 4px solid transparent;
}
.nav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav a.active { color: #fff; background: rgba(255, 255, 255, 0.14); border-left-color: var(--color-accent); }

.main { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1.25rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.page-title { flex: 1; margin: 0; font-size: 1.2rem; }
.user-menu { display: flex; align-items: center; gap: 0.6rem; }
.user-meta { display: flex; flex-direction: column; text-align: right; line-height: 1.25; }
.user-meta small { color: var(--color-muted); }

.content { flex: 1; padding: 1.25rem; }
.footer { padding: 0.75rem 1.25rem; font-size: 0.85rem; color: var(--color-muted); text-align: center; }

/* Mobile menu: a CSS-only checkbox toggle, so the menu works without JavaScript. */
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.hamburger { display: none; flex-direction: column; gap: 4px; padding: 0.5rem; cursor: pointer; }
.hamburger span { display: block; width: 22px; height: 3px; background: var(--color-text); border-radius: 2px; }
.nav-backdrop { display: none; }

@media (max-width: 800px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
    .main { margin-left: 0; }
    .hamburger { display: flex; }
    .user-meta { display: none; }
    .nav-toggle:checked ~ .sidebar { transform: translateX(0); }
    .nav-toggle:checked ~ .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 25;
        background: rgba(15, 23, 42, 0.45);
    }
}

/* ---------- Lists, tables, filters ---------- */

.section-gap { margin-top: 1.25rem; }
.small { font-size: 0.85rem; }
.card h2 { font-size: 1.1rem; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.toolbar p { margin: 0; }
.search-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.search-form input[type="search"], .search-form select {
    padding: 0.4rem 0.6rem;
    font: inherit;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.search-form input[type="search"] { min-width: 14rem; }
.button-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table thead th { font-size: 0.85rem; color: var(--color-muted); white-space: nowrap; background: #f8fafc; }
.table tbody tr:hover { background: #f8fafc; }
.table .num { text-align: right; white-space: nowrap; }
.table .actions { white-space: nowrap; text-align: right; }
.table .empty { padding: 2rem; text-align: center; color: var(--color-muted); }
.table a.sort { color: inherit; text-decoration: none; }
.table a.sort:hover { color: var(--color-primary); text-decoration: underline; }

.btn-danger-outline { color: var(--color-error); border-color: #e8b4b0; }
.btn-danger-outline:hover { color: #fff; background: var(--color-error); border-color: var(--color-error); }

.badge {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.5;
    border-radius: 999px;
    white-space: nowrap;
}
.badge-ok      { color: var(--color-success); background: var(--color-success-bg); }
.badge-warning { color: var(--color-warning); background: var(--color-warning-bg); }
.badge-danger  { color: var(--color-error);   background: var(--color-error-bg); }
.badge-info    { color: var(--color-info);    background: var(--color-info-bg); }
.badge-muted   { color: var(--color-muted);   background: #eef1f5; }

.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 1rem; font-size: 0.9rem; }
.pagination-summary { color: var(--color-muted); }
.pagination-links { display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; }
.pagination-links a {
    min-width: 2rem;
    padding: 0.3rem 0.6rem;
    text-align: center;
    text-decoration: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.pagination-links a:hover { border-color: var(--color-primary); }
.pagination-links a.current { color: #fff; background: var(--color-primary); border-color: var(--color-primary); }
.pagination-links .gap { padding: 0 0.25rem; color: var(--color-muted); }

/* ---------- Forms (extra) ---------- */

.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0 1rem; }
.form select { width: 100%; padding: 0.6rem 0.7rem; font: inherit; background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius); }
.form input[type="tel"], .form input[type="file"] { width: 100%; font: inherit; }
.form input[type="tel"] { padding: 0.6rem 0.7rem; border: 1px solid var(--color-border); border-radius: var(--radius); }
.form .check { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.form .check input { width: auto; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; }
.req { color: var(--color-error); }
.logo-row { display: flex; align-items: center; gap: 1rem; }
.logo-preview { object-fit: contain; background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius); }
.settings-form .card { max-width: 46rem; }

/* ---------- Sidebar groups ---------- */

.nav-heading {
    margin: 1rem 1rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}
.nav ul { padding-top: 0; padding-bottom: 0.25rem; }

/* ---------- Role / permission matrix ---------- */

.matrix th[scope="row"] { font-weight: 500; }
.matrix th[scope="row"] small { display: block; }
.matrix .group-row th { padding-top: 1rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-primary); background: #f3f7fb; }
.matrix .check-col { text-align: center; min-width: 6rem; }
.matrix input[type="checkbox"] { width: 1.1rem; height: 1.1rem; }

/* ---------- Tables become stacked cards on phones ---------- */

@media (max-width: 700px) {
    .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .table tr { display: block; padding: 0.5rem 0; border-bottom: 2px solid var(--color-border); }
    .table td { display: flex; justify-content: space-between; gap: 1rem; padding: 0.3rem 0.25rem; border: 0; text-align: right; }
    .table td[data-label]::before { content: attr(data-label); font-weight: 600; color: var(--color-muted); text-align: left; }
    .table td.actions { justify-content: flex-end; flex-wrap: wrap; }
    .matrix { min-width: 34rem; }
    .matrix thead { position: static; width: auto; height: auto; clip: auto; }
    .matrix tr { display: table-row; padding: 0; border: 0; }
    .matrix td, .matrix th { display: table-cell; text-align: left; }
    .matrix .check-col { text-align: center; }
    .search-form input[type="search"] { min-width: 0; flex: 1 1 100%; }
}

/* ---------- Notifications ---------- */

.bell { position: relative; display: inline-flex; align-items: center; padding: 0.35rem; color: var(--color-text); border-radius: var(--radius); }
.bell:hover { background: #eef1f5; }
.badge-count {
    position: absolute;
    top: -0.1rem;
    right: -0.15rem;
    min-width: 1.15rem;
    padding: 0 0.3rem;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.15rem;
    text-align: center;
    color: #fff;
    background: var(--color-error);
    border-radius: 999px;
}
.is-hidden { display: none; }
.notification-list { margin: 0; padding: 0; list-style: none; }
.notification-list li { border-bottom: 1px solid var(--color-border); }
.notification-list a { display: flex; justify-content: space-between; gap: 1rem; padding: 0.75rem 0.5rem; color: inherit; text-decoration: none; }
.notification-list a:hover { background: #f8fafc; }
.notification-list .unread { background: var(--color-info-bg); }
.notification-list .unread .notification-message { font-weight: 600; }
.notification-list .empty { padding: 2rem; text-align: center; color: var(--color-muted); }
.notification-time { white-space: nowrap; }

.timeline { margin: 0; padding: 0 0 0 1.25rem; border-left: 2px solid var(--color-border); list-style: none; }
.timeline li { position: relative; padding: 0 0 1rem 1rem; }
.timeline li::before { content: ""; position: absolute; left: -1.55rem; top: 0.35rem; width: 0.7rem; height: 0.7rem; background: var(--color-accent); border-radius: 50%; }
.timeline .small { display: block; }

/* ---------- Identity confirmation (step-up) ---------- */

.stepup { margin: 1.25rem 0 0; padding: 0.75rem 1rem 0.25rem; border: 1px solid var(--color-border); border-radius: var(--radius); background: #f8fafc; }
.stepup legend { padding: 0 0.4rem; font-weight: 600; }
.inline-label { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; }
.inline-label input { padding: 0.35rem 0.5rem; font: inherit; border: 1px solid var(--color-border); border-radius: var(--radius); }

/* ---------- Printable documents (GRN, issue voucher, purchase orders) ---------- */

.document { max-width: 52rem; margin: 0 auto; }
.letterhead { display: flex; align-items: center; gap: 1rem; padding-bottom: 0.75rem; margin-bottom: 1rem; border-bottom: 2px solid var(--color-primary); }
.letterhead h2 { margin: 0 0 0.15rem; font-size: 1.3rem; }
.letterhead p { margin: 0; font-size: 0.9rem; color: var(--color-muted); }
.document-title { margin: 0 0 1rem; font-size: 1.4rem; letter-spacing: 0.04em; text-transform: uppercase; }
.document-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; }
.summary-line { margin: 0 0 1rem; }
.danger-text { color: var(--color-error); font-weight: 600; }
.document-table tfoot th, .document-table tfoot td { font-weight: 700; border-top: 2px solid var(--color-text); }
.signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; margin-top: 3.5rem; font-size: 0.9rem; }
.signatures .line { display: block; margin-bottom: 0.35rem; border-top: 1px solid var(--color-text); }

/* ---------- Stock takes and reports ---------- */

.group-row th { background: #eef1f5; text-align: left; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }
.row-alert { background: var(--color-warning-bg); }
.decision { display: grid; gap: 1.5rem; margin-top: 1rem; }
.count-input { width: 7rem; text-align: right; }
.count-box { width: 7rem; min-width: 7rem; }
.document-table .count-box { border: 1px solid var(--color-text); height: 2rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.stat { padding: 0.9rem 1rem; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); }
.stat strong { display: block; font-size: 1.6rem; line-height: 1.2; }
.stat span { color: var(--color-muted); font-size: 0.85rem; }
.stat.is-alert { border-color: #f0dc9c; background: var(--color-warning-bg); }
.chart-box { position: relative; height: 22rem; margin: 1rem 0; }
.report-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.report-list li { padding: 0.7rem 0.9rem; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); }
.report-list a { font-weight: 600; }
.nav-badge { margin-left: 0.4rem; padding: 0 0.45rem; border-radius: 999px; background: var(--color-error); color: #fff; font-size: 0.75rem; font-weight: 700; }

/* ---------- Fingerprint: workstation pairing, scanner check, scanner dialog ---------- */

.pairing-card { border-left: 4px solid var(--color-accent); }
.pairing-code {
    margin: 0.25rem 0 0.75rem;
    font: 700 2rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: 0.15em;
    user-select: all;
}

.check-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.check-list li { padding: 0.55rem 0; border-bottom: 1px solid var(--color-border); }
.check-list li:last-child { border-bottom: 0; }
.check-mark { display: inline-block; width: 1.4rem; font-weight: 700; text-align: center; }
.check-list li[data-result="ok"] .check-mark { color: var(--color-success); }
.check-list li[data-result="fail"] .check-mark { color: var(--color-error); }
.check-list li[data-result="skip"] { color: var(--color-muted); }

.fp-modal {
    width: min(26rem, calc(100vw - 2rem));
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.35);
    color: var(--color-text);
}
.fp-modal::backdrop { background: rgba(15, 23, 42, 0.55); }
.fp-body { padding: 1.5rem; text-align: center; }
.fp-mock { margin: 0 0 1rem; padding: 0.4rem 0.6rem; font-size: 0.85rem; font-weight: 600; color: var(--color-warning); background: var(--color-warning-bg); border-radius: var(--radius); }
.fp-icon { width: 4.5rem; height: 4.5rem; margin: 0 auto 1rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; }
.fp-icon-finger::before { content: "\261D"; }
.fp-icon-check::before { content: "\2713"; }
.fp-icon-cross::before { content: "\2717"; }
.fp-tone-info { color: var(--color-info); background: var(--color-info-bg); }
.fp-tone-ok { color: var(--color-success); background: var(--color-success-bg); }
.fp-tone-danger { color: var(--color-error); background: var(--color-error-bg); }
.fp-tone-warning { color: var(--color-warning); background: var(--color-warning-bg); }
.fp-modal[data-state="capturing"] .fp-icon { animation: fp-pulse 1s ease-in-out infinite; }
.fp-title { font-size: 1.15rem; margin-bottom: 0.4rem; }
.fp-text { color: var(--color-muted); margin-bottom: 1.25rem; }
.fp-actions { display: flex; justify-content: center; gap: 0.5rem; }
@keyframes fp-pulse { 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .fp-modal[data-state="capturing"] .fp-icon { animation: none; } }

/* ---------- Print: strip the chrome, keep the document ---------- */

@media print {
    body { background: #fff; color: #000; }
    .sidebar, .topbar, .footer, .nav-backdrop, .no-print { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; }
    .card { border: 0; box-shadow: none; padding: 0; }
}
