/* Technosport sales dashboard */
:root {
  color-scheme: light;
  --page: #f9f9f9;
  --surface-1: #ffffff;
  --surface-2: #f3f3f3;
  --text-primary: #191919;
  --text-secondary: #666666;
  --grid: #e7e7e7;
  --axis: #c2c2c2;
  --border: rgba(11, 11, 11, 0.10);
  --hover: rgba(11, 11, 11, 0.05);
  --accent: #257de0;
  --good-text: #006c10;
  --bad-text: #b42324;
  --warning: #fbb315;
  --critical: #dc3c3d;
  --serious: #f18a59;
  --good: #0aac23;
  --series-1: #257de0; /* Website */
  --series-2: #f47230; /* Myntra */
  --series-3: #00b894; /* Flipkart */
  --series-4: #f2a600; /* Amazon */
  --series-5: #ee7fac; /* Ajio */
  --series-6: #008a17; /* Flipkart SOR */
  --series-7: #6a4ce2; /* Blinkit */
  --series-other: #a3a3a3;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0b0b0b;
    --surface-1: #191919;
    --surface-2: #222222;
    --text-primary: #efefef;
    --text-secondary: #9c9c9c;
    --grid: #303030;
    --axis: #474747;
    --border: rgba(255, 255, 255, 0.10);
    --hover: rgba(255, 255, 255, 0.06);
    --accent: #338ced;
    --good-text: #53c556;
    --bad-text: #eb6263;
    --series-1: #338ced;
    --series-2: #e76624;
    --series-3: #00a888;
    --series-4: #d28e05;
    --series-5: #e24d8b;
    --series-6: #0aac23;
    --series-7: #9887ef;
    --series-other: #6b6b6b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.wrap { max-width: 1280px; margin: 0 auto; padding: 20px 24px 48px; }

header.top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 16px;
}
header.top h1 { font-size: 20px; font-weight: 600; margin: 0; }
.muted { color: var(--text-secondary); }
.small { font-size: 12px; }

nav.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--grid); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
nav.tabs button { flex: none; white-space: nowrap; }
nav.tabs button {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-secondary); font: inherit; font-weight: 500; padding: 10px 14px; cursor: pointer;
}
nav.tabs button:hover { color: var(--text-primary); }
nav.tabs button[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent); }

.view[hidden] { display: none; }

.filters { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 16px; }
.filters label.lbl { font-size: 12px; color: var(--text-secondary); margin-right: 4px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  appearance: none; border: 0; background: var(--surface-1); color: var(--text-secondary);
  font: inherit; font-size: 13px; padding: 6px 12px; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { color: var(--text-primary); background: var(--surface-2); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  font: inherit; font-size: 12px; cursor: pointer;
}
.chip[aria-pressed="false"] { color: var(--text-secondary); opacity: 0.55; }
.sw { flex: none; display: inline-block; vertical-align: middle; }

input[type="search"], select {
  font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
}
input[type="search"] { min-width: 240px; }

.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px;
}
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.card .sub { font-size: 12px; color: var(--text-secondary); margin: 0 0 12px; }
.stack > * + * { margin-top: 16px; }

