/* WAESTAOS design system — Waesta brand tokens (amber + navy), Inter, flat surfaces, dense ledger-style tables. */
:root {
  --wa-amber-50: #FFFBEB; --wa-amber-100: #FEF3C7; --wa-amber-400: #FBBF24; --wa-amber-500: #F59E0B; --wa-amber-600: #D97706; --wa-amber-700: #B45309;
  --wa-navy-50: #EFF6FF; --wa-navy-100: #DBEAFE; --wa-navy-600: #1D4ED8; --wa-navy-700: #1E40AF; --wa-navy-800: #1E3A8A; --wa-navy-900: #1E2F6A; --wa-ink: #0F1B4D;
  --wa-gray-50: #F9FAFB; --wa-gray-100: #F3F4F6; --wa-gray-200: #E5E7EB; --wa-gray-400: #9CA3AF; --wa-gray-600: #4B5563; --wa-gray-800: #1F2937; --wa-gray-900: #111827;
  --wa-success: #059669; --wa-warning: #B45309; --wa-danger: #DC2626; --wa-info: #0284C7;
  --canvas: #F6F4EF; --surface: #FFFFFF; --border: #E4E0D6; --border-strong: #CFC9BA; --text: #1F2937; --muted: #5B6472;
  --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  --sidebar-w: 248px;
}
@media (prefers-color-scheme: dark) { /* dark support is intentionally light-only for print-parity of finance documents */ }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.55; color: var(--text); background: var(--canvas); }
h1, h2, h3, h4 { font-family: var(--font); line-height: 1.25; margin: 0 0 .5em; color: var(--wa-ink); letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; } h2 { font-size: 18px; font-weight: 650; } h3 { font-size: 15px; font-weight: 650; }
a { color: var(--wa-navy-700); text-decoration: none; } a:hover { text-decoration: underline; }
p { margin: 0 0 .75em; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--wa-amber-500); color: #111; padding: 8px 14px; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--wa-amber-500); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---------- layout ---------- */
.wa-layout { display: flex; min-height: 100vh; }
.wa-sidebar { width: var(--sidebar-w); background: var(--wa-ink); color: #C9D2F0; position: fixed; inset: 0 auto 0 0; overflow-y: auto; z-index: 40; display: flex; flex-direction: column; transition: transform .2s; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--wa-amber-500); color: var(--wa-ink); display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.brand small { display: block; font-weight: 500; font-size: 10.5px; color: #8E9BD0; letter-spacing: .08em; text-transform: uppercase; }
.nav-group { padding: 10px 10px 2px; }
.nav-title { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: #7D8BC4; padding: 8px 10px 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #C9D2F0; min-height: 40px; font-weight: 500; }
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--wa-amber-500); color: var(--wa-ink); font-weight: 650; }
.nav-link .badge-count { margin-left: auto; background: var(--wa-danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 11.5px; color: #7D8BC4; border-top: 1px solid rgba(255,255,255,.08); }
.wa-main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(246,244,239,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 10px 24px; min-height: 58px; }
.menu-btn { display: none; }
.search { flex: 1; max-width: 460px; position: relative; }
.search input { width: 100%; padding: 9px 12px 9px 36px; border: 1px solid var(--border-strong); border-radius: 999px; background: #fff; font: inherit; min-height: 40px; }
.search .icon { position: absolute; left: 12px; top: 11px; color: var(--muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; background: #fff; border: 1px solid var(--border); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--wa-navy-700); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.content { padding: 24px; max-width: 1480px; width: 100%; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { margin: 0; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.site-foot { padding: 14px 24px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.offline-banner { display: none; background: var(--wa-amber-100); color: var(--wa-amber-700); padding: 8px 24px; font-weight: 600; border-bottom: 1px solid var(--wa-amber-400); }
body.is-offline .offline-banner { display: block; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; min-height: 40px; border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: #fff; color: var(--wa-ink); font: 600 14px var(--font); cursor: pointer; text-decoration: none; transition: transform .08s, background .15s, box-shadow .15s; }
.btn:hover { background: var(--wa-gray-50); text-decoration: none; box-shadow: 0 1px 0 rgba(15,27,77,.08); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--wa-amber-500); border-color: var(--wa-amber-600); color: var(--wa-ink); }
.btn-primary:hover { background: var(--wa-amber-400); }
.btn-navy { background: var(--wa-navy-700); border-color: var(--wa-navy-800); color: #fff; } .btn-navy:hover { background: var(--wa-navy-800); }
.btn-danger { background: #fff; color: var(--wa-danger); border-color: #F1B8B8; } .btn-danger:hover { background: #FEF2F2; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-lg { min-height: 48px; font-size: 15px; }
.btn[disabled], .btn.loading { opacity: .6; pointer-events: none; }
.btn-block { width: 100%; }
.inline-form { display: inline; }

/* ---------- cards & stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); gap: 10px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 16px; }
.stat { padding: 16px 18px; position: relative; display: block; color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--wa-amber-500); }
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 700; color: var(--wa-ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin-top: 4px; line-height: 1.15; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.stat.accent { background: var(--wa-ink); border-color: var(--wa-ink); } .stat.accent .label, .stat.accent .sub { color: #A8B4E8; } .stat.accent .value { color: #fff; }
.stat.alert .value { color: var(--wa-danger); }
.trend-up { color: var(--wa-success); } .trend-down { color: var(--wa-danger); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.wa-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.wa-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; padding: 10px 14px; border-bottom: 1px solid var(--border-strong); background: #FBFAF7; white-space: nowrap; position: sticky; top: 0; }
.wa-table th a { color: inherit; } .wa-table th .sort { color: var(--wa-amber-600); }
.wa-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.wa-table tbody tr:hover { background: #FCFBF8; }
.wa-table .num, .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.wa-table tfoot td { font-weight: 700; border-top: 2px solid var(--border-strong); background: #FBFAF7; }
.wa-table .row-actions { opacity: 0; white-space: nowrap; text-align: right; } .wa-table tr:hover .row-actions, .wa-table tr:focus-within .row-actions { opacity: 1; }
.cur { color: var(--muted); font-size: 11.5px; margin-right: 4px; font-family: var(--font); }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .strong { font-weight: 650; } .text-danger { color: var(--wa-danger); } .text-success { color: var(--wa-success); }
.table-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.pager { display: flex; gap: 4px; } .pager a, .pager span { min-width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); padding: 0 8px; }
.pager .current { background: var(--wa-ink); color: #fff; border-color: var(--wa-ink); } .pager .off { opacity: .4; }

/* ---------- badges ---------- */
.wa-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; line-height: 1.6; white-space: nowrap; }
.wa-badge::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.wa-badge-success { background: #DCFCE7; color: #047857; } .wa-badge-warning { background: var(--wa-amber-100); color: var(--wa-amber-700); }
.wa-badge-danger { background: #FEE2E2; color: #B91C1C; } .wa-badge-info { background: var(--wa-navy-100); color: var(--wa-navy-800); } .wa-badge-neutral { background: var(--wa-gray-100); color: var(--wa-gray-600); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.col-12 { grid-column: span 12; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; } .col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: var(--wa-gray-800); }
.field label.req::after { content: ' *'; color: var(--wa-danger); }
.input, select.input, textarea.input { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: #fff; font: 16px var(--font); color: var(--text); }
@media (min-width: 900px) { .input, select.input, textarea.input { font-size: 14px; } }
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { outline: 3px solid rgba(245,158,11,.35); border-color: var(--wa-amber-600); }
.input.invalid { border-color: var(--wa-danger); background: #FFF8F8; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 4px; } .field-error { font-size: 12.5px; color: var(--wa-danger); margin-top: 4px; font-weight: 600; }
.field-error::before { content: '✗ '; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.filters .field { min-width: 150px; } .filters .field.grow { flex: 1; min-width: 220px; }
.checkbox { display: flex; align-items: center; gap: 8px; min-height: 40px; } .checkbox input { width: 18px; height: 18px; accent-color: var(--wa-amber-600); }
.form-actions { display: flex; gap: 10px; padding-top: 6px; flex-wrap: wrap; }
.line-items th, .line-items td { padding: 6px 8px; } .line-items .input { min-height: 36px; padding: 6px 8px; }
.total-box { margin-left: auto; width: 320px; max-width: 100%; } .total-box div { display: flex; justify-content: space-between; padding: 5px 0; } .total-box .grand { border-top: 2px solid var(--wa-ink); font-weight: 700; font-size: 16px; margin-top: 4px; padding-top: 8px; }

/* ---------- flash / empty / misc ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius-md); margin-bottom: 14px; border: 1px solid; font-weight: 500; display: flex; gap: 10px; }
.flash-success { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; } .flash-error, .flash-danger { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }
.flash-warning { background: var(--wa-amber-50); border-color: var(--wa-amber-400); color: var(--wa-amber-700); } .flash-info { background: var(--wa-navy-50); border-color: var(--wa-navy-100); color: var(--wa-navy-800); }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); } .empty .icon { width: 36px; height: 36px; color: var(--wa-amber-600); margin-bottom: 8px; } .empty h3 { color: var(--wa-ink); }
.dl { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; } .dl dt { color: var(--muted); font-size: 13px; } .dl dd { margin: 0; font-weight: 500; word-break: break-word; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border-strong); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 16px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; } .tabs a.active { color: var(--wa-ink); border-color: var(--wa-amber-500); text-decoration: none; }
.progress { height: 8px; background: var(--wa-gray-200); border-radius: 999px; overflow: hidden; } .progress > span { display: block; height: 100%; background: var(--wa-amber-500); border-radius: 999px; }
.timeline { list-style: none; padding: 0; margin: 0; } .timeline li { padding: 0 0 14px 20px; border-left: 2px solid var(--border-strong); position: relative; margin-left: 6px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--wa-amber-500); }
.chart-box svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,27,77,.55); display: none; place-items: center; z-index: 90; padding: 16px; } .modal-backdrop.open { display: grid; }
.modal { background: #fff; border-radius: var(--radius-lg); width: 460px; max-width: 100%; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.3); } .modal h2 { margin-bottom: 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.skeleton { background: linear-gradient(90deg, #EEE9DD, #F7F4EC, #EEE9DD); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; min-height: 16px; } @keyframes sk { to { background-position: -200% 0; } }
.notif-dot { position: relative; } .notif-dot b { position: absolute; top: -4px; right: -4px; background: var(--wa-danger); color: #fff; font-size: 10px; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }

/* ---------- auth / plain ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-art { background: var(--wa-ink); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art::after { content: ''; position: absolute; right: -170px; bottom: -190px; width: 420px; height: 420px; border-radius: 50%; border: 56px solid var(--wa-amber-500); opacity: .95; }
.auth-art > * { position: relative; z-index: 2; }
.auth-art h1 { color: #fff; font-size: 40px; max-width: 12ch; line-height: 1.08; } .auth-art p { color: #B9C4F0; max-width: 40ch; }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; } .auth-card { width: 400px; max-width: 100%; }
.plain-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; } .plain-card { max-width: 520px; width: 100%; padding: 32px; }

@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .wa-sidebar { transform: translateX(-100%); } body.nav-open .wa-sidebar { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.5); }
  .wa-main { margin-left: 0; } .menu-btn { display: inline-flex; } .content { padding: 16px; } .topbar { padding: 8px 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; } .col-6, .col-4, .col-3, .col-8 { grid-column: span 12; }
  .auth-wrap { grid-template-columns: 1fr; } .auth-art { display: none; } .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 8px; }
  .user-chip .uname { display: none; } .wa-table .row-actions { opacity: 1; }
}
@media (max-width: 520px) { .grid-4 { grid-template-columns: 1fr; } .stat .value { font-size: 22px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print { .wa-sidebar, .topbar, .page-actions, .site-foot, .filters, .row-actions, .no-print { display: none !important; } .wa-main { margin: 0; } body { background: #fff; } .card { border: 0; } .content { padding: 0; } }

/* password show/hide */
.pw-wrap { position: relative; display: block; }
.pw-wrap .input { padding-right: 46px; }
.pw-toggle { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: var(--radius-md); cursor: pointer; }
.pw-toggle:hover { color: var(--wa-ink); background: var(--wa-gray-100); }
.pw-toggle:focus-visible { outline: 3px solid var(--wa-amber-500); outline-offset: -2px; }

/* ---------- help assistant ---------- */
.help-widget { position: fixed; right: 20px; bottom: 20px; z-index: 60; font-size: 14px; }
.help-fab { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 999px; border: 0; background: var(--wa-ink); color: #fff; font: 600 14px var(--font); cursor: pointer; box-shadow: 0 6px 24px rgba(15,27,77,.35); }
.help-fab:hover { background: var(--wa-navy-800); } .help-fab .icon { color: var(--wa-amber-400); }
.help-panel { position: absolute; right: 0; bottom: 60px; width: 400px; max-width: calc(100vw - 24px); height: min(620px, calc(100vh - 100px)); background: #fff; border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: 0 18px 60px rgba(15,27,77,.35); display: flex; flex-direction: column; overflow: hidden; }
.help-panel[hidden] { display: none; }
.help-head { background: var(--wa-ink); color: #fff; padding: 12px 14px; display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.help-sub { font-size: 12px; color: #A8B4E8; } .help-close { border: 0; background: transparent; color: #fff; font-size: 26px; line-height: 1; width: 40px; height: 40px; cursor: pointer; border-radius: 8px; } .help-close:hover { background: rgba(255,255,255,.12); }
.help-body { flex: 1; overflow-y: auto; padding: 12px 14px; background: #FBFAF7; }
.help-context { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.help-ctx-title { font-weight: 700; color: var(--wa-ink); margin-bottom: 4px; } .help-check { margin: 4px 0 8px; padding-left: 18px; color: var(--muted); } .help-check li { margin: 2px 0; }
.help-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.help-chip { border: 1px solid var(--border-strong); background: #fff; color: var(--wa-navy-700); border-radius: 999px; padding: 6px 12px; font: 600 12.5px var(--font); cursor: pointer; min-height: 32px; text-align: left; } .help-chip:hover { background: var(--wa-navy-50); }
.help-msg { margin: 10px 0; display: flex; flex-direction: column; gap: 8px; } .help-user { align-items: flex-end; }
.help-bubble { max-width: 92%; padding: 9px 12px; border-radius: 14px; background: #fff; border: 1px solid var(--border); } .help-user .help-bubble { background: var(--wa-navy-700); color: #fff; border-color: var(--wa-navy-700); }
.help-thinking { color: var(--muted); font-style: italic; }
.help-card { background: #fff; border: 1px solid var(--border-strong); border-left: 4px solid var(--wa-amber-500); border-radius: 10px; padding: 10px 12px; } .help-card-title { font-weight: 700; color: var(--wa-ink); } .help-card-sum { margin: 4px 0 6px; color: var(--muted); }
.help-card ol, .help-card ul { margin: 4px 0 8px; padding-left: 20px; } .help-card li { margin: 3px 0; } .help-card-sub { font-weight: 650; font-size: 12.5px; margin-top: 6px; color: var(--wa-amber-700); }
.help-error { background: var(--wa-amber-50); border: 1px solid var(--wa-amber-400); border-radius: 10px; padding: 10px 12px; } .help-error p { margin: 4px 0 0; }
.help-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: #fff; } .help-form .input { flex: 1; }
.help-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 8px 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); background: #fff; }
.help-explain { margin-left: 12px; border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 6px; padding: 2px 10px; font: 600 12.5px var(--font); cursor: pointer; }
.help-topic > summary { list-style: none; } .help-topic > summary::-webkit-details-marker { display: none; } .help-topic[open] > summary { background: #FBFAF7; }
@media (max-width: 520px) { .help-widget { right: 10px; bottom: 10px; } .help-panel { position: fixed; inset: auto 8px 68px 8px; width: auto; max-width: none; height: min(78vh, 640px); } }
@media print { .help-widget { display: none !important; } }
.help-fab { touch-action: none; cursor: grab; user-select: none; }
.help-widget.is-dragging .help-fab { cursor: grabbing; box-shadow: 0 10px 32px rgba(15,27,77,.5); }
.help-widget.is-dragging .help-panel { display: none; }
.help-widget.is-moved .help-panel { right: auto; left: 0; bottom: 60px; top: auto; }
.help-widget.is-moved:not(.is-left) .help-panel { left: auto; right: 0; }
.help-widget.is-moved.is-top .help-panel { bottom: auto; top: 60px; }
.help-widget.is-moved.is-top .help-panel { height: min(620px, calc(100vh - 100px)); }
@media (max-width: 520px) { .help-widget.is-moved .help-panel { position: fixed; left: 8px; right: 8px; width: auto; top: auto; bottom: 8px; height: min(78vh, 640px); } .help-widget.is-moved.is-top .help-panel { top: 8px; bottom: auto; } }
/* Simple document editor (editor.js) */
.rte { border: 1px solid var(--border-strong); border-radius: 10px; background: #fff; overflow: hidden; }
.rte:focus-within { box-shadow: 0 0 0 3px rgba(245,158,11,.25); border-color: var(--wa-amber-400); }
.rte-bar { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 8px 10px; background: #f6f7fb; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 2; }
.rte-group { display: inline-flex; gap: 4px; align-items: center; padding-right: 12px; border-right: 1px solid var(--border); }
.rte-btn, .rte-select { min-height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; color: var(--wa-ink); font: 500 13px var(--font); cursor: pointer; }
.rte-btn:hover, .rte-select:hover { background: #eef1fb; }
.rte-b { font-weight: 700; } .rte-i { font-style: italic; } .rte-u { text-decoration: underline; }
.rte-fields { border-color: var(--wa-amber-400); font-weight: 600; }
.rte-src { margin-left: auto; background: transparent; border-style: dashed; color: var(--muted); }
.rte-area { padding: 18px 22px; font: 400 15px/1.6 var(--font); outline: none; overflow-wrap: anywhere; }
.rte-area h1, .rte-area h2, .rte-area h3 { margin: 1em 0 .4em; }
.rte-area table { width: 100%; border-collapse: collapse; } .rte-area td, .rte-area th { border: 1px solid #b8bdd0; padding: 6px 8px; }
.ph-chip { display: inline-block; padding: 1px 9px; margin: 0 1px; border-radius: 999px; background: #fdf1d3; border: 1px solid var(--wa-amber-400); color: #6b4a00; font: 600 .88em var(--font); white-space: nowrap; user-select: all; cursor: default; }
.rte textarea.rte-source { width: 100%; border: 0; border-radius: 0; font: 13px/1.5 ui-monospace, Consolas, monospace; min-height: 320px; }
@media (max-width: 640px) { .rte-group { border-right: 0; padding-right: 0; } .rte-src { margin-left: 0; } }
@media print { .rte-bar { display: none; } }
.req-mark { color: var(--wa-danger); font-weight: 700; }
.req-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px 16px; }
.req-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.req-item:hover { background: #f6f7fb; } .req-item small { display: block; font-size: 12px; }
.req-item input { margin-top: 3px; width: 18px; height: 18px; }
.mm-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; align-items: end; }
.mm-go { grid-column: 1 / -1; }
.mm-status { display: flex; gap: 10px; align-items: center; padding: 12px 14px; margin-bottom: 14px; border-radius: 10px; background: #eef1fb; border: 1px solid var(--border); font-weight: 600; }
.mm-status.mm-ok { background: #e7f6ec; border-color: #9ad3ad; } .mm-status.mm-fail { background: #fdecea; border-color: #f0b3ad; }
.mm-spin { width: 16px; height: 16px; border-radius: 50%; border: 3px solid #b9c2ea; border-top-color: var(--wa-navy-800, #1b2a7a); animation: mmspin 1s linear infinite; }
@keyframes mmspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .mm-spin { animation: none; } }
/* sidebar: collapsible group with sub-items (Accounting) */
button.nav-link { width: 100%; background: none; border: 0; text-align: left; font: inherit; font-weight: 500; cursor: pointer; }
.nav-toggle .nav-chev { margin-left: auto; width: 16px; height: 16px; transition: transform .18s ease; }
.nav-toggle[aria-expanded="true"] .nav-chev { transform: rotate(180deg); }
.nav-toggle.is-current { color: #fff; background: rgba(255,255,255,.07); }
.nav-sub { margin: 2px 0 6px 20px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.14); display: flex; flex-direction: column; gap: 1px; }
.nav-sub[hidden] { display: none; }
.nav-sublink { display: block; padding: 7px 10px; border-radius: 7px; color: #AEB9E6; font-size: 13.5px; }
.nav-sublink:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-sublink.active { background: var(--wa-amber-500); color: var(--wa-ink); font-weight: 650; }
@media (prefers-reduced-motion: reduce) { .nav-toggle .nav-chev { transition: none; } }
/* card hubs (Settings, Accounting setup) */
.hub-group { margin: 26px 0 10px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.hub-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: #fff; border: 1px solid var(--border); border-radius: 14px; color: inherit; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.hub-card:hover, .hub-card:focus-visible { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(15,27,77,.12); border-color: var(--wa-amber-400); text-decoration: none; }
.hub-icon { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--wa-ink); color: var(--wa-amber-400); }
.hub-icon .icon { width: 22px; height: 22px; }
.hub-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hub-text small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.hub-go { flex: none; width: 18px; height: 18px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .hub-card { transition: none; } .hub-card:hover { transform: none; } }
.jump { position: relative; display: inline-block; }
.jump > summary { list-style: none; cursor: pointer; } .jump > summary::-webkit-details-marker { display: none; }
.jump-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 230px; background: #fff; border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: 0 14px 40px rgba(15,27,77,.22); padding: 6px; display: flex; flex-direction: column; }
.jump-menu a { padding: 9px 12px; border-radius: 8px; color: var(--wa-ink); text-decoration: none; }
.jump-menu a:hover { background: #eef1fb; } .jump-menu a.active { background: var(--wa-amber-500); font-weight: 650; }
/* delegation */
.acting-banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: #fff4d6; border: 1px solid var(--wa-amber-400); color: #5a3d00; }
.deleg-row { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding-bottom: 10px; border-bottom: 1px solid var(--border); } .deleg-row:last-child { border: 0; padding-bottom: 0; }
/* permission matrix */
.matrix-bar { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 6; background: #fff; }
.matrix-wrap { overflow: auto; max-height: 72vh; }
.matrix { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.matrix th, .matrix td { padding: 8px 10px; border-bottom: 1px solid var(--border); background: #fff; }
.matrix thead th { position: sticky; top: 0; z-index: 4; text-align: center; vertical-align: bottom; min-width: 110px; }
.matrix .matrix-perm { position: sticky; left: 0; z-index: 3; text-align: left; min-width: 280px; max-width: 340px; font-weight: 500; }
.matrix thead .matrix-perm { z-index: 5; }
.matrix .matrix-perm code { display: block; color: var(--muted); }
.matrix .matrix-area th { background: #eef1fb; text-transform: uppercase; letter-spacing: .06em; font-size: 11.5px; text-align: left; position: static; }
.matrix .is-sensitive th, .matrix .is-sensitive td { background: #fff7f6; }
.matrix-cell { text-align: center; } .matrix-cell input { width: 19px; height: 19px; cursor: pointer; } .matrix-cell input:disabled { cursor: not-allowed; opacity: .35; }
.matrix-col-actions { font-size: 11.5px; }
.linklike { background: none; border: 0; padding: 0; color: var(--wa-navy-800, #1b2a7a); cursor: pointer; font: inherit; font-size: 11.5px; text-decoration: underline; }
[data-matrix].is-dirty .matrix-bar { background: #fff8e0; }
/* per-page guide */
.page-guide { margin: 0 0 16px; border: 1px solid var(--border); border-left: 4px solid var(--wa-amber-400); border-radius: 10px; background: #fffdf6; }
.page-guide > summary { display: flex; gap: 10px; align-items: center; padding: 10px 14px; cursor: pointer; list-style: none; font-size: 14px; }
.page-guide > summary::-webkit-details-marker { display: none; }
.page-guide > summary .icon { color: var(--wa-amber-500); flex: none; }
.page-guide > summary::after { content: 'Hide'; margin-left: auto; font-size: 12px; color: var(--muted); }
.page-guide:not([open]) > summary::after { content: 'Show'; }
.page-guide-body { padding: 0 16px 12px 42px; font-size: 14px; }
.page-guide-body p { margin: 0 0 6px; } .page-guide-body ol { margin: 4px 0 8px 18px; padding: 0; } .page-guide-body li { margin: 2px 0; }
.page-guide-avoid { color: #7a4a00; }
/* stat tiles: the number scales with the tile so long amounts (e.g. 19,790,800) always fit, at a medium weight */
.stat { container-type: inline-size; min-width: 0; overflow: hidden; }
.stat .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; }
.stat .value { font-size: clamp(15px, 12cqi, 26px); font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .value small, .stat .value .unit { font-size: .6em; font-weight: 500; margin-right: 2px; }
.stat .sub { overflow-wrap: anywhere; }
.grid > .stat, .grid-3 > .stat, .grid-4 > .stat { min-width: 0; }

/* ---------- mobile refinements (phones and small tablets) ---------- */
.content, .card, .stack, .grid > *, .grid-main > *, .form-grid > *, .page-header > * { min-width: 0; }
.card { max-width: 100%; }
@media (max-width: 900px) {
  .content { padding: 12px; }
  .page-header { align-items: flex-start; margin-bottom: 14px; gap: 10px; }
  .page-header h1 { font-size: 22px; line-height: 1.2; }
  .page-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  .page-actions .btn { flex: 1 1 auto; justify-content: center; }
  .card-body { padding: 14px; } .card-head { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .filters { flex-direction: column; align-items: stretch; gap: 10px; } .filters .field { width: 100%; min-width: 0; } .filters .btn { width: 100%; }
  .wa-table { font-size: 13px; } .wa-table th, .wa-table td { padding: 8px 10px; }
  .card > table.wa-table, section > table.wa-table, .card-body > table.wa-table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .col-2, .col-5, .col-7, .col-9, .col-10, .col-11 { grid-column: span 12; }
  .btn { min-height: 40px; }
  .wa-sidebar { width: min(86vw, 300px); }
  .tabs a { padding: 9px 12px; }
  .hub-grid { grid-template-columns: 1fr; } .hub-card { padding: 13px 14px; } .hub-icon { width: 40px; height: 40px; }
  .site-foot { flex-direction: column; gap: 4px; text-align: center; }
  .matrix .matrix-perm { min-width: 190px; } .matrix-bar { position: static; }
  .page-guide-body { padding-left: 16px; }
  .deleg-row { flex-direction: column; }
  .acting-banner { font-size: 13px; }
}
@media (max-width: 640px) {
  .grid-4, .dash-kpis, .grid-3:has(> .stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 11px 12px; } .stat .label { font-size: 10.5px; letter-spacing: .05em; } .stat .sub { font-size: 11.5px; }
  .dash-kpis .stat { min-height: 78px; }
  .page-header h1 { font-size: 20px; }
  .card { border-radius: 12px; }
  .help-fab span { display: none; } .help-fab { min-height: 46px; width: 46px; padding: 0; justify-content: center; }
  .topbar { gap: 8px; padding: 8px 10px; }
  .doc-title, .docbar-title { font-size: 12px; }
  .board-col { flex-basis: 78vw; }
  h2 { font-size: 16px; } h3 { font-size: 15px; }
}

/* ---------- letterhead (browser print, report print view, settings preview) ---------- */
.letterhead { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.lh-brand { display: flex; gap: 14px; align-items: center; min-width: 0; }
.lh-logo { max-height: 64px; max-width: 200px; object-fit: contain; }
.lh-name { font-size: 20px; font-weight: 700; color: var(--wa-ink, #0f1b4d); line-height: 1.2; }
.lh-tagline { font-size: 12px; font-style: italic; color: #b45309; margin-top: 2px; }
.lh-contact { text-align: right; font-size: 12px; color: #4b5563; line-height: 1.5; }
.lh-rule { height: 3px; background: #f59e0b; border-bottom: 1px solid var(--wa-ink, #0f1b4d); margin: 12px 0 14px; }
.lh-date { font-size: 11.5px; color: #6b7280; margin-bottom: 8px; }
.letterhead-preview { background: #fff; }
.lh-sample { margin-top: 18px; } .lh-sample-title { font-weight: 700; letter-spacing: .06em; color: var(--wa-ink, #0f1b4d); } .lh-sample-title span { color: #b45309; margin-left: 8px; }
.lh-line { height: 9px; background: #e5e7eb; border-radius: 4px; margin-top: 10px; } .lh-line.short { width: 60%; }
.print-letterhead, .print-foot { display: none; }
.logo-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 170px; padding: 18px; border: 2px dashed var(--border-strong); border-radius: 14px; background: #fafbff; text-align: center; cursor: pointer; transition: background .15s, border-color .15s; }
.logo-drop:hover, .logo-drop.is-over, .logo-drop:focus-within { background: #fff8e0; border-color: var(--wa-amber-400); }
.logo-drop-img { max-height: 90px; max-width: 80%; object-fit: contain; }
.logo-drop-text small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.logo-drop-error { margin-top: 8px; color: var(--wa-danger); font-weight: 600; }
@media (max-width: 640px) { .letterhead { flex-direction: column; } .lh-contact { text-align: left; } }
@media print {
  /* any screen printed from the browser gets the letterhead and a footer */
  .print-letterhead { display: block; margin: 0 0 14px; }
  .print-foot { display: block; position: fixed; bottom: 0; left: 0; right: 0; padding-top: 6px; border-top: 1px solid #d1d5db; font-size: 10px; color: #6b7280; text-align: center; background: #fff; }
  .print-view .letterhead, .print-letterhead .letterhead { color: #000; }
  .lh-logo { max-height: 60px; }
  .page-guide, .acting-banner { display: none !important; }
  body { background: #fff !important; }
}
/* SMS */
.sms-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; } .sms-chips .ph-chip { cursor: pointer; border: 1px solid var(--wa-amber-400); }
.sms-warn { color: var(--wa-danger); font-weight: 600; }
.sms-bubble { background: #eef1fb; border-radius: 14px 14px 14px 4px; padding: 10px 14px; margin-bottom: 8px; max-width: 420px; white-space: pre-wrap; }
.label-like { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.lh-motto { font-style: italic; font-weight: 700; color: var(--wa-ink, #0f1b4d); font-size: 11px; margin-bottom: 2px; }

/* ---------- client portal polish ---------- */
.brand-logo { width: 44px; height: 34px; border-radius: 8px; background: #fff; display: grid; place-items: center; padding: 3px; flex: none; }
.brand-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.portal-contact { margin: 14px 12px 0; padding: 12px; border-radius: 10px; background: rgba(255,255,255,.07); font-size: 12px; color: #B9C4F0; display: flex; flex-direction: column; gap: 3px; overflow-wrap: anywhere; }
.portal-contact strong { color: #fff; font-weight: 600; font-size: 12.5px; } .portal-contact a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.mm-done { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 10px; background: #e7f6ec; border: 1px solid #9ad3ad; margin-bottom: 12px; }
.mm-done a { font-weight: 600; }
.empty-inline { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 13px; } .empty-inline strong { display: block; color: var(--wa-ink); font-weight: 600; margin-bottom: 2px; }
.auth-contact { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.auth-contact strong { color: var(--wa-ink); font-weight: 600; } .auth-logo { max-width: 200px; max-height: 64px; object-fit: contain; margin-bottom: 18px; display: block; }
.auth-art .auth-logo-tile { background: #fff; border-radius: 12px; padding: 8px 12px; display: inline-flex; align-self: flex-start; } .auth-art .auth-logo-tile img { max-height: 48px; max-width: 220px; object-fit: contain; }
@media (max-width: 640px) {
  .portal .table-cards thead { display: none; }
  .portal .table-cards, .portal .table-cards tbody, .portal .table-cards tfoot { display: block; }
  .portal .table-cards tbody tr { display: block; margin: 10px 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
  .portal .table-cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; border: 0; padding: 5px 0; text-align: right; }
  .portal .table-cards td[data-label]::before { content: attr(data-label); font-family: inherit; font-variant-numeric: normal; color: var(--muted); font-weight: 500; font-size: 12px; text-align: left; flex: none; }
  .portal .table-cards tfoot tr { display: flex; justify-content: space-between; gap: 12px; padding: 6px 16px; }
  .portal .table-cards tfoot td { display: block; padding: 0; border: 0; } .portal .table-cards tfoot td[colspan] { flex: 1; text-align: left; }
}
