@font-face {
  font-family: Archivo;
  src: url("/archivo.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/plex-mono.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

/* UI values adapted from Mectory's Riso console tokens. */
:root {
  --bg: #f1eadd;
  --surface: #f7f2e8;
  --surface-sunken: #e8dfce;
  --surface-track: #ded2bd;
  --surface-inverse: #1f1d1a;
  --surface-inverse-hover: #3a3630;
  --text: #1f1d1a;
  --text-2: #555048;
  --text-3: #6f675b;
  --text-inverse: #f1eadd;
  --text-attn: #b83a17;
  --line: rgb(31 29 26 / .13);
  --line-strong: rgb(31 29 26 / .26);
  --status-run: #6493c6;
  --status-run-deep: #3f6e9f;
  --overlay-backdrop: rgb(31 29 26 / .3);
  --shadow-pop: 0 0 0 1px var(--line), 0 16px 40px -16px rgb(31 29 26 / .35);
  --font-cjk: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC";
  --font-sans: Archivo, var(--font-cjk), system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", var(--font-cjk), ui-monospace, monospace;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-pill: 999px;
  --h-md: 30px;
  --h-row: 36px;
  --h-touch: 44px;
  color-scheme: light;
  color: var(--text);
  background: var(--bg);
  font: 13px/19px var(--font-sans);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, h3, p { margin: 0; }
a { color: var(--text-2); text-underline-offset: .2em; }
a:hover { color: var(--text); }
button, select, input { font: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
button:disabled { opacity: .5; cursor: wait; }

.frame { width: min(1100px, calc(100% - 64px)); margin: 0 auto; }
.masthead { border-bottom: 1px solid var(--line); background: var(--surface); }
.masthead-inner { height: 52px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; gap: var(--sp-2); align-items: center; font-weight: 800; letter-spacing: -.03em; }
.mark { display: flex; align-items: end; gap: 2px; height: 13px; }
.mark i { display: block; width: 3px; height: 5px; background: var(--status-run-deep); }
.mark i:nth-child(2) { height: 9px; }
.mark i:nth-child(3) { height: 13px; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
.primary, .quiet { border: 0; padding: 0 13px; min-height: var(--h-md); font-size: 12.5px; }
.primary { border-radius: var(--r-pill); background: var(--surface-inverse); color: var(--text-inverse); font-weight: 600; }
.primary:hover { background: var(--surface-inverse-hover); }
.quiet { color: var(--text-2); background: transparent; border-radius: var(--r-sm); }
.quiet:hover { background: var(--surface-sunken); color: var(--text); }

.heading { display: flex; align-items: end; justify-content: space-between; gap: var(--sp-6); padding: var(--sp-8) 0 var(--sp-5); }
.kicker { font: 11px/16px var(--font-mono); color: var(--text-3); margin-bottom: var(--sp-1); }
h1 { font-size: clamp(28px, 4.2vw, 38px); line-height: 1.08; font-weight: 700; letter-spacing: -.03em; }
.filters { display: flex; gap: var(--sp-2); }
.filters label { display: grid; gap: var(--sp-1); font-size: 11.5px; color: var(--text-3); }
select, input {
  color: var(--text); background: var(--surface-sunken); border: 1px solid var(--line);
  border-radius: var(--r-sm); min-height: var(--h-md); padding: 0 var(--sp-2);
}
input:focus, select:focus { background: var(--surface); }
select { max-width: 242px; min-width: 112px; }
.overview { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); padding: var(--sp-5) var(--sp-6) 0; }
.overview-top { display: flex; justify-content: space-between; align-items: start; gap: var(--sp-3); }
.overview h2 { font-size: 14px; font-weight: 700; }
.overview h2 span { color: var(--text-3); margin-left: 3px; font: 11px var(--font-mono); }
.total { font-size: clamp(38px, 6.2vw, 66px); line-height: 1.05; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.045em; margin: var(--sp-1) 0 var(--sp-5); }
.intervals { display: flex; align-items: center; gap: 2px; background: var(--surface-sunken); border-radius: var(--r-sm); padding: 2px; }
.intervals button { height: 24px; background: transparent; border: 0; border-radius: 5px; padding: 0 var(--sp-2); white-space: nowrap; color: var(--text-2); font-size: 12px; }
.intervals button:hover { background: var(--surface-track); color: var(--text); }
.intervals button[aria-pressed=true] { color: var(--text-inverse); background: var(--surface-inverse); }

.chart { display: flex; align-items: end; gap: clamp(2px, .5vw, 6px); height: 118px; border-bottom: 1px solid var(--line-strong); background: repeating-linear-gradient(to top, transparent 0 calc(25% - 1px), var(--line) calc(25% - 1px) 25%); }
.chart .bar { flex: 1 1 0; min-width: 0; height: var(--bar); background: var(--status-run); border-radius: 2px 2px 0 0; }
.chart .bar:hover { background: var(--status-run-deep); }
.chart .bar.zero { background: var(--surface-track); }
.chart-empty { align-self: center; flex: 1; text-align: center; color: var(--text-3); }
.chart-caption { display: flex; justify-content: space-between; padding: var(--sp-2) 0 var(--sp-4); font: 11px/16px var(--font-mono); color: var(--text-3); }
.overview-bottom { display: grid; grid-template-columns: 1fr 1fr 1fr; border-top: 1px solid var(--line); }
.overview-bottom div { padding: var(--sp-3) var(--sp-2) var(--sp-3) 0; display: grid; gap: var(--sp-1); }
.overview-bottom div + div { border-left: 1px solid var(--line); padding-left: var(--sp-4); }
.overview-bottom span { font-size: 11.5px; color: var(--text-3); }
.overview-bottom strong { font-size: 15px; font-variant-numeric: tabular-nums; font-weight: 700; }

.status { color: var(--text-3); min-height: 20px; margin-top: var(--sp-1); font-size: 12.5px; }
.status.error { color: var(--text-attn); }
.ledgers { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-6); }
.ledgers h2 { font-size: 14px; font-weight: 700; margin-bottom: var(--sp-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: var(--sp-2) var(--sp-3); font-size: 13px; height: var(--h-row); white-space: nowrap; }
th { font-weight: 600; font-size: 12px; color: var(--text-3); background: var(--surface-sunken); }
td { border-top: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
td:last-child { font-weight: 700; }
td small { display: block; color: var(--text-3); font: 10.5px/16px var(--font-mono); }
tr:hover td { background: rgb(31 29 26 / .04); }
.table-link { font: inherit; font-weight: 650; color: var(--text); background: transparent; padding: 0; border: 0; text-align: left; }
.table-link:hover { text-decoration: underline; text-underline-offset: .2em; }
.empty { color: var(--text-3); }
footer { display: flex; justify-content: space-between; gap: var(--sp-4); margin: var(--sp-8) 0 var(--sp-6); font-size: 12px; color: var(--text-3); }

.auth { max-width: 435px; margin: clamp(48px, 13vh, 124px) auto; padding: var(--sp-6); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.auth h1 { font-size: 28px; }
.auth p { margin: var(--sp-3) 0 var(--sp-5); color: var(--text-3); }
.auth .status { margin: var(--sp-2) 0 0; }
dialog { color: var(--text); background: var(--surface); border: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: var(--sp-6); width: min(510px, calc(100% - 32px)); max-height: calc(100% - 32px); }
dialog::backdrop { background: var(--overlay-backdrop); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.dialog-head h2 { font-size: 17px; line-height: 22px; }
form label, #issued label { display: grid; gap: var(--sp-1); margin-bottom: var(--sp-3); font-weight: 600; }
form input, #issued input { width: 100%; }
#issued { padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md); margin-top: var(--sp-4); }
#issued label { margin-bottom: var(--sp-1); }
#issued input { font: 12px var(--font-mono); }
.muted { color: var(--text-3); font-size: 12px; margin-bottom: var(--sp-2); }
.key-list { list-style: none; padding: 0; margin: var(--sp-2) 0 var(--sp-5); }
.key-list li { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); border-top: 1px solid var(--line); padding: var(--sp-1) 0; }
#account-name { margin-bottom: var(--sp-4); }

@media (max-width: 700px) {
  .frame { width: calc(100% - 32px); }
  .masthead-inner { height: 56px; }
  .heading { align-items: start; flex-direction: column; gap: var(--sp-3); }
  .filters { width: 100%; }
  .filters label { flex: 1; }
  select { width: 100%; min-width: 0; max-width: none; }
  .overview { padding: var(--sp-3) var(--sp-3) 0; }
  .overview-top { flex-wrap: wrap; }
  .overview-top .intervals { margin-bottom: var(--sp-2); }
  .total { margin-bottom: var(--sp-2); }
  .chart { height: 97px; }
  .overview-bottom div + div { padding-left: var(--sp-2); }
  .overview-bottom strong { font-size: 12px; }
  .ledgers { grid-template-columns: 1fr; gap: var(--sp-5); }
}
@media (pointer: coarse) {
  .primary, .quiet, select, input, .intervals button { min-height: var(--h-touch); }
  .table-link { min-height: 32px; }
}
@media (max-width: 375px) {
  th, td { font-size: 12px; padding-inline: var(--sp-2); }
  .overview-bottom { grid-template-columns: 1.15fr 1fr 1fr; }
}
