/* The merchant portal's style: the treasury console's (internal/console/web/console.css), copied. */
/* Sulafat console: no scripts, no inline styles, no fonts loaded (CSP default-src 'none'). */
:root {
  --bg: #f4f5f7; --surface: #fff; --surface-2: #f8f9fb; --line: #e3e6eb; --line-strong: #cfd4dc;
  --fg: #111827; --fg-2: #374151; --muted: #6b7280; --faint: #9ca3af;
  --accent: #2f5bd3; --accent-hover: #2449b3; --accent-soft: #eef2fd; --ring: rgba(47, 91, 211, .28);
  --bad: #b42318; --bad-soft: #fef3f2; --bad-line: #fecdca;
  --ok: #067647; --ok-soft: #ecfdf3; --ok-line: #abefc6;
  --warn: #b54708; --warn-soft: #fffaeb; --warn-line: #fedf89;
  --info: #175cd3; --info-soft: #eff8ff; --info-line: #b2ddff;
  --side: #0f172a; --side-fg: #cbd5e1; --side-muted: #64748b; --side-hover: #1e293b; --side-on: #1e2a44;
  --env: #f79009; --radius: 8px; --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --surface: #111a2e; --surface-2: #0f182a; --line: #1f2a40; --line-strong: #2c3a55;
    --fg: #e5e9f0; --fg-2: #c7cfdb; --muted: #8b97ab; --faint: #5d6a80;
    --accent: #5b82f0; --accent-hover: #7596f3; --accent-soft: #17244a; --ring: rgba(91, 130, 240, .35);
    --bad: #f97066; --bad-soft: #2a1215; --bad-line: #5c1f1d;
    --ok: #47cd89; --ok-soft: #0c2419; --ok-line: #135c3a;
    --warn: #fdb022; --warn-soft: #2a1d08; --warn-line: #5c3d0b;
    --info: #53b1fd; --info-soft: #0b1f36; --info-line: #164373;
    --side: #070c18; --side-hover: #121b2e; --side-on: #17233d; --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; color: var(--fg); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 18px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 28px 0 10px; }
p { margin: 0 0 12px; }
small { font-size: 12px; }
code { font-family: var(--mono); font-size: 12px; word-break: break-all; }
code[title] { word-break: normal; white-space: nowrap; }
pre { font-family: var(--mono); font-size: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; overflow-x: auto; margin: 0 0 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Shell: dark sidebar, top bar with the page title and who is signed in. */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-fg); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; border-top: 3px solid var(--env); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 15px; padding: 0 8px; }
.brand:hover { text-decoration: none; }
.mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(135deg, #3b6cf0, #1d3fa8); color: #fff; font-weight: 700; font-size: 15px; flex: none; }
.env { display: inline-block; margin: 10px 8px 14px; padding: 1px 8px; border-radius: 999px; background: var(--env); color: #1f1300; font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.side nav { display: flex; flex-direction: column; gap: 1px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: var(--side-fg); font-size: 13.5px; }
.side nav a:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.side nav a.on { background: var(--side-on); color: #fff; box-shadow: inset 3px 0 0 #5b82f0; }
.side nav a.on .i { stroke: #8fa9f5; }
.side .group { margin: 16px 10px 4px; color: var(--side-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }

.body { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px 32px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.who { display: flex; align-items: center; gap: 14px; }
.who form { margin: 0; }
.lang { color: var(--muted); font-size: 13px; }
.me { display: flex; align-items: center; gap: 8px; color: var(--fg); line-height: 1.25; }
.me:hover { text-decoration: none; }
.me .nm { display: block; font-weight: 500; font-size: 13px; }
.me small { display: block; color: var(--muted); font-size: 11.5px; }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px; }
main { padding: 24px 32px 48px; max-width: 1320px; width: 100%; }
main > :first-child { margin-top: 0; }

/* Sign-in pages: one centred card. */
body.auth { display: grid; place-items: start center; min-height: 100vh; border-top: 3px solid var(--env); }
body.auth main { width: 100%; max-width: 440px; padding: 56px 16px 32px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; font-size: 16px; margin-bottom: 20px; }
.auth-brand .env { margin: 0; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 4px 16px rgba(16, 24, 40, .06); padding: 28px; }
.auth-card h1 { margin-bottom: 16px; }
.auth-card .card { border: 0; padding: 0; margin: 0; box-shadow: none; background: none; max-width: none; }
.auth-card button { width: 100%; padding: 9px 14px; }
body.auth footer { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 18px; color: var(--muted); font-size: 13px; }
body.auth footer form { margin: 0; }

/* Cards, key-value lists, tiles. */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin: 0 0 16px; }
.card > :last-child { margin-bottom: 0; }
.card.ok { border-left: 3px solid var(--ok); }
.card.bad { border-left: 3px solid var(--bad); }
.narrow { max-width: 480px; }
dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 24px; margin: 0 0 16px; }
dl.card { padding: 16px 20px; }
dt { color: var(--muted); }
dd { margin: 0; min-width: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 0 0 8px; }
.tile { display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; position: relative; overflow: hidden; }
.tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--line-strong); }
.tile.ok::before { background: var(--ok); }
.tile.bad::before { background: var(--bad); }
.tile.warn::before { background: var(--warn); }
.tile .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.tile .value { font-size: 22px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.tile.ok .value { color: var(--ok); }
.tile.bad .value { color: var(--bad); }
.tile .sub { color: var(--muted); font-size: 12.5px; }
.tile .sub p { margin: 0; }
.tile a.more { margin-top: auto; padding-top: 6px; font-size: 13px; }

/* Tables: in a card, a quiet header, numbers aligned. */
.scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin: 0 0 16px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
table.dense th { white-space: normal; vertical-align: bottom; }
table.dense th, table.dense td { padding: 8px 10px; }
table.dense th:first-child, table.dense td:first-child { padding-left: 14px; }
td.n, th.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.nw { white-space: nowrap; }
tr.dim td { color: var(--muted); }
td.empty { color: var(--muted); text-align: center; padding: 28px 14px; }
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt .unit { color: var(--muted); font-size: 12px; }
.amt.zero { color: var(--faint); }
.amt.zero .unit { color: var(--faint); }

/* Status pills: the colour follows the state's meaning. */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; border: 1px solid var(--line-strong); color: var(--fg-2); background: var(--surface-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill[data-s=confirmed], .pill[data-s=active], .pill[data-s=approved], .pill[data-s=executed], .pill[data-s=accepted], .pill[data-s=ok], .pill[data-s=open] { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.pill[data-s=pending], .pill[data-s=awaiting_approval], .pill[data-s=claimed], .pill[data-s=proposed], .pill[data-s=planned] { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.pill[data-s=authorized], .pill[data-s=signed], .pill[data-s=broadcast] { color: var(--info); background: var(--info-soft); border-color: var(--info-line); }
.pill[data-s=failed], .pill[data-s=rejected], .pill[data-s=dropped], .pill[data-s=reverted], .pill[data-s=revoked], .pill[data-s=frozen], .pill[data-s=bad] { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line); }
.pill[data-s=cancelled], .pill[data-s=superseded], .pill[data-s=expired] { color: var(--muted); }

/* Forms and buttons. */
label { display: grid; gap: 5px; margin: 0 0 14px; font-weight: 500; color: var(--fg-2); font-size: 13px; }
label:has(> input[type=checkbox]) { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; color: var(--fg); font-size: 14px; }
input, select, textarea { font: inherit; font-size: 14px; font-weight: 400; color: var(--fg); padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 6px; width: 100%; background: var(--surface); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
input[type=checkbox] { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
textarea { font-family: var(--mono); font-size: 12px; line-height: 1.5; resize: vertical; margin: 0 0 12px; }
button { font: inherit; font-size: 13.5px; font-weight: 500; padding: 7px 16px; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 6px; cursor: pointer; white-space: nowrap; }
button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { background: var(--bad); border-color: var(--bad); }
button.danger:hover { filter: brightness(.92); }
button.ghost { background: transparent; color: var(--fg-2); border-color: var(--line-strong); padding: 5px 12px; font-size: 13px; }
button.ghost:hover { background: var(--surface-2); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-size: 13px; }
.inline, .filters { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 8px 14px 0; }
.inline input, .filters input, .filters select { width: auto; }
.filters button { background: var(--surface); color: var(--fg-2); border-color: var(--line-strong); }
.filters button:hover { background: var(--surface-2); }
.filters label { display: inline-flex; gap: 8px; align-items: center; margin: 0; font-size: 13px; }
td .inline { margin: 0; flex-wrap: nowrap; }
td .inline input { min-width: 140px; padding: 5px 8px; }
td .inline button { padding: 5px 12px; }
.actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; margin: 0 0 16px; }
.actions form { display: flex; gap: 8px; margin: 0; }
.actions input { width: 240px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 0 0 14px; }
.toolbar > * { margin: 0; }
.danger-zone { border-color: var(--bad-line); }

/* Messages. */
.error, .notice { display: flex; gap: 8px; padding: 10px 14px; border-radius: var(--radius); border: 1px solid; margin: 0 0 16px; }
.error { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line); }
.notice { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.hint { color: var(--muted); }
p.lead { color: var(--muted); max-width: 80ch; }
.frozen { color: var(--bad); font-weight: 600; }
.okt { color: var(--ok); font-weight: 500; }
.tag { display: inline-block; font-size: 11.5px; border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 6px; color: var(--muted); }
.tag.bad { color: var(--bad); border-color: var(--bad-line); background: var(--bad-soft); }
code.key { font-size: 16px; letter-spacing: 1px; }
.fingerprint { font-size: 2em; letter-spacing: .2em; font-family: var(--mono); }
details.card summary { cursor: pointer; font-weight: 500; }
details.card[open] summary { margin-bottom: 12px; }
.back { display: inline-block; margin-top: 4px; font-size: 13px; }

/* QR codes stay dark on white, whatever the theme, so they scan. */
.qr { margin: 8px 0 16px; text-align: center; }
.qr svg { display: block; margin: 0 auto; max-width: 100%; height: auto; background: #fff; padding: 10px; border-radius: 8px; border: 1px solid var(--line); }
.qr figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* Narrow screens: the sidebar becomes a strip on top; its links scroll sideways. */
@media (max-width: 900px) {
  .shell { display: block; }
  .side { position: static; height: auto; padding: 10px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
  .env { margin: 0; }
  .side nav { flex-direction: row; overflow-x: auto; width: 100%; gap: 2px; padding-bottom: 2px; }
  .side nav a { white-space: nowrap; padding: 6px 10px; }
  .side nav a.on { box-shadow: inset 0 -2px 0 #5b82f0; }
  .side .group { display: none; }
  .top { position: static; padding: 12px 16px; }
  main { padding: 16px 16px 40px; }
  .me small { display: none; }
  dl { grid-template-columns: 1fr; gap: 2px; }
  dd { margin-bottom: 8px; }
}
/* The portal's own states. */
.pill[data-s=received], .pill[data-s=paid] { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.pill[data-s=unconfirmed], .pill[data-s=checking], .pill[data-s=requested] { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.pill[data-s=refused] { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line); }
.merchant { color: var(--muted); font-size: 13px; }
.once { font-size: 18px; letter-spacing: .5px; user-select: all; }
.muted { color: var(--muted); }
.pill[data-s=claimed] { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
label.check { display: flex; gap: 8px; align-items: center; }
label.check input { width: auto; }
