/* Hermes Billing — Operations console.
   A live revenue NOC: dark instrument surfaces, figures in tabular mono, money
   state carried by a semantic palette, and ONE signature — recovered "found
   money" in gold, the product's whole reason to exist. Not a card kit. */

:root {
  --bg: #0a1416;
  --surface: #0e1d21;
  --surface-2: #13272c;
  --rule: #1d363d;
  --rule-2: #2a4953;

  --ink: #eaf2f1;
  --ink-2: #a6bebe;
  --muted: #6f8a8d;

  /* signature: recovered / found money */
  --gold: #e6bb52;
  --gold-soft: #f1d487;
  --gold-bg: rgba(230,187,82,.12);

  /* semantic money states */
  --paid: #40cf8e;       --paid-bg: rgba(64,207,142,.13);
  --ar: #4fa9e2;         --ar-bg: rgba(79,169,226,.13);
  --pending: #e3a93f;    --pending-bg: rgba(227,169,63,.13);
  --denied: #f06b52;     --denied-bg: rgba(240,107,82,.13);
  --reversed: #b79cf0;   --reversed-bg: rgba(183,156,240,.13);

  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --rail-w: 244px;
  --maxw: 1240px;
  --r: 10px;
}

[data-theme="light"] {
  --bg: #eef2f1; --surface: #ffffff; --surface-2: #f4f8f7;
  --rule: #dde6e4; --rule-2: #c3d1ce;
  --ink: #0f2429; --ink-2: #44585d; --muted: #6c8085;
  --gold: #9a7414; --gold-soft: #b78c1d; --gold-bg: rgba(154,116,20,.1);
  --paid: #118a54; --paid-bg: rgba(17,138,84,.1);
  --ar: #1f6f9c; --ar-bg: rgba(31,111,156,.1);
  --pending: #a9730a; --pending-bg: rgba(169,115,10,.1);
  --denied: #b3341f; --denied-bg: rgba(179,52,31,.1);
  --reversed: #6e52a0; --reversed-bg: rgba(110,82,160,.1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; line-height: 1.12; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

.app { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100vh; }

/* ---- rail ---- */
.rail {
  border-right: 1px solid var(--rule); background: var(--surface);
  padding: 24px 18px; display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark {
  font-family: var(--mono); font-weight: 600; font-size: 18px;
  color: #0a1416; background: linear-gradient(145deg, var(--gold-soft), var(--gold));
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px;
}
.brand .word { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.brand .word span { color: var(--gold); font-weight: 600; }

.status { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.status .live {
  display: inline-flex; align-items: center; gap: 7px; align-self: flex-start;
  font-weight: 700; letter-spacing: 0.08em; font-size: 11px; color: var(--paid);
}
.status .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--paid); box-shadow: 0 0 0 0 var(--paid); animation: pulse 2.2s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(64,207,142,.5);} 70%{box-shadow:0 0 0 7px rgba(64,207,142,0);} 100%{box-shadow:0 0 0 0 rgba(64,207,142,0);} }
@media (prefers-reduced-motion: reduce) { .status .pulse { animation: none; } }
.status .synced { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }

nav { display: flex; flex-direction: column; gap: 2px; }
nav .label { font-size: 11px; color: var(--muted); margin: 6px 10px 6px; letter-spacing: 0.08em; text-transform: uppercase; }
nav button {
  text-align: left; font: inherit; color: var(--ink-2); cursor: pointer;
  background: none; border: 0; border-radius: 8px; padding: 9px 11px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
nav button:hover { background: var(--surface-2); color: var(--ink); }
nav button[aria-current="true"] { background: var(--gold-bg); color: var(--gold-soft); font-weight: 600; box-shadow: inset 2px 0 0 var(--gold); }
nav button .tag { font-size: 11px; color: var(--muted); font-family: var(--mono); }

.rail .foot { margin-top: auto; }
.themebtn {
  font: inherit; font-size: 12.5px; cursor: pointer; color: var(--ink-2);
  background: none; border: 1px solid var(--rule-2); border-radius: 8px; padding: 7px 12px;
}
.themebtn:hover { border-color: var(--gold); color: var(--ink); }

/* ---- main ---- */
main { padding: 34px clamp(18px, 4vw, 56px) 80px; max-width: calc(var(--maxw) + 112px); }
.view-head { margin-bottom: 24px; }
.view-head h1 { font-size: 28px; }
.view-head p { margin: 7px 0 0; color: var(--ink-2); max-width: 66ch; }

/* ---- hero: revenue in motion ---- */
.flow {
  border: 1px solid var(--rule); border-radius: var(--r); padding: 26px 28px 24px;
  background: radial-gradient(130% 160% at 100% 0, var(--surface-2), var(--surface) 62%);
  position: relative; overflow: hidden;
}
.flow::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: linear-gradient(90deg, var(--paid), var(--ar) 55%, var(--gold)); opacity: .8; }
.flow .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; flex-wrap: wrap; }
.flow .headline .big { font-size: clamp(38px, 5.4vw, 60px); font-weight: 700; letter-spacing: -0.035em; line-height: 1; }
.flow .headline .of { color: var(--muted); font-size: 14.5px; margin-top: 8px; }
.flow .headline .of b { color: var(--ink-2); font-weight: 500; }
.flow .recovered {
  text-align: right; border-left: 1px solid var(--rule); padding-left: 22px; min-width: 190px;
}
.flow .recovered .v { font-size: clamp(26px, 3vw, 34px); font-weight: 700; color: var(--gold); letter-spacing: -0.02em; }
.flow .recovered .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }

.flowbar { display: flex; height: 18px; margin: 24px 0 14px; border-radius: 4px; overflow: hidden; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--rule); }
.flowbar span { display: block; height: 100%; width: 0; transition: width 1s cubic-bezier(.22,.61,.36,1); }
.flowbar .s-paid { background: var(--paid); }
.flowbar .s-ar { background: var(--ar); }
.flowbar .s-denied { background: var(--denied); }
@media (prefers-reduced-motion: reduce) { .flowbar span { transition: none; } }
.legend { display: flex; flex-wrap: wrap; gap: 14px 24px; }
.legend .it { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend .amt { margin-left: 2px; color: var(--ink); font-weight: 500; }

/* ---- metric tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(156px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; margin-top: 24px; }
.tile { background: var(--surface); padding: 16px 18px; }
.tile .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tile .v { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin-top: 5px; }
.tile .v small { font-size: 13px; color: var(--muted); font-weight: 400; }
.tile.gold .v { color: var(--gold); }

/* ---- sections + tables ---- */
section.block { margin-top: 38px; }
section.block > h2 { font-size: 13px; color: var(--ink-2); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--rule-2); display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
section.block > h2 .meta { color: var(--muted); font-weight: 400; font-size: 12.5px; text-transform: none; letter-spacing: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; padding: 0 12px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
thead th.r, td.r { text-align: right; }
tbody td { padding: 12px; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
tbody tr:hover { background: var(--surface-2); }
td .cid { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
td .sub { color: var(--muted); font-size: 12px; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 100px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-paid { color: var(--paid); background: var(--paid-bg); }
.st-accepted { color: var(--ar); background: var(--ar-bg); }
.st-partially_paid, .st-pending { color: var(--pending); background: var(--pending-bg); }
.st-denied, .st-rejected, .st-transmission_failed { color: var(--denied); background: var(--denied-bg); }
.st-reversed { color: var(--reversed); background: var(--reversed-bg); }
.st-none { color: var(--muted); background: var(--surface-2); }
.flag { font-size: 11.5px; font-weight: 700; color: var(--gold); background: var(--gold-bg); padding: 2px 8px; border-radius: 5px; }

.empty { color: var(--muted); padding: 30px 12px; text-align: center; }
.loading { color: var(--muted); padding: 44px 0; }
.linkbtn { font: inherit; background: none; border: 0; color: var(--gold-soft); cursor: pointer; padding: 0; font-weight: 600; }
.linkbtn:hover { text-decoration: underline; }

/* ---- admin ---- */
.admincard { padding: 20px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); }
.genbtn { font: inherit; font-weight: 600; cursor: pointer; color: #0a1416; background: linear-gradient(145deg, var(--gold-soft), var(--gold)); border: 0; border-radius: 8px; padding: 10px 18px; }
.genbtn:disabled { opacity: .55; cursor: default; }
.keyout { margin-top: 16px; }
.klabel { font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.cmd { font-family: var(--mono); font-size: 13px; background: var(--bg); color: var(--ink); border: 1px solid var(--rule-2); border-radius: 8px; padding: 12px 14px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 0; }
.copybtn { font: inherit; font-size: 12.5px; cursor: pointer; margin-top: 8px; color: var(--ink-2); background: none; border: 1px solid var(--rule-2); border-radius: 6px; padding: 6px 12px; }
.copybtn:hover { border-color: var(--gold); color: var(--ink); }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 24px; }
.loginbox { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 30px 28px; }
.loginbox h2 { font-size: 20px; margin-top: 4px; }
.loginbox input { font: inherit; font-size: 15px; color: var(--ink); background: var(--bg); border: 1px solid var(--rule-2); border-radius: 8px; padding: 11px 13px; }
.loginbox input:focus { outline: none; border-color: var(--gold); }
.loginbox button { font: inherit; font-weight: 600; cursor: pointer; color: #0a1416; background: linear-gradient(145deg, var(--gold-soft), var(--gold)); border: 0; border-radius: 8px; padding: 11px; margin-top: 4px; }
.loginbox button:disabled { opacity: .6; cursor: default; }
.loginerr { font-size: 13px; color: var(--denied); min-height: 18px; }
.userbox { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.logoutbtn { font: inherit; font-size: 12px; cursor: pointer; color: var(--ink-2); background: none; border: 0; padding: 0; text-decoration: underline; }
.logoutbtn:hover { color: var(--gold); }

/* ---- workflow builder ---- */
.wfbuild { display: flex; flex-direction: column; gap: 14px; }
.wfinput, .wfsel { font: inherit; font-size: 14px; color: var(--ink); background: var(--bg); border: 1px solid var(--rule-2); border-radius: 7px; padding: 9px 11px; }
.wfinput:focus, .wfsel:focus { outline: none; border-color: var(--gold); }
.wflabel { font-size: 14px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wfgroup { border: 1px solid var(--rule); border-radius: 8px; padding: 14px; background: var(--surface); }
.wfgrouplabel { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.wfrow { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.wfrow .wfinput { flex: 1; min-width: 120px; }
.addbtn { font: inherit; font-size: 12.5px; cursor: pointer; color: var(--ink-2); background: none; border: 1px dashed var(--rule-2); border-radius: 7px; padding: 7px 12px; }
.addbtn:hover { border-color: var(--gold); color: var(--ink); }
.rmbtn { font: inherit; cursor: pointer; color: var(--muted); background: none; border: 0; font-size: 18px; line-height: 1; padding: 0 6px; }
.rmbtn:hover { color: var(--denied); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 14px 20px; padding: 16px; }
  .rail nav { flex-direction: row; flex-wrap: wrap; }
  .rail nav .label { display: none; }
  .rail .foot { margin: 0; }
  .flow .recovered { border-left: 0; padding-left: 0; text-align: left; }
  main { padding: 22px 16px 60px; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody tr { padding: 10px 0; }
  tbody td { border: 0; padding: 4px 2px; display: flex; justify-content: space-between; gap: 16px; }
  tbody td::before { content: attr(data-l); color: var(--muted); font-size: 12px; }
  td.r { text-align: left; }
}
