/* tokens + base — terminal aesthetic, dark/light themes */

:root {
  --bg:        #0c0c0e;
  --bg-2:      #161719;
  --bg-3:      #1e1f22;
  --bg-hover:  #26282c;
  --fg:        #eceef1;
  --fg-dim:    #a4abb6;
  --fg-mute:   #6b7280;
  --rule:      #26282c;
  --rule-2:    #3a3d43;
  --up:        #4bce97;
  --dn:        #f87168;
  --up-soft:   rgba(75, 206, 151, 0.16);
  --dn-soft:   rgba(248, 113, 104, 0.15);
  --accent:    #579dff;
  --accent-2:  #6cc3e0;
  --warn:      #f5cd47;
  /* Trello vivid label palette (theme-independent) */
  --tl-green:  #4bce97;
  --tl-yellow: #f5cd47;
  --tl-orange: #fea362;
  --tl-red:    #f87168;
  --tl-purple: #9f8fef;
  --tl-blue:   #579dff;
  --tl-sky:    #6cc3e0;
  --tl-lime:   #94c748;
  --tl-pink:   #e774bb;
  --tl-ink:    #1d2125;
  --shadow:    0 0 0 1px var(--rule), 0 1px 0 0 rgba(255,255,255,0.02) inset;
  --row-h:     22px;
  --gap:       12px;
  --hd-h:      30px;
  --mono:      'IBM Plex Mono', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans:      'Open Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif:     var(--sans);
  --paper-grain: none;
  --paper-glow:
    radial-gradient(ellipse 70% 55% at 20% -5%, rgba(87, 157, 255, 0.07), transparent 60%),
    radial-gradient(ellipse 60% 45% at 95% 105%, rgba(159, 143, 239, 0.06), transparent 60%);
}

:root[data-theme="light"] {
  --bg:        #e4ecf4;
  --bg-2:      #ffffff;
  --bg-3:      #f1f3f6;
  --bg-hover:  #e9eef5;
  --fg:        #172b4d;
  --fg-dim:    #44546f;
  --fg-mute:   #8993a4;
  --rule:      #dfe4ec;
  --rule-2:    #c1c9d6;
  --up:        #1f845a;
  --dn:        #c9372c;
  --up-soft:   rgba(31, 132, 90, 0.12);
  --dn-soft:   rgba(201, 55, 44, 0.10);
  --accent:    #0c66e4;
  --accent-2:  #1d7f8c;
  --warn:      #946f00;
  --tl-green:  #4bce97;
  --tl-yellow: #e2b203;
  --tl-orange: #fca100;
  --tl-red:    #ef5c48;
  --tl-purple: #8270db;
  --tl-blue:   #0c66e4;
  --tl-sky:    #1d92c2;
  --tl-lime:   #6a9a23;
  --tl-pink:   #cd519d;
  --tl-ink:    #ffffff;
  --paper-grain: none;
  --paper-glow:
    radial-gradient(ellipse 70% 55% at 20% -5%, rgba(12, 102, 228, 0.10), transparent 60%),
    radial-gradient(ellipse 60% 45% at 95% 105%, rgba(159, 143, 239, 0.10), transparent 60%);
}

:root[data-density="compact"] {
  --row-h: 18px;
  --gap: 8px;
  --hd-h: 26px;
}
:root[data-density="comfy"] {
  --row-h: 28px;
  --gap: 16px;
  --hd-h: 34px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: #1c1b18; color: var(--fg); font-family: var(--sans); }
body { font-size: 13px; line-height: 1.45; -webkit-font-smoothing: antialiased; }

.dash {
  background: var(--bg);
  background-image: var(--paper-glow), var(--paper-grain);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100%;
}
/* monospace tabular numerals for all data cells — terminal soul */
.px, .chg, .clk-big, .clk-compact, .clk-s, .clk-h, .kpi-px, .metal-px,
.fx-px, .commod-cell-px, .tt-px, .tt-chg, .mc-time, .plan-time, .plan-dur,
.cal-d, .wx-temp, .topbar-time, .mkt-c-px, .commod-cell-px {
  font-family: var(--mono);
  font-feature-settings: "tnum", "zero";
  font-variant-numeric: tabular-nums;
}

/* ---------------- TOPBAR ---------------- */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  font-size: 11px;
  letter-spacing: 0.06em;
}
.topbar-l, .topbar-r { display: flex; align-items: center; gap: 14px; }
.topbar-r { justify-content: flex-end; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-glyph {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 14px;
  letter-spacing: -0.06em;
}
.brand-name {
  font-family: var(--sans);
  font-weight: 800;
  font-style: normal;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--accent);
  line-height: 1;
  margin-top: 0;
}
.brand-logo {
  height: 46px;
  width: auto;
  display: block;
  object-fit: contain;
}
/* Logo is dark navy — keep as-is on light theme, brighten to legible on dark */
[data-theme="dark"] .brand-logo {
  filter: brightness(0) invert(1) drop-shadow(0 0 0.4px #fff) drop-shadow(0 0 0.4px #fff);
}
.brand-sub {
  color: var(--fg-mute);
  font-size: 10px;
  letter-spacing: 0.14em;
  padding-left: 10px;
  margin-left: 6px;
  border-left: 1px solid var(--rule);
}
.greet {
  font-family: var(--sans);
  font-style: normal;
  color: var(--fg);
  font-weight: 700;
  letter-spacing: 0;
  font-size: 14px;
}
.topbar-date { color: var(--fg-dim); }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--bg-hover); border: 1px solid var(--rule);
  color: var(--fg); cursor: pointer; padding: 0; line-height: 1;
  transition: border-color 120ms, color 120ms;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle-glyph { font-size: 14px; }
