/* KGT Petty Cash — calm, neutral, data-first. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --border: #e3e6ea;
  --text: #1c2430;
  --muted: #667085;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e6f4f2;
  --ok: #15803d;   --ok-soft: #e8f5ec;
  --warn: #b45309; --warn-soft: #fdf3e4;
  --bad: #b42318;  --bad-soft: #fdecea;
  --info: #3b5bdb; --info-soft: #edf1fd;
  --grey-soft: #eef0f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419; --surface: #171d24; --surface-2: #1e262f; --border: #2a333d;
    --text: #e6e9ed; --muted: #98a2b3; --accent: #2dd4bf; --accent-ink: #062b27; --accent-soft: #11332f;
    --ok: #4ade80; --ok-soft: #12301d; --warn: #fbbf24; --warn-soft: #33260c;
    --bad: #f87171; --bad-soft: #3a1717; --info: #93a8ff; --info-soft: #1b2346; --grey-soft: #232b35;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; position: sticky; top: 0;
        height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 4px 10px 18px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
               display: grid; place-items: center; font-size: 14px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.side .foot { margin-top: auto; font-size: 13px; color: var(--muted); padding: 10px; border-top: 1px solid var(--border); }
.side .foot form { display: inline; }
.main { padding: 28px 32px 60px; max-width: 1200px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .shell { display: block; }
  .side { display: none; }
  .main { padding: 16px 16px 96px; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface);
            border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px;
              color: var(--muted); padding: 4px 0; position: relative; }
  .tabbar a.on { color: var(--accent); }
  .tabbar a:hover { text-decoration: none; }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .snap { color: var(--accent-ink); }
  .tabbar .snap span.circle { background: var(--accent); width: 46px; height: 46px; border-radius: 50%; display: grid;
              place-items: center; margin-top: -20px; box-shadow: 0 4px 12px rgba(15,118,110,.35); }
  .tabbar .badge { position: absolute; top: 0; right: 22%; }
  .mobile-head { display: flex !important; }
  h1 { font-size: 20px; }
}
.mobile-head { display: none; align-items: center; justify-content: space-between; margin: -4px 0 14px; }
.mobile-head .brand { padding: 0; }

/* ---------- surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
        padding: 18px; }
.card + .card { margin-top: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px;
             border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .g2, .g3, .split { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 16px; }

.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 13px; color: var(--muted); }
a.stat { color: inherit; display: block; }
a.stat:hover { text-decoration: none; border-color: var(--accent); }

/* ---------- pills, badges */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
        font-weight: 600; white-space: nowrap; background: var(--grey-soft); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.matched, .pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.suggested, .pill.info { background: var(--info-soft); color: var(--info); }
.pill.missing, .pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.lost, .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.no_receipt, .pill.personal { background: var(--grey-soft); color: var(--muted); }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px;
         min-width: 20px; text-align: center; }
.badge.soft { background: var(--grey-soft); color: var(--muted); }

