:root,
[data-theme="dark"] {
  --bg: #0a0c0f;
  --panel: #11151a;
  --panel-2: #171c23;
  --line: #222a34;
  --text: #e7eaef;
  --muted: #8b95a5;
  --faint: #5d6776;
  --accent: #f5a623;
  --accent-ink: #120c00;
  --new: #3ddc84;
  --new-bg: rgba(61, 220, 132, 0.07);
  --ok: #3ddc84;
  --warn: #ff5d5d;
  --mark: rgba(245, 166, 35, 0.28);
  --c-osakkeet: #4ea1ff;
  --c-kryptot: #b48cff;
  --c-forex: #2ec4b6;
  --c-raaka-aineet: #e8894a;
  --c-makro: #ff6b8b;
  --pos: #3ddc84;
  --neg: #ff5d6c;
  --crit: #ff4d5e;
  --crit-bg: rgba(255, 77, 94, 0.07);
}

[data-theme="light"] {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #eef0f3;
  --line: #dde1e7;
  --text: #14181e;
  --muted: #5b6573;
  --faint: #8a93a1;
  --accent: #b86e00;
  --accent-ink: #ffffff;
  --new: #0d9a4f;
  --new-bg: rgba(13, 154, 79, 0.06);
  --ok: #0d9a4f;
  --warn: #d12f2f;
  --mark: rgba(245, 166, 35, 0.35);
  --c-osakkeet: #1f6fd1;
  --c-kryptot: #7a4fd6;
  --c-forex: #0f8a80;
  --c-raaka-aineet: #c0601f;
  --c-makro: #cf3460;
  --pos: #0d9a4f;
  --neg: #d12f3f;
  --crit: #d1263a;
  --crit-bg: rgba(209, 38, 58, 0.06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.mono, .status, .meta, .chip .n, .summary, table { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* ---------- yläpalkki */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { font-weight: 800; letter-spacing: .06em; font-size: 15px; white-space: nowrap; }
.logo span { color: var(--accent); }
.status {
  display: inline-flex; align-items: center; gap: 7px; min-width: 0;
  background: none; border: 0; padding: 4px 6px; border-radius: 6px; cursor: pointer;
  font-size: 12px; color: var(--muted);
}
.status:hover { background: var(--panel-2); }
#status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.status.live .dot { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 2.4s infinite; }
.status.err .dot { background: var(--warn); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(61,220,132,.55); } 70% { box-shadow: 0 0 0 7px rgba(61,220,132,0); } 100% { box-shadow: 0 0 0 0 rgba(61,220,132,0); } }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); cursor: pointer; font-size: 16px; line-height: 1;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- suodattimet */
.controls {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 10px 0 0;
}
.filters { display: flex; gap: 8px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px;
}
.search:focus-within { border-color: var(--accent); }
.search span { color: var(--muted); font-size: 17px; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; height: 38px; font-size: 15px; }
select {
  height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
  padding: 0 28px 0 10px; cursor: pointer; max-width: 190px;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 17px, calc(100% - 10px) 17px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
select:focus { outline: none; border-color: var(--accent); }
.cats {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 0; scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--cc, var(--accent)); }
.chip .n { font-size: 11px; color: var(--muted); font-weight: 500; }
.chip:hover { border-color: var(--cc, var(--accent)); }
.chip[aria-pressed="true"] { background: var(--cc, var(--accent)); border-color: var(--cc, var(--accent)); color: var(--accent-ink); }
.chip[aria-pressed="true"]::before { background: currentColor; }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .8; }

