/* ============================================================
   Indian Railway PVC Calculator — Stylesheet
   Aesthetic: modern fintech — clean sans, depth, color accents
   Type: Geist (UI) + Geist Mono (tabular numbers only)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700;800&family=Geist+Mono:wght@400;500;600&display=swap');

:root {
  --ink:            #0B1220;
  --ink-2:          #1E293B;
  --ink-3:          #334155;
  --mute:           #64748B;
  --mute-2:         #94A3B8;
  --line:           #E8ECF2;
  --line-2:         #F1F5F9;
  --paper:          #F7F9FC;
  --paper-2:        #FFFFFF;
  --tint:           #F1F5F9;

  --brand:          #0A1A35;          /* deep navy */
  --brand-2:        #122444;
  --brand-fg:       #F8FAFC;
  --accent:         #E0700C;          /* saffron */
  --accent-2:       #C25E07;
  --accent-soft:    #FEF0DC;
  --accent-glow:    rgba(224,112,12,0.35);

  --blue:           #2563EB;
  --blue-soft:      #DBEAFE;
  --violet:         #7C3AED;
  --violet-soft:    #EDE9FE;
  --teal:           #0D9488;
  --teal-soft:      #CCFBF1;

  --good:           #059669;
  --good-soft:      #D1FAE5;
  --bad:            #DC2626;
  --bad-soft:       #FEE2E2;
  --warn:           #D97706;
  --warn-soft:      #FEF3C7;

  --radius:         10px;
  --radius-lg:      16px;
  --radius-pill:    999px;
  --shadow-sm:      0 1px 2px rgba(11,18,32,0.05);
  --shadow:         0 2px 8px rgba(11,18,32,0.06), 0 1px 2px rgba(11,18,32,0.04);
  --shadow-md:      0 8px 24px -8px rgba(11,18,32,0.14), 0 2px 6px rgba(11,18,32,0.05);
  --shadow-lg:      0 28px 56px -16px rgba(11,18,32,0.28);

  --font-serif:     'Geist', system-ui, sans-serif;
  --font-sans:      'Geist', system-ui, -apple-system, sans-serif;
  --font-mono:      'Geist Mono', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin: 0 0 12px 0;
}
h1 { font-size: 32px; line-height: 1.12; font-weight: 800; }
h2 { font-size: 24px; line-height: 1.2; }
h3 { font-size: 18px; line-height: 1.3; font-weight: 600; }
h4 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--mute); }
.small { font-size: 12px; }
.tiny  { font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--mute); font-weight: 600; }
.serif { font-family: var(--font-sans); }
.center { text-align: center; }
.right  { text-align: right; }

/* ---------- Layout ---------- */
.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: linear-gradient(180deg, var(--brand-2) 0%, var(--brand) 100%);
  color: var(--brand-fg);
  padding: 0 28px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 1px 0 var(--accent);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  min-width: 0;
}
.topbar .brand > div { min-width: 0; }
.topbar .brand .title,
.topbar .brand .subtitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand .mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.topbar .brand .title { font-family: var(--font-sans); font-size: 16px; font-weight: 700; line-height: 1; letter-spacing: -0.01em; }
.topbar .brand .subtitle { font-size: 10px; opacity: 0.55; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 5px; font-weight: 500; }