.tiles { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .tiles { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.tile .label { font-size: 12px; color: var(--text-secondary); }
.tile .value { font-size: 28px; font-weight: 600; margin-top: 4px; }
.tile.hero .value { font-size: 48px; line-height: 1.1; }
.tile .value.sm { font-size: 20px; }
.tile .delta { font-size: 12px; margin-top: 4px; color: var(--text-secondary); }
.delta .up { color: var(--good-text); font-weight: 600; }
.delta .down { color: var(--bad-text); font-weight: 600; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-secondary); margin: 4px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; width: 14px; border-radius: 1px; }
.legend i.dash { height: 0; width: 14px; border-top: 2px dashed currentColor; border-radius: 0; }

.chart { position: relative; width: 100%; }
.chart > svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-secondary); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .base { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .gap { stroke: var(--surface-1); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover, .chart .hit.on { fill: var(--hover); }
.chart .hitline { fill: transparent; cursor: crosshair; }
.chart .xhair { stroke: var(--axis); stroke-width: 1; }
.chart .today { stroke: var(--text-secondary); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .endlbl { fill: var(--text-primary); font-size: 12px; font-weight: 600; }

.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 160px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); padding: 8px 10px; font-size: 12px;
}
.tip .t { font-weight: 600; margin-bottom: 4px; color: var(--text-primary); }
.tip .r { display: flex; align-items: center; gap: 6px; justify-content: space-between; color: var(--text-secondary); }
.tip .r b { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; margin-left: 12px; }
.tip .r span { display: inline-flex; align-items: center; gap: 6px; }
.tip .tot { border-top: 1px solid var(--grid); margin-top: 4px; padding-top: 4px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 12px; }

.tablewrap { overflow: auto; max-height: 560px; border: 1px solid var(--grid); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--text-secondary); z-index: 1; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text-primary); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--hover); }
tbody tr.clickable { cursor: pointer; }
tbody tr.sel { background: var(--surface-2); }
tfoot td { font-weight: 600; background: var(--surface-2); position: sticky; bottom: 0; }

.toggle { appearance: none; border: 0; background: none; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; padding: 0; }
.note { font-size: 12px; color: var(--text-secondary); margin-top: 8px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.badge svg { flex: none; }

.msg { padding: 40px; text-align: center; color: var(--text-secondary); }
.msg.err { color: var(--bad-text); }
ul.warn { margin: 0; padding-left: 18px; }
ul.warn li { margin: 4px 0; }
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 1000px) { .split { grid-template-columns: minmax(0, 1fr); } }

.tiles.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .tiles.three { grid-template-columns: 1fr; } }
.tile .value.big { font-size: 40px; line-height: 1.15; }
.tile .value .unit { font-size: 14px; font-weight: 500; color: var(--text-secondary); }
.tile .rev { font-size: 18px; font-weight: 600; margin-top: 2px; }
.pill { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-secondary); }
input[type="date"] { font: inherit; font-size: 13px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); }
.filters + .filters { margin-top: -6px; }
.tile .est { font-size: 12px; color: var(--text-secondary); margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--grid); }
.est-cell { color: var(--text-secondary); font-style: italic; }
.est-cell small { font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: .03em; }
.estline { font-size: 11px; color: var(--text-secondary); font-style: italic; }
.demo-banner { background: var(--surface-2); border: 1px dashed var(--axis); border-radius: 8px; padding: 8px 12px; font-size: 12px; color: var(--text-secondary); margin-bottom: 14px; }
.tablewrap.free { max-height: none; overflow-x: auto; overflow-y: visible; }
.tablewrap.free tfoot td { position: static; }

