/*
 * INSOVANT workspace and sign-in screens, in the brand's evergreen system (same palette, type and
 * shapes as the landing page, site.css). Loaded last, so it retunes the workspace's existing theme
 * tokens instead of adding a parallel system:
 *   Settings > Light       -> forest light (white cards on a cool off-white canvas)
 *   Settings > Soft Green  -> forest light on a green-tinted canvas
 *   Settings > Dark Green  -> forest dark (same values as the landing page's dark theme)
 * Shape rule: buttons, chips and tags are pills; cards and panels 16px; rows and inputs 10-12px.
 */

/* ---------- Tokens ---------- */
.app {
  --green: #1c5232; --deep: #0f2a1b; --lime: #2f7a4d; --pale: #e6efe8; --ink: #102a1c; --muted: #5f7166;
  --line: #dde5df; --wash: #f4f6f4; --white: #ffffff;
  --ws-bg: #f4f6f4; --ws-sidebar: #fbfcfb; --ws-card: #ffffff; --ws-text: #102a1c; --ws-muted: #5f7166;
  --ws-border: #dde5df; --ws-accent: #1c5232; --ws-hover: #eef4ef; --ws-soft: #e6efe8; --ws-input: #ffffff;
  --ws-on-accent: #f4f8f5; --ws-strong-border: #c4d1c8; --ws-raised: #ffffff;
  --ws-shadow: 0 1px 2px rgba(16, 42, 28, 0.04), 0 12px 32px -14px rgba(16, 42, 28, 0.16);
  --wt-body: #3f5247;
  --wt-good-bg: #e2f0e6; --wt-good-fg: #1c5232;
  --wt-att-bg: #f8e4e0; --wt-att-fg: #9d3423;
  --wt-watch-bg: #f7eed8; --wt-watch-fg: #7c5310;
  color-scheme: light;
}
body[data-theme="soft-green"] .app { --ws-bg: #e8f0ea; --wash: #e8f0ea; --ws-sidebar: #f3f8f4; --ws-hover: #dfeae2; --wt-body: #2f4639; }
body[data-theme="dark-green"] .app {
  /* Same "evergreen at night" values as the landing page's dark theme. */
  --green: #58d68d; --deep: #a6ecc4; --lime: #58d68d; --pale: #15241b; --ink: #f1eee4; --muted: #869a8c;
  --line: #1b2b21; --wash: #070d09; --white: #101a14;
  --ws-bg: #070d09; --ws-sidebar: #0b130e; --ws-card: #101a14; --ws-text: #f1eee4; --ws-muted: #869a8c;
  --ws-border: #1b2b21; --ws-accent: #58d68d; --ws-hover: #15241b; --ws-soft: #15241b; --ws-input: #0b130e;
  --ws-on-accent: #04130a; --ws-strong-border: #2a4434; --ws-raised: #101a14;
  --ws-shadow: inset 0 1px 0 rgba(241, 238, 228, 0.05), 0 1px 2px rgba(0, 0, 0, 0.4), 0 20px 44px -22px rgba(0, 0, 0, 0.85);
  --wt-body: #b4c4b8;
  --wt-good-bg: rgba(88, 214, 141, 0.14); --wt-good-fg: #8fe3b2;
  --wt-att-bg: rgba(240, 128, 110, 0.15); --wt-att-fg: #f2a79a;
  --wt-watch-bg: rgba(230, 190, 100, 0.14); --wt-watch-fg: #e7c77c;
  color-scheme: dark;
}

/* ---------- Frame ---------- */
body .app { font-family: 'Manrope', system-ui, sans-serif; background: var(--ws-bg); color: var(--ws-text); -webkit-font-smoothing: antialiased; }
body .app h1, body .app h2, body .app h3, body .app h4 { font-family: 'Manrope', system-ui, sans-serif; color: var(--ws-text); }
body .app .content { background: var(--ws-bg); padding: 32px; }
body .app .maincol { background: var(--ws-bg); }

/* Sidebar */
body .app .sidebar { background: var(--ws-sidebar); border-right: 1px solid var(--ws-border); box-shadow: none; }
body .app .side-brand { padding: 20px 16px; border-bottom: 1px solid var(--ws-border); }
body .app .side-brand .brand { color: var(--ws-text); font-family: 'Manrope', system-ui, sans-serif; font-weight: 600; letter-spacing: 0.26em; font-size: 16px; }
body .app .side-brand .brand small { color: var(--ws-muted); font-family: 'Manrope', system-ui, sans-serif; font-weight: 500; }
body .app .nav-section { padding: 24px 16px 8px; font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.1em; color: var(--ws-muted); }
body .app .side-links { padding: 0 8px; display: grid; gap: 2px; }
body .app .side-link {
  display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 12px; margin: 0; border: 0; border-radius: 10px;
  font-size: 14px; line-height: 20px; font-weight: 500; color: var(--wt-body); background: transparent; box-shadow: none;
  transition: background-color 200ms ease, color 200ms ease;
}
body .app .side-link .ico { color: var(--ws-muted); transition: color 200ms ease; }
body .app .side-link.active { background: var(--ws-soft); color: var(--ws-accent); font-weight: 600; }
body .app .side-link.active .ico { color: var(--ws-accent); }
body .app .side-link::before, body .app .side-link.active::before { display: none; }
body .app .side-link:focus-visible { outline: 2px solid var(--ws-accent); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  body .app .side-link:not(.active):hover { background: var(--ws-hover); color: var(--ws-text); }
}
body .app .side-bottom { padding: 16px; border-top: 1px solid var(--ws-border); }
body .app .api-note { background: var(--ws-card); border: 1px solid var(--ws-border); border-radius: 12px; padding: 12px; font-size: 12px; line-height: 16px; color: var(--ws-muted); }
body .app .api-note b { color: var(--ws-accent); font-weight: 600; font-size: 12px; }

/* Top bar */
body .app .topbar { height: 64px; padding: 0 24px; gap: 12px; background: var(--ws-sidebar); border-bottom: 1px solid var(--ws-border); }
body .app .menu-toggle, body .app .topbar .icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 9999px; border: 1px solid var(--ws-border);
  background: var(--ws-card); color: var(--ws-text); cursor: pointer; transition: border-color 200ms ease, background-color 200ms ease;
}
@media (hover: hover) and (pointer: fine) { body .app .menu-toggle:hover, body .app .topbar .icon-btn:hover { border-color: var(--ws-strong-border); background: var(--ws-hover); } }
body .app .searchbox { margin-left: auto; }
body .app .searchbox input {
  width: min(320px, 28vw); border-radius: 9999px; padding: 8px 16px 8px 36px; font-size: 14px; line-height: 20px;
  font-family: 'Manrope', system-ui, sans-serif;
}
body .app .avatar {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 9999px; background: var(--ws-accent); color: var(--ws-on-accent);
  font-size: 14px; font-weight: 600; letter-spacing: 0.02em; border: 0; box-shadow: none; cursor: pointer;
}

/* Inputs: index.html forces every input dark with !important (an old dark retheme), which put dark
   fields into the light workspace. Fields follow the workspace theme instead. */
body .app input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), body .app select, body .app textarea {
  background: var(--ws-input) !important; color: var(--ws-text) !important; border: 1px solid var(--ws-strong-border) !important;
  border-radius: 10px; font-family: 'Manrope', system-ui, sans-serif;
}
body .app .searchbox input { border-radius: 9999px !important; }
body .app input::placeholder, body .app textarea::placeholder { color: var(--ws-muted) !important; opacity: 1; }
body .app input:focus-visible, body .app select:focus-visible, body .app textarea:focus-visible { outline: 2px solid var(--ws-accent); outline-offset: 1px; }

/* Page intro */
body .app .page-head { margin-bottom: 24px; align-items: flex-end; gap: 16px; }
body .app .crumb { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ws-muted); margin-bottom: 8px; }
body .app .page-head h1 { font-size: 30px; line-height: 36px; font-weight: 600; letter-spacing: -0.025em; color: var(--ws-text); }
body .app .page-head p { font-size: 16px; line-height: 24px; color: var(--wt-body); margin-top: 8px; }

/* Panels and KPI tiles */
body .app .panel, body .app .metric {
  background: var(--ws-card); border: 1px solid var(--ws-border); border-radius: 16px; box-shadow: var(--ws-shadow);
}
body .app .panel { padding: 24px; }
body .app .panel-head { margin-bottom: 16px; gap: 12px; }
body .app .content .panel-head h3 { font-size: 18px; line-height: 28px; font-weight: 600; letter-spacing: -0.015em; }
body .app .metric { padding: 20px; transition: border-color 200ms ease, transform 200ms var(--lp-ease-out, ease); }
@media (hover: hover) and (pointer: fine) { body .app .metric:hover { border-color: var(--ws-strong-border); } }
body .app .metric .metric-label { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--wt-body); }
body .app .metric .metric-num { margin-top: 8px; font-size: 30px; line-height: 36px; font-weight: 600; letter-spacing: -0.025em; color: var(--ws-text); font-variant-numeric: tabular-nums; }
body .app .metric .metric-foot { margin-top: 8px; font-size: 13px; line-height: 20px; color: var(--wt-body); }
body .app .ws-tile-icon {
  top: 16px; right: 16px; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9999px;
  background: var(--ws-soft); color: var(--ws-accent); font-size: 18px;
}
body .app .ws-chip { border-radius: 9999px; font-size: 12px; line-height: 16px; font-weight: 600; padding: 4px 10px; }
body .app .ws-badge { border-radius: 9999px; font-size: 12px; font-weight: 600; padding: 2px 10px; }
body .app .grid { gap: 16px; }

