/* ZSE daily market overview – dashboard theme (dark / light, primary colours, RTL) */

/* ---------- theme tokens ---------- */
:root,
:root[data-theme="dark"] {
  --bg: #11111d;
  --bg-2: #161627;
  --glow: rgba(255, 255, 255, 0.04);
  --topbar: rgba(17, 17, 29, 0.85);
  --card: rgba(255, 255, 255, 0.045);
  --card-hover: rgba(255, 255, 255, 0.07);
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.02);
  --border: rgba(255, 255, 255, 0.09);
  --row-line: rgba(255, 255, 255, 0.05);
  --text: #f1f2f6;
  --muted: #8b8fa7;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f5f9;
  --bg-2: #ffffff;
  --glow: rgba(0, 0, 0, 0.02);
  --topbar: rgba(255, 255, 255, 0.88);
  --card: #ffffff;
  --card-hover: #f7f8fb;
  --surface: #f1f3f7;
  --surface-2: #fafbfc;
  --border: #e3e6ee;
  --row-line: #edf0f4;
  --text: #171a2b;
  --muted: #6b7088;
  --shadow: 0 20px 50px rgba(20, 24, 40, 0.18);
  color-scheme: light;
}

/* Primary colour presets (used for buttons, active states, focus, logo) */
:root, [data-primary="emerald"] { --primary: #22c55e; --primary-strong: #15803d; --on-primary: #04130a; }
[data-primary="ocean"]  { --primary: #3b82f6; --primary-strong: #1d4ed8; --on-primary: #ffffff; }
[data-primary="violet"] { --primary: #8b5cf6; --primary-strong: #6d28d9; --on-primary: #ffffff; }
[data-primary="ruby"]   { --primary: #e11d48; --primary-strong: #9f1239; --on-primary: #ffffff; }
[data-primary="amber"]  { --primary: #f59e0b; --primary-strong: #b45309; --on-primary: #1c1203; }
[data-primary="aqua"]   { --primary: #06b6d4; --primary-strong: #0e7490; --on-primary: #021a1f; }
[data-primary="pink"]   { --primary: #ec4899; --primary-strong: #be185d; --on-primary: #ffffff; }
[data-primary="indigo"] { --primary: #6366f1; --primary-strong: #4338ca; --on-primary: #ffffff; }
.sw-emerald { background: #22c55e; } .sw-ocean { background: #3b82f6; } .sw-violet { background: #8b5cf6; }
.sw-ruby { background: #e11d48; } .sw-amber { background: #f59e0b; } .sw-aqua { background: #06b6d4; }
.sw-pink { background: #ec4899; } .sw-indigo { background: #6366f1; }

/* Fixed semantic colours (price up / down) – these do not follow the primary colour */
:root {
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.14);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.14);
  --blue: #3b82f6;
  --violet: #a855f7;
  --amber: #f59e0b;
  --flat: #94a3b8;
  --radius: 16px;
  --font: "Montserrat", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}
:root[data-theme="light"] { --green: #16a34a; --red: #dc2626; --flat: #64748b; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 10%, transparent), transparent 60%), var(--bg);
  background-color: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  min-height: 100vh;
}
a { color: inherit; }
button { font: inherit; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 10;
}
:root[data-nav="scroll"] .topbar { position: relative; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  font-weight: 800; font-size: 12px; letter-spacing: .5px; color: var(--on-primary);
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.pill {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
}
.meta { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.updated { display: flex; align-items: center; gap: 6px; }
.updated .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
.lang { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.lang a { text-decoration: none; padding: 4px 12px; border-radius: 999px; font-weight: 600; font-size: 12px; color: var(--muted); }
.lang a.active { background: var(--primary); color: var(--on-primary); }

.tools { display: flex; gap: 6px; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted); padding: 0;
}
.icon-btn:hover { color: var(--text); border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
.icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#customizer-open svg { animation: spin 8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #customizer-open svg { animation: none; } }
:root[data-theme="dark"] .i-sun, :root:not([data-theme]) .i-sun { display: none; }
:root[data-theme="light"] .i-moon { display: none; }

/* ---------- layout ---------- */
main { padding: 24px 28px; display: grid; gap: 20px; max-width: 1600px; margin: 0 auto; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }

.panel, .kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  min-width: 0;
}
:root[data-theme="light"] .panel, :root[data-theme="light"] .kpi { box-shadow: 0 1px 2px rgba(20, 24, 40, .04); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.panel h2 { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.label { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.muted { color: var(--muted); }
.tag {
  font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px;
}

/* ---------- KPI cards ---------- */
.kpi { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 6px; }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent, var(--primary)); }
.accent-green { --accent: var(--green); }
.accent-red { --accent: var(--red); }
.accent-blue { --accent: var(--blue); }
.accent-violet { --accent: var(--violet); }
.accent-amber { --accent: var(--amber); }
.kpi header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.kpi .value .sep { color: var(--muted); font-weight: 400; }
.kpi .hint { margin: 0; font-size: 12.5px; }
.spark { min-height: 56px; margin-top: auto; }

.range { margin-top: auto; padding-top: 8px; }
.ends { display: flex; justify-content: space-between; font-size: 11px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.track {
  position: relative; height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--red), var(--amber), var(--green));
  opacity: .9;
}
[dir="rtl"] .track { background: linear-gradient(-90deg, var(--red), var(--amber), var(--green)); }
.track.small { height: 4px; min-width: 90px; }
.marker {
  position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--bg); transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px rgba(127, 127, 127, .35);
}
[dir="rtl"] .marker { transform: translate(50%, -50%); }
.track.small .marker { width: 10px; height: 10px; }

/* Numbers and amounts always read left-to-right, even in RTL layout */
[dir="rtl"] .value, [dir="rtl"] .badge, [dir="rtl"] .tag, [dir="rtl"] .what strong,
[dir="rtl"] .ends span, [dir="rtl"] td.num, [dir="rtl"] .mono, [dir="rtl"] .pill { unicode-bidi: isolate; direction: ltr; }
[dir="rtl"] td.num { text-align: left; }
[dir="rtl"] .kpi .value { text-align: right; }
/* Croatian/English text keeps its own reading order inside the RTL layout */
[dir="rtl"] .sub, [dir="rtl"] .hint, [dir="rtl"] .label, [dir="rtl"] th, [dir="rtl"] .who strong, [dir="rtl"] .who small,
[dir="rtl"] .cell-name, [dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] footer p { unicode-bidi: plaintext; text-align: right; }
[dir="rtl"] th.num { text-align: left; }
[dir="rtl"] footer p { text-align: center; }
[dir="rtl"] .apexcharts-canvas { direction: ltr; }

.stack { display: flex; height: 8px; border-radius: 999px; overflow: hidden; margin-top: auto; gap: 2px; }
.stack span { display: block; min-width: 0; }
.stack .up { background: var(--green); }
.stack .flat { background: var(--flat); }
.stack .down { background: var(--red); }

/* ---------- colours for changes ---------- */
.up { color: var(--green); }
.down { color: var(--red); }
.flat { color: var(--flat); }
.badge {
  display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  background: rgba(148, 163, 184, .14); color: var(--flat);
}
.badge.up { background: var(--green-bg); color: var(--green); }
.badge.down { background: var(--red-bg); color: var(--red); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: start; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--row-line); white-space: nowrap; }
tbody tr:hover { background: var(--card-hover); }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: end; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); }
.range-col { width: 130px; }
th[data-k] { cursor: pointer; user-select: none; }
th[data-k]:hover { color: var(--text); }
th.sorted-asc::after { content: " ▲"; font-size: 9px; color: var(--primary); }
th.sorted-desc::after { content: " ▼"; font-size: 9px; color: var(--primary); }
.cell-name { display: inline-flex; align-items: center; gap: 10px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- lists (gainers / losers / most traded) ---------- */
.list-panel { position: relative; overflow: hidden; }
.list-panel::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--accent); opacity: .7; }
.rows { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.rows > li { min-width: 0; }
.who small .flag { margin-inline-end: 4px; }
.row-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
}
.row-item:hover { background: var(--card-hover); }
.avatar {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  font-size: 11px; font-weight: 700; background: rgba(148, 163, 184, .14); color: var(--flat);
}
.avatar.up { background: var(--green-bg); color: var(--green); }
.avatar.down { background: var(--red-bg); color: var(--red); }
.avatar.sm { width: 26px; height: 26px; border-radius: 8px; font-size: 9.5px; }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.who small { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.what { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-variant-numeric: tabular-nums; }
.what strong { font-size: 13px; }
.empty { margin: 8px 0 0; }

/* ---------- market mix ---------- */
.seg-toggle { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg-toggle button {
  font-size: 12px; font-weight: 600; border: 0; background: none; color: var(--muted);
  padding: 5px 10px; border-radius: 7px; cursor: pointer;
}
.seg-toggle button.active { background: var(--primary); color: var(--on-primary); }
.mix-chart { min-height: 320px; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters input[type="search"], .filters select {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; outline: none;
}
.filters input[type="search"] { flex: 1 1 260px; min-width: 0; }
.filters input:focus, .filters select:focus { border-color: var(--primary); }
.filters select option { background: var(--bg-2); color: var(--text); }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--primary); }

/* ---------- theme customizer drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(5, 6, 12, .55); backdrop-filter: blur(3px); z-index: 40; }
.drawer-backdrop[hidden] { display: none; }
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-end: 0; z-index: 50;
  width: min(340px, 100vw); display: flex; flex-direction: column;
  background: var(--bg-2); border-inline-start: 1px solid var(--border); box-shadow: var(--shadow);
  transform: translateX(100%); transition: transform .25s ease; visibility: hidden;
}
[dir="rtl"] .drawer { transform: translateX(-100%); }
.drawer.open { transform: none; visibility: visible; }
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; display: grid; gap: 22px; align-content: start; }
.opt-group { display: grid; gap: 10px; }
.opt-group .hint { margin: 0; font-size: 11.5px; }
.opt-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt-row button {
  padding: 9px 10px; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 600;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
}
.opt-row button:hover { color: var(--text); }
.opt-row button.active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatches button {
  display: grid; justify-items: center; gap: 6px; padding: 10px 4px; border-radius: 12px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.swatches button small { font-size: 10.5px; line-height: 1.2; text-align: center; }
.swatches button.active { border-color: var(--primary); color: var(--text); box-shadow: 0 0 0 1px var(--primary) inset; }
.sw { width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25); }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.btn-ghost {
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 600;
  background: none; color: var(--text); border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.opt-row button:focus-visible, .swatches button:focus-visible, .btn-ghost:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- trading status flags (EHO) ---------- */
.flag {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
  padding: 2px 7px; border-radius: 6px; white-space: nowrap; vertical-align: middle;
}
.flag.sm { font-size: 9.5px; padding: 1px 6px; }
.flag-susp { background: var(--red-bg); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 40%, transparent); }
.flag-obs { background: rgba(245, 158, 11, .14); color: var(--amber); border: 1px solid rgba(245, 158, 11, .4); }
.status-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  padding: 10px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--border);
}
.status-chip {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-size: 12.5px;
  padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
}
a.status-chip[href]:hover { border-color: var(--primary); }

/* ---------- announcements & events ---------- */
.mini-select {
  font: inherit; font-size: 12px; color: var(--text); background: var(--surface); max-width: 220px;
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px;
}
.mini-select option { background: var(--bg-2); color: var(--text); }
.news-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.news-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 6px; border-bottom: 1px solid var(--row-line); }
.news-item:last-child { border-bottom: 0; }
.news-list:not(.show-all) .news-item.extra { display: none; }
.news-item[hidden] { display: none !important; }
.news-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.news-title { color: var(--text); text-decoration: none; font-weight: 600; font-size: 13px; line-height: 1.35; }
a.news-title:hover { color: var(--primary); text-decoration: underline; }
.news-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; color: var(--muted); font-size: 11.5px; }
.chip {
  font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 6px; max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary);
}
.doc-link { color: var(--muted); }
.doc-link:hover { color: var(--primary); }
.more-btn { margin-top: 10px; width: 100%; }
.news-list.compact .news-item { padding: 8px 0; }

.tabs { margin-bottom: 12px; width: 100%; }
.tabs button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.count-pill { font-size: 10px; padding: 0 6px; border-radius: 999px; background: rgba(127, 127, 127, .2); }
.tabs button.active .count-pill { background: rgba(0, 0, 0, .15); }
.tab-panel { max-height: 520px; overflow-y: auto; }
.event-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.event-list li { display: flex; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.cal {
  flex: none; width: 46px; height: 50px; border-radius: 10px; display: grid; place-content: center; text-align: center;
  background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary);
}
.cal strong { font-size: 18px; line-height: 1; }
.cal small { font-size: 10.5px; font-weight: 600; text-transform: uppercase; }

/* ---------- securities accordion ---------- */
.accordion .sec-row td { cursor: pointer; }
.accordion .sec-row.open td { background: var(--card-hover); border-bottom-color: transparent; }
.accordion .sec-row.is-flagged td:first-child { box-shadow: inset 3px 0 0 var(--red); }
[dir="rtl"] .accordion .sec-row.is-flagged td:first-child { box-shadow: inset -3px 0 0 var(--red); }
.row-toggle {
  display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; margin: 0;
  color: inherit; cursor: pointer; text-align: start; max-width: 360px;
}
.row-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: 6px; }
.chev { flex: none; width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s ease; }
[dir="rtl"] .chev { transform: scaleX(-1); }
.row-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); stroke: var(--primary); }
.row-name { display: flex; flex-direction: column; min-width: 0; }
.row-name strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.row-name small { color: var(--muted); font-size: 11px; }
.news-dot {
  display: inline-block; min-width: 16px; padding: 0 5px; border-radius: 999px; text-align: center; font-weight: 700;
  background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary);
}
.sec-detail > td { padding: 0 12px 16px; background: var(--card-hover); white-space: normal; }
.detail-grid {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px;
  padding: 14px 16px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border);
  position: sticky; left: 12px; max-width: calc(100vw - 80px);
}
.facts { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; align-content: start; }
.facts > div { min-width: 0; }
.facts .wide { grid-column: 1 / -1; }
.facts dt { color: var(--muted); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.facts dd .track { max-width: 320px; margin-top: 6px; }
.facts dd .ends { max-width: 320px; }
.detail-news { min-width: 0; display: grid; gap: 6px; align-content: start; }
.show-sm, .show-sm-inline { display: none; }

/* Index rows: expandable on phones only */
.idx-toggle { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: default; text-align: start; }
.idx-detail { display: none; }
.idx-detail > td { white-space: normal; padding: 4px 12px 14px; background: var(--card-hover); }
.idx-detail .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.idx-row.open .chev { transform: rotate(90deg); stroke: var(--primary); }

/* ---------- price history ---------- */
.grid-1 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.chart-ctrls { display: flex; gap: 8px; flex-wrap: wrap; }
.ranges { width: fit-content; max-width: 100%; margin-bottom: 8px; overflow-x: auto; }
.ranges button { white-space: nowrap; }
.hist-meta { min-height: 22px; display: flex; gap: 8px; align-items: center; font-size: 12.5px; margin-bottom: 4px; }
.hist-chart { min-height: 240px; }
.hist-chart > p { margin: 20px 0; }
.perf-panel { display: grid; gap: 6px; }
.perf-panel[hidden], .tab-panel[hidden] { display: none; }
.perf-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.perf-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.perf-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13px; }
.spark-col { width: 140px; }
.spark-wrap { display: inline-flex; align-items: center; gap: 8px; }
.spark-wrap small { font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 44px; text-align: end; }
.spark-svg { display: block; overflow: visible; }
.spark-svg path { fill: none; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark-svg.up path { stroke: var(--green); }
.spark-svg.down path { stroke: var(--red); }
.detail-chart { grid-column: 1 / -1; min-width: 0; display: grid; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.ret-chips { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.ret-chip { display: inline-flex; gap: 6px; align-items: baseline; padding: 4px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ret-chip small { color: var(--muted); font-weight: 600; }
.chart-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.chart-bar .ranges { margin-bottom: 0; }

/* ---------- notices / footer ---------- */
.notice { background: var(--red-bg); border: 1px solid rgba(239, 68, 68, .35); border-radius: 12px; padding: 14px 16px; margin: 0; }
.notice-list { color: var(--muted); margin: 0; }
.debug { background: #000; color: #9be29b; padding: 14px; border-radius: 12px; overflow: auto; font-size: 12px; }
footer { padding: 10px 28px 28px; color: var(--muted); font-size: 12px; text-align: center; }

/* ApexCharts tooltip */
.apexcharts-tooltip { box-shadow: none !important; border: 1px solid var(--border) !important; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-news { order: 2; }   /* phones: facts, then chart, then announcements */
}
@media (max-width: 700px) {
  .hide-sm { display: none; }
  .show-sm { display: block; }
  .show-sm-inline { display: inline-block; }
  .idx-detail:not([hidden]) { display: table-row; }
  .idx-row td { cursor: pointer; }
  .idx-toggle { cursor: pointer; min-height: 32px; }
  /* tables: tighter cells so name, price and change fit without sideways scrolling */
  th, td { padding: 10px 6px; }
  th:first-child, td:first-child { padding-left: 2px; }
  #sec .avatar.sm { display: none; }
  /* fixed layout: name takes what is left, numbers get fixed room; headers may wrap */
  th { white-space: normal; line-height: 1.25; vertical-align: bottom; }
  table:not(#sec):not(.indices) td:first-child { white-space: normal; }
  #sec th:nth-child(3), table.indices th:nth-child(2) { width: 92px; }
  #sec th:nth-child(4), table.indices th:nth-child(4) { width: 78px; }
  .idx-toggle { display: flex; width: calc(100vw - 236px); max-width: none; min-width: 0; }
  .row-toggle { display: flex; width: calc(100vw - 254px); max-width: none; min-width: 0; }
  .row-toggle .chev, .idx-toggle .chev { flex: none; }
  .row-name { flex: 1 1 auto; min-width: 0; }
  .idx-name { flex: 1 1 auto; min-width: 0; }
  .row-name strong, .idx-name { display: block; max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .row-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sec-detail > td, .idx-detail > td { width: auto; }
  .tabs button { flex: 1 1 0; min-width: 0; white-space: normal; line-height: 1.2; padding: 6px 4px; font-size: 12.5px; flex-wrap: wrap; gap: 4px; }
  .row-toggle { gap: 6px; }
  .row-name strong { max-width: calc(100vw - 250px); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-name strong { max-width: 140px; }
  .detail-grid { max-width: calc(100vw - 100px); padding: 12px; left: 0; }
  .sec-detail > td { padding: 0 6px 12px; }
}
@media (max-width: 600px) {
  /* compact two-row header; it scrolls away on phones to save space */
  .topbar { padding: 12px 16px; position: relative; gap: 10px; }
  .brand { gap: 10px; }
  .logo { width: 36px; height: 36px; border-radius: 10px; font-size: 10.5px; }
  .topbar h1 { font-size: 17px; gap: 8px; }
  .topbar .sub { font-size: 12px; }
  .meta { flex-wrap: nowrap; gap: 8px; }
  .tools { gap: 4px; }
  main { padding: 16px; gap: 16px; }
  .kpis { grid-template-columns: 1fr; gap: 16px; }
  .kpi .value { font-size: 22px; }
  .meta { width: 100%; justify-content: space-between; }
  footer { padding: 8px 16px 24px; }
}

/* ---------- touch screens & phones: bigger tap targets, readable text ---------- */
@media (max-width: 700px), (pointer: coarse) {
  .icon-btn { width: 42px; height: 42px; }
  .lang a { padding: 9px 13px; font-size: 13px; }
  .seg-toggle button { min-height: 40px; padding: 8px 12px; font-size: 13px; }
  .filters input[type="search"], .filters select { min-height: 44px; font-size: 16px; } /* 16px stops iOS zooming in */
  .mini-select { min-height: 40px; font-size: 14px; }
  .check { min-height: 44px; font-size: 14px; }
  .check input { width: 20px; height: 20px; }
  .status-chip { min-height: 40px; padding: 6px 12px; font-size: 13px; }
  .doc-link { display: inline-block; padding: 6px 4px; margin: -6px -4px; }
  a.news-title { display: block; padding: 6px 0; margin: -6px 0; }
  .more-btn, .btn-ghost { min-height: 44px; }
  .opt-row button { min-height: 44px; }
  th[data-k] { padding-top: 14px; padding-bottom: 14px; }
}
@media (max-width: 700px) {
  .label, th, .facts dt { font-size: 11.5px; }
  .tag, .chip, .news-meta, .ends, .row-name small, .who small, .count-pill { font-size: 12px; }
  .flag, .flag.sm { font-size: 11px; padding: 2px 7px; }
  .badge { font-size: 12.5px; }
  .avatar.sm { font-size: 11px; }
  .swatches button small { font-size: 11.5px; }
  .cal small { font-size: 11.5px; }
}

/* ---------- logo image in light mode ----------
   A white logo disappears on a light background. In light mode it is shown in dark tone;
   if there is a separate dark version (class="logo-light"), that one is shown instead. */
.brand img { display: block; max-height: 42px; width: auto; }
.brand .logo-light { display: none; }
:root[data-theme="light"] .brand img:not(.logo-light):not(.logo-dark) { filter: brightness(0) saturate(100%); opacity: .88; }
:root[data-theme="light"] .brand .logo-dark { display: none; }
:root[data-theme="light"] .brand .logo-light { display: block; }