/* Layout: a working dashboard. One column of cards, tabs for the four questions, red used only as YouTube's accent. */
:root {
  --bg: #f6f5f3;
  --panel: #ffffff;
  --fg: #1c1b1a;
  --muted: #6b6762;
  --line: #e3e0db;
  --accent: #c4302b;
  --accent-fg: #ffffff;
  --ok: #1d7a46;
  --bad: #b3261e;
  --warn: #9a5b00;
  --c-old: #2f5d8a;
  --c-new: #e0803a;
  --c-short: #7a4fb5;
  --c-long: #2a9d8f;
  --c-muted: #c9c5be;
  --hover: rgba(28, 27, 26, 0.05);
  --selected: rgba(28, 27, 26, 0.09);
  --sans: "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", Tahoma, sans-serif;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151413;
    --panel: #1f1e1c;
    --fg: #eeece8;
    --muted: #a09b94;
    --line: #34322f;
    --accent: #e5524c;
    --accent-fg: #ffffff;
    --ok: #5fc48a;
    --bad: #f0827a;
    --warn: #e0a850;
    --c-old: #6ea3d6;
    --c-new: #f0a468;
    --c-short: #b08ee6;
    --c-long: #5cc7b9;
    --c-muted: #55524d;
    --hover: rgba(238, 236, 232, 0.06);
    --selected: rgba(238, 236, 232, 0.11);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans); font-size: 15px; line-height: 1.45; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.page { max-width: 1280px; margin: 0 auto; padding: 20px 16px 48px; display: flex; flex-direction: column; gap: 16px; }

h1 { margin: 0; font-size: 1.6rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.head { display: flex; flex-direction: column; gap: 10px; }
.head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stamp { color: var(--muted); font-size: 0.85rem; }
.stamp.stale { color: var(--warn); }
.takeaway { margin: 0; max-width: 78ch; color: var(--muted); }
.takeaway b, .em { color: var(--fg); font-weight: 600; }
.note { margin: 0; max-width: 78ch; color: var(--muted); font-size: 0.85rem; }
.warn { color: var(--warn); }

.tabs { display: flex; gap: 18px; overflow-x: auto; border-bottom: 1px solid var(--line); flex: 1 1 auto; min-width: 0; }
.tab { flex: none; padding: 6px 0; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: inherit; cursor: pointer; }
.tab:hover { color: var(--fg); }
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }

.segment { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.segment button { padding: 5px 10px; border: 0; border-right: 1px solid var(--line); background: none; color: var(--muted); font: inherit; font-size: 0.85rem; cursor: pointer; }
.segment button:last-child { border-right: 0; }
.segment button[aria-pressed="true"] { background: var(--fg); color: var(--panel); }

.panel { display: flex; flex-direction: column; gap: 16px; }
.card, .tile { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 2px; }
.label { color: var(--muted); font-size: 0.85rem; }
.big { font-size: 1.9rem; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.big.mid { font-size: 1.25rem; }
.sub { color: var(--muted); font-size: 0.85rem; }
.up { color: var(--ok); }
.down { color: var(--bad); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: 0.85rem; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 2px; }
.c-old { background: var(--c-old); } .c-new { background: var(--c-new); }
.c-short { background: var(--c-short); } .c-long { background: var(--c-long); } .c-muted { background: var(--c-muted); }
.pill { display: inline-block; padding: 0 8px; border: 1px solid currentColor; border-radius: 999px; font-size: 0.8rem; white-space: nowrap; }
.pill.Trending { color: var(--ok); } .pill.Stalled { color: var(--muted); } .pill.bad { color: var(--bad); } .pill.ok { color: var(--ok); }

.bars, .momentum, .chart { position: relative; }
.bars { display: flex; flex-direction: column; gap: 4px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 10px; width: 100%; padding: 4px 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.bar-label { grid-column: 1 / -1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.bar-row:hover .bar-label { text-decoration: underline; }
.bar-track { display: block; height: 12px; min-width: 0; }
.bar-fill { display: block; height: 100%; min-width: 2px; border-radius: 4px; }
.bar-val { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }

.momentum { display: flex; flex-direction: column; gap: 8px; }
.stack { display: flex; gap: 2px; height: 16px; }
.stack > span { display: block; min-width: 3px; border-radius: 4px; }
.m-row { display: grid; grid-template-columns: 3.5rem minmax(0, 1fr) auto; align-items: baseline; gap: 10px; width: 100%; padding: 6px 0; border: 0; border-top: 1px solid var(--line); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.m-row:hover .m-what { text-decoration: underline; }
.m-n { font-size: 1.4rem; font-weight: 600; line-height: 1; }
.m-what { color: var(--muted); font-size: 0.85rem; }

.filters, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.input, .btn { padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--fg); font: inherit; font-size: 0.9rem; max-width: 100%; }
.input.short { width: 7rem; }
.btn { cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn:disabled { opacity: 0.55; cursor: default; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; }
.count { margin-left: auto; color: var(--muted); font-size: 0.85rem; }
.chip { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form { display: flex; flex-direction: column; }
.form .row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.form .row:first-child { border-top: 0; }

.table-wrap { max-height: 36rem; overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.table th { position: sticky; top: 0; z-index: 1; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); color: var(--muted); font-weight: 600; text-align: left; white-space: nowrap; }
.table td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table .num { text-align: right; white-space: nowrap; }
.table td.nowrap { white-space: nowrap; }
.table td.title-cell { min-width: 14rem; max-width: 30rem; font-size: 0.95rem; text-align: left; }
.table td.text-cell { min-width: 14rem; max-width: 34rem; font-size: 0.95rem; text-align: left; overflow-wrap: anywhere; }
.table td.video-cell { max-width: 18rem; color: var(--muted); text-align: left; }
.sort { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.sort:hover { color: var(--fg); }
.table th[aria-sort] { color: var(--fg); }
.table th[aria-sort="ascending"] .sort::after { content: " \2191"; }
.table th[aria-sort="descending"] .sort::after { content: " \2193"; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--hover); }
.table tr[aria-selected="true"] td { background: var(--selected); }
.table td.barcell { position: relative; }
.cellbar { position: absolute; right: 10px; bottom: 3px; height: 3px; border-radius: 2px; opacity: 0.7; }
@media (max-width: 820px) { .table .sec { display: none; } }

.detail-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; }
.thumb img { display: block; width: 200px; max-width: 100%; border-radius: var(--radius); }
.detail-body { flex: 1 1 16rem; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.detail-title { font-size: 1.3rem; font-weight: 600; line-height: 1.35; text-align: left; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--muted); font-size: 0.85rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); gap: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-v { font-size: 1.4rem; font-weight: 600; }

.chart { min-height: 280px; }
.chart.low { min-height: 200px; }
.chart svg { display: block; overflow: visible; }
.tick { font-size: 12px; fill: var(--muted); }
.grid-line { stroke: var(--line); stroke-width: 1; }
.axis-line { stroke: var(--muted); stroke-width: 1; }
.line { fill: none; stroke: var(--c-old); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.point { fill: var(--c-old); stroke: var(--panel); stroke-width: 1.5; }
.dot { stroke: var(--panel); stroke-width: 1; fill-opacity: 0.75; cursor: pointer; }
.dot:hover { fill-opacity: 1; stroke: var(--fg); }
.dot.Short { fill: var(--c-short); } .dot.Long { fill: var(--c-long); }
.month-bar { fill: var(--c-old); }
.hit { fill: transparent; }
.hit:hover + .month-bar, .month:hover .month-bar { opacity: 0.75; }
.chart-empty { display: flex; align-items: center; justify-content: center; min-height: inherit; color: var(--muted); font-size: 0.85rem; text-align: center; }

.tip { position: absolute; z-index: 5; max-width: min(20rem, 90%); padding: 6px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); font-size: 0.8rem; pointer-events: none; }
.tip-head { color: var(--muted); text-align: left; overflow-wrap: anywhere; }
.tip-line { display: flex; justify-content: space-between; gap: 16px; }
.tip-k { color: var(--muted); }

.meter { height: 8px; border-radius: 4px; background: var(--c-muted); overflow: hidden; margin-top: 4px; }
.meter > span { display: block; height: 100%; background: var(--c-old); }

.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: min(100%, 22rem); }
