:root {
  /* Hellion Tech brand: ink #0C1219, red #D72529 (sampled from the logo). */
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #f0f1f3;
  --border: #e1e4e8;
  --text: #0c1219;
  --muted: #6a7280;
  --accent: #d72529;
  --accent-weak: #fdeced;
  --green: #1a7f47;
  --green-weak: #e4f4ea;
  --amber: #9a6700;
  --amber-weak: #fbf1d6;
  --red: #b23b3b;
  --teal: #0f7285;
  --teal-weak: #ddf1f4;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1219;
    --surface: #141b24;
    --surface-2: #1b232e;
    --border: #29323d;
    --text: #e8ebef;
    --muted: #98a2ae;
    --accent: #f2585c;      /* lifted for contrast on the dark ink background */
    --accent-weak: #2b1517;
    --green: #4ac07d;
    --green-weak: #14271c;
    --amber: #e0b64a;
    --amber-weak: #2a2413;
    --red: #f0736f;
    --teal: #45c2d6;
    --teal-weak: #10262b;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 22px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
/* The `hidden` attribute must always win, even over class rules that set
   `display` (e.g. .modal{display:flex}). Without this the modal never hides. */
[hidden] { display: none !important; }
body {
  margin: 0;
  /* Lato is bundled for the PDFs; use it here too so screen and paper match. */
  font: 15px/1.5 "Lato", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
@font-face { font-family: "Lato"; font-weight: 400; font-display: swap;
  src: local("Lato"), url("/assets/Lato-Regular.ttf") format("truetype"); }
@font-face { font-family: "Lato"; font-weight: 600; font-display: swap;
  src: local("Lato Semibold"), url("/assets/Lato-Semibold.ttf") format("truetype"); }
@font-face { font-family: "Lato"; font-weight: 700; font-display: swap;
  src: local("Lato Bold"), url("/assets/Lato-Bold.ttf") format("truetype"); }

.brand-logo { height: 30px; width: auto; display: block; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 650; }
.logo { color: var(--accent); font-size: 22px; }
.mode-badge {
  font-size: 12px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 999px;
}

main { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-card .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-size: 24px; font-weight: 650; margin-top: 4px; }
.stat-card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-card .value.amount-line { font-size: 18px; }
.stat-card.outstanding .value { color: var(--amber); }
.stat-card.paid .value { color: var(--green); }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 20px; }
.panel-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { font-size: 15px; margin: 0; font-weight: 650; }
.hint { font-size: 12px; color: var(--muted); }

.reimburse { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.rb { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); }
.rb.owed { border-left: 3px solid var(--amber); }
.rb.settled { border-left: 3px solid var(--green); opacity: .8; }
.rb-name { font-weight: 650; font-size: 14px; }
.rb-amt { font-size: 15px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.rb.owed .rb-amt { color: var(--amber); }
.rb.settled .rb-amt { color: var(--green); font-size: 13px; }
.rb-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

.btn.small { height: 32px; font-size: 13px; padding: 0 12px; margin-top: 12px; }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 28px; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s; margin-bottom: 20px;
}
.dropzone:hover, .dropzone:focus { border-color: var(--accent); background: var(--accent-weak); outline: none; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-weak); }
.dz-icon { font-size: 30px; color: var(--accent); }
.dz-title { font-weight: 600; margin: 8px 0 4px; }
.dz-sub { color: var(--muted); font-size: 13px; margin: 0; }
.upload-log { margin-top: 16px; text-align: left; font-size: 13px; display: grid; gap: 4px; }
.upload-log .u-item { padding: 6px 10px; border-radius: 8px; background: var(--surface-2); }
.upload-log .u-item.ok { color: var(--green); }
.upload-log .u-item.dupe { color: var(--amber); }
.upload-log .u-item.err { color: var(--red); }
.upload-log .u-busy { color: var(--muted); }

/* Toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.control, .search, .btn {
  height: 38px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 0 12px; font-size: 14px;
}
.search { flex: 1 1 220px; min-width: 160px; }
.control { cursor: pointer; }
.spacer { flex: 1; }
.btn { background: var(--accent); color: #fff; border-color: transparent; cursor: pointer; font-weight: 550; padding: 0 16px; }
.btn:hover { filter: brightness(1.06); }
.btn.ghost, .control.ghost { background: var(--surface); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }

/* Table */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; min-width: 720px; }
.grid th, .grid td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.grid th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap; }
.grid th.num, .grid td.num { text-align: right; }
.grid th.actions-col { cursor: default; text-align: right; }
.grid tbody tr:hover { background: var(--surface-2); }
.grid td.payer { font-weight: 600; }
.grid td.muted, .grid .muted { color: var(--muted); }
.num-amount { font-variant-numeric: tabular-nums; font-weight: 600; }

.badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; font-weight: 600; display: inline-block; }
.badge.invoice { background: var(--accent-weak); color: var(--accent); }
.badge.receipt { background: var(--teal-weak); color: var(--teal); }

.chip { font-size: 12.5px; padding: 4px 11px; border-radius: 999px; border: 1px solid transparent; cursor: pointer; font-weight: 600; }
.chip.paid { background: var(--green-weak); color: var(--green); }
.chip.unpaid { background: var(--amber-weak); color: var(--amber); }
.chip:hover { filter: brightness(.97); border-color: var(--border); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--muted); height: 30px; width: 32px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red); }

.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); width: 560px; max-width: 100%; max-height: 90vh; overflow-y: auto; padding: 22px 24px; }
.modal-card h2 { margin: 0 0 16px; font-size: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 550; }
.form-grid .col-2 { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea {
  height: 38px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2);
  color: var(--text); padding: 0 11px; font-size: 14px; font-family: inherit;
}
.form-grid textarea { height: auto; padding: 9px 11px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* Toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 9px; font-size: 14px; box-shadow: var(--shadow); z-index: 100; }

/* `hidden` must override layout classes such as .modal and .upload-log. */
[hidden] { display: none !important; }
.bulk-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: -4px 0 14px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-weak); }
.bulk-bar .btn { margin: 0; }
.rb { text-align: left; font-family: inherit; color: var(--text); cursor: pointer; width: 100%; }
.rb:hover { filter: brightness(.98); transform: translateY(-1px); }
.reclaim { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.reclaim.yes { background: var(--green-weak); color: var(--green); }
.reclaim.check { background: var(--amber-weak); color: var(--amber); }
.reclaim.no { color: var(--muted); background: var(--surface-2); }

/* Tabs */
.tabs { display: flex; gap: 4px; }
.tab { background: transparent; border: 1px solid transparent; color: var(--muted); font: inherit;
  font-size: 14px; font-weight: 600; padding: 7px 14px; border-radius: 9px; cursor: pointer; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent-weak); color: var(--accent); border-color: var(--accent); }

/* Transaction status chips (not clickable — status is derived from coverage) */
.chip.unaccounted { background: var(--amber-weak); color: var(--amber); cursor: default; }
.chip.partial { background: var(--teal-weak); color: var(--teal); cursor: default; }
.chip.matched { background: var(--green-weak); color: var(--green); cursor: default; }
.chip.ignored { background: var(--surface-2); color: var(--muted); cursor: default; }

.grid td.num.neg { color: var(--amber); font-variant-numeric: tabular-nums; }
.grid td.num.pos { color: var(--green); font-variant-numeric: tabular-nums; }
.ref-cell { color: var(--muted); font-size: 13px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Coverage bar */
.bar { display: inline-block; width: 60px; height: 6px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden; margin-right: 6px; vertical-align: middle; }
.bar span { display: block; height: 100%; background: var(--green); }

/* Match score */
.score { font-weight: 700; font-size: 12px; padding: 2px 7px; border-radius: 999px; }
.score.hi { background: var(--green-weak); color: var(--green); }
.score.mid { background: var(--amber-weak); color: var(--amber); }
.score.lo { background: var(--surface-2); color: var(--muted); }

/* ---------------------------------------------------------------------------
   Login gate — matches the Hellion Oracle sign-in aesthetic so the two internal
   apps feel like one system. Tokens taken from oracle.helliontech.eu / the
   Keycloak "hellion" theme. Square corners, mono display type, red accent.
   --------------------------------------------------------------------------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: #0a0e17; color: #f5f7fa;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
/* engineering dot grid */
.auth-gate::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle, rgba(155,166,181,.08) 1px, transparent 1px);
  background-size: 24px 24px;
}
/* slow radar sweep */
.auth-gate::after {
  content: ""; position: absolute; inset: -50%; pointer-events: none;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(226,58,46,.07) 25deg,
              transparent 60deg, transparent 360deg);
  animation: hellion-sweep 8s linear infinite;
}
@keyframes hellion-sweep { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .auth-gate::after { animation: none; } }

.auth-card {
  position: relative; z-index: 1; width: 448px; max-width: 100%;
  padding: 40px; text-align: center;
  background: #11161f; border: 1px solid #1f2832; border-radius: 0;
  box-shadow: 0 20px 40px rgba(0,0,0,.4);
  animation: hellion-card-in .5s ease-out;
}
@keyframes hellion-card-in { from { opacity: 0; transform: translateY(12px); } }
/* red corner ticks */
.auth-card::before, .auth-card::after {
  content: ""; position: absolute; top: 0; width: 48px; height: 1px; background: #e23a2e;
}
.auth-card::before { left: 0; }
.auth-card::after  { right: 0; }

.auth-logo { height: 132px; width: auto; margin: 0 auto 22px; display: block;
  filter: drop-shadow(0 0 30px rgba(226,58,46,.18)); }
