/* ==========================================================================
   Vasuki India - Planet and market explorer
   Tokens, base, components, pages, responsive, print. No inline styles are used anywhere (strict CSP).
   ========================================================================== */
:root {
  --paper: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --ink: #111b32;
  --ink-soft: #4b5870;
  --rule: #d3dae5;
  --rule-soft: #e5eaf1;
  --navy: #111b32;
  --navy-hover: #1d2b4d;
  --amber: #c27a12;
  --amber-pale: #f6e7cb;
  --pos: #0b7a62;
  --pos-pale: #e0f2ec;
  --neg: #b3303f;
  --neg-pale: #f8e4e7;
  --focus: #1b4fd8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(17, 27, 50, 0.05), 0 4px 14px rgba(17, 27, 50, 0.05);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.print-only { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; color: var(--ink); }
h1 { font-size: 1.75rem; margin-bottom: 0.5rem; }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.1rem); letter-spacing: -0.005em; }
h3 { font-size: 1.25rem; margin-bottom: 0.6rem; }
h4 { font-size: 1.05rem; margin-bottom: 0.4rem; }
p { margin: 0 0 0.8rem; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); }
.block-text { display: block; }
.lede { font-size: 1.05rem; margin: 0.5rem 0 1rem; max-width: 64ch; color: var(--ink-soft); }
.label { font-weight: 600; margin: 0 0 0.3rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

/* ---------- header and navigation ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 0.5rem 1.5rem; flex-wrap: wrap;
  padding: 0.7rem clamp(1rem, 4vw, 2.5rem);
  padding-top: calc(0.7rem + env(safe-area-inset-top, 0px));
  background: var(--surface); border-bottom: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(17, 27, 50, 0.03);
}
.bar-name { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; order: 1; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font: 700 1.15rem var(--serif); letter-spacing: 0.01em; }
.brand-mark { width: 0.8rem; height: 0.8rem; background: var(--amber); transform: rotate(45deg); border-radius: 2px; }
.bar-title { color: var(--ink-soft); font-size: 0.92rem; }
.nav { display: flex; gap: 0.25rem; order: 2; margin-left: auto; }
.session { display: flex; align-items: center; gap: 0.9rem; font-size: 0.9rem; order: 3; min-width: 0; }
.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }
.nav-btn {
  background: none; border: 0; border-radius: 8px; padding: 0.5rem 0.9rem; color: var(--ink-soft);
  font-weight: 600; font-size: 0.95rem; white-space: nowrap;
}
.nav-btn:hover { background: var(--surface-2); color: var(--ink); }
.nav-btn.on { background: var(--navy); color: #fff; }

main {
  max-width: 1080px; margin: 0 auto;
  padding: clamp(1.1rem, 3.5vw, 2.5rem) clamp(0.9rem, 4vw, 2.5rem) calc(4rem + env(safe-area-inset-bottom, 0px));
}

/* ---------- buttons ---------- */
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
button[type="submit"], .primary {
  background: var(--navy); color: #fff; border: 1px solid var(--navy); border-radius: 8px;
  padding: 0.65rem 1.25rem; font-weight: 600; min-height: 44px;
}
button[type="submit"]:hover:not(:disabled), .primary:hover:not(:disabled) { background: var(--navy-hover); }
button[type="submit"]:disabled { opacity: 0.55; cursor: progress; }
.secondary {
  background: var(--surface); color: var(--ink); border: 1px solid var(--ink); border-radius: 8px;
  padding: 0.6rem 1.15rem; font-weight: 600; min-height: 44px;
}
.secondary:hover:not(:disabled) { background: var(--surface-2); }
.secondary:disabled, .primary:disabled { opacity: 0.55; }
.ghost {
  background: transparent; color: var(--ink); border: 1px solid var(--rule); border-radius: 8px;
  padding: 0.45rem 0.85rem; font-weight: 600; font-size: 0.9rem; min-height: 38px;
}
.ghost:hover:not(:disabled) { border-color: var(--ink); background: var(--surface-2); }
.ghost:disabled { opacity: 0.45; }
.ghost.danger { color: var(--neg); }
.ghost.danger:hover:not(:disabled) { border-color: var(--neg); background: var(--neg-pale); }
.link { background: none; border: 0; padding: 0.25rem 0; color: var(--focus); text-decoration: underline; font-size: 0.9rem; }
.chip {
  background: var(--surface); color: var(--ink-soft); border: 1px solid var(--rule); border-radius: 999px;
  padding: 0.4rem 0.9rem; font-size: 0.9rem; text-align: left;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }

/* ---------- forms ---------- */
textarea, select, input[type="text"], input[type="email"], input[type="password"], input[type="search"] {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 8px; padding: 0.7rem 0.85rem; min-height: 44px;
}
textarea:focus, select:focus, input:focus { border-color: var(--focus); }
textarea { resize: vertical; min-height: 5rem; }
input[readonly] { background: var(--surface-2); }
#sql { font: 0.85rem/1.5 var(--mono); margin: 0.5rem 0 0.75rem; }
select { width: auto; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(1rem, 3vw, 1.6rem); }
.field { margin: 0 0 1rem; }
.field label, .login label { display: block; margin: 0 0 0.3rem; font-weight: 600; font-size: 0.95rem; }
.check, .radio { display: flex; gap: 0.6rem; align-items: flex-start; margin: 0.5rem 0; cursor: pointer; }
.check input, .radio input { margin-top: 0.3rem; width: 1.1rem; height: 1.1rem; flex: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.2rem; }
.form-status { min-height: 1.4rem; margin: 0.8rem 0 0; color: var(--ink-soft); }
.form-status.error { color: var(--neg); font-weight: 600; }
.form-status.working::after, .status.working::after, .upload-status.working::after {
  content: ""; display: inline-block; width: 0.9em; height: 0.9em; margin-left: 0.6em; vertical-align: -0.1em;
  border: 2px solid var(--rule); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error { color: var(--neg); min-height: 1.4rem; margin: 0.8rem 0 0; }
.notice { border-radius: 8px; padding: 0.85rem 1rem; margin: 0 0 1rem; border: 1px solid; }
.notice p { margin: 0.4rem 0 0; }
.notice.ok { background: var(--pos-pale); border-color: #a9d8c9; }
.notice.bad { background: var(--neg-pale); border-color: #e8b7bf; color: #7a1d29; }
.copy-row { display: flex; gap: 0.6rem; margin-top: 0.6rem; }
.copy-row input { flex: 1; min-width: 0; }

.status { min-height: 1.5rem; margin-bottom: 1rem; color: var(--ink-soft); }
.status.error { color: var(--neg); font-weight: 600; }
.status.info { color: var(--ink); background: var(--amber-pale); padding: 0.7rem 0.9rem; border-radius: 8px; }

/* ---------- sign in ---------- */
.login { max-width: 26rem; margin: clamp(1rem, 8vh, 4rem) auto 0; }
.login label { margin-top: 1rem; }
.login button[type="submit"] { margin-top: 1.4rem; width: 100%; }

/* ---------- explore: ask ---------- */
.ask { margin-bottom: 1.25rem; }
.ask-title { display: block; font: 600 clamp(1.4rem, 3.6vw, 2.1rem)/1.2 var(--serif); margin-bottom: 0.8rem; }
.ask-actions { display: flex; align-items: center; gap: 0.5rem 1rem; margin-top: 0.8rem; flex-wrap: wrap; }
.chat { margin: 0 0 1.5rem; padding: 0.9rem 1.1rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.chat summary { cursor: pointer; font-weight: 600; }
.chat-log { max-height: 22rem; overflow-y: auto; margin: 0.75rem 0; display: flex; flex-direction: column; gap: 0.6rem; }
.chat-msg p { margin: 0 0 0.4rem; }
.chat-msg.user { align-self: flex-end; max-width: 85%; background: var(--navy); color: #fff; padding: 0.5rem 0.9rem; border-radius: 14px 14px 2px 14px; }
.chat-msg.user p { margin: 0; }
.chat-suggestions { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 0.45rem; }
.chat-form { display: flex; gap: 0.5rem; }
.chat-form input { flex: 1; min-width: 0; }
.chat-form button { flex: none; }

/* ---------- results sheet ---------- */
#results:not(:empty) {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; box-shadow: var(--shadow);
  padding: clamp(1rem, 3.5vw, 2.25rem); overflow: hidden;
}
.brief-head { border-top: 4px solid var(--navy); padding-top: 1rem; margin-top: -0.25rem; }
.kicker { margin: 0 0 0.3rem; color: var(--amber); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.brief-meta { margin: 0.5rem 0; color: var(--ink-soft); max-width: 80ch; font-size: 0.95rem; }
.head-actions { margin-top: 0.9rem; }
.bottom-line { margin: 1.5rem 0 1rem; padding: 1rem 0 0.2rem; border-top: 1px solid var(--rule-soft); }
.bottom-line h3 { font: 700 0.8rem var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 0.5rem; }
.headline { font: 600 clamp(1.3rem, 2.6vw, 1.8rem)/1.3 var(--serif); margin: 0; max-width: 48ch; }
.lede-inline, .caution { margin: 0.6rem 0; padding: 0.15rem 0 0.15rem 0.8rem; border-left: 3px solid var(--amber); max-width: 70ch; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.75rem; margin: 1.2rem 0; }
.kpi { padding: 0.85rem 1rem; background: var(--surface-2); border: 1px solid var(--rule-soft); border-radius: 8px; }
.kpi-value { font: 600 clamp(1.5rem, 3vw, 2rem)/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.kpi-label { margin-top: 0.35rem; font-weight: 600; font-size: 0.88rem; line-height: 1.3; }
.kpi-sub { color: var(--ink-soft); font-size: 0.8rem; margin-top: 0.15rem; }
.kpi-value.pos, .pos { color: var(--pos); }
.kpi-value.neg, .neg { color: var(--neg); }

.two-col { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 2rem; margin: 1.6rem 0; align-items: start; }
.two-col.even { grid-template-columns: 1fr 1fr; gap: 1.5rem; margin: 0.4rem 0; }
.findings ul { margin: 0; padding-left: 1.1rem; }
.findings li { margin-bottom: 0.65rem; max-width: 62ch; }
.evidence { border-left: 3px solid var(--amber); padding: 0.2rem 0 0.2rem 1rem; background: linear-gradient(90deg, rgba(246, 231, 203, 0.35), transparent 70%); }
.evidence h3 { font-size: 1.05rem; }
.meter { display: flex; gap: 4px; margin: 0.5rem 0 0.3rem; max-width: 180px; }
.seg { flex: 1; height: 8px; background: var(--rule); border-radius: 2px; }
.seg.on { background: var(--amber); }
.ev-label { margin: 0.2rem 0; }
.caution-text { margin: 0.7rem 0 0; }

.panel { margin: 2rem 0; padding-top: 1.1rem; border-top: 1px solid var(--rule-soft); }
.panel > h3 { margin-bottom: 0.6rem; }
.panel summary, details summary { cursor: pointer; font-weight: 600; }
.panel > .muted { margin: 0.2rem 0 0.6rem; }
.when { margin: 1rem 0; }
.when figcaption { font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.4rem; }
.block { margin: 2rem 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.summary { max-width: 68ch; font-size: 1.04rem; }
.method { margin: 2.5rem 0 0; padding-top: 1rem; border-top: 1px solid var(--rule); color: var(--ink-soft); font-size: 0.85rem; max-width: 90ch; }

/* charts */
.ribbon-wrap, .bars-wrap { width: 100%; }
.ribbon, .bars { display: block; width: 100%; }
.ribbon { height: 40px; }
.bars { height: 150px; }
.ribbon-track { fill: var(--surface-2); stroke: var(--rule); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ribbon-ep { fill: var(--amber); }
.bars-zero { stroke: var(--ink-soft); stroke-width: 1; vector-effect: non-scaling-stroke; }
.bar-pos { background: var(--pos); fill: var(--pos); }
.bar-neg { background: var(--neg); fill: var(--neg); }
.axis { position: relative; height: 1.4rem; margin-top: 0.25rem; font-size: 0.75rem; color: var(--ink-soft); }
.tick { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.tick::before { content: ""; position: absolute; left: 50%; top: -0.25rem; height: 0.2rem; border-left: 1px solid var(--ink-soft); }
.tick.at-start { transform: none; }
.tick.at-end { transform: translateX(-100%); }
.tick.at-start::before { left: 0; }
.tick.at-end::before { left: 100%; }
.bars-axis { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.75rem; color: var(--ink-soft); margin-top: 0.25rem; }

.dbars { list-style: none; margin: 0.4rem 0 0.2rem; padding: 0; }
.dbar {
  display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr 5rem; align-items: center; gap: 0 0.9rem;
  padding: 0.28rem 0; border-bottom: 1px solid var(--rule-soft);
}
.dbar:last-child { border-bottom: 0; }
.dbar-label { font-size: 0.9rem; overflow-wrap: anywhere; line-height: 1.25; }
.dbar-track { position: relative; height: 0.85rem; background: var(--surface-2); border-radius: 2px; }
.dbar-zero { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--ink-soft); }
.dbar-fill { position: absolute; top: 2px; bottom: 2px; border-radius: 2px; }
.dbar-value { text-align: right; font-size: 0.88rem; font-variant-numeric: tabular-nums; font-weight: 600; }
.two-col.even .dbar { grid-template-columns: 1fr auto; grid-template-areas: "label value" "track track"; gap: 0.15rem 0.6rem; padding: 0.4rem 0; }
.two-col.even .dbar-label { grid-area: label; }
.two-col.even .dbar-value { grid-area: value; }
.two-col.even .dbar-track { grid-area: track; }

/* tabs inside results */
.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-bottom: 1rem; }
.tabs-label { margin-right: 0.4rem; color: var(--ink-soft); font-size: 0.92rem; }
.tab { background: var(--surface); border: 1px solid var(--rule); border-radius: 999px; padding: 0.35rem 0.9rem; color: var(--ink); font-size: 0.9rem; min-height: 36px; }
.tab:hover { border-color: var(--ink); }
.tab.on { background: var(--navy); border-color: var(--navy); color: #fff; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--rule-soft); border-radius: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.data caption { text-align: left; padding: 0.5rem 0.7rem; color: var(--ink-soft); }
.data th, .data td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--rule-soft); white-space: nowrap; }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr:hover { background: var(--surface-2); }
.data thead th { background: var(--surface-2); border-bottom: 2px solid var(--ink); font-weight: 600; text-align: left; vertical-align: bottom; padding: 0; font-size: 0.85rem; }
.data thead th:not(:has(button)) { padding: 0.5rem 0.75rem; }
.data th.num, .data td.num { text-align: right; }
.data td.name { font-weight: 600; }
.sort { background: none; border: 0; font-weight: 600; font-size: inherit; color: inherit; padding: 0.55rem 0.75rem; width: 100%; text-align: inherit; white-space: normal; min-height: 44px; }
.sort:hover { background: var(--rule-soft); }

/* compare */
.compare-hz { display: inline-flex; gap: 0.5rem; align-items: center; margin: 0.5rem 0 1rem; }
.compare-hz select { font: inherit; padding: 0.4rem 0.6rem; min-height: 40px; }
.compare-controls { display: flex; flex-wrap: wrap; gap: 0 1.5rem; }
.legend { margin: 0 0 1.25rem; padding: 0.75rem 1rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface-2); }
.legend dl { margin: 0.75rem 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1rem; }
.legend dt { font-weight: 600; }
.legend dd { margin: 0; }
.legend-note { margin: 0.75rem 0 0; font-size: 0.9rem; opacity: 0.8; }

/* ---------- data page ---------- */
.data-page { max-width: 780px; }
.upload-panel { margin: 1.5rem 0; padding: clamp(1rem, 3vw, 1.5rem); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); }
.file-label { display: block; margin: 1rem 0 0.3rem; font-weight: 600; }
input[type="file"] { display: block; width: 100%; padding: 0.7rem; background: var(--surface-2); border: 1px dashed var(--ink-soft); border-radius: 8px; font: inherit; }
.modes { margin: 0.9rem 0 0.2rem; }
progress { width: 12rem; max-width: 100%; height: 0.6rem; }
.upload-status { min-height: 1.5rem; margin-top: 0.8rem; color: var(--ink-soft); }
.upload-status.error { color: var(--neg); font-weight: 600; }
.upload-status.ok { color: var(--pos); font-weight: 600; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1.2rem; margin: 1rem 0; }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.layouts { margin: 1rem 0; }

/* ---------- users page ---------- */
.users-page { max-width: 860px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
.page-head .primary { flex: none; margin-top: 0.2rem; }
.panel-slot { margin-bottom: 1rem; }
.form h3 { margin-bottom: 0.3rem; }
.users-page input[type="search"] { margin: 0.5rem 0 0.4rem; }
.user-list { list-style: none; margin: 0.8rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.user-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.5rem 1rem; align-items: center;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.9rem 1rem;
}
.user-row.is-off { background: var(--surface-2); }
.user-row.is-off .user-name { color: var(--ink-soft); }
.avatar { width: 2.6rem; height: 2.6rem; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 0.95rem; letter-spacing: 0.02em; }
.user-main { min-width: 0; }
.user-name { font-weight: 600; overflow-wrap: anywhere; }
.user-email { overflow-wrap: anywhere; }
.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.25rem 0; }
.badges:empty { display: none; }
.badge { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em; padding: 0.15rem 0.55rem; border-radius: 999px; background: var(--rule-soft); color: var(--ink-soft); }
.badge.admin { background: var(--navy); color: #fff; }
.badge.off { background: var(--neg-pale); color: var(--neg); }
.badge.wait { background: var(--amber-pale); color: #7a4d06; }
.badge.you { background: var(--pos-pale); color: var(--pos); }
.user-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- reports portal ---------- */
.related, .reports-page { margin-top: 2rem; }
.reports-page { margin-top: 0; }
.related { padding: clamp(1rem, 3vw, 1.5rem); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); }
.related .chip, .report-link .chip { display: inline-block; padding: 0.05rem 0.55rem; margin: 0 0.3rem 0.2rem 0; font-size: 0.78rem; cursor: default; }
.report-list { display: flex; flex-direction: column; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); margin: 0.6rem 0 0.8rem; overflow: hidden; }
.report-link {
  display: grid; grid-template-columns: 1fr auto; column-gap: 1rem; align-items: baseline; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--rule-soft); padding: 0.75rem 0.95rem; color: var(--ink); width: 100%; min-height: 44px;
}
.report-link:last-child { border-bottom: 0; }
.report-link:hover, .report-link:focus-visible { background: var(--amber-pale); }
.report-link.busy { opacity: 0.6; cursor: progress; }
.report-name { font-weight: 600; overflow-wrap: anywhere; }
.report-path, .report-why { grid-column: 1; }
.report-go { grid-column: 2; grid-row: 1; color: var(--focus); font-size: 0.85rem; white-space: nowrap; }
.related .more { margin: 0 1rem 0.5rem 0; }
.report-cat { border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); margin: 0.6rem 0; }
.report-cat > summary { cursor: pointer; padding: 0.8rem 0.95rem; font-weight: 600; }
.report-cat-body { padding: 0 0.95rem 0.6rem; }
.report-folder { margin: 0.8rem 0 0; font-size: 0.95rem; }

/* ---------- phones and small tablets ---------- */
@media screen and (max-width: 760px) {
  body { font-size: 16px; }
  .bar { gap: 0.4rem 1rem; padding-bottom: 0; }
  .bar-title { display: none; }
  .session { order: 2; margin-left: auto; }
  .who { max-width: 9.5rem; }
  .nav {
    order: 3; width: 100%; margin: 0 calc(-1 * clamp(1rem, 4vw, 2.5rem)); padding: 0 clamp(1rem, 4vw, 2.5rem);
    overflow-x: auto; scrollbar-width: none; gap: 0;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-btn { border-radius: 0; border-bottom: 3px solid transparent; padding: 0.7rem 1rem; flex: none; }
  .nav-btn:hover { background: none; }
  .nav-btn.on { background: none; color: var(--ink); border-bottom-color: var(--amber); }

  .two-col { grid-template-columns: 1fr; gap: 1.2rem; }
  .two-col.even { gap: 0.5rem; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .kpi { padding: 0.7rem 0.8rem; }
  .kpi:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
  .ask-actions > button { width: 100%; }
  .ask-actions { flex-direction: column; align-items: stretch; }
  .head-actions button { width: 100%; }
  .page-head { flex-direction: column; }
  .page-head .primary { width: 100%; }

  .dbar { grid-template-columns: 1fr auto; grid-template-areas: "label value" "track track"; gap: 0.15rem 0.6rem; padding: 0.45rem 0; }
  .dbar-label { grid-area: label; }
  .dbar-value { grid-area: value; }
  .dbar-track { grid-area: track; }
  .tick.minor { display: none; }
  .bars { height: 120px; }

  .data { font-size: 0.85rem; }
  .data th, .data td { padding: 0.45rem 0.55rem; }
  .data tbody td.name, .data thead th:first-child { position: sticky; left: 0; background: var(--surface); box-shadow: 1px 0 0 var(--rule-soft); }
  .data thead th:first-child { background: var(--surface-2); }

  .legend dl { grid-template-columns: 1fr; }
  .legend dd { margin-bottom: 0.4rem; }
  .compare-hz { display: flex; flex-wrap: wrap; width: 100%; }
  .compare-hz select { flex: 1; max-width: 100%; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: 0.5rem; }

  .user-row { grid-template-columns: auto 1fr; }
  .user-actions { grid-column: 1 / -1; justify-content: stretch; }
  .user-actions .ghost { flex: 1 1 auto; }
  .form-actions > button { flex: 1 1 100%; }
  .copy-row { flex-direction: column; }
  .report-link { grid-template-columns: 1fr; }
  .report-go { grid-column: 1; grid-row: auto; }
  .chat-form { flex-direction: column; }
  .chat-msg.user { max-width: 95%; }
}
@media (prefers-reduced-motion: reduce) {
  .status.working::after, .form-status.working::after, .upload-status.working::after { animation: none; }
}

/* ==========================================================================
   Print: a clean A4 executive summary. Page breaks are left to flow naturally; only small blocks are kept
   whole, so pages fill properly. Charts are HTML/SVG and keep their proportions on paper.
   ========================================================================== */
@media print {
  @page {
    size: A4; margin: 13mm 13mm 17mm;
    @bottom-left { content: "Vasuki India  |  Planet and market explorer"; font: 7.5pt system-ui, Arial, sans-serif; color: #5b667c; }
    @bottom-right { content: "Page " counter(page) " of " counter(pages); font: 7.5pt system-ui, Arial, sans-serif; color: #5b667c; }
  }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html { scroll-padding-top: 0; }
  body { background: #fff; font-size: 9.5pt; line-height: 1.42; }
  .bar, .ask, .status, .tabs, .nav, .no-print, .chat, .related, .reports-page, .data-page, .users-page, .login { display: none !important; }
  .print-only { display: block; }
  main { max-width: none; padding: 0; }
  #results:not(:empty) { border: 0; box-shadow: none; border-radius: 0; padding: 0; overflow: visible; background: none; }

  h2 { font-size: 21pt; }
  h3 { font-size: 12pt; margin-bottom: 0.25rem; break-after: avoid; }
  h4 { font-size: 10pt; margin: 0.5rem 0 0.2rem; break-after: avoid; }

  .print-brand { display: flex !important; justify-content: space-between; align-items: baseline; font-size: 8.5pt; color: #5b667c; border-bottom: 1px solid var(--rule); padding-bottom: 0.25rem; margin-bottom: 0.5rem; }
  .print-brand .brand { font-size: 11pt; color: var(--ink); }
  .brief-head { border-top: 0; margin-top: 0; padding-top: 0; break-inside: avoid; }
  .kicker { font-size: 7.5pt; }
  .brief-meta { margin: 0.25rem 0; font-size: 8.5pt; max-width: none; }
  .bottom-line { margin: 0.6rem 0 0.3rem; padding-top: 0.45rem; break-inside: avoid; }
  .headline { font-size: 14.5pt; max-width: none; }

  .kpis { display: grid; grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; margin: 0.55rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); break-inside: avoid; }
  .kpi { background: none; border: 0; border-radius: 0; padding: 0.45rem 0.6rem 0.45rem 0; }
  .kpi + .kpi { padding-left: 0.6rem; border-left: 1px solid var(--rule); }
  .kpi-value { font-size: 17pt; }
  .kpi-label { font-size: 8pt; }
  .kpi-sub { font-size: 7pt; }

  .two-col { gap: 1.4rem; margin: 0.7rem 0; break-inside: avoid; }
  .two-col.even { margin: 0.2rem 0; break-inside: auto; }
  .findings li { margin-bottom: 0.25rem; }
  .evidence { background: none; }
  .evidence h3 { font-size: 10.5pt; }
  .panel { margin: 0.8rem 0 0; padding-top: 0.5rem; }
  .when { margin: 0.4rem 0; break-inside: avoid; }
  .when figcaption { font-size: 8pt; }
  .ribbon { height: 11mm; }
  .bars { height: 30mm; }
  .axis, .bars-axis { font-size: 7pt; }
  .lede { font-size: 9.5pt; margin: 0.2rem 0 0.4rem; max-width: none; color: var(--ink); }

  .dbars { margin: 0.2rem 0; }
  .dbar { grid-template-columns: 40mm 1fr 16mm; padding: 0.1rem 0; break-inside: avoid; }
  .dbar-label { font-size: 8pt; }
  .dbar-value { font-size: 8pt; }
  .dbar-track { height: 0.6rem; }
  .two-col.even .dbar { grid-template-columns: 1fr auto; padding: 0.15rem 0; }
  .muted.small { font-size: 7.5pt; }

  .print-tables { break-inside: auto; }
  table.data { font-size: 7.5pt; }
  .data th, .data td { padding: 0.18rem 0.35rem; white-space: normal; }
  .data thead { display: table-header-group; }
  .data tr { break-inside: avoid; }
  .data thead th { background: #eef1f6; }
  .data tbody tr:hover { background: none; }
  .method { margin-top: 0.8rem; padding-top: 0.4rem; font-size: 7.5pt; max-width: none; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