.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sicon { flex: none; vertical-align: -2px; }
.alert { border: 1px solid var(--border); border-left: 4px solid var(--critical); background: var(--surface-1); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.alert-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.alert-head .toggle { margin-left: auto; }
.alert-list { font-size: 12px; margin-top: 4px; color: var(--text-primary); }
.statgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1000px) { .statgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) { .statgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { display: flex; flex-direction: column; gap: 2px; text-align: left; font: inherit; color: inherit; cursor: pointer; padding: 12px 14px; }
.stat .label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.stat .value { font-size: 26px; font-weight: 600; }
.stat:hover { background: var(--hover); }
.stat.on { outline: 2px solid var(--accent); outline-offset: -2px; }
.hbars { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 10px; }
.hbar { display: grid; grid-template-columns: 22px minmax(120px, 170px) minmax(0, 1fr) 72px 16px; align-items: center; gap: 8px; font-size: 13px; }
.hbar .rk { color: var(--text-secondary); text-align: right; font-variant-numeric: tabular-nums; }
.hbar .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .bar { display: block; width: 100%; }
.hbar .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
#tp-q { margin-bottom: 10px; }

button.hbar { appearance: none; border: 0; background: none; font: inherit; color: inherit; text-align: left; padding: 3px 4px; border-radius: 6px; cursor: pointer; width: 100%; }
button.hbar:hover { background: var(--hover); }
.hbars.wide .hbar { grid-template-columns: 22px minmax(150px, 210px) minmax(0, 1fr) 72px 16px; }
.gtiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.gtiles .label { display: inline-flex; align-items: center; gap: 6px; }
.clip { display: inline-block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
#sy-q { margin-bottom: 10px; }
.split + .card { margin-top: 12px; }

/* ---------- sign in ---------- */
.top-right { display: flex; gap: 12px; align-items: baseline; }
.signout { color: var(--accent); text-decoration: none; }
.signout:hover { text-decoration: underline; }
main.login { max-width: 340px; margin: 12vh auto 0; padding: 28px 26px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; }
main.login h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
main.login form { display: grid; gap: 6px; margin-top: 16px; }
main.login label { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
main.login input { font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); }
main.login button { margin-top: 14px; font: inherit; font-weight: 600; padding: 9px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; }
.login-error { border-left: 4px solid var(--critical); background: var(--surface-2); padding: 8px 10px; border-radius: 6px; font-size: 13px; margin: 12px 0 0; }

/* ---------- TV view (full screen, today by channel) ---------- */
.tv-open { appearance: none; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); border-radius: 6px; padding: 3px 10px; cursor: pointer; font: inherit; font-size: 12px; }
.tv-open:hover { background: var(--surface-2); }
body.tv-mode .wrap { display: none; }
.tv { height: 100vh; overflow: hidden; box-sizing: border-box; padding: 3vh 4vw; display: flex; flex-direction: column; gap: 2.4vh; background: var(--page); }
.tv[hidden] { display: none; }
.tv-head { display: flex; justify-content: space-between; align-items: flex-start; }
.tv-title { font-size: clamp(22px, 2.6vw, 52px); font-weight: 600; }
.tv-sub { font-size: clamp(13px, 1.2vw, 24px); color: var(--text-secondary); margin-top: 0.4vh; }
.tv-right { text-align: right; }
.tv-clock { font-size: clamp(22px, 2.6vw, 52px); font-weight: 600; font-variant-numeric: tabular-nums; }
.tv-exit { margin-top: 1vh; appearance: none; border: 1px solid var(--border); background: transparent; color: var(--text-secondary); border-radius: 6px; padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer; opacity: 0.5; }
.tv-exit:hover { opacity: 1; }
.tv-total { display: flex; align-items: baseline; gap: 4vw; border-bottom: 1px solid var(--border); padding-bottom: 2vh; }
.tv-big { font-size: clamp(48px, 7vw, 150px); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.tv-unit { font-size: clamp(16px, 1.6vw, 32px); color: var(--text-secondary); }
.tv-rev { font-size: clamp(28px, 3.6vw, 76px); font-weight: 600; font-variant-numeric: tabular-nums; }
.tv-rows { display: flex; flex-direction: column; gap: calc(1.3vh * var(--tv-scale, 1)); flex: 1; }
.tv-row { display: grid; grid-template-columns: minmax(140px, 18vw) 1fr minmax(80px, 9vw) minmax(110px, 12vw); align-items: center; gap: 2vw;
  font-size: calc(clamp(16px, 2vw, 42px) * var(--tv-scale, 1)); font-variant-numeric: tabular-nums; }
.tv-row.est { color: var(--text-secondary); font-size: calc(clamp(14px, 1.6vw, 32px) * var(--tv-scale, 1)); }
.tv-ch { display: flex; align-items: center; gap: 0.8vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-sw { width: 0.75em; height: 0.75em; flex: none; }
.tv-bar { width: 100%; height: calc(clamp(12px, 2.2vh, 30px) * var(--tv-scale, 1)); }
.tv-u { text-align: right; font-weight: 600; }
.tv-r { text-align: right; color: var(--text-secondary); }
.tv-sep { margin-top: 1.2vh; font-size: clamp(12px, 1.1vw, 22px); color: var(--text-secondary); border-top: 1px dashed var(--border); padding-top: 1.2vh; }
.tv-empty { font-size: clamp(18px, 2vw, 40px); color: var(--text-secondary); }
body.tv-mode { cursor: none; }
body.tv-mode .tv-exit { cursor: pointer; }

/* ---------- phones ---------- */
.card, .tile, .view { min-width: 0; }
@media (max-width: 640px) {
  .wrap { padding: 12px 12px 40px; }
  header.top { flex-wrap: wrap; gap: 6px; }
  header.top h1 { font-size: 18px; }
  nav.tabs { margin: 0 -12px 14px; padding: 0 12px; position: sticky; top: 0; z-index: 5; background: var(--page); }
  nav.tabs button { padding: 10px 10px; white-space: nowrap; }
  .filters { gap: 8px; }
  .filters > span { max-width: 100%; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg button { padding: 6px 10px; white-space: nowrap; }
  input[type="date"], select { font-size: 14px; }
  .card { padding: 12px; border-radius: 10px; }
  .stack, .tiles { gap: 10px; }
  .tiles { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tiles .tile.hero { grid-column: 1 / -1; }
  .tiles.three { grid-template-columns: minmax(0, 1fr); }
  .tile .value { font-size: 22px; }
  .tile.hero .value { font-size: 38px; }
  .tile .value.big { font-size: 32px; }
  h2 { font-size: 15px; }
  .sub, .note { font-size: 12px; }
  /* wide tables scroll sideways with the first column pinned */
  table { font-size: 12.5px; }
  th, td { padding: 7px 8px; }
  th:first-child, td:first-child { position: sticky; left: 0; background: var(--surface-1); z-index: 1; box-shadow: 1px 0 0 var(--grid); }
  th:first-child { background: var(--surface-2); z-index: 3; }
  tfoot td:first-child, .tablewrap.free tfoot td:first-child { background: var(--surface-2); position: sticky; left: 0; }
  .grid-2 { grid-template-columns: minmax(0, 1fr) !important; }
  .tablewrap { max-height: 70vh; }
  .hbar { grid-template-columns: 18px minmax(0, 1fr) minmax(40px, 0.8fr) 56px 16px; gap: 6px; font-size: 12px; }
  .hbars.wide .hbar { grid-template-columns: 18px minmax(0, 1.2fr) minmax(40px, 0.8fr) 56px 16px; }
  .alert { font-size: 12px; }
  /* TV view on a phone: name + numbers on one line, bar underneath */
  .tv { padding: 16px; gap: 14px; height: auto; min-height: 100vh; overflow: visible; }
  .tv-head { gap: 12px; }
  .tv-title { font-size: 20px; }
  .tv-clock { font-size: 20px; }
  .tv-sub { font-size: 12px; }
  .tv-total { gap: 16px; flex-wrap: wrap; padding-bottom: 12px; }
  .tv-big { font-size: 56px; }
  .tv-rev { font-size: 28px; }
  .tv-rows { gap: 12px; }
  .tv-row, .tv-row.est { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "ch u r" "bar bar bar"; gap: 4px 14px; font-size: 17px; }
  .tv-row.est { font-size: 15px; }
  .tv-ch { grid-area: ch; } .tv-u { grid-area: u; } .tv-r { grid-area: r; min-width: 76px; }
  .tv-bar { grid-area: bar; height: 8px; }
  .tv-sep { font-size: 12px; }
}

.dl-btn { appearance: none; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); border-radius: 8px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.dl-btn:hover { background: var(--surface-2); }

.dl-btn:disabled { opacity: 0.6; cursor: progress; }
.err-text { color: var(--critical); }
.dl-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }
