:root {
    --navy: #16324f;
    --blue: #2f5d7e;
    --cyan: #8cc4df;
    --surface: #f4f7f9;
    --light: #d9eaf4;
    --line: #d9e1e7;
    --text: #233342;
    --muted: #6d7c89;
    --success: #247654;
    --warning: #956315;
    --danger: #ad3037;
    --sidebar-width: 232px;
    --shadow: 0 2px 9px rgba(22, 50, 79, .09);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--text); background: var(--surface); font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid color-mix(in srgb, var(--cyan) 70%, #fff); outline-offset: 2px; }

/* Shared STS application shell */
.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; z-index: 30; top: 0; display: flex; height: 100vh; flex-direction: column; overflow: hidden; color: #dce8ef; background: var(--navy); }
.brand { display: flex; height: 108px; flex: 0 0 108px; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 8px 14px; border-bottom: 1px solid #ffffff1d; color: #fff; }
.brand:hover { color: #fff; background: #ffffff08; }
.brand img { display: block; width: 176px; max-height: 78px; object-fit: contain; }
.brand-module { color: var(--light); font-size: 9px; font-weight: 850; letter-spacing: 3px; }
.sidebar nav { flex: 1 1 auto; overflow: auto; padding: 10px 8px; }
.nav-item { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; gap: 11px; width: 100%; min-height: 38px; margin: 1px 0; padding: 7px 10px; border-radius: 5px; color: #dce8ef; font-weight: 650; }
.nav-item:hover, .nav-item.active { color: #fff; background: #ffffff14; }
.nav-item.active { box-shadow: inset 3px 0 0 var(--cyan); }
.nav-icon { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 4px; background: #ffffff12; font-size: 10px; font-weight: 850; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user { flex: 0 0 auto; padding: 14px 18px; border-top: 1px solid #ffffff1d; }
.sidebar-user strong, .sidebar-user > small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user > small { color: #a8c2d2; }
.sidebar-user-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.sidebar-user-actions form { margin: 0; }
.sidebar-action { display: inline-flex; padding: 0; border: 0; color: #fff; background: transparent; font-size: 12px; font-weight: 650; }
.sidebar-action:hover { color: var(--cyan); }
.main-column { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; min-height: 82px; align-items: center; gap: 18px; padding: 13px 24px; border-bottom: 1px solid var(--line); background: #fff; }
.page-heading { min-width: 0; }
.page-heading p { margin: 0 0 1px; color: var(--blue); font-size: 9px; font-weight: 850; letter-spacing: 1.2px; }
.topbar h1 { margin: 0; font-size: 21px; line-height: 1.2; }
.module-context { margin-left: auto; padding: 5px 9px; border-radius: 3px; color: var(--navy); background: var(--light); font-size: 10px; font-weight: 850; letter-spacing: 1px; }
.mobile-menu { display: none; padding: 4px; border: 0; color: var(--navy); background: transparent; font-size: 23px; }
.content { width: 100%; max-width: 1800px; margin-inline: auto; padding: 20px 24px 42px; }

/* Page headings and actions */
.hero { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.hero h2 { margin: 2px 0; font-size: clamp(23px, 2.2vw, 29px); line-height: 1.2; }
.hero p { max-width: 780px; margin: 4px 0 0; color: var(--muted); }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 6px; background: #fff; box-shadow: var(--shadow); }
.report-head h2 { margin: 2px 0 5px; font-size: 22px; }
.report-head p { margin: 0; color: var(--muted); }
.actions, .page-actions, .form-actions, .approval-actions, .inline-form { display: flex; align-items: center; gap: 8px; }
.actions { justify-content: flex-end; flex-wrap: wrap; }
.page-actions { justify-content: flex-end; margin-bottom: 14px; }
.btn { display: inline-flex; min-height: 36px; align-items: center; justify-content: center; gap: 6px; padding: 8px 13px; border: 1px solid var(--blue); border-radius: 4px; color: var(--blue); background: #fff; font-weight: 750; text-decoration: none; }
.btn:hover { filter: brightness(.96); }
.btn.primary { color: #fff; background: var(--blue); }
.btn.danger { border-color: #e8bcbc; color: var(--danger); background: #fff; }

/* Metrics and panels */
.cards { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { min-width: 0; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 5px; background: #fff; box-shadow: var(--shadow); }
.metric { padding: 13px 14px; }
.metric span { display: block; overflow: hidden; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .35px; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.metric strong { display: block; margin-top: 4px; font-size: 24px; line-height: 1.15; }
.panel { min-width: 0; margin: 0 0 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: #fff; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 16px; }
.panel > .muted { padding: 0 17px 15px; }
.panel.form-grid { padding: 20px 22px; }
.panel > h3, .panel > h4 { margin: 0; padding: 16px 18px 0; }
.panel > .form-grid, .panel > form:not(.inline-form) { margin: 0; padding: 16px 18px 18px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.subnav { display: flex; gap: 5px; margin-bottom: 18px; overflow-x: auto; padding: 5px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.subnav a { flex: 0 0 auto; padding: 8px 11px; border-radius: 4px; color: var(--muted); font-weight: 750; }
.subnav a:hover, .subnav a.active { color: var(--navy); background: var(--light); }
.stack-list { display: grid; gap: 10px; padding: 14px 17px 18px; }
.admin-record { border: 1px solid var(--line); border-radius: 5px; background: #fbfcfd; }
.admin-record summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; cursor: pointer; }
.admin-record summary span, .admin-record summary small { display: block; }
.admin-record summary small { margin-top: 2px; color: var(--muted); }
.admin-record > form { padding: 0 14px 14px; }

/* Tables and status */
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 2; padding: 9px 10px; border-bottom: 1px solid var(--line); color: #415563; background: #edf3f6; text-align: left; font-size: 10px; font-weight: 800; letter-spacing: .35px; text-transform: uppercase; }
td { padding: 9px 10px; border-bottom: 1px solid #e9eef1; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f7fafb; }
td small { display: block; margin-top: 2px; color: var(--muted); }
.badge { display: inline-flex; min-height: 21px; align-items: center; justify-content: center; padding: 2px 8px; border-radius: 999px; color: #50636f; background: #edf2f5; font-size: 10px; font-weight: 800; line-height: 1.25; text-transform: uppercase; white-space: nowrap; }
.badge-paid, .badge-approved-for-payment, .badge-manager-approved, .badge-active { color: var(--success); background: #e4f4ed; }
.badge-returned { color: #87560c; background: #fff2df; }
.badge-rejected { color: var(--danger); background: #ffeaeb; }
.badge-submitted, .badge-manager-review, .badge-finance-review { color: var(--blue); background: #eaf5fb; }
.muted { color: var(--muted); font-weight: 400; }

/* Forms and workflow detail */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 750; }
.span-2 { grid-column: 1 / -1; }
input, select, textarea { width: 100%; padding: 8px 9px; border: 1px solid var(--line); border-radius: 4px; color: var(--text); background: #fff; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
.receipt { padding: 14px; border: 1px dashed #b9c8d0; border-radius: 5px; background: #f8fafb; }
.receipt small { color: var(--muted); font-weight: 400; }
.empty { padding: 42px 20px; color: var(--muted); text-align: center; }
.empty h2, .empty h3 { margin-top: 0; color: var(--text); }
.flash { margin-bottom: 16px; padding: 11px 13px; border: 1px solid #bfdfce; border-radius: 5px; color: var(--success); background: #edf8f2; }
.report-total { margin-top: 5px; font-size: 24px; font-weight: 800; text-align: right; }
.eyebrow { color: var(--blue); font-size: 10px; font-weight: 850; letter-spacing: 1.4px; text-transform: uppercase; }
.timeline { display: grid; gap: 0; padding: 4px 18px 18px; }
.timeline > div { padding: 10px 0 10px 16px; border-left: 3px solid var(--line); }
.timeline span { display: block; color: var(--muted); font-size: 12px; }
.timeline p { margin: 5px 0 0; }
.approval-actions { flex-wrap: wrap; margin: 0 18px 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.approval-actions form { display: flex; gap: 8px; }
.approval-actions input { min-width: 220px; }
.inline-form { margin: 16px 18px 18px; }
.compact-form { display: flex; gap: 8px; min-width: 290px; }
.compact-form select { min-width: 160px; }
.table-actions { display: flex; align-items: center; gap: 9px; }
.table-actions form { margin: 0; }
.link-button { padding: 0; border: 0; color: var(--blue); background: transparent; font-weight: 700; }
.danger-text { color: var(--danger); }
.check { display: flex !important; grid-auto-flow: column; grid-template-columns: auto 1fr; align-items: center; justify-content: start; gap: 7px !important; }
.check input { width: auto; }
.check-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px 14px; margin-bottom: 14px; }

/* Sign-in */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, var(--navy), #274f6e); }
.login-card { width: min(420px, 100%); overflow: hidden; padding: 0 28px 28px; border-radius: 7px; background: #fff; box-shadow: 0 18px 50px rgba(7, 27, 44, .4); text-align: center; }
.login-logo-panel { margin: 0 -28px 22px; padding: 18px 34px; background: var(--navy); }
.login-logo-panel img { display: block; width: 100%; max-height: 100px; object-fit: contain; }
.login-card h1 { margin-bottom: 5px; }
.login-card p { margin-top: 0; margin-bottom: 20px; color: var(--muted); }

@media (max-width: 1150px) {
    .cards { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
}

@media (max-width: 760px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); height: 100dvh; transform: translateX(-100%); transition: transform .2s ease; }
    .nav-open .sidebar { transform: translateX(0); }
    .nav-open::after { content: ""; position: fixed; inset: 0; z-index: 25; background: rgba(8, 25, 38, .52); }
    .mobile-menu { display: inline-flex; }
    .topbar { padding-inline: 14px; }
    .module-context { display: none; }
    .content { padding: 16px 14px 32px; }
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .hero, .report-head { align-items: flex-start; flex-direction: column; }
    .actions, .page-actions { width: 100%; }
    .actions .btn, .page-actions .btn { flex: 1; }
    .cards, .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .panel.form-grid { padding: 16px 14px; }
    .approval-actions form { width: 100%; flex-direction: column; }
    .approval-actions input { min-width: 0; }
    .report-total { text-align: left; }
    .compact-form { min-width: 240px; }
    .check-grid { grid-template-columns: 1fr; }
}
