@font-face { font-family: "Bricolage"; src: url("/static/fonts/bricolage.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Instrument"; src: url("/static/fonts/instrument.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }

:root {
  --bg: #0b1412; --side: #111e1a; --card: #14231f; --card-2: #1a2d27; --rule: #263d36;
  --ink: #eef5f1; --quiet: #93a89e; --pine: #6fd3bf; --gold: #f2c14e; --gold-ink: #1c1503;
  --alert-bg: #3d2c08; --alert-ink: #fde3ae; --danger: #ff9d92; --ok: #6fd3bf; --field: #0e1a17;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --display: "Bricolage", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --body: "Instrument", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eef3f0; --side: #fbfcf8; --card: #fbfcf8; --card-2: #eef3f0; --rule: #d2ddd7;
  --ink: #15302a; --quiet: #55695f; --pine: #0b5f52; --gold: #f2c14e; --gold-ink: #1c1503;
  --alert-bg: #fbe9c8; --alert-ink: #6b3f00; --danger: #a3271c; --ok: #0b5f52; --field: #fff;
  --shadow: 0 18px 50px rgba(21, 48, 42, .18);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--body); }
h1, h2, h3, p, dl { margin: 0; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--pine); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.sprite { position: absolute; width: 0; height: 0; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.logo { display: inline-flex; align-items: center; gap: 10px; font: 650 22px/1 var(--display); letter-spacing: -.01em; text-decoration: none; color: var(--ink); }
.logo img { display: block; border-radius: 8px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 8px 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 650; font-size: 15px; cursor: pointer; transition: filter .15s ease, background-color .15s ease, border-color .15s ease; }
.btn.gold { background: var(--gold); color: var(--gold-ink); }
.btn.gold:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: var(--rule); color: var(--ink); }
.btn.ghost:hover { background: var(--card-2); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: .45; cursor: default; filter: none; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; background: none; border: 0; border-radius: 10px; cursor: pointer; color: var(--ink); }
.link { background: none; border: 0; padding: 0; color: var(--gold); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
:root[data-theme="light"] .link { color: var(--pine); }

/* Header */
.shell { display: grid; grid-template: 66px minmax(0, 1fr) / 270px minmax(0, 1fr); grid-template-areas: "top top" "side main"; min-height: 100dvh; }
.top { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 clamp(14px, 2.6vw, 34px); background: var(--bg); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 20; }
.top-left, .top-right, [data-tools] { display: flex; align-items: center; gap: clamp(8px, 1.4vw, 18px); }
.menu-toggle { display: none; }
.theme { display: inline-flex; padding: 3px; gap: 2px; background: var(--card-2); border-radius: 999px; }
.theme button { display: grid; place-items: center; width: 32px; height: 30px; background: none; border: 0; border-radius: 999px; color: var(--quiet); cursor: pointer; }
.theme button .icon { width: 17px; height: 17px; }
.theme button[aria-pressed="true"] { background: var(--bg); color: var(--ink); }
:root[data-theme="light"] .theme { background: #dbe5e0; }
:root[data-theme="light"] .theme button[aria-pressed="true"] { background: #fff; }

.menu { position: relative; }
.menu summary { display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; list-style: none; font-weight: 600; font-size: 15px; }
.menu summary::-webkit-details-marker { display: none; }
.menu .chev { width: 17px; height: 17px; transition: rotate .15s ease; }
.menu[open] .chev { rotate: 180deg; }
.flag { width: 24px; height: 16px; border-radius: 3px; flex: none; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #3b3010; color: var(--gold); font: 700 13px var(--body); }
:root[data-theme="light"] .avatar { background: #0b5f52; color: #fbfcf8; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 170px; padding: 6px; background: var(--card); border: 1px solid var(--rule); border-radius: 12px; box-shadow: var(--shadow); display: grid; z-index: 30; }
.menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; background: none; border: 0; border-radius: 8px; text-align: left; cursor: pointer; }
.menu-pop button:hover { background: var(--card-2); }
.menu-pop-account { min-width: 230px; }
.menu-email { padding: 9px 10px; color: var(--quiet); font-size: 14px; overflow-wrap: anywhere; border-bottom: 1px solid var(--rule); margin-bottom: 4px; }

/* Sidebar */
.side { grid-area: side; padding: 22px 14px; background: var(--side); border-right: 1px solid var(--rule); display: flex; flex-direction: column; gap: 16px; position: sticky; top: 66px; height: calc(100dvh - 66px); overflow-y: auto; }
.shop { display: flex; align-items: center; gap: 12px; padding: 4px 10px; min-width: 0; }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot.pending { background: var(--gold); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 25%, transparent); }
.shop-text { min-width: 0; }
.shop-label { color: var(--quiet); font-size: 13px; line-height: 1.3; }
.shop-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The balance is why people open this page, so it's the one thing in the rail with a frame. */
.side-balance { padding: 16px; background: var(--card); border: 1px solid var(--rule); border-right-color: color-mix(in srgb, var(--gold) 55%, var(--rule)); border-bottom-color: color-mix(in srgb, var(--gold) 55%, var(--rule)); border-radius: 16px; display: grid; gap: 14px; }
.side-balance-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; color: var(--quiet); font-size: 14px; }
.side-balance-row strong { color: var(--ink); font: 650 20px/1.1 var(--display); text-align: right; overflow-wrap: anywhere; font-variant-numeric: lining-nums tabular-nums; }
.side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-actions .btn { padding: 8px 6px; min-width: 0; font-size: 14px; }
.side nav { display: grid; gap: 3px; }
.side nav button, .side nav a { position: relative; display: flex; align-items: center; gap: 13px; width: 100%; min-height: 44px; padding: 9px 12px; background: none; border: 0; border-radius: 10px; color: var(--quiet); font-size: 16px; text-align: left; text-decoration: none; cursor: pointer; }
.side nav button:hover, .side nav a:hover { background: var(--card-2); color: var(--ink); }
.side nav button[aria-current="page"] { background: var(--card-2); color: var(--ink); font-weight: 650; }
.side nav button[aria-current="page"]::before { content: ""; position: absolute; left: -6px; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--gold); }
.side nav button[aria-current="page"] .icon { color: var(--gold); }
:root[data-theme="light"] .side nav button[aria-current="page"] .icon { color: var(--pine); }
.nav-gap { height: 10px; }
.scrim { display: none; }

/* Main */
.view { grid-area: main; width: 100%; max-width: 1180px; padding: clamp(20px, 3.6vw, 44px); display: grid; grid-template-columns: minmax(0, 1fr); gap: 26px; align-content: start; }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.title h1, .head h1 { font: 680 clamp(28px, 3.2vw, 34px)/1.1 var(--display); letter-spacing: -.02em; }
.title p { margin-top: 8px; color: var(--quiet); overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stat { padding: 22px; background: var(--card); border: 1px solid var(--rule); border-radius: 16px; min-width: 0; }
.stat p:first-child { color: var(--quiet); font-size: 15px; }
.stat .v { margin-top: 12px; font: 680 clamp(28px, 3vw, 36px)/1.1 var(--display); overflow-wrap: anywhere; font-variant-numeric: lining-nums tabular-nums; }
.stat .v small { font-size: .5em; font-weight: 500; color: var(--quiet); }
.stat .sub { margin-top: 8px; color: var(--quiet); font-size: 14px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font: 650 20px/1.2 var(--display); }
.alert { padding: 13px 16px; background: var(--alert-bg); color: var(--alert-ink); border-radius: 12px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--rule); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 18px; text-align: left; border-bottom: 1px solid var(--rule); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th { color: var(--quiet); font-weight: 500; font-size: 14px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 170px; }
.empty { padding: 30px 18px; color: var(--quiet); text-align: center; }
.row-link { background: none; border: 0; padding: 0; color: var(--pine); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-weight: 550; }
.state { font-weight: 650; }
.state-paid, .state-sent, .state-delivered, .state-confirmed { color: var(--ok); }
.state-underpaid, .state-paid_late, .state-failed, .state-rejected { color: var(--danger); }
.state-expired, .state-orphaned { color: var(--quiet); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.tools input { width: 250px; max-width: 100%; }
.tools select { width: auto; }
.pager { display: flex; gap: 10px; align-items: center; color: var(--quiet); }

label { display: grid; gap: 6px; font-size: 14px; color: var(--quiet); }
input, select { width: 100%; min-height: 44px; padding: 9px 12px; background: var(--field); border: 1px solid var(--rule); border-radius: 10px; color: var(--ink); font-size: 16px; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.card { padding: 22px; background: var(--card); border: 1px solid var(--rule); border-radius: 16px; display: grid; gap: 13px; min-width: 0; }
.card h2 { font: 650 20px/1.2 var(--display); }
.card p { color: var(--quiet); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 16px; }
.facts dt { color: var(--quiet); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

dialog { width: min(540px, calc(100% - 32px)); padding: 24px; background: var(--card); color: var(--ink); border: 1px solid var(--rule); border-radius: 16px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(4, 10, 9, .65); }
dialog h2 { font: 650 23px/1.15 var(--display); margin-bottom: 8px; }
dialog form, .stack { display: grid; gap: 13px; }
.note { color: var(--quiet); }
.error { color: var(--danger); font-size: 14px; min-height: 1.4em; }
.buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.secret { padding: 11px 13px; background: var(--field); border: 1px solid var(--rule); border-radius: 10px; overflow-wrap: anywhere; user-select: all; }

/* Sign-in screens */
.auth { min-height: 100dvh; display: grid; align-content: center; justify-items: center; gap: 22px; padding: 76px 16px 32px; position: relative; background: var(--bg); }
.auth-tools { position: absolute; top: 14px; right: 16px; }
.auth form { width: min(410px, 100%); padding: 28px; background: var(--card); border: 1px solid var(--rule); border-radius: 18px; display: grid; gap: 14px; }
.auth h1 { font: 680 30px/1.1 var(--display); letter-spacing: -.02em; }
.auth .btn { width: 100%; min-height: 46px; }
.hint { color: var(--quiet); font-size: 14px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

@media (max-width: 900px) {
  .shell { grid-template: 62px minmax(0, 1fr) / minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .menu-toggle { display: inline-grid; }
  .top .logo span { display: none; }
  .side { position: fixed; top: 62px; bottom: 0; left: 0; width: min(290px, 86vw); height: auto; z-index: 15; translate: -102% 0; visibility: hidden; transition: translate .2s ease, visibility .2s; }
  .side.open { translate: 0 0; visibility: visible; }
  .scrim { display: block; position: fixed; inset: 62px 0 0; background: rgba(4, 10, 9, .55); z-index: 10; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .cards { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .side, .menu .chev { transition: none; }
}
