/* ==========================================================================
   SmartPay Web — design system
   --------------------------------------------------------------------------
   One stylesheet for every screen. The palette is the desktop client's navy
   and gold; the type is Hanken Grotesk for reading and Fraunces for titles
   and the figures that matter. Fonts are bundled, so the site looks the same
   on a LAN with no internet.

   Contents
     1  Tokens            6  Buttons             11  Tabs
     2  Base              7  Forms               12  Modals and toasts
     3  Shell & sidebar   8  Cards and stats     13  Pages (login, notices)
     4  Top bar           9  Grid (tables)       14  Utilities
     5  Page furniture   10  Badges and notes    15  Print
   ========================================================================== */

@font-face {
    font-family: "Hanken Grotesk";
    src: url("../fonts/hanken-grotesk-latin-wght-normal.woff2") format("woff2");
    font-weight: 100 900; font-style: normal; font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Hanken Grotesk";
    src: url("../fonts/hanken-grotesk-latin-ext-wght-normal.woff2") format("woff2");
    font-weight: 100 900; font-style: normal; font-display: swap;
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: "Fraunces";
    src: url("../fonts/fraunces-latin-wght-normal.woff2") format("woff2");
    font-weight: 100 900; font-style: normal; font-display: swap;
}

/* 1 ─ Tokens ─────────────────────────────────────────────────────────────── */
:root {
    --navy-900: #12263f;
    --navy-800: #183150;
    --navy-700: #1e3a5f;      /* brand */
    --navy-600: #2b4d79;
    --navy-500: #3a5a85;
    --navy-100: #dee6f0;
    --navy-50:  #eef2f7;

    --gold-600: #a8861c;
    --gold-500: #c9a227;      /* accent */
    --gold-300: #e6cd82;
    --gold-100: #f8f0d4;

    --ink:      #1c2b3a;
    --ink-2:    #45566a;
    --muted:    #6b7a8c;
    --line:     #d8dfe8;
    --line-2:   #e8ecf2;
    --paper:    #f1f4f8;
    --surface:  #ffffff;

    --ok:       #2d6a4f;  --ok-bg:     #e2efda;
    --warn:     #8a5a00;  --warn-bg:   #fdf1d3;
    --danger:   #9b2226;  --danger-bg: #fce4e4;
    --info:     #1d4ed8;  --info-bg:   #e3ecfd;

    --font: "Hanken Grotesk", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    --display: "Fraunces", Georgia, "Times New Roman", serif;

    --r-sm: 5px;
    --r: 8px;
    --r-lg: 12px;
    --shadow-1: 0 1px 2px rgba(18, 38, 63, .06), 0 1px 1px rgba(18, 38, 63, .04);
    --shadow-2: 0 10px 30px -12px rgba(18, 38, 63, .28), 0 2px 6px rgba(18, 38, 63, .08);
    --sidebar-w: 268px;
    --topbar-h: 62px;
}

/* 2 ─ Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--navy-800); }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14.5px; font-weight: 650; }
p { margin: 0 0 .75em; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .small { font-size: 12.5px; }
.muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: var(--navy-50); padding: 12px; border-radius: var(--r-sm); }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); z-index: 100; }
.skip:focus { left: 8px; }
::selection { background: var(--gold-300); color: var(--navy-900); }

/* 3 ─ Shell & sidebar ────────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: var(--sidebar-w); }

.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
    display: flex; flex-direction: column;
    background: var(--navy-800);
    color: #d5deea;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 16px 18px 14px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 9px; flex: none;
    display: grid; place-items: center;
    font-family: var(--display); font-size: 23px; font-weight: 600; color: var(--navy-900);
    background: var(--gold-500);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--display); font-size: 21px; font-weight: 560; letter-spacing: -.01em; }
.brand-tag { font-size: 12px; color: var(--gold-300); }

/* The woven band under the brand: a kente strip, drawn rather than pictured.
   It is the one decorative thing in the application. */