/* Buttons */
body .app .btn { border-radius: 9999px; font-family: 'Manrope', system-ui, sans-serif; font-weight: 600; transition: background-color 200ms ease, border-color 200ms ease, color 200ms ease, transform 140ms cubic-bezier(0.23, 1, 0.32, 1); }
body .app .btn:hover { transform: none; }
body .app .btn:active { transform: scale(0.97); }
body .app .btn-primary { background: var(--ws-accent); color: var(--ws-on-accent); border-color: transparent; }
body .app .btn-outline { background: var(--ws-card); color: var(--ws-text); border: 1px solid var(--ws-strong-border); }
body .app .btn-ghost { color: var(--wt-body); }
@media (hover: hover) and (pointer: fine) {
  body .app .btn-primary:hover { filter: brightness(0.92); }
  body .app .btn-outline:hover { border-color: var(--ws-accent); color: var(--ws-accent); }
}

/* Tables */
body .app .live-table, body .app .table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
body .app .live-table th, body .app .table th {
  text-align: left; font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ws-muted); background: transparent; padding: 12px; border-bottom: 1px solid var(--ws-border);
}
body .app .live-table td, body .app .table td { padding: 12px; border-bottom: 1px solid var(--ws-border); color: var(--wt-body); }
body .app .live-table tr:last-child td, body .app .table tr:last-child td { border-bottom: 0; }
body .app .live-table td b { color: var(--ws-text); font-weight: 600; font-variant-numeric: tabular-nums; }
@media (hover: hover) and (pointer: fine) { body .app .live-table tbody tr:hover td { background: var(--ws-hover); } }

/* Status tags */
body .app .ma-status, body .app .status-tag {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 9999px; font-size: 12px; line-height: 16px; font-weight: 600;
  background: var(--ws-soft); color: var(--ws-accent); border: 0; text-transform: capitalize;
}
body .app .ma-status.failed { background: var(--wt-att-bg); color: var(--wt-att-fg); }
body .app .ma-status.running, body .app .status-tag.pending { background: var(--wt-watch-bg); color: var(--wt-watch-fg); }