.auth-card h1 {
  margin: 0; font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
  font-size: 26px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: #f5f7fa;
}
.auth-sub { margin: 12px auto 26px; max-width: 320px; font-size: 14px;
  line-height: 1.55; color: #9ba6b5; }
.auth-btn {
  width: 100%; height: 50px; border-radius: 0; border: 1px solid #e23a2e;
  background: #e23a2e; color: #fff; cursor: pointer;
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
  font-size: 14px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase;
}
.auth-btn:hover { background: #ff5a3a; border-color: #ff5a3a; }
.auth-btn:focus-visible { outline: 2px solid #e23a2e; outline-offset: 2px; }
.auth-error {
  margin: 18px 0 0; padding: 10px 12px; text-align: left; font-size: 13px;
  background: rgba(226,58,46,.10); border: 1px solid #e23a2e; color: #f5f7fa;
}
.auth-foot {
  margin: 26px 0 0; font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: #5a6573;
}
.topbar-btn { height: 30px; font-size: 12px; padding: 0 12px; margin: 0; }

/* Bulk invoice dropzone — the primary action on the Bank tab */
.dropzone.accent-zone { border-color: var(--accent); background: var(--accent-weak); }
.dropzone.accent-zone .dz-icon { color: var(--accent); }
.upload-log .sub-item { font-size: 12px; padding: 3px 10px 3px 24px; opacity: .9; }

/* Document preview */
.modal-card.viewer { width: min(1000px, 96vw); height: 92vh; display: flex;
  flex-direction: column; padding: 14px 16px; }
.viewer-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.viewer-head h2 { margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 46%; }
.viewer-body { flex: 1; min-height: 0; border: 1px solid var(--border); border-radius: 9px;
  overflow: auto; background: var(--surface-2); display: flex; align-items: center;
  justify-content: center; }
.viewer-frame { width: 100%; height: 100%; border: 0; }
.viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Drill-down affordance on the financial tables */
table.mini.drillable tbody tr { cursor: pointer; }
table.mini.drillable tbody tr:hover { background: var(--accent-weak); }
table.mini.drillable tbody tr:hover td:first-child { font-weight: 700; }

/* Business update editor */
.upd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.upd-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px;
  color: var(--muted); font-weight: 600; }
.upd-grid .col-2 { grid-column: 1 / -1; }
.upd-grid textarea, .upd-grid input {
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2);
  color: var(--text); padding: 9px 11px; font: inherit; font-size: 13.5px; font-weight: 400;
  resize: vertical; }
.upd-grid textarea:focus, .upd-grid input:focus {
  outline: none; border-color: var(--accent); background: var(--surface); }
.lbl-hint { font-weight: 400; color: var(--muted); opacity: .85; font-size: 11.5px; }
.upd-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px;
  justify-content: flex-end; font-size: 12.5px; }

/* Financials tab */
.report-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.report-summary { margin-top: 12px; font-size: 13px; line-height: 1.5; }
.bar.wide { width: 120px; }

/* Upload-invoice-on-transaction zone (inside the attach modal) */
.txn-upload { display: flex; gap: 12px; align-items: center; margin: 14px 0 6px;
  padding: 14px 16px; border: 2px dashed var(--border); border-radius: 10px;
  background: var(--surface-2); cursor: pointer; font-size: 13px; line-height: 1.45;
  transition: border-color .15s, background .15s; }
.txn-upload:hover, .txn-upload:focus, .txn-upload.drag {
  border-color: var(--accent); background: var(--accent-weak); outline: none; }
.tu-icon { font-size: 22px; }
.txn-upload code { font-size: 12px; background: var(--surface); padding: 1px 5px; border-radius: 4px; }

.gvc-tag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: 2px 6px; border-radius: 5px; background: var(--surface-2); color: var(--muted);
  white-space: nowrap; }
.gvc-tag.warn-tag { background: var(--amber-weak); color: var(--amber); }

.sub-head { font-size: 13px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.warn { color: var(--amber); font-weight: 600; }
.ok-text { color: var(--green); font-weight: 600; }
.vat-note { font-size: 12px; margin-top: 10px; }
#txnDocs table.mini { margin-bottom: 4px; }

/* Reimbursement statement */
.rb-stmt { margin-top: 8px; font-size: 12px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--accent); cursor: pointer; font-weight: 600; }
.rb-stmt:hover { background: var(--accent-weak); }
.modal-card.wide { width: 760px; }
.stmt-block { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 14px; margin: 0; user-select: all; }
.stmt-actions { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; align-items: center; }
.stmt-meta { font-size: 13px; margin-bottom: 10px; display: grid; gap: 4px; }
.stmt-meta .warn { color: var(--amber); font-weight: 600; }
.stmt-items { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 9px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.mini th, table.mini td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.mini th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
table.mini td.num, table.mini th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.mini td.reclaim { text-align: center; }