/* ---------- uudet uutiset */
.newbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 10px; padding: 8px 12px; border-radius: 8px;
  background: var(--new-bg); border: 1px solid color-mix(in srgb, var(--new) 45%, transparent);
  color: var(--new); font-size: 13px; font-weight: 600;
}
.newbar[hidden] { display: none; }
.newbar button { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font-size: 13px; padding: 2px; }
.jump {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 20; border: 0; border-radius: 999px; padding: 9px 16px; cursor: pointer;
  background: var(--new); color: #04140a; font-weight: 700; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
.jump[hidden] { display: none; }

/* ---------- sivun rakenne */
main { max-width: 1000px; margin: 0 auto; padding: 16px 16px 60px; display: flex; flex-direction: column; gap: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panel h2, .others h2 { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.panel-meta { color: var(--faint); font-size: 12px; margin: 4px 0 0; }
.placeholder { color: var(--muted); font-size: 14px; margin: 10px 0 2px; }

/* ---------- 1. markkinakatsaus */
.overview h2 { color: var(--accent); }
.disclaimer {
  margin: 8px 0 12px; padding: 6px 10px; border-radius: 6px; font-size: 12px; font-weight: 600;
  color: var(--muted); background: var(--panel-2); border-left: 3px solid var(--accent);
}
.ov-headline { margin: 0 0 6px; font-size: 18px; font-weight: 700; line-height: 1.3; }
.ov-summary { margin: 0 0 14px; color: var(--text); opacity: .9; font-size: 14.5px; line-height: 1.55; }
.pcards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 4px 0 6px; }
.pcard { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.pc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pc-name { font-weight: 800; font-size: 14px; }
.pc-unit { color: var(--faint); font-size: 11.5px; }
.pc-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pc-price { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.pc-delta { font-size: 13px; font-weight: 700; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.pc-delta small { color: var(--faint); font-weight: 500; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.pc-sub { font-size: 12.5px; color: var(--muted); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.pc-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 11.5px; color: var(--faint); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.spark-wrap { position: relative; height: 44px; cursor: crosshair; touch-action: pan-y; }
.spark { width: 100%; height: 100%; display: block; overflow: visible; }
.spark path { stroke: var(--muted); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .cross { stroke: var(--faint); stroke-width: 1; opacity: 0; }
.spark-wrap.hover .cross { opacity: 1; }
.spark-dot { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--panel-2); pointer-events: none; }
.spark-tip {
  position: absolute; top: 0; transform: translate(-50%, -30%); white-space: nowrap; pointer-events: none;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px;
  font-size: 11.5px; color: var(--text); font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.outlook { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }
.outlook.dir-up { --dc: var(--pos); } .outlook.dir-down { --dc: var(--neg); } .outlook.dir-flat { --dc: var(--muted); }
.outlook p { margin: 4px 0 0; font-size: 13px; color: var(--text); opacity: .88; line-height: 1.45; }
.outlook.pending p { color: var(--faint); font-size: 12.5px; }
.ol-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ol-dir { color: var(--dc); font-weight: 800; font-size: 14px; }
.ol-dir::before { content: "24 h: "; color: var(--faint); font-weight: 600; font-size: 11.5px; }
.ol-conf { font-size: 11px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--muted); }
.ol-conf.conf-kohtalainen { border-color: var(--muted); color: var(--text); }
.ol-conf.conf-korkea { border-color: var(--accent); color: var(--accent); }
.outlook .ol-trig { font-size: 12.5px; color: var(--muted); }
.outlook .ol-meta { font-size: 11.5px; color: var(--faint); }
.ol-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
.ol-nums > div { background: var(--bg); border-radius: 6px; padding: 5px 8px; }
.ol-nums .k { display: block; font-size: 10.5px; color: var(--faint); }
.ol-nums .v { font-size: 13.5px; font-weight: 700; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.ol-nums small { color: var(--muted); font-weight: 500; }
.sig { font-size: 11.5px; font-weight: 800; letter-spacing: .08em; border-radius: 4px; padding: 2px 8px; border: 1px solid; }
.sig-buy { color: var(--pos); } .sig-sell { color: var(--neg); } .sig-hold { color: var(--muted); }
.accuracy { margin: 10px 0 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.accuracy summary { cursor: pointer; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.accuracy .csv { float: right; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--accent); }
.acc-scroll { overflow-x: auto; }
.acc { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.acc th, .acc td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
.acc thead th { font-size: 11px; color: var(--faint); font-weight: 600; cursor: help; }
.acc tbody th small, .acc td small { display: block; color: var(--faint); font-size: 11px; font-weight: 500; }
.acc td span { font-weight: 700; }
.acc .muted { color: var(--faint); white-space: normal; }
.acc.recent td { font-size: 12px; }
.acc-note { font-size: 11.5px; color: var(--faint); margin: 8px 0 2px; }
.ol-note { margin: 2px 0 6px; font-size: 11.5px; color: var(--faint); }
.history { margin: 10px 0 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.hist-head { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.hist-head .watch-title { margin: 0 auto 0 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { font: inherit; font-size: 12px; font-weight: 600; color: var(--muted); background: transparent; border: 0; padding: 4px 10px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--text); }
.hist-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 10px 0 4px; font-size: 11.5px; color: var(--muted); }
.hist-legend span, .hist-tip div { display: inline-flex; align-items: center; gap: 6px; }
.lg-actual, .lg-target, .lg-band { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--text); }
.lg-target { border-top-color: var(--accent); }
.lg-band { height: 10px; border: 0; border-radius: 2px; background: var(--accent); opacity: .22; }
.hist-chart { position: relative; min-height: 120px; touch-action: pan-y; }
.hist-chart svg { display: block; overflow: visible; cursor: crosshair; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.hist-chart .grid { stroke: var(--line); stroke-width: 1; }
.hist-chart .axis { stroke: var(--faint); stroke-width: 1; }
.hist-chart .tick { stroke: var(--faint); }
.hist-chart .ylab, .hist-chart .xlab { fill: var(--faint); font-size: 10.5px; }
.hist-chart .xlab { text-anchor: middle; }
.hist-chart .future { fill: var(--bg); opacity: .5; }
.hist-chart .now { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.hist-chart .nowlab { fill: var(--muted); font-size: 10.5px; }
.hist-chart .actual { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.hist-chart .target { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; }
.hist-chart .band { fill: var(--accent); opacity: .16; }
.hist-chart .band-1 { stroke: var(--accent); stroke-width: 6; opacity: .25; stroke-linecap: round; }
.hist-chart .target-1 { fill: var(--accent); }
.hist-chart .last { fill: var(--text); stroke: var(--panel-2); stroke-width: 2; }
.hist-chart .cross { stroke: var(--faint); stroke-width: 1; opacity: 0; }
.hist-chart .hp { stroke: var(--panel-2); stroke-width: 2; opacity: 0; }
.hist-chart .hp-a { fill: var(--text); } .hist-chart .hp-f { fill: var(--accent); }
.hist-chart svg.hover .cross, .hist-chart svg.hover .hp { opacity: 1; }
.hist-tip {
  position: absolute; top: 8px; pointer-events: none; z-index: 2; max-width: 290px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  font-size: 12px; line-height: 1.5; box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}
.hist-tip div { display: flex; }
.hist-tip b { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.hist-tip .tt-time { color: var(--muted); font-size: 11.5px; }
.hist-tip .tt-sub { display: block; color: var(--muted); font-size: 11.5px; }
.hist-tip .sig { font-size: 10px; padding: 0 5px; }

.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; border-top: 3px solid var(--tc); }
.tile.pos { --tc: var(--pos); } .tile.neu { --tc: var(--faint); } .tile.neg { --tc: var(--neg); }
.tile-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.tile .asset { font-weight: 700; font-size: 13px; }
.tile .tone { color: var(--tc); font-size: 11.5px; font-weight: 700; text-transform: capitalize; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.tile p { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.watch-title { margin: 16px 0 6px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.watch { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.watch li { display: grid; grid-template-columns: 82px 1fr auto; gap: 10px; align-items: baseline; font-size: 13.5px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.watch li:last-child { border-bottom: 0; }
.watch .kind { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.watch .event .kind { color: var(--c-osakkeet); }
.watch .risk .kind { color: var(--neg); }
.watch .when { color: var(--accent); font-size: 12px; white-space: nowrap; font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ---------- 2. kriittiset uutiset */
.critical { border-color: color-mix(in srgb, var(--crit) 55%, var(--line)); background: linear-gradient(180deg, var(--crit-bg), var(--panel) 120px); }
.critical h2 { color: var(--crit); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.critical .count { color: var(--muted); font-weight: 600; letter-spacing: 0; text-transform: none; font-size: 12px; }
.pill-btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; }
.pill-btn:hover { border-color: var(--accent); }
.pill-btn[aria-pressed="true"] { border-color: var(--new); color: var(--new); }
.cr-list { margin-top: 8px; display: flex; flex-direction: column; }
.cr-item { position: relative; padding: 11px 0 11px 14px; border-top: 1px solid var(--line); }
.cr-item::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 2px; background: var(--lc); }
.cr-item.lvl-critical { --lc: var(--crit); }
.cr-item.lvl-significant { --lc: var(--accent); }
.cr-item.new { animation: flash 1.6s ease-in-out 3; background: var(--crit-bg); }
@keyframes flash { 50% { background: color-mix(in srgb, var(--crit) 22%, transparent); } }
.cr-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 11.5px; color: var(--muted); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.cr-meta time { color: var(--accent); font-weight: 600; }
.cr-meta .src { color: var(--text); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.lvl { color: var(--lc); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; border: 1px solid var(--lc); border-radius: 4px; padding: 0 5px; }
.asset-tag { color: var(--cc, var(--muted)); font-size: 11px; }
.asset-tag::before { content: "◆ "; font-size: 8px; vertical-align: 1px; }
.cr-item h3 { margin: 4px 0 0; font-size: 16px; line-height: 1.35; font-weight: 650; }
.cr-item h3 a, .row h3 a { text-decoration: none; }
.cr-item h3 a:hover, .row h3 a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.why { margin: 4px 0 0; color: var(--text); opacity: .82; font-size: 13.5px; }
.why::before { content: "→ "; color: var(--lc); font-weight: 700; }
.why.kw { color: var(--faint); font-size: 12px; }
.also { margin-top: 5px; font-size: 12px; color: var(--faint); }
.also a { color: var(--muted); }

/* ---------- 3. muut uutiset */
.others-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 6px 2px 0; }
.others h2 { color: var(--muted); }
.summary { color: var(--faint); font-size: 11.5px; padding: 8px 2px; }
.list { display: flex; flex-direction: column; }
.row {
  position: relative; display: grid; grid-template-columns: 150px 1fr; gap: 12px;
  padding: 7px 8px 7px 10px; border-bottom: 1px solid var(--line);
}
.row::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: transparent; }
.row:hover { background: var(--panel); }
.row.new { background: var(--new-bg); }
.row.new::before { background: var(--new); }
.row-meta { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); padding-top: 2px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.row-meta time { color: var(--accent); }
.row-meta .src { color: var(--muted); text-transform: uppercase; letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row h3 { margin: 0; font-size: 14px; line-height: 1.4; font-weight: 500; }
.row h3 a:visited { color: var(--muted); }
.row p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-tags { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 2px; }
.row-tags:empty { display: none; }
.also-inline { color: var(--faint); font-size: 11px; }
.tag { color: var(--cc); font-size: 11px; }
.tag::before { content: "#"; opacity: .6; }
.badge-new { background: var(--new); color: #04140a; font-weight: 800; font-size: 10px; padding: 1px 6px; border-radius: 4px; letter-spacing: .05em; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.empty { text-align: center; color: var(--muted); padding: 60px 16px; }
.more { display: block; margin: 18px auto; padding: 9px 18px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.more:hover { border-color: var(--accent); }

[data-cat="osakkeet"] { --cc: var(--c-osakkeet); }
[data-cat="kryptot"] { --cc: var(--c-kryptot); }
[data-cat="forex"] { --cc: var(--c-forex); }
[data-cat="raaka-aineet"] { --cc: var(--c-raaka-aineet); }
[data-cat="makro"] { --cc: var(--c-makro); }

/* ---------- lähdedialogi */
dialog {
  width: min(680px, calc(100vw - 32px)); max-height: 80vh;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
}
dialog::backdrop { background: rgba(0,0,0,.55); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.dlg-head h2 { margin: 0; font-size: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
td { padding: 6px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.st { width: 18px; }
td.n { text-align: right; color: var(--muted); white-space: nowrap; }
td .err { color: var(--warn); display: block; word-break: break-word; }
.ok-i { color: var(--ok); } .bad-i { color: var(--warn); }
.dlg-note { color: var(--muted); font-size: 12px; margin: 12px 0 0; }

/* ---------- tila-ikkuna: tekoäly */
.ai-status { font-size: 13px; background: var(--panel-2); border-radius: 8px; padding: 4px 12px; margin-bottom: 12px; }
.ai-status p { margin: 8px 0; }
.ai-status .err { color: var(--warn); }
dialog h3 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 14px 0 4px; }

/* ---------- tabletti */
@media (max-width: 860px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile:last-child { grid-column: 1 / -1; }
}

/* ---------- puhelin */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .logo { font-size: 13px; }
  .brand { gap: 8px; }
  .status .wide { display: none; }
  main { padding: 12px 10px 60px; gap: 14px; }
  .panel { padding: 14px 12px; border-radius: 10px; }
  .filters { flex-wrap: wrap; }
  .search { flex-basis: 100%; }
  select { flex: 1; max-width: none; height: 36px; background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; }
  .ov-headline { font-size: 16.5px; }
  .pcards { grid-template-columns: 1fr; }
  .pc-price { font-size: 23px; }
  .ol-nums { grid-template-columns: 1fr 1fr; }
  .ol-nums > div:last-child { grid-column: 1 / -1; }
  .watch li { grid-template-columns: 1fr auto; gap: 2px 10px; }
  .watch .kind { grid-column: 1 / -1; }
  .cr-item h3 { font-size: 15.5px; }
  .row { grid-template-columns: 1fr; gap: 2px; padding: 8px 6px 8px 10px; }
  .row-meta { flex-direction: row; gap: 10px; }
}