/* Notes, empty states, upload */
body .app .market-kicker { background: var(--ws-soft); border: 1px solid var(--ws-border); border-radius: 12px; color: var(--wt-body); padding: 12px 16px; font-size: 14px; line-height: 20px; }
body .app .empty-state { background: var(--ws-bg); border: 1px dashed var(--ws-strong-border); border-radius: 12px; color: var(--wt-body); padding: 24px; }
body .app .dropzone { border: 1.5px dashed var(--ws-strong-border); border-radius: 16px; background: var(--ws-bg); transition: border-color 200ms ease, background-color 200ms ease; }
@media (hover: hover) and (pointer: fine) { body .app .dropzone:hover { border-color: var(--ws-accent); background: var(--ws-soft); } }
body .app .subtle { color: var(--wt-body); }
body .toast { background: var(--deep, #0f2a1b); color: #f1f7f2; border-radius: 12px; font-family: 'Manrope', system-ui, sans-serif; font-size: 14px; box-shadow: 0 12px 32px -12px rgba(16, 42, 28, 0.4); }

/* ---------- Sign in and sign up ---------- */
body .auth-screen {
  --au-page: #f4f6f4; --au-card: #ffffff; --au-ink: #102a1c; --au-text: #3f5247; --au-muted: #5f7166; --au-line: #c4d1c8; --au-brand: #1c5232;
  background: var(--au-page); color: var(--au-ink); font-family: 'Manrope', system-ui, sans-serif;
}
body .auth-screen .auth-left { background: var(--au-page); color: var(--au-ink); }
body .auth-screen h1, body .auth-screen h2 { font-family: 'Manrope', system-ui, sans-serif; color: var(--au-ink); letter-spacing: -0.025em; font-weight: 600; }
body .auth-screen p, body .auth-screen label, body .auth-screen .auth-row, body .auth-screen .auth-foot { color: var(--au-text); }
body .auth-screen .eyebrow { color: var(--au-brand); }
body .auth-screen .eyebrow::before { background: var(--au-brand); }
body .auth-screen .brand { color: var(--au-ink); }
body .auth-screen a { color: var(--au-brand); font-weight: 600; }
body .auth-screen input:not([type="checkbox"]):not([type="radio"]), body .auth-screen select, body .auth-screen .signup-input, body .auth-screen .signup-select {
  background: var(--au-card) !important; color: var(--au-ink) !important; border: 1px solid var(--au-line) !important; border-radius: 10px !important;
  font-family: 'Manrope', system-ui, sans-serif;
}
body .auth-screen input::placeholder { color: var(--au-muted) !important; opacity: 1; }
body .auth-screen input:focus-visible, body .auth-screen select:focus-visible { outline: 2px solid var(--au-brand); outline-offset: 1px; box-shadow: none !important; }
body .auth-screen .btn-primary, body .auth-screen .auth-submit, body .auth-screen .signup-next {
  background: var(--au-brand) !important; color: #f4f8f5 !important; border: 0 !important; border-radius: 9999px !important; font-weight: 600; box-shadow: none !important;
}
body .auth-screen .auth-art, body .auth-screen .signup-aside { background: #0f2a1b; color: #c9dccf; }
body .auth-screen .auth-art h2, body .auth-screen .signup-aside h2 { color: #f1f7f2; }
body .auth-screen .auth-art p, body .auth-screen .signup-aside p { color: #c9dccf; }
body .auth-screen .auth-art .brand, body .auth-screen .signup-aside .brand { color: #f1f7f2; }
body .auth-screen .field-error, body .auth-screen [role="alert"] { color: #9d3423; }

@media (prefers-reduced-motion: reduce) {
  body .app .side-link, body .app .metric, body .app .btn, body .app .dropzone { transition: none; }
}

/* ---------- Sign in and sign up: beat the old dark retheme (it sets these with !important) ---------- */
body .auth-screen, body .auth-screen .auth-left { background: var(--au-page) !important; color: var(--au-ink) !important; font-family: 'Manrope', system-ui, sans-serif !important; }
body .auth-screen .login-wrap h1, body .auth-screen .signup-wrap h1, body .auth-screen .auth-form-wrap h1, body .auth-screen h1 { color: var(--au-ink) !important; }
body .auth-screen .login-wrap > p, body .auth-screen .auth-left p, body .auth-screen label, body .auth-screen .auth-row, body .auth-screen .auth-foot { color: var(--au-text) !important; }
body .auth-screen .eyebrow { color: var(--au-brand) !important; }
body .auth-screen .auth-left .brand, body .auth-screen .auth-left .brand span { color: var(--au-ink) !important; font-family: 'Manrope', system-ui, sans-serif !important; }
body .auth-screen .auth-left .brand small { color: var(--au-muted) !important; }
body .auth-screen .auth-left a { color: var(--au-brand) !important; }
body .auth-screen [data-login-show] { color: var(--au-brand) !important; background: transparent !important; }

/* The brand side: a solid forest panel with the logo's line. The div-built "business pulse" bars and
   the decorative rings are gone; this panel is about the brand, not a fake chart. */
body .auth-screen .auth-art { background: #0f2a1b !important; }
body .auth-screen .auth-art::before, body .auth-screen .auth-art::after { display: none !important; }
body .auth-screen .auth-illustration { display: none !important; }
body .auth-screen .signup-aside { background: transparent !important; border: 0 !important; box-shadow: none !important; backdrop-filter: none !important; }
body .auth-screen .signup-aside h2 { color: #f1f7f2 !important; font-size: 36px !important; line-height: 40px !important; }
body .auth-screen .signup-aside p { color: #c9dccf !important; }
body .auth-screen .signup-aside .brand, body .auth-screen .signup-aside .brand span { color: #f1f7f2 !important; }
body .auth-screen .signup-aside .brand small { color: #9fbfab !important; }
body .auth-screen .signup-aside::after {
  content: "Not a dashboard. A diagnosis."; display: block; margin-top: 32px; padding-top: 24px; border-top: 1px solid #2c5039;
  font-size: 20px; line-height: 28px; font-weight: 600; color: #8fd6ac; letter-spacing: -0.01em;
}

/* Sign-up wizard */
body .auth-screen .signup-overline { color: var(--au-brand) !important; }
body .auth-screen .signup-lede, body .auth-screen .signup-hint, body .auth-screen .signup-foot { color: var(--au-text) !important; }
body .auth-screen .wizard-question h1, body .auth-screen .wizard-question h2, body .auth-screen .wizard-question h3,
body .auth-screen .wizard-question legend, body .auth-screen .wizard-question label { color: var(--au-ink) !important; }
body .auth-screen .wizard-progress i { background: #d2e3d6 !important; border-radius: 9999px; }
body .auth-screen .wizard-progress i.done, body .auth-screen .wizard-progress i.active, body .auth-screen .wizard-progress i.current { background: var(--au-brand) !important; }
body .auth-screen .wizard-progress-label, body .auth-screen .signup-trust { color: var(--au-muted) !important; }
body .auth-screen .signup-error { color: #9d3423 !important; }
body .auth-screen .signup-input:focus, body .auth-screen .signup-select:focus, body .auth-screen input:focus {
  outline: 2px solid var(--au-brand) !important; outline-offset: 1px; box-shadow: none !important; border-color: var(--au-brand) !important;
}
/* Department and role cards (steps 7 and 8): the old global theme painted them #181818 with dark text. */
body .auth-screen .choice-chip label { background: var(--au-card) !important; border: 1px solid var(--au-line) !important; color: var(--au-ink) !important; border-radius: 12px !important; font-size: 14px !important; line-height: 20px !important; font-weight: 500; }
body .auth-screen .choice-chip label::before { background: var(--au-card) !important; border: 1.5px solid #8fa596 !important; }
@media (hover: hover) and (pointer: fine) { body .auth-screen .choice-chip label:hover { background: #f1f6f2 !important; border-color: var(--au-brand) !important; } }
body .auth-screen .choice-chip input:focus-visible + label { outline: 2px solid var(--au-brand) !important; outline-offset: 2px; }
body .auth-screen .choice-chip.role input:checked + label::before { box-shadow: inset 0 0 0 4px #e6efe8 !important; }
body .auth-screen .wizard-terms { border-color: var(--au-line) !important; color: var(--au-text) !important; }
body .auth-screen .wizard-terms a { color: var(--au-brand) !important; text-decoration: underline; }
body .auth-screen .choice-chip input:checked + label { border-color: var(--au-brand) !important; background: #e6efe8 !important; color: var(--au-ink) !important; box-shadow: none !important; }
body .auth-screen .choice-chip input:checked + label::before { background: var(--au-brand) !important; border-color: var(--au-brand) !important; color: #fff !important; }

/* Wizard back button: its label was pale green on white. */
body .auth-screen .signup-back { background: transparent !important; color: var(--au-ink) !important; border: 1px solid var(--au-line) !important; border-radius: 9999px !important; }
@media (hover: hover) and (pointer: fine) { body .auth-screen .signup-back:hover { border-color: var(--au-brand) !important; color: var(--au-brand) !important; } }

/* Country combobox (app.js) */
.cbx { position: relative; display: grid; gap: 8px; }
.cbx-label { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--au-ink, #102a1c); }
.cbx-field { position: relative; display: flex; align-items: center; }
.cbx-field > .ph { position: absolute; left: 14px; font-size: 18px; color: var(--au-muted, #5f7166); pointer-events: none; }
.cbx-field .cbx-ok { left: auto; right: 14px; color: var(--au-brand, #1c5232); }
body .auth-screen .cbx-field input { width: 100%; padding: 12px 44px !important; font-size: 16px; line-height: 24px; }
.cbx-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 5; margin: 0; padding: 4px; list-style: none; max-height: 288px; overflow: auto;
  background: #ffffff; border: 1px solid var(--au-line, #c4d1c8); border-radius: 12px; box-shadow: 0 16px 40px -16px rgba(16, 42, 28, 0.3);
  transform-origin: top; animation: cbx-in 160ms cubic-bezier(0.23, 1, 0.32, 1);
}
.cbx-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 15px; line-height: 20px; color: var(--au-ink, #102a1c); }
.cbx-list li em { font-style: normal; font-size: 12px; font-weight: 600; color: var(--au-muted, #5f7166); }
.cbx-list li[aria-selected="true"] { background: #e6efe8; color: var(--au-brand, #1c5232); }
.cbx-list .cbx-empty { cursor: default; color: var(--au-muted, #5f7166); }
@keyframes cbx-in { from { opacity: 0; transform: scaleY(0.96) translateY(-2px); } to { opacity: 1; transform: none; } }

/* Workspace motion (app.js adds .ws-enter on navigation; never on data refreshes) */
@media (prefers-reduced-motion: no-preference) {
  body .app .content.ws-enter > * { animation: ws-rise 220ms cubic-bezier(0.23, 1, 0.32, 1) both; }
  body .app .content.ws-enter .metric { animation: ws-rise 260ms cubic-bezier(0.23, 1, 0.32, 1) both; animation-delay: calc(var(--ws-i, 0) * 30ms); }
  body .app .content.ws-enter svg rect { transform-box: fill-box; transform-origin: bottom; animation: ws-grow 520ms cubic-bezier(0.22, 1, 0.36, 1) both; }
}
@keyframes ws-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes ws-grow { from { transform: scaleY(0.05); } to { transform: none; } }

/* ---------- AI Business Analyst ---------- */
body .app .chat-layout { border: 1px solid var(--ws-border); border-radius: 16px; overflow: hidden; background: var(--ws-card); box-shadow: var(--ws-shadow); }
body .app .chat-history { background: var(--ws-sidebar); border-right: 1px solid var(--ws-border); padding: 20px 12px; }
body .app .chat-history h4 { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ws-muted); margin: 0 8px 8px; }
body .app .chat-history .history-item { font-size: 14px !important; line-height: 20px; color: var(--wt-body) !important; padding: 8px !important; border-radius: 10px; transition: background-color 200ms ease, color 200ms ease; }
@media (hover: hover) and (pointer: fine) { body .app .chat-history button.history-item:hover { background: var(--ws-hover) !important; color: var(--ws-text) !important; } }
body .app .chat-main { background: var(--ws-card); }
body .app .chat-messages { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
body .app .chat-messages .message {
  max-width: min(640px, 88%); padding: 14px 16px; border-radius: 16px 16px 16px 6px; border: 1px solid var(--ws-border);
  background: var(--ws-bg); color: var(--ws-text); font-size: 15px; line-height: 24px; box-shadow: none;
}
body .app .chat-messages .message small { display: block; margin-bottom: 6px; font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.08em; color: var(--ws-accent); }
body .app .chat-messages .message.user {
  align-self: flex-end; border-radius: 16px 16px 6px 16px; background: var(--ws-accent); border-color: transparent; color: var(--ws-on-accent);
}
body .app .chat-messages .message.user small { color: var(--ws-on-accent); opacity: 0.75; }
body .app .chat-messages .message b, body .app .chat-messages .message strong { color: inherit; font-weight: 600; }
body .app .chat-messages .message table { font-size: 13px; }
body .app .chat-compose { border-top: 1px solid var(--ws-border); padding: 16px 24px 20px; background: var(--ws-card); }
body .app .chat-compose .suggestion {
  border: 1px solid var(--ws-strong-border); background: var(--ws-card); color: var(--wt-body); border-radius: 9999px; padding: 6px 12px; font-size: 13px; line-height: 20px;
  font-family: 'Manrope', system-ui, sans-serif; cursor: pointer; transition: border-color 200ms ease, color 200ms ease, background-color 200ms ease;
}
@media (hover: hover) and (pointer: fine) { body .app .chat-compose .suggestion:hover { border-color: var(--ws-accent); color: var(--ws-accent); } }
body .app .chat-compose #question { border-radius: 9999px !important; padding: 12px 18px !important; font-size: 15px; }
body .app .chat-compose .btn-primary { border-radius: 9999px; padding: 12px 20px; }
@media (prefers-reduced-motion: no-preference) {
  /* Feedback: the newest message eases in; earlier messages never replay. */
  body .app .chat-messages .message:last-child { animation: ws-rise 220ms cubic-bezier(0.23, 1, 0.32, 1) both; }
}

/* index.html's older "workspaceEnter" replayed on every render (each chat reply, each live refresh).
   It is replaced by the navigation-only entrance above (.ws-enter, added and removed by app.js). */
body .app .content > * { animation: none; }

/* Chat bubbles: index.html colours .message with !important (old themes); the bubbles follow the
   workspace theme instead, and long answers (tables) scroll inside the bubble, not past the column. */
body .app .chat-main { min-width: 0; }
body .app .chat-messages .message { background: var(--ws-bg) !important; color: var(--ws-text) !important; border: 1px solid var(--ws-border) !important; max-width: min(680px, 100%); overflow-x: auto; }
body .app .chat-messages .message.user { background: var(--ws-accent) !important; color: var(--ws-on-accent) !important; border-color: transparent !important; }
body .app .chat-messages .message :is(p, h1, h2, h3, h4, h5, li, td, th, span, strong, b, em, code) { color: inherit !important; }
body .app .chat-messages .message :is(h1, h2, h3, h4, h5) { font-size: 16px; line-height: 24px; font-weight: 600; margin: 12px 0 4px; }
body .app .chat-messages .message table { width: 100%; border-collapse: collapse; margin: 8px 0; }
body .app .chat-messages .message :is(td, th) { padding: 6px 8px; border-bottom: 1px solid var(--ws-border); text-align: left; vertical-align: top; }
body .app .chat-messages .message th { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ws-muted) !important; }
body .app .chat-messages .message small { color: var(--ws-accent) !important; }
body .app .chat-messages .message.user small { color: var(--ws-on-accent) !important; opacity: 0.75; }
/* Analysis context card */
body .app .content .grid > aside p, body .app .content .grid > aside div { font-size: 14px; line-height: 20px; }
body .app .content .grid > aside * { color: var(--wt-body) !important; }
body .app .content .grid > aside h3 { color: var(--ws-text) !important; }
body .app .content .grid > aside :is(small, b, strong) { color: var(--ws-accent) !important; }

/* ---------- Phone and small tablet workspace ---------- */
.ws-top-title { display: none; }
@media (max-width: 760px) {
  body .app { height: 100dvh; min-height: 0; }
  body .app .topbar { height: 56px; padding: 0 12px; gap: 8px; }
  body .app .top-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
  body .app .menu-toggle, body .app .topbar .icon-btn, body .app .avatar { width: 40px; height: 40px; flex: none; }
  .ws-top-title { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; line-height: 24px; font-weight: 600; color: var(--ws-text); }

  /* Sidebar becomes a drawer that slides over the page. */
  body .app .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(84vw, 300px); z-index: 30; transform: translateX(-102%); visibility: hidden;
    transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 260ms; box-shadow: none; overflow-y: auto; overscroll-behavior: contain; }
  body .app .sidebar.open { transform: none; visibility: visible; transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1); box-shadow: 16px 0 48px -12px rgba(8, 24, 14, 0.35); }
  body .app .sidebar.open::after { display: none; }
  body .app .sidebar .side-link { min-height: 44px; }
  .sidebar-scrim { z-index: 25 !important; background: rgba(8, 24, 14, 0.38) !important; }

  body .app .content { padding: 20px 16px 40px; overflow-x: hidden; }
  body .app .page-head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 20px; }
  body .app .page-head h1 { font-size: 24px; line-height: 32px; }
  body .app .page-head p { font-size: 14px; line-height: 20px; }
  body .app .page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  body .app .page-actions .btn { min-height: 40px; padding: 8px 16px; font-size: 14px; }
  body .app .grid.g2, body .app .grid.g3 { grid-template-columns: minmax(0, 1fr); }
  body .app .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  body .app .metric { padding: 16px; min-width: 0; }
  body .app .metric .metric-num { font-size: 20px; line-height: 28px; overflow-wrap: anywhere; }
  body .app .panel { padding: 16px; min-width: 0; }
  body .app .dropzone { padding: 32px 16px; }
  body .app table { font-size: 13px; }
  body .app .chat-layout { grid-template-columns: minmax(0, 1fr); }
  body .app .chat-history { display: none; }
  /* AI analyst: chat full width, context panel below it (the grid sets columns inline). */
  body .app .content > .grid:has(> .chat-layout) { grid-template-columns: minmax(0, 1fr) !important; }
  body .app .chat-layout { min-height: 60dvh; }
  body .app .chat-messages .message { max-width: 92%; }
  body .app .chat-compose .suggestions { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  body .app .chat-compose .suggestion { flex: none; }
}
@media (max-width: 480px) {
  /* Indian rupee figures (₹18,48,982) do not fit two to a row at 360px. */
  body .app .grid.g4 { grid-template-columns: minmax(0, 1fr); }
  body .app .metric .metric-num { font-size: 24px; line-height: 32px; }
}
@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  body .app .sidebar, body .app .sidebar.open { transition: none; }
}

/* ---------- Phone pass 2: type sizes, touch targets, stacked tables ---------- */
@media (max-width: 760px) {
  /* 16px inputs: iOS Safari zooms the page into any field smaller than that. */
  body .app input:not([type=checkbox]):not([type=radio]):not([type=file]), body .app select, body .app textarea,
  body .auth-screen input:not([type=checkbox]):not([type=radio]), body .auth-screen select { font-size: 16px !important; }
  body .app .content .btn, body .app .content button.btn { min-height: 44px; }
  body .app .chat-compose .suggestion { min-height: 40px; padding: 8px 14px; font-size: 14px; }
  body .app .chat-compose form button { min-height: 44px; }
  body .app .content .panel p, body .app .content .panel li, body .app .content .panel .subtle,
  body .app .content .panel summary, body .app .content .panel label, body .app .content .field label { font-size: 14px; line-height: 20px; }
  body .app .content .sample-label, body .app .content label.subtle, body .app .content .theme-current, body .app .content .message small { font-size: 12px; }
  body .app .content summary { min-height: 40px; display: flex; align-items: center; }
  body .app .content input[type=checkbox] { width: 20px; height: 20px; }

  /* Tables with four or more columns become one card per row (labels come from app.js). */
  body .app table.ws-stack { min-width: 0 !important; width: 100%; border: 0; }
  body .app table.ws-stack thead { display: none; }
  body .app table.ws-stack, body .app table.ws-stack tbody, body .app table.ws-stack tr { display: block; width: 100%; }
  body .app table.ws-stack tr { border: 1px solid var(--ws-border); border-radius: 12px; padding: 8px 14px; margin-bottom: 10px; background: var(--ws-card); }
  body .app table.ws-stack td { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 12px; align-items: start; padding: 8px 0 !important;
    border: 0 !important; text-align: left !important; font-size: 14px; line-height: 20px; background: none !important; white-space: normal; overflow-wrap: anywhere; }
  body .app table.ws-stack td > .ws-v { min-width: 0; }
  body .app table.ws-stack td + td { border-top: 1px solid var(--ws-border) !important; }
  body .app table.ws-stack td::before { content: attr(data-label); color: var(--ws-muted); font-size: 13px; line-height: 20px; font-weight: 500; }
  body .app table.ws-stack td:first-child, body .app table.ws-stack td[colspan] { display: block; }
  body .app table.ws-stack td:first-child { font-size: 15px; font-weight: 600; color: var(--ws-text); padding-top: 6px !important; }
  body .app table.ws-stack td:first-child::before, body .app table.ws-stack td[colspan]::before { content: none; }

  /* Auth screens */
  body .auth-screen .brand small { display: none; }
  body .auth-screen label, body .auth-screen .signup-field label { font-size: 14px !important; line-height: 20px; }
  body .auth-screen .signup-hint, body .auth-screen .auth-foot, body .auth-screen .wizard-terms { font-size: 14px !important; line-height: 20px; }
  body .auth-screen .wizard-progress-label, body .auth-screen .wizard-progress-label span, body .auth-screen .signup-trust,
  body .auth-screen .password-criteria span, body .auth-screen .eyebrow, body .auth-screen .signup-overline { font-size: 12px !important; line-height: 16px; }
  body .auth-screen .signup-input, body .auth-screen .signup-select, body .auth-screen .login-wrap input:not([type=checkbox]) { min-height: 48px; }
  body .auth-screen .login-wrap a[href*="forgot"], body .auth-screen .auth-row a { display: inline-block; padding: 10px 0; font-size: 14px; }
  body .auth-screen input[type=checkbox] { width: 20px; height: 20px; flex: none; }
  body .auth-screen .signup-next, body .auth-screen .signup-back, body .auth-screen #loginForm button[type=submit] { min-height: 48px; }
}
/* Auth widgets the old dark theme still painted (all widths). */
body .auth-screen .show-secret, body .auth-screen .login-wrap .btn-ghost { background: #eef3ef !important; color: var(--au-brand) !important; border: 0 !important;
  border-radius: 8px !important; font-size: 13px !important; font-weight: 600; min-height: 36px; padding: 6px 12px !important; }
body .auth-screen .password-meter { background: #dfe8e2 !important; }
body .auth-screen .password-criteria span { color: var(--au-muted) !important; }
