/* UMHT FinFlow stylesheet. Palette and type facts live in facts/ui.md. Brand red is sampled from the FinFlow logo master. */

/* Inter is self-hosted because the Content Security Policy only allows same-origin assets. Variable font, weights 100 to 900. */
@font-face {
  font-family: 'Inter';
  src: url('fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #111827;
  --text: #1f2937;
  --muted: #64748b;
  --faint: #94a3b8;
  --primary: #dc1828;
  --primary-hover: #b9131f;
  --primary-bg: #fdecee;
  --primary-ring: rgba(220, 24, 40, 0.18);
  --sidebar-bg: #111827;
  --sidebar-hover: #1f2937;
  --sidebar-text: #e5e7eb;
  --sidebar-muted: #9ca3af;
  --sidebar-line: #1f2937;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #e5e7eb;
  --line-subtle: #f1f5f9;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --amber: #d97706;
  --amber-bg: #fef3c7;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 1px 3px rgba(17, 24, 39, 0.04);
  --shadow-lg: 0 20px 60px rgba(17, 24, 39, 0.18);
  --control-h: 36px;
  font-family: 'Inter', 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
* { box-sizing: border-box; }
/* Elements with the hidden attribute stay hidden even when a class sets display (the Clear filters text-link relies on it). */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
a { color: var(--primary); text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 24px; letter-spacing: -0.4px; margin-bottom: 6px; font-weight: 700; color: var(--ink); line-height: 1.25; }
h2 { font-size: 16px; letter-spacing: -0.2px; margin-bottom: 8px; color: var(--ink); font-weight: 600; }
h3 { font-size: 13px; margin-bottom: 6px; color: #334155; font-weight: 600; }
small, .muted { color: var(--muted); }
.small-text { font-size: 12px; line-height: 1.6; }
code { font-size: 12px; background: var(--line-subtle); padding: 2px 6px; border-radius: 4px; color: var(--ink); font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; }
.caption { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; font-weight: 600; color: var(--muted); }
.gap-bottom { margin-bottom: 20px; }
.top-gap { margin-top: 14px; }
.space-between { justify-content: space-between; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--primary); color: #fff; padding: 8px 14px; border-radius: 6px; z-index: 200; font-weight: 600; }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

.icon { width: 18px; height: 18px; display: inline-block; vertical-align: middle; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Brand and sidebar */
.brand { display: flex; gap: 10px; align-items: center; }
.brand a { display: block; line-height: 0; }
.brand-logo { max-width: 100%; height: auto; display: block; }
.sidebar { width: 240px; position: fixed; inset: 0 auto 0 0; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; z-index: 30; padding: 24px 14px 16px; overflow-y: auto; }
.sidebar .brand { padding: 2px 10px 0; }
.workspace-tag { font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--sidebar-muted); margin: 12px 0 26px 10px; font-weight: 600; }
.nav-label { font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; color: #6b7280; margin: 0 12px 8px; font-weight: 600; }
.sidebar nav { display: grid; gap: 2px; }
.nav-item { border: 0; background: none; color: #9ca3af; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; text-align: left; font-size: 13px; font-weight: 500; width: 100%; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-item .count { margin-left: auto; font-size: 10px; background: rgba(255, 255, 255, 0.14); border-radius: 10px; padding: 2px 7px; font-weight: 600; }
.nav-item.active .count { background: rgba(0, 0, 0, 0.25); color: #fff; }
.sidebar .divider { height: 1px; background: var(--sidebar-line); margin: 16px 10px; }
.sidebar-bottom { margin-top: auto; }
.security-note { display: flex; gap: 10px; border: 1px solid var(--sidebar-line); background: #0f172a; border-radius: 8px; padding: 12px; font-size: 11px; color: #94a3b8; line-height: 1.6; margin: 16px 4px; }
.security-note strong { color: #f1f5f9; font-weight: 600; }
.security-note .icon { color: var(--primary); margin-top: 2px; }
.account { display: flex; align-items: center; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--sidebar-line); }
.avatar { border-radius: 50%; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; background: #374151; color: #f9fafb; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.avatar.large { width: 44px; height: 44px; font-size: 15px; }
.account-name { font-size: 12px; color: #f3f4f6; font-weight: 500; }
.account-role { font-size: 10px; color: #9ca3af; margin-top: 2px; }
.account button { margin-left: auto; color: #9ca3af; }
.account button:hover { color: #fff; }
.icon-btn { border: 0; background: transparent; padding: 8px; border-radius: 7px; color: var(--muted); display: inline-flex; transition: background .15s; }
.icon-btn:hover { background: var(--line); color: var(--ink); }
.sidebar .icon-btn:hover { background: var(--sidebar-hover); color: #fff; }

/* Main frame */
.main { margin-left: 240px; min-height: 100vh; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 32px; background: rgba(255, 255, 255, 0.92); border-bottom: 1px solid var(--line); gap: 16px; position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px); }
.breadcrumb { font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.breadcrumb strong { color: var(--ink); font-weight: 600; }
.top-tools { display: flex; align-items: center; gap: 12px; }
.top-date { font-size: 12px; color: var(--muted); font-weight: 500; }
.notification-button { position: relative; }
.notification-dot { position: absolute; right: 7px; top: 6px; width: 8px; height: 8px; border: 1.5px solid #fff; background: var(--primary); border-radius: 50%; }
.content { padding: 28px 32px 44px; max-width: 1600px; margin: auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { font-size: 13px; color: var(--muted); margin-bottom: 0; line-height: 1.6; max-width: 640px; }
.demo-banner { background: var(--amber-bg); border-bottom: 1px solid #fde68a; color: #92400e; padding: 8px 20px; text-align: center; font-size: 12px; font-weight: 500; }
.mobile-menu { display: none; }
.mobile-overlay { display: none; }
.initial-load { height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; color: var(--muted); gap: 14px; text-align: center; padding: 20px; }
.initial-logo { border-radius: 14px; animation: pulseLogo 2s infinite ease-in-out; }
@keyframes pulseLogo { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.05); opacity: 0.85; } }
.initial-load p { font-size: 13px; }

/* Buttons */
.button { border: 1px solid #d1d5db; border-radius: var(--radius-sm); background: var(--surface); color: #374151; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-size: 13px; height: var(--control-h); white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s; box-shadow: 0 1px 1px rgba(17, 24, 39, 0.03); }
.button:hover { background: #f9fafb; border-color: #9ca3af; color: var(--ink); }
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button.danger { color: var(--red); border-color: #fca5a5; }
.button.danger:hover { background: var(--red-bg); }
.button.danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.button.danger-solid:hover { background: #b91c1c; border-color: #b91c1c; }
.button.small { padding: 0 10px; font-size: 12px; height: 30px; }
.button .icon { width: 15px; height: 15px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.text-link { border: 0; background: none; color: var(--primary); font-size: 12px; padding: 0; display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.text-link:hover { text-decoration: underline; color: var(--primary-hover); }
.text-link .icon { height: 13px; width: 13px; }

/* Status strip and notes */
.status-strip { display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; border-radius: var(--radius-sm); background: var(--line-subtle); border: 1px solid var(--line); color: #334155; font-size: 13px; line-height: 1.6; margin-bottom: 20px; }
.status-strip .icon { color: var(--muted); margin-top: 2px; }
.status-strip.rejected, .status-strip.cancelled { background: var(--red-bg); border-color: #fecaca; color: #991b1b; }
.status-strip.rejected .icon, .status-strip.cancelled .icon { color: var(--red); }
.status-strip.paid, .status-strip.approved, .status-strip.withdrawn { background: var(--good-bg); border-color: #bbf7d0; color: #166534; }
.status-strip.paid .icon, .status-strip.approved .icon, .status-strip.withdrawn .icon { color: var(--good); }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-sm); background: #f8fafc; border: 1px solid var(--line); font-size: 12px; color: #475569; line-height: 1.6; margin: 14px 0; }
.note .icon { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; }
.note.info { background: #eff6ff; border-color: #dbeafe; color: #1e40af; }
.note.warning { background: var(--amber-bg); border-color: #fde68a; color: #92400e; }
.note.success { background: var(--good-bg); border-color: #bbf7d0; color: #166534; }
.error-banner { background: var(--red-bg); border: 1px solid #fecaca; color: #991b1b; padding: 12px 15px; border-radius: var(--radius-sm); font-size: 13px; margin: 0 0 15px; line-height: 1.6; }

/* Welcome strip and metrics */
.welcome-strip { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; gap: 15px; box-shadow: var(--shadow); }
.welcome-strip p { margin: 0; font-size: 13px; color: #475569; line-height: 1.6; }
.welcome-strip strong { color: var(--ink); }
.welcome-strip .tag { font-size: 10px; color: var(--primary); border: 1px solid #f5b5bb; background: var(--primary-bg); border-radius: 4px; padding: 3px 7px; white-space: nowrap; font-weight: 600; letter-spacing: .5px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.metric.featured { background: var(--sidebar-bg); color: #fff; border-color: var(--sidebar-bg); position: relative; overflow: hidden; }
.metric.featured:after { content: ''; position: absolute; width: 140px; height: 140px; border: 20px solid rgba(220, 24, 40, 0.16); border-radius: 50%; right: -60px; top: -60px; pointer-events: none; }
.metric-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 16px; font-weight: 600; }
.metric-top .icon { width: 16px; height: 16px; color: var(--faint); }
.metric.featured .metric-top, .metric.featured .metric-note { color: #94a3b8; }
.metric.featured .metric-top .icon { color: var(--primary); }
.metric-value { font-size: 26px; font-weight: 700; letter-spacing: -0.6px; margin-bottom: 8px; font-variant-numeric: tabular-nums; color: var(--ink); }
.metric.featured .metric-value { color: #fff; }
.metric-value .currency-prefix { font-size: 13px; letter-spacing: 0; margin-right: 4px; font-weight: 500; opacity: .75; }
.metric-note { color: var(--muted); font-size: 11px; line-height: 1.6; }

/* Cards and grids */
.grid-main { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(260px, 1fr); gap: 20px; margin-bottom: 20px; }
.lower-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.card-pad { padding: 20px 22px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; padding: 18px 22px 0; margin-bottom: 14px; }
.card-head p { font-size: 12px; color: var(--muted); margin: 3px 0 0; line-height: 1.6; }
.card-head h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; margin-bottom: 0; }
.card-head select { font-size: 12px; border-color: var(--line); padding: 4px 26px 4px 10px; height: 30px; min-height: 30px; width: auto; }
.count-pill { font-size: 10px; background: var(--primary-bg); color: var(--primary); border: 1px solid #f5b5bb; border-radius: 10px; padding: 2px 7px; font-weight: 700; }
.chart { height: 200px; position: relative; padding: 0 18px 12px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-label { font-size: 10px; fill: var(--muted); }
.chart-caption { display: flex; align-items: center; justify-content: space-between; padding: 0 22px 18px; color: var(--muted); font-size: 11px; }
.legend { display: inline-flex; gap: 7px; align-items: center; }
.legend:before { content: ''; width: 8px; height: 8px; background: var(--primary); border-radius: 50%; }
.approval-summary { padding: 0 22px 18px; }
.approval-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-subtle); }
.approval-row:last-child { border: 0; }
.square-icon { height: 36px; width: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--line-subtle); color: #475569; flex-shrink: 0; }
.square-icon.amber { background: var(--amber-bg); color: #b45309; }
.square-icon.purple { background: #f3e8ff; color: #7e22ce; }
.square-icon.red { background: var(--red-bg); color: var(--red); }
.approval-row h3 { font-size: 13px; margin: 0 0 3px; font-weight: 600; color: var(--ink); }
.approval-row p { font-size: 11px; margin: 0; color: var(--muted); }
.approval-row .stat { margin-left: auto; font-size: 18px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.approval-footer { padding: 14px 22px; border-top: 1px solid var(--line); font-size: 12px; color: #475569; display: flex; justify-content: space-between; align-items: center; background: #f8fafc; font-weight: 500; }
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.quick-actions.two { grid-template-columns: 1fr 1fr; margin-top: 0; }
.quick-action { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); text-align: left; padding: 16px; font-size: 13px; font-weight: 600; color: var(--ink); transition: border-color .15s, background .15s; }
.quick-action:hover { border-color: var(--primary); background: var(--primary-bg); }
.quick-action .icon { display: block; margin-bottom: 12px; color: var(--primary); width: 20px; height: 20px; }
.quick-action small { display: block; font-size: 11px; margin-top: 6px; line-height: 1.6; color: var(--muted); font-weight: 400; }
.timeline-item { display: flex; gap: 12px; margin: 12px 0; font-size: 12px; }
.timeline-dot { width: 8px; height: 8px; background: #cbd5e1; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.timeline-dot.good { background: var(--good); }
.timeline-dot.bad { background: var(--red); }
.timeline-item p { margin-bottom: 3px; line-height: 1.6; }
.timeline-item small { font-size: 11px; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; text-align: left; }
th { background: #f8fafc; color: #475569; font-size: 11px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; padding: 11px 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
th.th-sortable { padding: 0; }
.th-button { border: 0; background: none; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; padding: 11px 16px; width: 100%; text-align: inherit; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; transition: background .12s, color .12s; }
th.amount .th-button { justify-content: flex-end; }
.th-button:hover { background: #f1f5f9; color: var(--ink); }
.sort-indicator { font-size: 9px; color: var(--faint); }
th.sorted-asc, th.sorted-desc { color: var(--ink); }
th.sorted-asc .sort-indicator, th.sorted-desc .sort-indicator { color: var(--primary); }
td { padding: 12px 16px; border-bottom: 1px solid var(--line-subtle); color: #334155; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
tr.row-muted td { color: var(--faint); }
.row-actions { white-space: nowrap; }
.row-actions > * { margin-left: 6px; }
.row-link { display: inline-flex; padding: 4px; color: var(--faint); }
.row-link:hover { color: var(--primary); }
.ref { color: var(--ink); font-size: 12px; font-weight: 700; transition: color .15s; }
.ref:hover { color: var(--primary); text-decoration: underline; }
.td-sub { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; white-space: normal; }
.amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; background: var(--line-subtle); color: #475569; line-height: 1.4; }
.badge:before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.approved, .badge.paid, .badge.withdrawn, .badge.verified, .badge.active, .badge.linked { background: var(--good-bg); color: #15803d; }
.badge.pending, .badge.submitted, .badge.partial { background: var(--amber-bg); color: #b45309; }
.badge.bank_pending { background: #f3e8ff; color: #7e22ce; }
.badge.rejected, .badge.cancelled, .badge.inactive { background: var(--red-bg); color: var(--red); }
.priority { font-size: 11px; color: var(--muted); font-weight: 500; }
.priority.Urgent { color: var(--red); font-weight: 700; }
.priority.High { color: var(--amber); font-weight: 700; }
.table-foot { border-top: 1px solid var(--line); padding: 11px 16px; display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); background: #f8fafc; align-items: center; flex-wrap: wrap; gap: 8px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .icon { height: 34px; width: 34px; color: var(--primary); background: var(--primary-bg); padding: 8px; border-radius: 10px; margin-bottom: 12px; }
.empty h3 { color: var(--ink); font-size: 15px; }
.empty p { font-size: 13px; line-height: 1.7; max-width: 380px; margin: 0 auto 16px; }

/* Data table component: toolbar, per-column filter row, empty row (public/assets/js/ui.js dataTable) */
.table-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
.table-count { font-size: 12px; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.table-tools { display: flex; align-items: center; gap: 14px; }
.table-filter-row th { background: #fbfcfd; padding: 6px 8px 8px; border-top: 0; text-transform: none; letter-spacing: 0; }
.table-filter-row th:first-child { padding-left: 12px; }
.col-filter-input, .col-filter-select { width: 100%; min-width: 90px; height: 30px; min-height: 30px; padding: 2px 8px; font-size: 12px; font-weight: 400; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: var(--text); text-transform: none; letter-spacing: 0; }
.col-filter-select { padding-right: 24px; }
.col-filter-input::placeholder { color: #b0b7c3; }
.col-filter-input:focus, .col-filter-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); outline: none; }
.col-filter-input::-webkit-search-cancel-button { cursor: pointer; }
.table-empty-row td { text-align: center; color: var(--muted); padding: 32px 16px; font-size: 13px; }

/* Filters and forms */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 150px; }
.filter-submit { display: flex; align-items: flex-end; }
input, select, textarea { border: 1px solid #d1d5db; border-radius: var(--radius-sm); background: #fff; color: var(--text); padding: 7px 12px; min-height: var(--control-h); max-width: 100%; width: 100%; transition: border-color .15s, box-shadow .15s; }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); outline: none; }
input[readonly] { background: #f8fafc; color: var(--muted); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; min-height: 84px; }
.field { display: grid; gap: 6px; font-size: 12px; color: #475569; margin-bottom: 14px; }
.field-label { font-weight: 600; color: #334155; }
.req { color: var(--red); margin-left: 3px; }
.help { font-size: 11px; color: var(--muted); line-height: 1.5; }
.field-error { display: block; font-size: 12px; color: var(--red); font-weight: 600; margin-top: 2px; }
.is-invalid input, .is-invalid select, .is-invalid textarea { border-color: var(--red); background: #fff8f8; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 18px; accent-color: var(--primary); }
.checkbox-label { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: #334155; margin-bottom: 10px; }
.checkbox-label input { width: 18px; margin-top: 2px; }
.checkbox-label .help { display: block; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .span2, .form-grid .field:has(textarea) { grid-column: span 2; }
.form-section { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-section h3 { margin-bottom: 12px; }
.stacked-form .actions { margin-top: 6px; }
.money-input { display: flex; align-items: stretch; }
.money-prefix { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid #d1d5db; border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: #f8fafc; font-size: 12px; color: #475569; font-weight: 600; white-space: nowrap; }
.money-input input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.form-total { font-size: 18px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.form-total .small-text { margin-right: 8px; font-weight: 400; color: var(--muted); }
.line-block { border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px 4px; margin: 0 0 12px; min-width: 0; background: #fafafa; }
.line-block legend { font-size: 12px; font-weight: 700; color: #334155; padding: 0 6px; }
.line-editor { display: grid; grid-template-columns: 1.5fr 1fr .8fr 150px 36px; gap: 10px; align-items: start; }
.line-editor .field { margin-bottom: 10px; }
.remove-line { margin-top: 24px; color: var(--red); }
.remove-line:hover { color: #b91c1c; }
.line-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.line-extra .field { margin-bottom: 10px; }
.pick-list { display: grid; gap: 6px; max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.pick-row { display: flex; gap: 12px; align-items: center; padding: 9px 12px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; font-size: 13px; }
.pick-row:hover { background: #f8fafc; border-color: var(--line); }
.pick-row input { width: 18px; }
.pick-row.disabled { opacity: .45; cursor: not-allowed; }
.pick-main { flex: 1; min-width: 0; }
.pick-main small { display: block; font-size: 11px; margin-top: 3px; color: var(--muted); }
.pick-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.confirm-summary { font-size: 13px; line-height: 1.7; color: #334155; }
.confirm-summary p { margin-bottom: 10px; }

/* Detail pages */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; }
.details { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; font-size: 13px; margin: 0; }
.details dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; font-weight: 600; }
.details dd { margin: 0; color: var(--ink); line-height: 1.6; overflow-wrap: anywhere; }
.details .full { grid-column: span 2; }
.purpose { white-space: pre-wrap; font-size: 13px; line-height: 1.8; color: #334155; }
.detail-amount { font-size: 28px; letter-spacing: -0.6px; margin: 12px 0 12px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.line-card { padding: 18px 22px; border-top: 1px solid var(--line); }
.line-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.line-head h3 { margin-bottom: 4px; color: var(--ink); }
.line-amount { text-align: right; display: grid; gap: 6px; justify-items: end; }
.line-amount strong { font-size: 16px; font-variant-numeric: tabular-nums; color: var(--ink); }
.attachments { display: grid; gap: 8px; margin-top: 10px; }
.attachment { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; overflow-wrap: anywhere; color: #334155; transition: background .15s; }
.attachment:hover { background: var(--line-subtle); }
.attachment .icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--primary); }
.attachment span { flex: 1; }
.attachment small { display: block; margin-top: 3px; color: var(--muted); }
.upload-label { display: block; border: 1px dashed #cbd5e1; border-radius: var(--radius-sm); padding: 12px; margin: 12px 0 0; text-align: center; color: #475569; font-size: 12px; cursor: pointer; transition: background .15s, border-color .15s; }
.upload-label:hover { background: #f8fafc; border-color: var(--primary); }
.upload-label input { display: block; border: 0; background: none; min-height: 0; padding: 8px 0 0; font-size: 11px; width: auto; margin: auto; }
.step { display: flex; align-items: center; gap: 11px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.step .circle { border: 1px solid #cbd5e1; border-radius: 50%; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; flex-shrink: 0; font-weight: 600; }
.step.done .circle { background: var(--good-bg); color: var(--good); border: 0; }
.step small { display: block; font-size: 11px; margin-top: 3px; color: var(--muted); }
.bank-note { font-size: 12px; color: var(--muted); line-height: 1.7; }

/* Inbox */
.inbox-list { display: grid; }
.inbox-card { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 16px; align-items: center; padding: 16px 22px; border-top: 1px solid var(--line); }
.inbox-title { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inbox-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.inbox-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* Notifications, reports, audit */
.alert-list { display: grid; }
.alert-item { display: block; padding: 14px 22px; font-size: 13px; color: #334155; border-bottom: 1px solid var(--line-subtle); }
.alert-item.unread { background: #eff6ff; font-weight: 600; }
.alert-item small { display: block; margin-top: 5px; font-size: 11px; color: var(--muted); }
.report-summary { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.report-total { background: var(--surface); border: 1px solid var(--line); padding: 16px 20px; border-radius: var(--radius); min-width: 190px; box-shadow: var(--shadow); }
.report-total strong { display: block; font-size: 22px; margin: 6px 0; font-variant-numeric: tabular-nums; color: var(--ink); }
.inline-code { white-space: pre-wrap; overflow-wrap: anywhere; background: #f8fafc; padding: 14px; font-size: 12px; max-height: 360px; overflow: auto; border-radius: 6px; border: 1px solid var(--line); font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; }
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Dialog and toast */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; max-width: 700px; width: calc(100% - 32px); max-height: 90vh; box-shadow: var(--shadow-lg); color: var(--text); }
dialog.wide { max-width: 960px; }
dialog::backdrop { background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; margin-top: 8px; border-top: 1px solid var(--line); flex-wrap: wrap; }
#toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 18px; background: var(--ink); color: #fff; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 13px; z-index: 100; display: none; max-width: 440px; line-height: 1.6; }
#toast.error { background: var(--red); }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-story { background: var(--sidebar-bg); color: #fff; padding: 56px 10%; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-story:after { content: ''; width: 500px; height: 500px; border: 60px solid rgba(220, 24, 40, 0.10); border-radius: 50%; position: absolute; right: -250px; top: 110px; pointer-events: none; }
.login-logo { width: 230px; height: auto; }
.login-copy { max-width: 430px; margin: 60px 0; }
.login-copy .caption { color: #f5b5bb; font-size: 11px; letter-spacing: 2px; }
.login-copy h1 { font-size: 44px; line-height: 1.15; font-weight: 700; letter-spacing: -1.2px; margin: 22px 0; color: #fff; }
.login-copy h1 span { color: var(--primary); }
.login-copy p { line-height: 1.8; color: #cbd5e1; font-size: 14px; }
.login-foot { font-size: 12px; color: #94a3b8; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--surface); }
.login-form-inner { width: 360px; max-width: 100%; }
.login-form h2 { font-size: 24px; margin-bottom: 8px; font-weight: 700; }
.login-form > .login-form-inner > p { color: var(--muted); line-height: 1.7; font-size: 13px; margin-bottom: 24px; }
.login-form input { padding: 10px 12px; min-height: 42px; }
.login-form .button { width: 100%; height: 42px; }
.login-form .caption { margin-bottom: 18px; }
.demo-box { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); }
.login-small { font-size: 11px; text-align: center; margin-top: 24px; color: var(--muted); line-height: 1.8; }
.signature-canvas { width: 100%; height: 180px; background: #fff; border: 1px dashed #cbd5e1; border-radius: 8px; touch-action: none; cursor: crosshair; }

/* Responsive */
@media (min-width: 1600px) { .content { padding-top: 36px; } .metric { padding: 22px 24px; } .chart { height: 230px; } }
@media (max-width: 1200px) {
  .sidebar { width: 210px; } .main { margin-left: 210px; } .content { padding: 24px 22px; } .topbar { padding: 0 22px; }
  .metrics { gap: 12px; } .metric { padding: 16px 14px; } .metric-value { font-size: 22px; } .grid-main { grid-template-columns: 1.5fr 1fr; }
  .detail-grid { grid-template-columns: minmax(0, 1fr) 280px; } .lower-grid { grid-template-columns: 1.4fr 1fr; } th, td { padding-left: 12px; padding-right: 12px; } .th-button { padding-left: 12px; padding-right: 12px; }
  .line-editor { grid-template-columns: 1fr 1fr; } .remove-line { margin-top: 0; }
}
@media (max-width: 960px) {
  .sidebar { width: 190px; padding-left: 10px; padding-right: 10px; } .main { margin-left: 190px; } .workspace-tag { margin-left: 4px; font-size: 9px; }
  .nav-item { font-size: 12px; padding: 9px 10px; gap: 9px; } .content { padding: 20px 18px; } .topbar { padding: 0 18px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main, .lower-grid, .detail-grid { grid-template-columns: 1fr; }
  .detail-grid aside { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } .top-date { display: none; } h1 { font-size: 22px; }
  .inbox-card { grid-template-columns: 1fr; } .inbox-actions { justify-content: flex-start; } .diff-grid { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; width: 250px; } .sidebar.open { transform: none; } .main { margin-left: 0; }
  .mobile-menu { display: inline-flex; } .mobile-overlay.open { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 25; }
  .topbar { height: 56px; padding: 0 14px; } .top-tools { gap: 6px; } .breadcrumb { gap: 8px; font-size: 12px; } .breadcrumb > span { display: none; }
  .content { padding: 16px 12px; } .page-head { gap: 10px; margin-bottom: 16px; } .page-head h1 { font-size: 22px; } .page-head .actions { width: 100%; } .page-head .actions .button { flex: 1; }
  .welcome-strip { padding: 12px 14px; flex-wrap: wrap; } .metrics { gap: 10px; } .metric { padding: 14px 12px; } .metric-value { font-size: 22px; }
  .card-head, .card-pad, .line-card, .inbox-card { padding: 14px; } .card-head { padding-bottom: 0; } .chart { height: 180px; }
  .quick-actions, .quick-actions.two { grid-template-columns: 1fr; } .quick-action { display: grid; grid-template-columns: 24px 1fr; gap: 0 10px; } .quick-action .icon { grid-row: span 2; margin: 0; align-self: center; } .quick-action small { grid-column: 2; }
  .form-grid { grid-template-columns: 1fr; } .form-grid .span2, .form-grid .field:has(textarea) { grid-column: auto; } .line-editor, .line-extra { grid-template-columns: 1fr; }
  .modal-body { padding: 16px; } .modal-head { padding: 16px; } .modal-foot .button { flex: 1; }
  .detail-grid aside { display: block; } .detail-grid aside .card { margin-bottom: 16px; } .details { grid-template-columns: 1fr; } .details .full { grid-column: auto; }
  .login { grid-template-columns: 1fr; } .login-story { padding: 28px 24px 32px; min-height: 180px; } .login-copy { margin: 20px 0 0; } .login-copy h1 { font-size: 28px; max-width: 300px; margin: 10px 0; } .login-logo { width: 180px; }
  .login-copy p, .login-foot, .login-copy .caption { display: none; } .login-form { padding: 28px 18px; } .login-form h2 { font-size: 22px; }
  .filters select, .filters .field { flex: 1; min-width: 45%; }
  .table-toolbar { padding: 10px 12px; } .col-filter-input, .col-filter-select { min-width: 110px; }
  .button, .icon-btn, input, select { min-height: 42px; } .button.small { min-height: 38px; } .col-filter-input, .col-filter-select { min-height: 36px; height: 36px; }
  #toast { bottom: 14px; right: 14px; left: 14px; } .report-total { min-width: 140px; flex: 1; } .line-head { flex-direction: column; } .line-amount { justify-items: start; text-align: left; }
}
@media print {
  .sidebar, .topbar, .actions, .filters, .demo-banner, #toast, .button, .mobile-overlay, .upload-label, .skip-link, .table-toolbar, .table-filter-row { display: none !important; }
  .main { margin: 0; } .content { padding: 0; } .card { box-shadow: none; break-inside: avoid; } .table-wrap { overflow: visible; } body { background: #fff; }
  th, td { white-space: normal; font-size: 10px; padding: 8px; } .detail-grid { display: block; } .sort-indicator { display: none; }
}