.topbar nav { display: flex; gap: 4px; align-items: center; }
.topbar nav a {
  color: rgba(248,250,252,0.66);
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 8px;
  border: 0;
  text-decoration: none;
  transition: color .15s, background .15s;
}
.topbar nav a:hover { color: var(--brand-fg); background: rgba(255,255,255,0.08); }
.topbar nav a.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 2px 10px var(--accent-glow);
}
.topbar .who {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(248,250,252,0.6);
  font-size: 12.5px;
  font-weight: 500;
}
.topbar .who strong { color: var(--brand-fg); font-weight: 600; }
.topbar .who a { color: var(--accent); text-decoration: none; font-weight: 600; }
.topbar .who a:hover { text-decoration: underline; }
.topbar .who-avatar {
  width: 30px; height: 30px; flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 28px;
  flex: 1;
}
.container.narrow { max-width: 880px; }
.container.tight  { max-width: 520px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  padding-bottom: 0;
  border-bottom: 0;
}
.page-head .crumbs { font-size: 11px; color: var(--mute); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 8px; font-weight: 600; }
.page-head .crumbs a { color: var(--mute); }
.page-head h1 { margin-bottom: 0; }
.page-head .lede { color: var(--mute); margin-top: 8px; font-size: 14.5px; max-width: 60ch; }

footer.foot {
  padding: 20px 28px;
  border-top: 1px solid var(--line);
  color: var(--mute);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  background: var(--paper-2);
}

/* ---------- Cards ---------- */
.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.card.flush { padding: 0; overflow: hidden; }
.card-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-head h3 { margin: 0; }
.card-body { padding: 22px; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px 32px;
}
.kv .k { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--mute); margin-bottom: 4px; font-weight: 600; }
.kv .v { font-size: 15px; color: var(--ink); font-weight: 500; }
.kv .v.big { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--ink);
  color: #fff;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--ink-2); color: #fff; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn.primary:hover { background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent-2) 100%); color:#fff; box-shadow: 0 6px 20px var(--accent-glow); }
.btn.ghost {
  background: var(--paper-2);
  border-color: var(--line);
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
}
.btn.ghost:hover { background: var(--tint); color: var(--ink); }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #b91c1c; color:#fff; }
.btn.sm { padding: 7px 13px; font-size: 12.5px; border-radius: 8px; }
.btn.lg { padding: 13px 24px; font-size: 15px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px 22px;
}
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.form-grid.one   { grid-template-columns: 1fr; }
.field.full { grid-column: 1 / -1; }
.field label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
  font-weight: 500;
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--paper-2);
  color: var(--ink);
  transition: border 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input.mono, .field .mono input { font-family: var(--font-mono); }
.field .hint { font-size: 12px; color: var(--mute); margin-top: 5px; }
.field .err  { font-size: 12px; color: var(--bad); margin-top: 5px; }

