/* Cosa Credits: operations dashboard. Summary tiles, usage table, balances, contract-rate check. */
:root {
  color-scheme: light;
  --bg: #f3f5f7; --surface: #ffffff; --ink: #17202b; --muted: #5d6b7a; --line: #dbe1e7; --accent: #1d4ed8;
  --good: #16794a; --good-bg: #e2f4ea; --warn: #a15c00; --warn-bg: #fdf0d5; --bad: #b3261e; --bad-bg: #fbe4e2;
  --hold: #4b3f8f; --hold-bg: #e9e6f7; --bar-cost: #8696a8; --bar-bill: #1d4ed8;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --bg: #0f151c; --surface: #17202a; --ink: #e8edf2; --muted: #93a2b2; --line: #2a3745; --accent: #7fa2ff;
    --good: #5fd39a; --good-bg: #153a2a; --warn: #f0b95a; --warn-bg: #3d2e10; --bad: #ff8f86; --bad-bg: #432020;
    --hold: #b8aaff; --hold-bg: #2a2550; --bar-cost: #5d6f82; --bar-bill: #7fa2ff; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans);
  padding: 24px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); }
.wrap { max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 8px 24px; }
h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.sub { color: var(--muted); font-size: 13px; }
h2 { margin: 0 0 12px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; min-width: 0; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-family: var(--mono); font-size: 26px; font-weight: 500; letter-spacing: -0.02em; margin: 2px 0; }
.tile .n { font-size: 12px; color: var(--muted); }
.tile.alert { border-color: var(--bad); } .tile.alert .v { color: var(--bad); }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; white-space: normal; }
th { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { border-top: 2px solid var(--line); border-bottom: 0; font-weight: 600; }
.who { font-weight: 500; } .brand { display: block; font-size: 12px; color: var(--muted); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; }
.pill.empty { background: var(--bad-bg); color: var(--bad); } .pill.low { background: var(--warn-bg); color: var(--warn); }
.pill.ok { background: var(--good-bg); color: var(--good); } .pill.hold { background: var(--hold-bg); color: var(--hold); }
.neg { color: var(--bad); }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.bars { display: flex; flex-direction: column; gap: 14px; }
.lbl { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 4px; }
.track { display: flex; flex-direction: column; gap: 3px; }
.bar { height: 10px; border-radius: 2px; } .bar.cost { background: var(--bar-cost); } .bar.bill { background: var(--bar-bill); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.rate { display: flex; flex-direction: column; gap: 10px; }
.rate-row { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 14px; align-items: baseline; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.rate-row:last-child { border-bottom: 0; padding-bottom: 0; }
.tag.ok { color: var(--good); } .tag.over { color: var(--warn); }
ul.clean { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.note { font-size: 12px; color: var(--muted); margin: 12px 0 0; }
.fresh { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; }
.dot.stale { background: var(--warn); } .dot.off { background: var(--bad); }
.center { min-height: 70vh; display: grid; place-items: center; }
.card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
label { font-size: 12px; font-weight: 600; color: var(--muted); }
input, select { width: 100%; padding: 10px 12px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
button { font: inherit; font-weight: 600; padding: 10px 14px; border-radius: 6px; border: 0; background: var(--accent); color: #fff; cursor: pointer; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.copy { margin-left: 8px; padding: 4px 10px; font-size: 12px; }
.msg { font-size: 13px; color: var(--muted); } .msg.err { color: var(--bad); }
.addrow { display: grid; grid-template-columns: 2fr 1fr 2fr auto; gap: 10px; align-items: end; }
@media (max-width: 640px) { .addrow { grid-template-columns: 1fr; } }
.overlay { position: fixed; inset: 0; background: rgba(10, 16, 24, 0.55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { width: min(440px, 100%); }
button.charge { padding: 5px 10px; font-size: 12px; white-space: nowrap; }
.ptable td { padding: 7px 10px; }
.ptable td:last-child { text-align: right; }
.ptable tr.sub td { font-weight: 600; border-top: 1px solid var(--line); }
.ptable tr.total td { font-weight: 700; border-top: 2px solid var(--line); font-size: 15px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
button.tab { background: transparent; color: var(--muted); border-radius: 6px 6px 0 0; padding: 9px 16px; border: 1px solid transparent; border-bottom: 0; font-weight: 500; }
button.tab.on { color: var(--ink); background: var(--surface); border-color: var(--line); font-weight: 600; margin-bottom: -1px; }
a.viewlink { color: var(--accent); font-size: 12px; font-weight: 500; white-space: nowrap; }
.banner { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); border-radius: 8px; padding: 10px 14px; font-size: 13px; }
.banner a { margin-left: 10px; }
