/* ZsoltMinder Trendalyzer — shared styles (app + exported view) */
:root {
  --bg: #0f1117;
  --panel: #1a1d27;
  --border: #2e334d;
  --text: #e8eaf0;
  --muted: #7c82a0;
  --muted2: #b0b4cc;
  --accent: #1e7ea1;
  /* chart (SVG) colors — themed */
  --svg-axis: #3a4060;
  --svg-grid: #20243a;
  --svg-text: #7c82a0;
  --watermark: #2b3050;
  --trail: #9aa0b4;
  --input-bg: #0f1117;
  --dir: #5cba8a;              /* direction-of-benefit ("better") marker */
}

/* Light theme — applied via <body data-theme="light"> */
body[data-theme="light"] {
  --bg: #ffffff;
  --panel: #f3f4f8;
  --border: #d6d9e4;
  --text: #1a1d27;
  --muted: #5b6178;
  --muted2: #383d56;
  --accent: #1e7ea1;
  --svg-axis: #b6bccd;
  --svg-grid: #eceef5;
  --svg-text: #5b6178;
  --watermark: #e6e8f1;
  --trail: #8a90a6;
  --input-bg: #ffffff;
  --dir: #2f9e6a;              /* slightly darker green for legibility on white */
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---------- App layout (full app only) ---------- */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 280px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--border); overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidebar.hidden { display: none; }
.sidebar-head {
  padding: 14px 14px 10px; border-bottom: 1px solid var(--border);
}
.sidebar-head h1 { font-size: 14px; margin: 0; font-weight: 700; }
.sidebar-head p { font-size: 11px; color: var(--muted); margin: 2px 0 0; }
.sidebar-body { padding: 12px 14px; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
}
.topbar .spacer { flex: 1; }

.section { margin-bottom: 16px; }
.section h2 {
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 8px;
}
.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: 12px; color: var(--muted2); margin-bottom: 3px; }
.field select, .field input[type="color"] {
  width: 100%; background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 5px; padding: 5px 6px; font-size: 12px;
}
.field input[type="color"] { height: 30px; padding: 2px; }
.row { display: flex; gap: 8px; }
.row > .field { flex: 1; }
.radio-row { display: flex; gap: 6px; }
.radio-row label {
  flex: 1; text-align: center; font-size: 12px; padding: 6px 4px;
  border: 1px solid var(--border); border-radius: 5px; cursor: pointer; color: var(--muted2);
}
.radio-row input { display: none; }
.radio-row input:checked + span { color: var(--text); }
.radio-row label:has(input:checked) { border-color: var(--accent); background: rgba(30,126,161,0.14); }

button.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 8px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
button.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted2); }
button.btn:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }
.hint { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* ---------- Player (shared) ---------- */
.zmt-player { display: flex; flex-direction: column; height: 100%; padding: 10px 14px 12px; }
.zmt-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.zmt-title-main { font-size: 15px; font-weight: 700; }
.zmt-title-sub { font-size: 12px; color: var(--muted); }
.zmt-chart { flex: 1; min-height: 0; position: relative; }
.zmt-svg { width: 100%; height: 100%; display: block; }

.zmt-axis path, .zmt-axis line { stroke: var(--svg-axis); }
.zmt-axis text { fill: var(--svg-text); font-size: 11px; }
.zmt-grid line { stroke: var(--svg-grid); }
.zmt-grid path { stroke: none; }
.zmt-axislabel { fill: var(--muted2); font-size: 12px; }
.zmt-trail { fill: none; stroke: var(--trail); stroke-width: 1.5; opacity: .55; }
.zmt-ptrail { stroke-width: 1.6; stroke-linecap: round; }
.zmt-ci { fill-opacity: .12; stroke-opacity: .35; stroke-width: 1; }
.zmt-bubble { stroke: var(--bg); }
.zmt-watermark { fill: var(--watermark); font-size: 46px; font-weight: 800; opacity: .9; }

/* timeseries layout */
.zmt-ts { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.zmt-ts-panel { flex: 1; min-height: 0; }
.zmt-spaghetti { fill: none; stroke-width: 0.7; opacity: 0.14; }
.zmt-band { stroke: none; }
.zmt-mean { fill: none; stroke-width: 2.4; }
.zmt-dirmark { fill: var(--dir); font-size: 12px; font-weight: 600; }
.zmt-visitmark { stroke: var(--muted); stroke-width: 1; stroke-opacity: .55; }

.zmt-playbar {
  display: flex; align-items: center; gap: 12px; margin-top: 8px;
  padding: 6px 4px;
}
.zmt-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  width: 36px; height: 30px; font-size: 13px; cursor: pointer; flex-shrink: 0;
}
.zmt-scrub { flex: 1; }
.zmt-wk { font-size: 12px; color: var(--muted2); min-width: 70px; font-variant-numeric: tabular-nums; }
.zmt-speed, .zmt-loop { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.zmt-speed input[type="range"] { width: 80px; }

/* ---------- Run picker modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8,9,14,.78);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 22px 24px; width: 380px; max-width: 90vw;
}
.modal h2 { margin: 0 0 4px; font-size: 16px; }
.modal p { margin: 0 0 16px; font-size: 12px; color: var(--muted); }
.run-list { display: flex; flex-direction: column; gap: 8px; }
.run-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px;
  cursor: pointer; background: var(--input-bg);
}
.run-item:hover { border-color: var(--accent); }
.run-item .rid { font-weight: 700; }
.run-item .rmeta { font-size: 11px; color: var(--muted); }

/* ---------- Measure "?" button + info modal ---------- */
.measure-row { display: flex; gap: 6px; align-items: stretch; }
.measure-row select { flex: 1; min-width: 0; }
.help-btn {
  flex-shrink: 0; width: 28px; border: 1px solid var(--border); border-radius: 5px;
  background: var(--input-bg); color: var(--muted2); font-size: 13px; font-weight: 700;
  cursor: pointer; line-height: 1;
}
.help-btn:hover { border-color: var(--accent); color: var(--accent); }

.help-modal { width: 460px; max-height: 82vh; overflow-y: auto; }
.help-modal h2 { margin: 0 0 8px; font-size: 16px; }
.help-modal .help-scale {
  margin: 0 0 12px; font-size: 12px; color: var(--dir); font-weight: 600;
}
.help-modal .help-eli5 {
  margin: 0 0 12px; font-size: 13px; color: var(--text); line-height: 1.5;
}
.help-modal .help-detail {
  font-size: 12px; color: var(--muted2); line-height: 1.55;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.help-modal .help-cite {
  margin-top: 12px; font-size: 11px; color: var(--muted); font-style: italic;
}
.help-modal .help-actions { margin-top: 16px; text-align: right; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted2); }
.legend .sw { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }

/* ---------- View tabs (Chart | Summary stats) + the stats pane ---------- */
.view-tabs {
  display: flex; gap: 6px; align-items: center; flex-shrink: 0;
  padding: 0 14px; border-bottom: 1px solid var(--border);
}
.view-tab {
  background: transparent; border: none; color: var(--muted);
  font-size: 13px; font-weight: 600; padding: 9px 10px; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.view-tab.active { color: var(--text); border-bottom-color: var(--accent); }
#stage.hidden { display: none; }

.stats-panel {                       /* the Summary-stats tab pane (fills the area) */
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 14px 16px; background: var(--bg);
}
.stats-panel.hidden { display: none; }
.stats-head { font-size: 12px; font-weight: 600; color: var(--muted2); margin-bottom: 10px; }
.stats-head .stats-sub { font-weight: 400; color: var(--muted); }
.stats-table { border-collapse: collapse; width: 100%; margin-bottom: 14px; font-size: 12px; }
.stats-table caption {
  caption-side: top; text-align: left; padding: 0 0 6px;
  font-weight: 600; color: var(--text);
}
.stats-table caption .stats-scale { font-weight: 400; color: var(--muted); }
.stats-table th, .stats-table td {
  text-align: right; padding: 4px 12px; border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.stats-table th {
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
}
.stats-table th:first-child, .stats-table td.arm { text-align: left; }
.stats-table td.arm .dot {
  width: 9px; height: 9px; border-radius: 50%;
  display: inline-block; margin-right: 6px; vertical-align: middle;
}
.stats-table tbody tr:last-child td { border-bottom: none; }
.stats-compare {
  font-size: 12px; color: var(--muted2); margin: -6px 0 14px;
  padding: 6px 10px; border-left: 2px solid var(--accent); background: rgba(30,126,161,0.06);
}
.stats-compare b { color: var(--text); font-variant-numeric: tabular-nums; }
.stats-compare-d { color: var(--muted); font-size: 11px; }
