/* Receipt Reporting dashboard - restrained finance UI. No external fonts or assets (CSP: self only). */
:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f9faf8;
  --ink: #1b1f1d;
  --ink-2: #4a524e;
  --muted: #7a837e;
  --line: #e2e5e0;
  --line-2: #d3d8d1;
  --accent: #0f6b5c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ed;
  --ok: #1d7a46;   --ok-bg: #e5f4ea;
  --warn: #9a5b00; --warn-bg: #fdf1dc;
  --bad: #b3261e;  --bad-bg: #fbe7e5;
  --info: #24569e; --info-bg: #e6eef9;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 1px 1px rgba(20, 30, 25, .04);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111413; --surface: #181c1a; --surface-2: #1d2220; --ink: #e8ece9; --ink-2: #b9c1bc; --muted: #8b948f;
    --line: #2a302d; --line-2: #343b37; --accent: #3fb59c; --accent-ink: #08130f; --accent-soft: #17302a;
    --ok: #5ccf8a; --ok-bg: #16301f; --warn: #f0b456; --warn-bg: #33270f; --bad: #ff8a80; --bad-bg: #3a1a18;
    --info: #8ab4f8; --info-bg: #182638; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 22px; margin: 0 0 2px; letter-spacing: -.01em; }
h3 { font-size: 16px; margin: 0 0 12px; }
h4 { font-size: 13px; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.card h4:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.brand-mark { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; letter-spacing: .04em; }
.brand-mark.sm { width: 32px; height: 32px; font-size: 12px; border-radius: 8px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { color: var(--ink-2); padding: 8px 10px; border-radius: 6px; font-weight: 500; }
.sidebar nav a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); }
.me { border-top: 1px solid var(--line); padding: 12px 8px 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.me small { display: block; color: var(--muted); font-size: 11px; }
.content { padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; max-width: 760px; }
.back { font-size: 12px; display: inline-block; margin-bottom: 6px; }
.badges { display: flex; gap: 6px; }

/* cards & grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.warn-card { border-color: var(--warn); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .card + .grid-2 { margin-top: 16px; }
.cur-title { display: flex; align-items: center; gap: 8px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; cursor: help; }
.kpi span { color: var(--muted); font-size: 12px; }
.kpi strong { font-size: 18px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.alert-kpi { background: var(--surface); cursor: pointer; color: var(--ink); }
.alert-kpi:hover { border-color: var(--accent); text-decoration: none; }
.defs dl { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; margin: 0; }
.defs dt { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.defs dd { margin: 0; color: var(--ink-2); }

/* chart */
.chart { width: 100%; height: auto; max-height: 220px; }
.chart .bar { fill: var(--accent); opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart .axis { stroke: var(--line-2); }
.chart .tick { fill: var(--muted); font-size: 10px; }

/* forms */
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.filters.inline { display: flex; flex-wrap: wrap; }
.filters .actions { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin-bottom: 8px; }
.filters .field { margin-bottom: 0; }
.field label { font-size: 12px; color: var(--ink-2); font-weight: 500; }
input, select, textarea, .select-like { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 6px; padding: 7px 9px; min-height: 34px; width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .select-like:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.select-like { text-align: left; cursor: pointer; }
.multiselect { position: relative; }
.ms-pop { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin-top: 4px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; max-height: 260px; overflow: auto; }
.ms-opt { display: flex; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.ms-opt:hover { background: var(--surface-2); }
.ms-opt input, .check input { width: auto; min-height: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.adj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 10px; }
.resolve-box { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }

/* buttons */
.btn { font: inherit; font-weight: 600; border-radius: 6px; padding: 7px 14px; min-height: 34px; border: 1px solid transparent; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--ink); background: var(--surface); }
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { border-color: var(--line-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.sm { padding: 4px 10px; min-height: 28px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; }
.icon-btn { border: 0; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); padding: 9px 10px; white-space: nowrap; position: sticky; top: 0; }
.table td { border-bottom: 1px solid var(--line); padding: 8px 10px; vertical-align: top; }
.table tbody tr:hover { background: var(--surface-2); }
.table.compact td, .table.compact th { padding: 6px 8px; }
.table tr.clickable { cursor: pointer; }
.table tr.sub td { color: var(--ink-2); font-size: 12.5px; }
.table tr.sub td:nth-child(2) { padding-left: 22px; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable .sort-ind { margin-left: 4px; font-size: 10px; color: var(--muted); }
th.sortable.active { color: var(--accent); }
th.sortable.active .sort-ind { color: var(--accent); }
.result-count { padding: 10px 12px; font-size: 12.5px; color: var(--ink-2); border-bottom: 1px solid var(--line); }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; font-size: 12.5px; color: var(--ink-2); }
.pagination > div { display: flex; gap: 8px; align-items: center; }
.page-no { min-width: 90px; text-align: center; }
pre.json, pre.raw { margin: 0; font-family: var(--mono); font-size: 11px; white-space: pre-wrap; word-break: break-word; max-width: 340px; max-height: 160px; overflow: auto; color: var(--ink-2); }
pre.raw { max-width: none; max-height: 360px; background: var(--surface-2); padding: 10px; border-radius: 6px; }
details summary { cursor: pointer; color: var(--accent); margin-top: 8px; }

/* key-value */
.kv { display: grid; grid-template-columns: minmax(150px, 38%) 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; word-break: break-word; }

/* badges, chips, alerts */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.info { color: var(--info); background: var(--info-bg); }
.badge.muted { color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { font: inherit; font-size: 12.5px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.chip b { margin-left: 4px; color: var(--ink); }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.alert { border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.spinner { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 16px; }
.spinner .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }
.history { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 15, 12, .45); display: grid; place-items: start center; padding: 48px 16px; z-index: 50; overflow: auto; }
.modal { background: var(--surface); border-radius: 10px; width: min(560px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(980px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; }
.modal-body { padding: 16px 18px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 20px; margin: 14px 0 2px; }
.login-card p { margin: 0 0 18px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
  .brand { padding: 0; }
  .me { border: 0; padding: 0; margin-left: auto; }
  .content { padding: 16px; }
  .grid-2, .kpi-row { grid-template-columns: 1fr; }
  .kpi strong { font-size: 16px; }
  .defs dl { grid-template-columns: 1fr; }
}

/* language switch */
.lang-switch { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; margin: 8px 8px 12px; align-self: flex-start; }
.lang-switch button { font: inherit; font-size: 12px; font-weight: 600; border: 0; background: var(--surface); color: var(--ink-2); padding: 4px 10px; cursor: pointer; }
.lang-switch button.on { background: var(--accent); color: var(--accent-ink); }
.login-card .lang-switch { margin: 0 0 12px; float: right; }
@media (max-width: 900px) { .sidebar .lang-switch { margin: 0; order: 2; } }
