/* Hedera Suite -- Bloomberg-terminal density on the open-design trading-terminal
 * scale. The spacing/type/radius tokens come from vendor tokens.css; the COLOR
 * identity is the one the design doc prescribes in prose (DESIGN.md), which the
 * generated tokens.css deviates from. So we override the palette here and keep
 * the scale.
 *
 * Fonts: system stack only. The CSP allows no external origin, and open-design
 * ships no font files -- naming Inter/Roboto Mono would silently fall back.
 * Every number is mono + tabular-nums so columns line up on the digit.
 */

:root {
  --bg: #0D0D0D;
  --surface: #141414;
  --surface-hover: #1A1A1A;
  --border: #2A2A2A;
  --gain: #00D4AA;
  --loss: #FF4757;
  --warn: #FFB800;
  --neutral: #808086;
  --text: #FFFFFF;
  --text-2: #AAAAAA;
  --text-3: #828282;
  --accent: #00D4AA;
  --info: #4C8DFF;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", "DejaVu Sans Mono", monospace;

  --row: 26px;
  --nav-w: 178px;
  --focus-ring: 0 0 0 2px rgba(0, 212, 170, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
}

/* every digit in the product is mono and lines up on the decimal point */
.num, .mono, table, input, select, textarea, button, pre, code {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: 0.01em; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.muted   { color: var(--text-3); }
.dim     { color: var(--text-2); }
.gain    { color: var(--gain); }
.loss    { color: var(--loss); }
.warnc   { color: var(--warn); }
.spacer  { flex: 1 1 auto; }
.right   { text-align: right; }
.nowrap  { white-space: nowrap; }
.tiny    { font-size: 11px; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--space-3);
  height: 40px; padding: 0 var(--space-3);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: 0.08em; font-size: 12px; white-space: nowrap; }
.brand-mark { color: var(--accent); }
.tickers { display: flex; gap: var(--space-4); overflow: hidden; font-size: 11px; }
.tickers .k { color: var(--text-3); margin-right: 4px; }
#clock { font-size: 11px; }

.iconbtn {
  display: none; background: none; border: 1px solid var(--border);
  color: var(--text-2); border-radius: var(--radius-sm); padding: 2px 7px; cursor: pointer;
}

.stalebar {
  position: sticky; top: 0; z-index: 40;
  padding: 5px var(--space-4);
  background: #3A2A00; color: var(--warn);
  border-bottom: 1px solid var(--warn);
  font-size: 12px; font-family: var(--font-mono);
}

/* ------------------------------------------------------------------ shell */
.shell { display: flex; min-height: calc(100vh - 40px); }

.nav {
  width: var(--nav-w); flex: 0 0 var(--nav-w);
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: var(--space-2) 0;
  position: sticky; top: 40px; align-self: flex-start;
  max-height: calc(100vh - 40px); overflow-y: auto;
}
.nav a {
  display: flex; align-items: center; gap: 6px;
  padding: 6px var(--space-4);
  color: var(--text-2); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.06em; border-left: 2px solid transparent;
}
.nav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav a.on { color: var(--text); border-left-color: var(--accent); background: var(--surface-hover); }

.main { flex: 1 1 auto; min-width: 0; padding: var(--space-4); }
.loading { color: var(--text-3); padding: var(--space-6); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--neutral); display: inline-block; }
.dot.live { background: var(--gain); }
.dot.down { background: var(--loss); }
.dot.warn { background: var(--warn); }

.pill {
  background: var(--loss); color: #fff; border-radius: var(--radius-pill);
  padding: 0 5px; font-size: 10px; font-family: var(--font-mono);
}

/* ------------------------------------------------------------------ cards */
.viewhead {
  display: flex; align-items: baseline; gap: var(--space-3);
  margin-bottom: var(--space-3); flex-wrap: wrap;
}
.viewhead h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.08em; }

.grid { display: grid; gap: var(--space-3); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.mt { margin-top: var(--space-3); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); min-width: 0;
}
.card-hd {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 6px var(--space-3); border-bottom: 1px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-2);
}
.card-bd { padding: var(--space-3); }
.card-bd.flush { padding: 0; }

.stat { padding: var(--space-3); }
.stat .k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.stat .v { font-family: var(--font-mono); font-size: 18px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .s { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); }

/* ----------------------------------------------------------------- tables */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface); color: var(--text-3);
  font-weight: 500; font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
  text-align: left; padding: 5px var(--space-2); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 4px var(--space-2); border-bottom: 1px solid #1E1E1E;
  height: var(--row); vertical-align: middle;
}
tbody tr:hover { background: var(--surface-hover); }
td.r, th.r { text-align: right; }
.empty { padding: var(--space-5); color: var(--text-3); text-align: center; }

/* ---------------------------------------------------------- shared atoms */
/* One row looks the same in the whale feed, the wallet detail and the token
   page. These atoms are the reason -- amount, account, token, venue, memo. */

.tok { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.tok img, .tok .fb {
  width: 16px; height: 16px; border-radius: 50%; flex: 0 0 16px;
  object-fit: cover; background: var(--surface-hover);
}
.tok .fb {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #0D0D0D; font-family: var(--font-mono);
}
.tok .sym { font-family: var(--font-mono); }

.acct { font-family: var(--font-mono); white-space: nowrap; }
.acct .id { color: var(--text-3); font-size: 11px; }
.labelbtn {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; color: inherit; border-bottom: 1px dashed var(--border);
}
.labelbtn:hover { color: var(--accent); border-bottom-color: var(--accent); }

.venue { font-size: 11px; color: var(--text-2); white-space: nowrap; }
.venue .cid { color: var(--text-3); }
.memo {
  font-family: var(--font-mono); font-size: 11px; color: var(--warn);
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hs { color: var(--text-3); }
.hs:hover { color: var(--accent); }

.badge {
  display: inline-block; padding: 0 5px; border-radius: var(--radius-sm);
  font-size: 10px; font-family: var(--font-mono); text-transform: uppercase;
  letter-spacing: 0.04em; border: 1px solid var(--border); color: var(--text-2);
  white-space: nowrap;
}
.badge.ok   { color: var(--gain); border-color: rgba(0, 212, 170, 0.4); background: rgba(0, 212, 170, 0.08); }
.badge.bad  { color: var(--loss); border-color: rgba(255, 71, 87, 0.4); background: rgba(255, 71, 87, 0.08); }
.badge.warn { color: var(--warn); border-color: rgba(255, 184, 0, 0.4); background: rgba(255, 184, 0, 0.08); }
.badge.info { color: var(--info); border-color: rgba(76, 141, 255, 0.4); background: rgba(76, 141, 255, 0.08); }

.route { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 11px; }
.route .arrow { color: var(--text-3); }
.route img, .route .fb {
  width: 14px; height: 14px; border-radius: 50%; flex: 0 0 14px; object-fit: cover;
}
.route .fb {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 700; color: #0D0D0D;
}

.spark { display: block; }

/* Token-icon fallback colours. A CLASS, not an inline style: the CSP is
   `style-src 'self'`, which blocks style ATTRIBUTES as well -- an inline
   background here is silently dropped in production. app.js hashes the token id
   into one of these 24 buckets, so a token always wears the same colour. */
.tc0  { background: hsl(0   62% 58%); }
.tc1  { background: hsl(15  62% 58%); }
.tc2  { background: hsl(30  62% 58%); }
.tc3  { background: hsl(45  62% 58%); }
.tc4  { background: hsl(60  62% 58%); }
.tc5  { background: hsl(75  62% 58%); }
.tc6  { background: hsl(90  62% 58%); }
.tc7  { background: hsl(105 62% 58%); }
.tc8  { background: hsl(120 62% 58%); }
.tc9  { background: hsl(135 62% 58%); }
.tc10 { background: hsl(150 62% 58%); }
.tc11 { background: hsl(165 62% 58%); }
.tc12 { background: hsl(180 62% 58%); }
.tc13 { background: hsl(195 62% 58%); }
.tc14 { background: hsl(210 62% 58%); }
.tc15 { background: hsl(225 62% 58%); }
.tc16 { background: hsl(240 62% 58%); }
.tc17 { background: hsl(255 62% 58%); }
.tc18 { background: hsl(270 62% 58%); }
.tc19 { background: hsl(285 62% 58%); }
.tc20 { background: hsl(300 62% 58%); }
.tc21 { background: hsl(315 62% 58%); }
.tc22 { background: hsl(330 62% 58%); }
.tc23 { background: hsl(345 62% 58%); }

.stat .v.sm { font-size: 14px; }
tbody tr.read { opacity: 0.55; }
input.wfull { width: 100%; }

/* ---------------------------------------------------------------- controls */
.btn {
  background: var(--surface-hover); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 3px 9px; font-size: 11px; cursor: pointer; font-family: var(--font-mono);
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #06231D; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { color: #06231D; filter: brightness(1.1); }
.btn.danger { color: var(--loss); border-color: rgba(255, 71, 87, 0.4); }
.btn.ghost { background: none; }
.btn.on { border-color: var(--accent); color: var(--accent); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: var(--space-3); }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-3); padding: 5px 12px; cursor: pointer;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

.filters {
  display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center;
  padding: var(--space-2) var(--space-3); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
}
.filters label { font-size: 10px; text-transform: uppercase; color: var(--text-3); letter-spacing: 0.06em; }

input, select, textarea {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 3px 6px; font-size: 12px; min-width: 0;
}
input[type=checkbox] { accent-color: var(--accent); }
input.w6 { width: 82px; }
input.w10 { width: 124px; }
input.w14 { width: 172px; }

.aggline {
  font-family: var(--font-mono); font-size: 12px; color: var(--text-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: var(--space-3);
}
.aggline b { color: var(--text); font-weight: 600; }

pre.log {
  margin: 0; padding: var(--space-2); background: #0A0A0A;
  border-top: 1px solid var(--border); color: var(--text-2);
  font-size: 11px; max-height: 210px; overflow: auto; white-space: pre-wrap;
  word-break: break-all;
}
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--space-3); font-size: 12px; }
.kv .k { color: var(--text-3); font-size: 11px; }
.kv .v { font-family: var(--font-mono); }

/* ----------------------------------------------------------------- modal */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.72);
  display: flex; align-items: center; justify-content: center; padding: var(--space-4);
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-4);
  width: 100%; max-width: 440px;
}
.modal-box h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: var(--space-3); }
.modal-box p { color: var(--text-2); font-size: 12px; margin: 0 0 var(--space-3); }
.modal-box input { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-4); }
.confirm-word {
  font-family: var(--font-mono); color: var(--warn); background: var(--bg);
  padding: 1px 5px; border-radius: var(--radius-sm); border: 1px solid var(--border);
}

.toasts { position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 70; display: grid; gap: 6px; }
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 7px var(--space-3); font-size: 12px; font-family: var(--font-mono);
  border-radius: var(--radius-sm); max-width: 380px;
}
.toast.bad { border-left-color: var(--loss); color: var(--loss); }

/* ----------------------------------------------------------------- login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: var(--space-4); }
.login-card {
  width: 100%; max-width: 340px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-6);
}
.login-brand { display: flex; gap: var(--space-3); align-items: center; margin-bottom: var(--space-5); }
.login-brand h1 { font-size: 14px; letter-spacing: 0.12em; }
.login-brand p { margin: 2px 0 0; font-size: 11px; }
.login-brand .brand-mark { font-size: 26px; }
#login { display: grid; gap: 6px; }
#login label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
#login input { padding: 7px; }
#login button {
  padding: 7px; margin-top: var(--space-2); background: var(--accent); color: #06231D;
  border: none; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer;
}
.err { color: var(--loss); font-size: 12px; font-family: var(--font-mono); min-height: 16px; margin: var(--space-3) 0 0; }
.login-foot { font-size: 10px; margin: var(--space-4) 0 0; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 860px) {
  .iconbtn { display: block; }
  .tickers { display: none; }
  .nav {
    position: fixed; top: 40px; left: 0; bottom: 0; z-index: 25;
    transform: translateX(-100%);
    transition: transform var(--motion-base) var(--ease-standard);
    max-height: none;
  }
  .nav.open { transform: translateX(0); }
  .main { padding: var(--space-2); }
  .memo { max-width: 130px; }
  table { font-size: 11px; }
}