/* ---------- Tables ---------- */
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.tbl thead th {
  text-align: left;
  font-weight: 600;
  padding: 12px 14px;
  background: var(--tint);
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.tbl tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.tbl tbody tr:hover td { background: var(--paper); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl .row-actions { white-space: nowrap; }
.tbl .row-actions a { margin-right: 10px; font-size: 12.5px; }

/* ---------- Price-indices grid (matches the screenshot style) ---------- */
.indices-tbl {
  /* Force a real horizontal scroll on narrow viewports instead of letting
     individual cells shrink and clip their content. The wrapper around the
     table has overflow-x:auto, so this kicks in only when needed. */
  min-width: 1180px;
}
.indices-tbl th, .indices-tbl td { min-width: 90px; }
.indices-tbl th.num, .indices-tbl td.num { min-width: 95px; }
.indices-tbl .month-cell { min-width: 70px; }
.indices-tbl td.cell.prov-capable { min-width: 105px; }   /* extra room for checkbox */
.indices-tbl input {
  width: 100%;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 4px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.indices-tbl input:focus {
  border-color: var(--accent);
  background: var(--paper-2);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.indices-tbl input.provisional { color: var(--accent); font-style: italic; }
.indices-tbl td { border-bottom: 1px solid var(--line-2); }
.indices-tbl .month-cell {
  font-weight: 600;
  font-family: var(--font-serif);
  font-size: 16px;
  width: 70px;
}
.indices-tbl .prov-cell { width: 60px; text-align: center; }

/* ---- Provisional-capable columns (RBI Cement, Explosives, Other Materials, Plant Machinery) ---- */
/* The four WPI columns get a noticeable cream-orange tint so they read
   as a distinct group, and any individual cell marked provisional goes
   one step further into a saturated accent tint. */
.indices-tbl th.prov-capable,
.indices-tbl td.cell.prov-capable {
  background: rgba(180, 83, 9, 0.10);
}

/* Each prov-capable cell holds an input + a tiny native checkbox tucked top-right. */
.indices-tbl td.cell { position: relative; }
.indices-tbl td.cell.prov-capable { padding-right: 22px; }
.indices-tbl .prov-check {
  position: absolute;
  top: 7px;
  right: 6px;
  width: 13px;
  height: 13px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);  /* native browser checkbox tinted to the brand accent */
  opacity: 0.55;
  transition: opacity 0.12s;
}
.indices-tbl .prov-check:hover   { opacity: 1; }
.indices-tbl .prov-check:checked { opacity: 1; }

/* When the prov toggle is on, much deeper tint + a 3px accent stripe on
   the left edge + the value goes accent-bold italic. The combined cues
   make the provisional state unmistakable at a glance. */
.indices-tbl td.cell.prov-capable:has(.prov-check:checked) {
  background: rgba(180, 83, 9, 0.38);
  box-shadow: inset 3px 0 0 0 var(--accent);
}
.indices-tbl td.cell.prov-capable:has(.prov-check:checked) > input[type="text"],
.indices-tbl td.cell.prov-capable:has(.prov-check:checked) > input[type="number"] {
  color: #5a2906;            /* deep burnt-saffron — still legible on the new tint */
  font-style: italic;
  font-weight: 600;
}

/* Other Sections (auto-averaged) — keep its distinct muted background */
.indices-tbl td.cell.derived > input[type="text"],
.indices-tbl td.cell.derived > input[type="number"] {
  background: var(--tint);
  color: var(--mute);
}

/* Column dividers between Fixed | WPI | Steel groups */
.indices-tbl .col-divider { border-left: 2px solid var(--line); }

/* Group-header row (small caps banner above the column names) */
.indices-tbl .group-head th {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
  background: var(--paper-2);
  padding: 9px 12px 5px;
  text-align: left;
  border-bottom: none;
  font-weight: 600;
}
.indices-tbl .group-head th.wpi    { color: var(--accent); background: rgba(180,83,9,0.18); }
.indices-tbl .group-head th.steel  { color: var(--brand);  background: var(--paper-2); }

/* Slightly softer placeholder ("—") for empty cells */
.indices-tbl input::placeholder { color: var(--mute-2); opacity: 0.45; }

/* Hover states keep the same relative contrast between the three tiers. */
.indices-tbl tbody tr:hover td.cell { background: var(--paper); }
.indices-tbl tbody tr:hover td.cell.prov-capable { background: rgba(180, 83, 9, 0.14); }
.indices-tbl tbody tr:hover td.cell.prov-capable:has(.prov-check:checked) { background: rgba(180, 83, 9, 0.44); }

/* ---------- Year navigation pill ---------- */
.year-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}
.year-nav button {
  background: transparent;
  border: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--ink-3);
}
.year-nav button:hover { background: var(--tint); }
.year-nav .year-label {
  font-family: var(--font-serif);
  font-size: 22px;
  padding: 0 16px;
  letter-spacing: -0.01em;
}

/* ---------- City pills (for steel rates filter) ---------- */
.city-tabs {
  display: inline-flex;
  gap: 6px;
}
.city-tabs button {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 16px;
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
}
.city-tabs button.active {
  background: var(--brand);
  color: var(--brand-fg);
  border-color: var(--brand);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.bad  { background: var(--bad-soft);  color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.mute { background: var(--tint);      color: var(--mute); }
.badge.brand { background: var(--brand); color: var(--brand-fg); }
.badge.mute::before { background: var(--mute-2); }

/* ---------- Flash messages ---------- */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 13.5px;
  border: 1px solid;
}
.flash.success { background: var(--good-soft); border-color: #86efac; color: var(--good); }
.flash.error   { background: var(--bad-soft);  border-color: #fca5a5; color: var(--bad); }
.flash.info    { background: var(--warn-soft); border-color: #fcd34d; color: var(--warn); }

/* ---------- Login page ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(900px 500px at 85% -5%, rgba(224,112,12,0.12), transparent 55%),
    radial-gradient(800px 500px at -5% 105%, rgba(10,26,53,0.10), transparent 55%),
    var(--paper);
}
.login-card {
  width: 400px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
}
.login-card .mark {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border-radius: 16px;
  display: grid; place-items: center;
  font-family: var(--font-sans);
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px var(--accent-glow);
}
.login-card h1 { font-size: 26px; margin-bottom: 4px; font-weight: 800; }
.login-card .sub { color: var(--mute); font-size: 13.5px; margin-bottom: 26px; }
.login-card .hint-creds { margin-top: 18px; padding: 12px; background: var(--tint); border-radius: var(--radius); font-size: 12px; color: var(--mute); font-family: var(--font-mono); }

/* ---------- PVC calculation result ---------- */
.pvc-result {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 22px;
}
@media (max-width: 980px) { .pvc-result { grid-template-columns: 1fr; } }

.pvc-summary {
  background: linear-gradient(145deg, var(--brand) 0%, #0F1419 100%);
  color: var(--brand-fg);
  border-radius: var(--radius-lg);
  padding: 30px;
  position: relative;
  overflow: hidden;
}
.pvc-summary::before {
  content: '';
  position: absolute;
  top: -50%; right: -20%;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(180,83,9,0.25), transparent 70%);
  pointer-events: none;
}
.pvc-summary .lbl { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(250,250,247,0.6); margin-bottom: 8px; }
.pvc-summary .val {
  font-family: var(--font-serif);
  font-size: 56px;
  line-height: 1;
  font-weight: 400;
  letter-spacing: -0.02em;
}
.pvc-summary .val.pos { color: #86efac; }
.pvc-summary .val.neg { color: #fca5a5; }
.pvc-summary .pct {
  margin-top: 6px;
  font-size: 14px;
  color: rgba(250,250,247,0.7);
  font-family: var(--font-mono);
}
.pvc-summary hr { border: 0; border-top: 1px solid rgba(250,250,247,0.12); margin: 22px 0; }
.pvc-summary .meta-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 6px 0; }
.pvc-summary .meta-row .k { color: rgba(250,250,247,0.6); }
.pvc-summary .meta-row .v { font-family: var(--font-mono); color: var(--brand-fg); }

.comp-tbl td.formula {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--mute);
  white-space: nowrap;
}
.comp-tbl td.amount.pos { color: var(--good); font-weight: 600; }
.comp-tbl td.amount.neg { color: var(--bad);  font-weight: 600; }
.comp-tbl tr.na td { color: var(--mute-2); font-style: italic; }

/* ---------- Stat cards on dashboard ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.stat.blue::after  { background: linear-gradient(90deg, var(--blue), #1d4ed8); }
.stat.teal::after  { background: linear-gradient(90deg, var(--teal), #0f766e); }
.stat.violet::after{ background: linear-gradient(90deg, var(--violet), #6d28d9); }
.stat .stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.stat .k { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--mute); font-weight: 600; }
.stat .stat-ico {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-2);
}
.stat.blue .stat-ico  { background: var(--blue-soft);  color: var(--blue); }
.stat.teal .stat-ico  { background: var(--teal-soft);  color: var(--teal); }
.stat.violet .stat-ico{ background: var(--violet-soft);color: var(--violet); }
.stat .stat-ico svg { width: 19px; height: 19px; }
.stat .v {
  font-family: var(--font-sans);
  font-size: 32px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.stat .delta { font-size: 12.5px; color: var(--mute); margin-top: 6px; font-weight: 500; }
.stat .delta strong { color: var(--ink-2); font-weight: 700; }

/* ---------- Tables ---------- */
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.tbl thead th {
  text-align: left;
  font-weight: 600;
  padding: 13px 18px;
  background: var(--paper);
  color: var(--mute);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}
.tbl tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
.tbl tbody tr { transition: background 0.12s; }
.tbl tbody tr:nth-child(even) td { background: rgba(241,245,249,0.4); }
.tbl tbody tr:hover td { background: var(--accent-soft); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 500; }
.tbl .row-actions { white-space: nowrap; text-align: right; }
.tbl .row-actions a {
  margin-left: 14px; font-size: 12.5px; font-weight: 600; color: var(--accent);
}
.tbl .row-actions a:hover { color: var(--accent-2); }

/* ---------- Misc helpers ---------- */
.flex-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.flex-grow { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 22px 0; }
.spacer-12 { height: 12px; } .spacer-24 { height: 24px; }
.no-pvc-banner {
  border: 1px dashed var(--accent);
  background: var(--accent-soft);
  padding: 18px 22px;
  border-radius: var(--radius);
  color: var(--accent-2);
  font-size: 13.5px;
}

.dummy-banner {
  background: repeating-linear-gradient(45deg, var(--tint), var(--tint) 10px, var(--paper) 10px, var(--paper) 20px);
  border: 1px dashed var(--mute-2);
  border-radius: var(--radius-lg);
  padding: 60px 30px;
  text-align: center;
}
.dummy-banner h2 { color: var(--mute); font-style: italic; }
.dummy-banner p  { color: var(--mute); max-width: 480px; margin: 0 auto; }

@media (max-width: 780px) {
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .container { padding: 20px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 14px; }
}/* ============================================================
 *  PVC v46 — clone visual markers
 * ============================================================
 *  Append this to your main stylesheet (e.g. assets/css/app.css
 *  or wherever your site CSS lives — whatever includes/header.php
 *  pulls in).
 *
 *  Two markers:
 *   1. .is-clone        → a colored LEFT BORDER STRIP on a list row
 *                         or a card, marking it as a clone.
 *   2. .clone-badge     → a small inline pill saying "CLONE",
 *                         optionally "CLONE OF <no>".
 *   3. .is-original     → (optional) subtle marker for an agreement
 *                         that HAS clones, so originals stand out too.
 * ============================================================ */

/* Amber left strip for clones — works on <tr> and on cards/divs. */
.is-clone {
  border-left: 5px solid #d97706 !important;   /* amber-600 */
  background: linear-gradient(90deg, rgba(217,119,6,0.06), transparent 220px);
}
/* When applied to a table row, color the first cell's left edge cleanly. */
tr.is-clone > td:first-child,
tr.is-clone > th:first-child {
  box-shadow: inset 5px 0 0 0 #d97706;
}

/* Teal left strip for originals that have clones (optional). */
.is-original-with-clones {
  border-left: 5px solid #0d9488 !important;   /* teal-600 */
}
tr.is-original-with-clones > td:first-child,
tr.is-original-with-clones > th:first-child {
  box-shadow: inset 5px 0 0 0 #0d9488;
}

/* Inline pill badge. */
.clone-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fef3c7;            /* amber-100 */
  color: #92400e;                /* amber-800 */
  border: 1px solid #fcd34d;     /* amber-300 */
  vertical-align: middle;
  margin-left: 8px;
  white-space: nowrap;
}
.clone-badge.original {
  background: #ccfbf1;            /* teal-100 */
  color: #115e59;                /* teal-800 */
  border-color: #5eead4;         /* teal-300 */
}

/* Detail-page banner strip (full-width amber bar at top of a clone). */
.clone-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 5px solid #d97706;
  background: #fffbeb;           /* amber-50 */
  color: #92400e;
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 14px;
}
.clone-banner strong { color: #78350f; }
.clone-banner a { color: #92400e; text-decoration: underline; }
/* ============================================================
 *  PRODUCTION UI LAYER (v3) — modern polish, mobile nav,
 *  auth screens, toggle switches, segmented controls.
 *  Appended so the existing system stays intact.
 * ============================================================ */

/* ---- Smooth scrolling + selection ---- */
html { scroll-behavior: smooth; }
::selection { background: var(--accent-soft); color: var(--accent-2); }

/* ---- Topbar upgrade: sticky + flex wrapper for mobile nav ---- */
.topbar { position: sticky; top: 0; z-index: 50; gap: 28px; }
.topbar .nav-wrap {
  display: flex;
  align-items: center;
  flex: 1 1 auto;          /* fill remaining width after brand */
  justify-content: flex-end;
  min-width: 0;
  gap: 20px;
}
.topbar .nav-wrap nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  margin: 0 auto;          /* center the nav group in the free space */
  padding: 5px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
}
.topbar .nav-wrap nav a { white-space: nowrap; }
.topbar .who {
  flex: 0 0 auto;
  padding-left: 0;
  margin-left: 0;
  white-space: nowrap;
  border-left: 0;
}
.nav-toggle {
  display: none; background: transparent; border: 0; cursor: pointer;
  width: 40px; height: 40px; border-radius: 8px; color: var(--brand-fg);
  align-items: center; justify-content: center;
}
.nav-toggle:hover { background: rgba(250,250,247,0.12); }
.nav-toggle svg { width: 22px; height: 22px; }

/* ---- Auth screens (login + signup) ---- */
.auth-card { width: 100%; max-width: 420px; }
.auth-card .seg { margin: 0 0 22px; }
.auth-card .field + .field { margin-top: 14px; }
.auth-meta {
  text-align: center; margin-top: 20px; font-size: 13px; color: var(--mute);
}
.auth-meta a { font-weight: 600; }
.auth-divider {
  display: flex; align-items: center; gap: 12px; margin: 22px 0;
  color: var(--mute-2); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.pw-strength { height: 4px; border-radius: 999px; background: var(--line); margin-top: 8px; overflow: hidden; }
.pw-strength > i { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }

/* Segmented control (User / Admin switch, request status filters) */
.segmented {
  display: inline-flex; background: var(--tint); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px; gap: 2px;
}
.segmented a, .segmented button {
  border: 0; background: transparent; cursor: pointer; text-decoration: none;
  font: 500 13px/1 var(--font-sans); color: var(--mute);
  padding: 8px 16px; border-radius: 999px; transition: all .15s;
}
.segmented a.active, .segmented button.active {
  background: var(--paper-2); color: var(--ink); box-shadow: var(--shadow-sm);
}

/* ---- Toggle switch (admin permission controls) ---- */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; cursor: pointer; background: var(--mute-2);
  border-radius: 999px; transition: background .18s;
}
.switch .track::before {
  content: ''; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .18s; box-shadow: var(--shadow-sm);
}
.switch input:checked + .track { background: var(--good); }
.switch input:checked + .track::before { transform: translateX(20px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---- Dashboard chart grid ---- */
.dash-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
@media (max-width: 860px) { .dash-grid { grid-template-columns: 1fr; } }

/* ---- Locked / gated feature card ---- */
.gated {
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  background: linear-gradient(120deg, var(--accent-soft) 0%, var(--paper-2) 60%);
  display: flex; gap: 16px; align-items: flex-start;
  box-shadow: var(--shadow-sm);
}
.gated .ico {
  flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: #fff; color: var(--accent-2); box-shadow: var(--shadow-sm);
}
.gated .ico svg { width: 22px; height: 22px; }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 52px 24px; }
.empty-state .ico {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px; display: grid; place-items: center;
  background: var(--tint); color: var(--mute);
}

/* ---- Responsive table → cards on phones ---- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 860px) {
  .topbar .brand { flex: 1 1 auto; }
  .topbar .brand .title, .topbar .brand .subtitle { overflow: visible; text-overflow: clip; }
  .topbar .nav-wrap {
    position: fixed; top: 72px; left: 0; right: 0; flex: 0 0 auto; flex-direction: column; align-items: stretch;
    background: var(--brand); padding: 12px 18px 18px; gap: 4px;
    border-bottom: 1px solid var(--accent); transform: translateY(-150%);
    transition: transform .22s ease; z-index: 49; box-shadow: var(--shadow-lg);
  }
  .topbar.open .nav-wrap { transform: translateY(0); }
  .topbar nav { flex-direction: column; align-items: stretch; gap: 0; width: 100%; overflow: visible; }
  .topbar nav a { padding: 12px 10px; border-radius: 8px; border-bottom: 0 !important; }
  .topbar .who { padding-top: 12px; margin-top: 6px; padding-left: 0; margin-left: 0; border-left: 0; border-top: 1px solid rgba(255,255,255,0.08); }
  .nav-toggle { display: inline-flex; }
  .topbar { padding: 0 18px; }
}

@media (max-width: 680px) {
  h1 { font-size: 30px; }
  .container { padding: 16px; }
  .card { padding: 18px; }
  .pvc-summary .val { font-size: 42px; }
  .btn-row { width: 100%; }
  .btn-row .btn { flex: 1 1 auto; justify-content: center; }
  .auth-card, .login-card { width: 100%; max-width: 100%; padding: 28px 22px; }
  .stat .v { font-size: 30px; }
  /* Stacked-card tables: each row becomes a labelled block */
  table.tbl.stacky thead { display: none; }
  table.tbl.stacky, table.tbl.stacky tbody, table.tbl.stacky tr, table.tbl.stacky td { display: block; width: 100%; }
  table.tbl.stacky tr { border: 1px solid var(--line); border-radius: var(--radius-lg); margin-bottom: 12px; padding: 6px 4px; }
  table.tbl.stacky td { border: 0 !important; padding: 7px 14px; display: flex; justify-content: space-between; gap: 14px; }
  table.tbl.stacky td::before {
    content: attr(data-label); font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
    color: var(--mute); font-weight: 600; flex: none;
  }
  table.tbl.stacky td.row-actions { justify-content: flex-start; gap: 16px; flex-wrap: wrap; }
  table.tbl.stacky td.row-actions::before { display: none; }
}

/* ---- Read-only indices view (user side) ---- */
.indices-tbl td.num { min-width: 92px; }
.indices-tbl th.num.prov-capable,
.indices-tbl td.num.prov-capable {
  background: rgba(224,112,12,0.05);
}
.indices-tbl td.num.is-prov {
  color: var(--accent-2);
  font-weight: 600;
}
.indices-tbl .month-cell {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-2);
}
.indices-tbl .group-head th.wpi   { color: var(--accent-2); background: rgba(224,112,12,0.08); }
.indices-tbl .group-head th.steel { color: var(--brand); }
.indices-tbl .col-divider { border-left: 2px solid var(--line); }

/* ---- Clickable stat cards (dashboard) ---- */
a.stat.stat-link { text-decoration: none; color: inherit; display: block; }
a.stat.stat-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
a.stat.stat-link .delta { color: var(--accent-2); font-weight: 600; }
a.stat.stat-link.blue .delta { color: var(--blue); }
/* With only two cards, keep them from stretching too wide */
.stats.stats-2 { grid-template-columns: repeat(2, minmax(220px, 380px)); }
@media (max-width: 560px){ .stats.stats-2 { grid-template-columns: 1fr; } }
/* Four cards: 4 across, then 2x2, then stacked */
.stats.stats-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px){ .stats.stats-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px){ .stats.stats-4 { grid-template-columns: 1fr; } }