.kente {
    height: 7px; flex: none;
    background:
        repeating-linear-gradient(90deg,
            var(--gold-500) 0 14px, var(--navy-900) 14px 18px,
            #2d6a4f 18px 30px, var(--navy-900) 30px 34px,
            #b3392f 34px 44px, var(--navy-900) 44px 48px,
            var(--gold-300) 48px 54px, var(--navy-900) 54px 58px);
}

.nav-find { position: relative; display: block; margin: 14px 14px 8px; color: #9fb0c6; }
.nav-find .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; }
.nav-find input[type=search] {
    width: 100%; height: 34px; padding: 0 10px 0 32px;
    font: inherit; color: #fff;
    background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .1); border-radius: var(--r-sm);
}
.nav-find input[type=search]::placeholder { color: #9fb0c6; }
.nav-find input[type=search]:focus { outline: none; border-color: var(--gold-500); background: rgba(255, 255, 255, .11); }

.nav { flex: 1; overflow-y: auto; padding: 2px 8px 24px; scrollbar-width: thin; scrollbar-color: var(--navy-500) transparent; }
.nav-group + .nav-group { margin-top: 2px; }
.nav-head {
    width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 9px 10px; border: 0; border-radius: var(--r-sm);
    font: inherit; font-size: 12.5px; font-weight: 650; text-align: left; color: #aebcd0;
    background: none; cursor: pointer;
}
.nav-head:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.nav-head .icon { width: 14px; height: 14px; transition: transform .16s ease; }
.nav-group.is-open > .nav-head { color: var(--gold-300); }
.nav-group.is-open > .nav-head .icon { transform: rotate(90deg); }
.nav-items { list-style: none; margin: 0; padding: 0 0 6px; display: none; }
.nav-group.is-open > .nav-items, .nav.is-finding .nav-items { display: block; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px 7px 12px; margin: 1px 0; border-radius: var(--r-sm);
    color: #d5deea; font-size: 13.5px; border-left: 3px solid transparent;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-link .icon { width: 17px; height: 17px; opacity: .8; }
.nav-link.is-current { background: rgba(201, 162, 39, .16); color: #fff; border-left-color: var(--gold-500); font-weight: 600; }
.nav-link.is-current .icon { opacity: 1; color: var(--gold-300); }
.nav-count {
    margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 99px;
    font-size: 11.5px; font-weight: 700; text-align: center; color: var(--navy-900); background: var(--gold-500);
}
.nav [hidden] { display: none !important; }
.scrim { display: none; }

/* 4 ─ Top bar ────────────────────────────────────────────────────────────── */
.topbar {
    position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
    display: flex; align-items: center; gap: 16px; padding: 0 24px;
    background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-family: var(--display); font-size: 22px; font-weight: 560; letter-spacing: -.012em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { margin: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-org { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; max-width: 340px; }
.topbar-org-name { font-weight: 650; color: var(--navy-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.topbar-date { font-size: 12px; color: var(--muted); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--navy-50); color: var(--navy-700); }
.icon-btn.menu-btn { display: none; }

.user-menu { position: relative; }
.user-menu > summary { list-style: none; display: flex; align-items: center; gap: 9px; padding: 5px 8px 5px 5px; border-radius: 99px; cursor: pointer; border: 1px solid var(--line); }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover { background: var(--navy-50); }
.user-menu > summary .icon { width: 14px; height: 14px; transform: rotate(90deg); color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: var(--navy-700); }
.user-name { font-weight: 600; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-pop { position: absolute; right: 0; top: calc(100% + 8px); width: 250px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-2); }
.user-pop-head { display: flex; flex-direction: column; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line-2); }
.user-pop-head span { font-size: 12px; color: var(--muted); }
.user-pop a, .user-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer; }
.user-pop a:hover, .user-pop button:hover { background: var(--navy-50); text-decoration: none; }
.user-pop form { margin: 0; }

/* 5 ─ Page furniture ─────────────────────────────────────────────────────── */
.content { flex: 1; padding: 22px 24px 48px; outline: none; }
.content > * + * { margin-top: 16px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--ink-2); max-width: 78ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* A row of filters and buttons above a grid. Filters on the left, actions pushed right with .spacer. */
.toolbar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.toolbar .field { margin: 0; min-width: 150px; }
.toolbar .spacer { flex: 1; }
.toolbar form { display: contents; }
.toolbar-card { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }

.split { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 16px; align-items: start; }
.split.is-wide-left { grid-template-columns: 1fr minmax(300px, 420px); }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.stack > * + * { margin-top: 16px; }

/* 6 ─ Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px; padding: 0 14px;
    font: inherit; font-weight: 600; white-space: nowrap;
    color: var(--navy-700); background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r-sm);
    cursor: pointer; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--navy-50); border-color: #c3cedb; text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { color: #fff; background: var(--navy-700); border-color: var(--navy-700); }
.btn-primary:hover { background: var(--navy-600); border-color: var(--navy-600); }
.btn-gold { color: var(--navy-900); background: var(--gold-500); border-color: var(--gold-500); }
.btn-gold:hover { background: #d6af34; border-color: #d6af34; }
.btn-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #7f1b1f; border-color: #7f1b1f; }
.btn-ghost { background: transparent; }
.btn-link { border-color: transparent; background: none; color: var(--info); padding: 0 6px; }
.btn-link:hover { background: var(--info-bg); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn.is-busy { pointer-events: none; opacity: .75; }
.btn.is-busy::before { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* 7 ─ Forms ──────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field > label, .field > .label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .req { color: var(--danger); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=datetime-local],
input[type=time], input[type=month], input[type=tel], input[type=search], input[type=url], input[type=file], select, textarea {
    width: 100%; min-height: 36px; padding: 6px 10px;
    font: inherit; color: var(--ink);
    background: var(--surface); border: 1px solid #c5cfdb; border-radius: var(--r-sm);
    transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 72px; resize: vertical; line-height: 1.45; }
select { padding-right: 28px; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2345566a' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 9px center; }
select[multiple], select[size] { background-image: none; padding-right: 10px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(43, 77, 121, .16); }
input[readonly], input:disabled, select:disabled, textarea:disabled, textarea[readonly] { background: var(--navy-50); color: var(--ink-2); }
input[type=number], input.num { text-align: right; font-variant-numeric: tabular-nums; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--navy-700); margin: 0; }
input[type=file] { padding: 5px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }
.form-grid .span-all { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; font-weight: 500; cursor: pointer; }
.check-list { display: flex; flex-direction: column; gap: 2px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--line-2); }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 14px 4px; margin: 0 0 14px; }
legend { padding: 0 6px; font-weight: 650; color: var(--navy-700); font-size: 13px; }

/* Type-to-find over a long drop-down (site.js adds it to select[data-search]). */
.combo { position: relative; }
.combo-input { width: 100%; }
.combo-list { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 3px); max-height: 260px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-2); }
.combo-list li { padding: 6px 9px; border-radius: 4px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-list li:hover, .combo-list li.is-active { background: var(--navy-50); }
.combo-list li.is-none { color: var(--muted); cursor: default; }

/* 8 ─ Cards and stats ────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.card-head h2, .card-head h3 { font-size: 14.5px; font-weight: 650; }
.card-head .sub { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.card-body { padding: 16px; }
.card-body.is-flush { padding: 0; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--line-2); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.card > .grid { border: 0; box-shadow: none; border-radius: 0 0 var(--r) var(--r); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat { padding: 14px 16px 13px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); border-top: 3px solid var(--navy-700); min-width: 0; }
.stat.is-gold { border-top-color: var(--gold-500); }
.stat.is-ok { border-top-color: var(--ok); }
.stat.is-warn { border-top-color: #c98a0a; }
.stat.is-danger { border-top-color: var(--danger); }
.stat-label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.stat-value { font-family: var(--display); font-size: 27px; font-weight: 540; line-height: 1.2; color: var(--navy-800); font-variant-numeric: tabular-nums lining-nums; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value small { font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--muted); margin-right: 3px; }
.stat-hint { font-size: 12px; color: var(--muted); }

/* Label / value pairs: a staff file, a run's header. */
.dl { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 10px 20px; margin: 0; }
.dl > div { min-width: 0; }
.dl dt { font-size: 12px; color: var(--muted); }
.dl dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.dl dd:empty::after { content: "\2014"; color: var(--muted); font-weight: 400; }

/* 9 ─ Grid ───────────────────────────────────────────────────────────────── */
.grid { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); overflow: hidden; }
.grid-bar { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.grid-search { position: relative; flex: 0 1 280px; color: var(--muted); }
.grid-search .icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; }
.grid-search input[type=search] { min-height: 32px; height: 32px; padding-left: 30px; }
.grid-count { font-size: 12.5px; color: var(--muted); }
.grid-tools { margin-left: auto; display: flex; gap: 4px; }
.grid-scroll { overflow: auto; max-height: calc(100vh - 250px); min-height: 60px; }
.grid.is-compact .grid-scroll { max-height: none; }
.grid table, table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.grid th, table.table th {
    position: sticky; top: 0; z-index: 2;
    padding: 9px 12px; text-align: left; white-space: nowrap;
    font-size: 12.5px; font-weight: 650; color: var(--navy-800);
    background: var(--navy-50); border-bottom: 1px solid #c3cedb;
    user-select: none;
}
.grid th[data-col] { cursor: pointer; }
.grid th[data-col]:hover { background: var(--navy-100); }
.grid th[aria-sort]::after { content: "\25B2"; font-size: 8px; margin-left: 6px; vertical-align: middle; color: var(--gold-600); }
.grid th[aria-sort=descending]::after { content: "\25BC"; }
.grid td, table.table td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.grid td.wrap, table.table td.wrap { white-space: normal; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid .num, table.table .num { text-align: right; font-variant-numeric: tabular-nums lining-nums; }
.grid tbody tr:hover td { background: #f7f9fc; }
.grid[data-selectable] tbody tr, .grid[data-row-link] tbody tr { cursor: pointer; }
.grid tbody tr.is-selected td { background: #fbf4dc; box-shadow: inset 0 1px 0 var(--gold-300), inset 0 -1px 0 var(--gold-300); }
.grid tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--gold-500), inset 0 1px 0 var(--gold-300), inset 0 -1px 0 var(--gold-300); }
.grid tbody tr:focus-visible { outline: none; }
.grid tbody tr:focus-visible td { background: var(--navy-50); }
.grid tr.is-warn td { background: #fffaeb; }
.grid tr.is-danger td { background: #fff3f3; }
.grid tr.is-ok td { background: #f3faf0; }
.grid tr.is-muted td { color: var(--muted); }
.grid tr.is-strong td { font-weight: 650; }
/* Totals carry the accountant's double rule. */
.grid tfoot td, table.table tfoot td { padding: 9px 12px; font-weight: 700; color: var(--navy-800); background: var(--surface); border-top: 1px solid var(--navy-700); box-shadow: inset 0 -3px 0 var(--surface), inset 0 -4px 0 var(--navy-700); position: sticky; bottom: 0; }
.grid-empty td { padding: 34px 16px; text-align: center; color: var(--muted); white-space: normal; }
.col-check { width: 36px; text-align: center !important; }
.col-check input { display: block; margin: 0 auto; }
.col-actions { text-align: right !important; width: 1%; }
.grid td.col-actions { position: sticky; right: 0; background: var(--surface); box-shadow: -8px 0 8px -8px rgba(18, 38, 63, .18); overflow: visible; }
.grid th.col-actions { right: 0; z-index: 3; }
.col-actions .btn { height: 28px; padding: 0 9px; font-size: 12.5px; }
.col-actions form { display: inline; }
.grid-pager { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); }
.grid-pager button { min-width: 30px; height: 28px; padding: 0 8px; font: inherit; font-size: 12.5px; color: var(--navy-700); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.grid-pager button:hover:not(:disabled) { background: var(--navy-50); }
.grid-pager button[aria-current] { background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.grid-pager button:disabled { opacity: .4; cursor: default; }
.yn.is-no { color: var(--muted); }
.yn.is-yes { color: var(--ok); font-weight: 600; }
table.table { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
table.table th { position: static; }
table.table input, table.table select { min-height: 30px; height: 30px; padding: 3px 8px; }

/* 10 ─ Badges and notes ──────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; line-height: 1.7; }
.badge.is-ok { color: var(--ok); background: var(--ok-bg); }
.badge.is-warn { color: var(--warn); background: var(--warn-bg); }
.badge.is-danger { color: var(--danger); background: var(--danger-bg); }
.badge.is-info { color: var(--info); background: var(--info-bg); }
.badge.is-muted { color: var(--ink-2); background: var(--line-2); }

.note { display: flex; gap: 10px; padding: 11px 14px; border-radius: var(--r-sm); border-left: 4px solid var(--info); background: var(--info-bg); color: #1e3a6f; }
.note .icon { margin-top: 1px; }
.note.is-warn { border-left-color: #c98a0a; background: var(--warn-bg); color: #5f4000; }
.note.is-danger { border-left-color: var(--danger); background: var(--danger-bg); color: #6f181b; }
.note.is-ok { border-left-color: var(--ok); background: var(--ok-bg); color: #1f4a37; }
.note p:last-child { margin: 0; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty .icon { width: 34px; height: 34px; stroke-width: 1.3; margin-bottom: 6px; color: #9aa9bb; }
.empty h3 { color: var(--ink-2); margin-bottom: 4px; }
.empty p { max-width: 52ch; margin: 0 auto 12px; }

/* A slim proportion bar: leave used, loan repaid, target reached. */
.meter { height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; min-width: 80px; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: var(--navy-600); }
.meter.is-ok > span { background: var(--ok); }
.meter.is-warn > span { background: #c98a0a; }
.meter.is-danger > span { background: var(--danger); }

/* 11 ─ Tabs ──────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs > button, .tabs > a {
    padding: 9px 14px 10px; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px;
    font: inherit; font-weight: 600; color: var(--ink-2); background: none; white-space: nowrap; cursor: pointer;
}
.tabs > button:hover, .tabs > a:hover { color: var(--navy-700); text-decoration: none; background: var(--navy-50); border-radius: var(--r-sm) var(--r-sm) 0 0; }
.tabs > .is-current { color: var(--navy-800); border-bottom-color: var(--gold-500); }
.tabs .tab-count { margin-left: 6px; padding: 0 6px; border-radius: 99px; font-size: 11.5px; background: var(--line-2); color: var(--ink-2); }
[data-tab-panel] { margin-top: 16px; }
[data-tab-panel][hidden] { display: none; }

/* 12 ─ Modals and toasts ─────────────────────────────────────────────────── */
dialog.modal { width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-2); color: var(--ink); overflow: visible; }
dialog.modal::backdrop { background: rgba(18, 38, 63, .5); }
dialog.modal-sm { width: min(440px, calc(100vw - 32px)); }
dialog.modal-lg { width: min(900px, calc(100vw - 32px)); }
dialog.modal-xl { width: min(1160px, calc(100vw - 32px)); }
dialog.modal > form, dialog.modal > .modal-frame { display: flex; flex-direction: column; max-height: calc(100vh - 48px); margin: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.modal-head h2 { font-family: var(--display); font-size: 19px; font-weight: 560; }
.modal-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.modal-body { padding: 16px 18px 6px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line-2); background: #fafbfd; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.prompt-q { white-space: pre-line; }

.toasts { position: fixed; right: 20px; top: 74px; z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: var(--r-sm); box-shadow: var(--shadow-2); animation: toast-in .22s ease; }
.toast > span { flex: 1; white-space: pre-line; overflow-wrap: anywhere; }
.toast > .icon { margin-top: 1px; color: var(--ok); }
.toast.is-warn { border-left-color: #c98a0a; } .toast.is-warn > .icon { color: #c98a0a; }
.toast.is-error { border-left-color: var(--danger); } .toast.is-error > .icon { color: var(--danger); }
.toast.is-info { border-left-color: var(--info); } .toast.is-info > .icon { color: var(--info); }
.toast-x { border: 0; background: none; padding: 2px; color: var(--muted); cursor: pointer; border-radius: 4px; }
.toast-x:hover { background: var(--navy-50); color: var(--ink); }
.toast-x .icon { width: 14px; height: 14px; display: block; }
@keyframes toast-in { from { opacity: 0; transform: translateX(14px); } }

/* 13 ─ Pages ─────────────────────────────────────────────────────────────── */
/* Sign-in: the woven band is the page; the form sits on plain paper beside it. */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(380px, .95fr); background: var(--surface); }
.login-art { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 44px 52px; color: #fff; background: var(--navy-800); overflow: hidden; }
.login-art::before {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 26px;
    background: repeating-linear-gradient(180deg,
        var(--gold-500) 0 34px, var(--navy-900) 34px 42px,
        #2d6a4f 42px 70px, var(--navy-900) 70px 78px,
        #b3392f 78px 102px, var(--navy-900) 102px 110px,
        var(--gold-300) 110px 124px, var(--navy-900) 124px 132px);
}
.login-art > * { position: relative; margin-left: 18px; }
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand .brand-mark { width: 46px; height: 46px; font-size: 28px; border-radius: 11px; }
.login-brand .brand-name { font-size: 26px; }
.login-pitch h1 { font-family: var(--display); font-weight: 480; font-size: clamp(34px, 4.2vw, 56px); line-height: 1.08; letter-spacing: -.02em; color: #fff; max-width: 13ch; }
.login-pitch p { margin: 18px 0 0; max-width: 44ch; font-size: 15.5px; color: #c4d0df; }
.login-facts { display: flex; gap: 28px; flex-wrap: wrap; margin: 0 0 0 18px; padding: 0; list-style: none; font-size: 13px; color: #aebcd0; }
.login-facts strong { display: block; color: var(--gold-300); font-size: 13px; font-weight: 650; }
.login-form { display: flex; flex-direction: column; justify-content: center; padding: 44px clamp(28px, 6vw, 84px); }
.login-form h2 { font-family: var(--display); font-size: 28px; font-weight: 540; letter-spacing: -.015em; }
.login-form > p { color: var(--ink-2); margin: 6px 0 24px; }
.login-form form { max-width: 380px; }
.login-form input { min-height: 44px; font-size: 15px; }
.login-form .btn { width: 100%; margin-top: 6px; }
.login-foot { margin-top: 28px; font-size: 12.5px; color: var(--muted); max-width: 380px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 62px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); height: 30px; padding: 0 9px; border: 0; border-radius: 4px; background: none; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--navy-600); cursor: pointer; }
.pw-toggle:hover { background: var(--navy-50); }

.notice-page { display: grid; place-items: center; padding: 40px 0; }
.notice-card { width: min(620px, 100%); padding: 30px 32px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid #c98a0a; border-radius: var(--r); box-shadow: var(--shadow-1); }
.notice-card.is-danger { border-top-color: var(--danger); }
.notice-card > .icon { width: 34px; height: 34px; color: #c98a0a; stroke-width: 1.4; }
.notice-card.is-danger > .icon { color: var(--danger); }
.notice-card h2 { font-family: var(--display); font-size: 22px; font-weight: 560; margin: 10px 0 8px; }
.notice-msg { font-size: 15px; white-space: pre-line; }
.notice-actions { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.narrow { max-width: 520px; }
.medium { max-width: 860px; }

/* 14 ─ Utilities ─────────────────────────────────────────────────────────── */
.num { text-align: right; font-variant-numeric: tabular-nums lining-nums; }
.right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; }
.bold { font-weight: 650; }
.figure { font-family: var(--display); font-variant-numeric: tabular-nums lining-nums; }
.text-ok { color: var(--ok); } .text-warn { color: var(--warn); } .text-danger { color: var(--danger); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 8px !important; } .mt-2 { margin-top: 16px !important; } .mt-3 { margin-top: 24px !important; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: 8px !important; } .mb-2 { margin-bottom: 16px !important; }
.hidden, [hidden] { display: none !important; }
.photo { width: 96px; height: 116px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--navy-50); }
.photo-sm { width: 40px; height: 48px; }
.chart-box { position: relative; height: 280px; }
.chart-box.is-short { height: 200px; }
.print-only { display: none; }
#printArea { display: none; }

/* Responsive */
@media (max-width: 1180px) {
    .topbar-org { display: none; }
    .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
    .workspace { margin-left: 0; }
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-2); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(18, 38, 63, .45); }
    .icon-btn.menu-btn { display: inline-grid; }
    .topbar { padding: 0 14px; gap: 10px; }
    .content { padding: 16px 14px 40px; }
    .user-name { display: none; }
    .split, .split.is-wide-left, .cols-2, .cols-3 { grid-template-columns: minmax(0, 1fr); }
    .login { grid-template-columns: minmax(0, 1fr); }
    .login-art { padding: 28px 28px 28px 34px; gap: 28px; }
    .login-facts { display: none; }
    .grid-scroll { max-height: none; }
}
@media (max-width: 620px) {
    .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
    .form-grid .span-2, .form-grid .span-3 { grid-column: auto; }
    .dl { grid-template-columns: minmax(0, 1fr); }
    .topbar-title h1 { font-size: 18px; }
    .grid-tools .btn { padding: 0 7px; }
}
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* 15 ─ Print ─────────────────────────────────────────────────────────────── */
/* Printing a screen prints its content only: no menu, no buttons. A grid's own
   Print button prints just that grid, with a heading (see site.js). */
@media print {
    @page { margin: 14mm 12mm; }
    body { background: #fff; font-size: 11px; }
    .sidebar, .topbar, .toasts, .scrim, .skip, .page-actions, .toolbar, .toolbar-card, .grid-bar, .grid-pager, .tabs,
    .btn, .col-actions, .col-check, .no-print, dialog { display: none !important; }
    .workspace { margin: 0; }
    .content { padding: 0; }
    .card, .grid, .stat { box-shadow: none; border-color: #999; break-inside: avoid; }
    .grid { break-inside: auto; }
    .grid-scroll { max-height: none; overflow: visible; }
    .grid th, .grid td { padding: 4px 6px; white-space: normal; font-size: 10px; }
    .grid th { position: static; background: #e8edf3 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .grid tfoot td { position: static; }
    .grid tr { break-inside: avoid; }
    .grid tr[hidden] { display: table-row !important; }       /* print every page of a paged grid */
    [data-tab-panel][hidden] { display: block !important; }
    .print-only { display: block; }
    body.printing-grid .shell { display: none !important; }
    body.printing-grid #printArea { display: block; }
    #printArea table { width: 100%; border-collapse: collapse; font-size: 10px; }
    #printArea th, #printArea td { padding: 4px 6px; border-bottom: 1px solid #bbb; text-align: left; vertical-align: top; }
    #printArea th { background: #e8edf3 !important; border-bottom: 1.5px solid #1e3a5f; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    #printArea .num { text-align: right; }
    #printArea tfoot td { font-weight: 700; border-top: 1.5px solid #1e3a5f; border-bottom: 3px double #1e3a5f; }
    #printArea tr.is-total td { font-weight: 700; border-top: 1.5px solid #1e3a5f; border-bottom: 3px double #1e3a5f; }
    #printArea tr { break-inside: avoid; }
    #printArea thead { display: table-header-group; }
    .print-heading { font-family: var(--display); font-size: 16px; margin-bottom: 2px; color: #000; }
    .print-sub { font-size: 10px; color: #444; margin-bottom: 8px; }
    a { color: inherit; text-decoration: none; }
}

/* Report catalogue */
.report-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1px; background: var(--line-2); }
.report-item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: var(--surface); color: var(--ink); }
.report-item:hover { background: #f7f9fc; text-decoration: none; }
.report-item .icon { color: var(--gold-600); margin-top: 2px; }
.report-item strong { display: block; color: var(--navy-700); }
.report-item small { color: var(--muted); }

/* report viewer: the printable-sheet button above each tab */
.rp-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 10px; }
