/* Shared chrome for kishansonar.in market tools (copied into each site's static/ by sync_common.sh) */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --s1: #2a78d6;   /* blue    */
  --s2: #eb6834;   /* orange  */
  --s3: #1baf7a;   /* aqua    */
  --s7: #4a3aa7;   /* violet  */
  --neutral: #898781;
  --band: rgba(137, 135, 129, 0.16);
  --up: #006300;
  --down: #c62828;
  --div-pos: #2a78d6;
  --div-neg: #e34948;
  --live: #0ca30c;
  --warn: #b77900;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .04);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, 0.10);
    --accent: #3987e5; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s7: #9085e9;
    --band: rgba(195, 194, 183, 0.14);
    --up: #0ca30c; --down: #e66767; --div-pos: #3987e5; --div-neg: #e66767;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, 0.10);
  --accent: #3987e5; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s7: #9085e9;
  --band: rgba(195, 194, 183, 0.14);
  --up: #0ca30c; --down: #e66767; --div-pos: #3987e5; --div-neg: #e66767;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* top bar */
.top { border-bottom: 1px solid var(--ring); background: var(--surface); }
.top .wrap { display: flex; align-items: center; gap: 16px; height: 56px; }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand .name { font-weight: 650; font-size: 17px; color: var(--ink); white-space: nowrap; }
.brand .by { font-size: 13px; color: var(--muted); white-space: nowrap; }
.brand .by a { color: var(--ink-2); }
.top nav { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.top nav a.tool { font-size: 14px; color: var(--ink-2); padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.top nav a.tool:hover { background: var(--surface-2); text-decoration: none; }
.top nav a.tool.on { color: var(--ink); font-weight: 600; background: var(--surface-2); }
.iconbtn {
  border: 1px solid var(--ring); background: transparent; color: var(--ink-2);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 15px;
}
.iconbtn:hover { background: var(--surface-2); }

/* page head */
.head { padding: 22px 0 6px; }
.head h1 { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
.head p { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; max-width: 760px; }

/* filters: one row above everything they scope */
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 14px 0; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: 13.5px;
  padding: 5px 11px; border-radius: 7px; cursor: pointer; white-space: nowrap; min-height: 30px;
}
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--ring); }
.seg button:disabled { opacity: .4; cursor: default; }
.field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
select {
  font: inherit; font-size: 13.5px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--ring); border-radius: 8px; padding: 5px 28px 5px 10px; min-height: 34px;
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
.spacer { flex: 1; }

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; min-width: 0;
}
.card h2 { margin: 0; font-size: 15px; font-weight: 620; }
.card .sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head .grow { flex: 1; min-width: 200px; }

/* legend: mirrors marks (line keys) */
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--ink-2); }
.legend button {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: inherit;
  font: inherit; padding: 2px 0; cursor: pointer;
}
.legend button.off { opacity: .4; }
.key { display: inline-block; width: 16px; height: 2px; border-radius: 1px; background: var(--c); }
.key.band { height: 10px; background: var(--band); border-radius: 2px; }
.key.dash { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); }

/* status chip */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2);
  border: 1px solid var(--ring); border-radius: 999px; padding: 3px 10px; background: var(--surface); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.live .dot { background: var(--live); box-shadow: 0 0 0 0 rgba(12, 163, 12, .5); animation: pulse 1.8s infinite; }
.chip.warn .dot { background: var(--warn); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(12, 163, 12, .45); } 70% { box-shadow: 0 0 0 7px rgba(12, 163, 12, 0); } 100% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0); } }
@media (prefers-reduced-motion: reduce) { .chip.live .dot { animation: none; } }

/* stat grid */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 18px; }
@media (max-width: 900px) and (min-width: 641px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat .l { font-size: 12.5px; color: var(--muted); }
.stat .v { font-size: 18px; font-weight: 600; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .d { font-size: 12.5px; color: var(--ink-2); margin-top: 1px; white-space: nowrap; }
.pos { color: var(--up); } .neg { color: var(--down); }

/* tables */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -18px; padding: 0 18px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { text-align: right; font-weight: 550; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td { text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.more { margin-top: 10px; border: 1px solid var(--ring); background: transparent; color: var(--ink-2); font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 8px; cursor: pointer; }

/* tooltip */
.tip {
  position: absolute; pointer-events: none; z-index: 20; background: var(--surface); color: var(--ink);
  border: 1px solid var(--ring); border-radius: 10px; padding: 8px 10px; font-size: 12.5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .12); min-width: 150px; display: none;
}
.tip .t { color: var(--muted); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip .r .n { color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.tip .r b { font-weight: 600; font-variant-numeric: tabular-nums; }

.note { font-size: 13px; color: var(--ink-2); background: var(--surface-2); border-radius: 10px; padding: 9px 12px; margin: 0 0 14px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

footer { color: var(--muted); font-size: 12.5px; padding: 18px 0 36px; border-top: 1px solid var(--ring); margin-top: 8px; }
footer p { margin: 4px 0; max-width: 900px; }

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .brand .by { display: none; }
  .top nav a.tool { padding: 6px 7px; font-size: 13px; }
  .head h1 { font-size: 20px; }
  .card { padding: 14px; }
  .tbl-wrap { margin: 0 -14px; padding: 0 14px; }
  select, .seg button { font-size: 16px; }   /* no iOS focus zoom */
  .seg button { padding: 5px 9px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .filters { gap: 8px; }
  .field { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .field select { flex: 1; min-width: 0; width: 100%; }
  .hide-sm { display: none; }
  .dlabel-sm { display: none; }
}