.topbar-time {
  color: var(--fg);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
}
.tb-s { color: var(--fg-mute); margin-left: 2px; font-size: 12px; }

/* ---------------- BOX (panel) ---------------- */
.tbox {
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  position: relative;
  box-shadow: 0 1px 0 rgba(9, 30, 66, 0.06), 0 1px 3px rgba(9, 30, 66, 0.10);
}
.tbox::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--rule-2), transparent);
  pointer-events: none;
}
.tbox-hd {
  height: var(--hd-h);
  flex: 0 0 var(--hd-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg-3);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.tbox-hd-l { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }
.tbox-hd-r { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.tbox-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  flex: 0 0 6px;
}
.tbox-title {
  color: var(--fg);
  font-weight: 700;
  letter-spacing: 0.08em;
}
.tbox-sub {
  color: var(--fg-mute);
  letter-spacing: 0;
  padding-left: 8px;
  border-left: 1px solid var(--rule);
  margin-left: 4px;
  font-family: var(--sans);
  font-style: normal;
  font-size: 11px;
  text-transform: none;
  font-weight: 500;
}
.hd-meta {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--fg-mute);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.tbox-body { min-width: 0; flex: 1 1 auto; }
.tbox-body-pad { padding: 10px 10px 12px; }

/* ---------------- PRICE / CHG ---------------- */
.px { font-weight: 600; color: var(--fg); transition: background 120ms, color 120ms; padding: 1px 4px; margin: -1px -4px; border-radius: 1px; display: inline-block; }
.px.px-up { background: var(--up-soft); color: var(--up); }
.px.px-dn { background: var(--dn-soft); color: var(--dn); }
.chg { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.chg-up { color: var(--up); }
.chg-dn { color: var(--dn); }
.chg-arrow { font-size: 9px; }
.chg-pct { font-variant-numeric: tabular-nums; }
.chg-abs { color: var(--fg-mute); font-weight: 400; font-size: 11px; }

/* ---------------- MARKET TABLE ---------------- */
.mkt-table { display: flex; flex-direction: column; }
.mkt-row {
  display: grid;
  grid-template-columns: 64px 1fr 90px 110px 70px;
  align-items: center;
  gap: 6px;
  padding: 4px 4px;
  height: var(--row-h);
  border-bottom: 1px dashed var(--rule);
  font-size: 12px;
  position: relative;
}
.mkt-row:last-child { border-bottom: 0; }
.mkt-row[data-flash="1"]::after,
.mkt-row[data-flash="-1"]::after {
  content: "";
  position: absolute;
  left: -1px; right: -1px; top: -1px; bottom: -1px;
  pointer-events: none;
  border-left: 2px solid var(--up);
  animation: flash-fade 700ms ease-out forwards;
}
.mkt-row[data-flash="-1"]::after { border-left-color: var(--dn); }
@keyframes flash-fade { from { opacity: 1; } to { opacity: 0; } }

.mkt-head {
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--fg-mute);
  border-bottom: 1px solid var(--rule);
  text-transform: uppercase;
  height: 22px;
}
.mkt-head .mkt-c-px, .mkt-head .mkt-c-chg { text-align: right; }
.mkt-c-sym b { color: var(--accent); font-weight: 700; letter-spacing: 0.04em; }
.mkt-c-name { color: var(--fg-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mkt-c-px { text-align: right; }
.mkt-c-chg { text-align: right; display: flex; justify-content: flex-end; }
.mkt-c-spk { display: flex; justify-content: flex-end; }

/* ---- editable crypto card ---- */
.crypto-row { grid-template-columns: 64px 1fr 90px 110px 70px 26px; }
.crypto-c-x {
  background: transparent; border: 0; color: var(--fg-mute);
  font-size: 15px; line-height: 1; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center; opacity: 0.45;
  transition: opacity 120ms, color 120ms;
}
.crypto-row:hover .crypto-c-x { opacity: 1; }
.crypto-c-x:hover { color: var(--dn); }
/* inline coin picker (search + chips) */
.crypto-picker-inline {
  margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--rule);
}
.crypto-search-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.crypto-search {
  flex: 1 1 auto; background: var(--bg); color: var(--fg); border: 1px solid var(--rule);
  border-radius: 6px; font-family: var(--mono); font-size: 12px; padding: 6px 9px; outline: none;
}
.crypto-search:focus { border-color: var(--accent); }
.crypto-search-count { color: var(--fg-mute); font-size: 10px; white-space: nowrap; }
.crypto-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; max-height: 124px; overflow-y: auto; }
.crypto-picker-hd { font-size: 9px; letter-spacing: 0.16em; color: var(--fg-mute); margin-right: 2px; }
.crypto-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--rule); border-radius: 999px;
  padding: 4px 10px; cursor: pointer; color: var(--fg);
  font-family: var(--mono); font-size: 11px;
}
.crypto-chip:hover { border-color: var(--accent); background: var(--bg-hover); }
.crypto-chip-sym { font-weight: 700; }
.crypto-chip-name { color: var(--fg-dim); font-family: var(--sans); font-size: 10px; }
.crypto-chip-plus { color: var(--accent); font-weight: 700; }
.crypto-pick-empty { color: var(--fg-mute); font-size: 11px; font-style: italic; }
.crypto-empty { color: var(--fg-mute); font-size: 11px; padding: 12px 4px; font-style: italic; }
.mkt-compact .mkt-row { grid-template-columns: 56px 1fr 80px 88px; }
.mkt-compact .mkt-c-spk { display: none; }

/* ---------------- COMMODITIES ---------------- */
.commod-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--rule);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin: 0 -10px -12px;
}
.commod-cell {
  background: var(--bg-2);
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
.commod-cell[data-flash="1"] { background: linear-gradient(180deg, var(--up-soft), var(--bg-2) 40%); }
.commod-cell[data-flash="-1"] { background: linear-gradient(180deg, var(--dn-soft), var(--bg-2) 40%); }
.commod-cell-hd { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: 0.1em; }
.commod-sym { color: var(--accent); font-weight: 700; }
.commod-name { color: var(--fg-mute); text-transform: uppercase; }
.commod-cell-px { display: flex; align-items: baseline; gap: 6px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.commod-unit { font-size: 10px; color: var(--fg-mute); font-weight: 400; }
.commod-cell-ft { display: flex; justify-content: space-between; align-items: center; }

/* ---------------- FX ---------------- */
.fx-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--rule);
  margin: 0 -10px -12px;
}
.fx-cell {
  background: var(--bg-2);
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fx-cell[data-flash="1"] { background: linear-gradient(180deg, var(--up-soft), var(--bg-2) 50%); }
.fx-cell[data-flash="-1"] { background: linear-gradient(180deg, var(--dn-soft), var(--bg-2) 50%); }
.fx-sym { font-size: 10px; letter-spacing: 0.16em; color: var(--fg-dim); font-weight: 600; }
.fx-slash { color: var(--fg-mute); margin: 0 2px; }
.fx-px { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.fx-chg { font-size: 11px; }

/* ---------------- METALS HERO ---------------- */
.metals-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metal-card {
  border: 1px solid var(--rule);
  padding: 12px;
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.metal-card.metal-gold { border-color: rgba(245, 166, 35, 0.4); }
.metal-card.metal-gold::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--accent); }
.metal-card.metal-silver::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--fg-dim); }
.metal-tag { font-size: 10px; letter-spacing: 0.14em; color: var(--fg-mute); }
.metal-px { display: flex; align-items: baseline; gap: 6px; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.metal-unit { font-size: 14px; color: var(--fg-mute); }
.metal-meta { display: flex; justify-content: space-between; align-items: center; }
.metal-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed var(--rule);
  padding-top: 8px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--fg-dim);
}
.metal-sub b { color: var(--fg); }

/* ---------------- TICKER TAPE ---------------- */
.ticker-tape {
  overflow: hidden;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--bg-2);
  height: 28px;
  display: flex;
  align-items: center;
  font-size: 11px;
  letter-spacing: 0.06em;
  position: relative;
}
.ticker-track {
  display: flex;
  white-space: nowrap;
  animation: ticker-scroll 140s linear infinite;
  gap: 0;
}
@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.tt-item { display: inline-flex; align-items: center; gap: 8px; padding: 0 14px; }
.tt-sym { color: var(--accent); font-weight: 700; letter-spacing: 0.04em; }
.tt-px { font-weight: 600; }
.tt-chg { font-size: 11px; }
.tt-up .tt-chg { color: var(--up); }
.tt-dn .tt-chg { color: var(--dn); }
.tt-sep { color: var(--rule-2); }