/* ---------- progress */
.progress { height: 8px; background: var(--grey-soft); border-radius: 99px; overflow: hidden; display: flex; }
.progress span { display: block; height: 100%; }
.progress .p-matched { background: var(--ok); }
.progress .p-no_receipt, .progress .p-personal { background: #9aa4b2; }
.progress .p-lost { background: var(--warn); }
.progress .p-suggested { background: var(--info); }
.progress.big { height: 12px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: 0; }

/* ---------- tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600;
     background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tfoot td { font-weight: 700; background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
td .sub { display: block; font-size: 12.5px; color: var(--muted); }
tr.fee td { color: var(--muted); font-size: 13.5px; }

/* mobile: tables become stacked rows */
@media (max-width: 640px) {
  table.rows thead { display: none; }
  table.rows, table.rows tbody, table.rows tr, table.rows td { display: block; width: 100%; }
  table.rows tr { padding: 12px 14px; border-bottom: 1px solid var(--border); display: grid;
                  grid-template-columns: 1fr auto; gap: 2px 10px; }
  table.rows td { border: 0; padding: 0; }
  table.rows td.m-hide { display: none; }
  table.rows td.m-full { grid-column: 1 / -1; }
  table.rows td.num { text-align: right; }
}

/* ---------- filters / tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
          color: var(--text); font-size: 13.5px; }
.tabs a:hover { text-decoration: none; border-color: var(--accent); }
.tabs a.on { background: var(--text); border-color: var(--text); color: var(--surface); }
.tabs a .n { color: var(--muted); margin-left: 4px; }
.tabs a.on .n { color: inherit; opacity: .7; }

/* ---------- forms */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search],
select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 12px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
@media (max-width: 520px) { .fields { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; }
.inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline .field { margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; border-radius: 8px;
       border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
       font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn svg { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; border: 1px solid transparent; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.flash.info { background: var(--info-soft); color: var(--info); }
.notice { padding: 12px 14px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 14px; margin-bottom: 12px; }
.notice.info { background: var(--info-soft); color: var(--info); }

/* ---------- drop zone */
.drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted);
        background: var(--surface); transition: .15s; cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop strong { color: var(--text); }
.drop svg { width: 26px; height: 26px; margin-bottom: 4px; }
svg { max-width: 100%; }
.cand svg, .page-head svg { width: 16px; height: 16px; }
.drop input { display: none; }

/* ---------- documents */
.thumb { width: 44px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--surface-2);
         border: 1px solid var(--border); display: grid; place-items: center; font-size: 10px; color: var(--muted);
         font-weight: 700; flex: none; }
.doc-cell { display: flex; gap: 12px; align-items: center; min-width: 260px; }
.doc-cell .sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.preview { background: var(--surface-2); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden;
           position: sticky; top: 16px; }
.preview img { width: 100%; display: block; }
.preview iframe, .preview object { width: 100%; height: 78vh; border: 0; display: block; background: #fff; }
@media (max-width: 860px) { .preview { position: static; } .preview iframe, .preview object { height: 60vh; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.cand { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.cand:last-child { border-bottom: 0; }
.cand .grow { flex: 1; min-width: 0; }
.cand .score { font-size: 12px; color: var(--muted); }

/* ---------- timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--border); position: relative; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%;
                       background: var(--surface); border: 2px solid var(--border); }
.timeline li.comment::before { border-color: var(--accent); }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .body { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-top: 4px; white-space: pre-wrap; }

/* ---------- auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth .brand { justify-content: center; padding-bottom: 8px; }
.qr { background: #fff; padding: 10px; border-radius: 10px; width: 220px; margin: 8px auto 12px; }
.qr svg { width: 100%; height: auto; display: block; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-family: var(--mono); font-size: 15px;
         background: var(--surface-2); padding: 14px; border-radius: 8px; margin: 12px 0; }
input.code { font-size: 22px; letter-spacing: .3em; text-align: center; font-family: var(--mono); }

/* ---------- snap */
.snap-wrap { max-width: 480px; margin: 0 auto; }
.snap-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
            width: 100%; aspect-ratio: 4 / 3; border-radius: 16px; background: var(--accent); color: var(--accent-ink);
            font-weight: 700; font-size: 18px; cursor: pointer; border: 0; }
.snap-btn svg { width: 56px; height: 56px; }
.snap-item { display: flex; gap: 12px; align-items: center; padding: 12px; border-bottom: 1px solid var(--border); }
.snap-item img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent);
           animation: spin .8s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- reports / print */
.report-head { margin-bottom: 18px; }
.summary-table td:first-child { color: var(--muted); }
@media print {
  .side, .tabbar, .no-print, .mobile-head { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  body { background: #fff; color: #000; font-size: 11px; }
  .card { border: 0; box-shadow: none; padding: 0; }
  th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  th, td { padding: 4px 6px; }
  a { color: #000; }
  table { page-break-inside: auto; } tr { page-break-inside: avoid; }
}

/* filter bar: Search | Supplier | Category | Type, then From (under Search) | To (under Supplier) */
.filters { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.filters .field { margin: 0; }
.filters .date-from { grid-column: 1; }
.filters .date-to { grid-column: 2; }
@media (max-width: 860px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .wide { grid-column: 1 / -1; }
  .filters .date-from { grid-column: 1; }
  .filters .date-to { grid-column: 2; }
}
