:root {
  --ink: #0a1424;
  --ink-soft: #203047;
  --muted: #64748b;
  --line: #d9e2ea;
  --panel: #ffffff;
  --panel-soft: #f7fafc;
  --canvas: #eef3f6;
  --navy: #061a2c;
  --navy-2: #0d2a43;
  --electric: #0072bc;
  --gold: #ff9f43;
  --teal: #158f93;
  --orange: #e86f1d;
  --green: #2e7d32;
  --red: #bf2e2e;
  --shadow: 0 18px 50px rgba(10, 20, 36, 0.09);
  --radius: 6px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: var(--font);
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--navy) 0%, #02111f 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
}

.brand {
  height: 96px;
  display: flex;
  align-items: center;
  padding: 22px 26px;
  background: rgba(255, 255, 255, 0.04);
}

.brand img {
  width: 172px;
  max-width: 100%;
  height: auto;
}

.nav-list {
  display: grid;
  gap: 4px;
  padding: 20px 0;
}

.nav-button {
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  border: 0;
  border-left: 4px solid transparent;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.nav-button svg,
.toolbar svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.91rem;
  font-weight: 650;
}

.nav-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-button.active {
  color: var(--gold);
  border-left-color: var(--gold);
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 24px 26px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(255, 159, 67, 0.14);
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-label {
  margin: 0 0 6px;
  color: var(--electric);
  font-size: 0.77rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: clamp(1.62rem, 1.4rem + 0.7vw, 2.2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 760;
  text-transform: uppercase;
}

.control select,
.file-button,
.ghost-button {
  height: 40px;
  border: 1px solid #c9d5df;
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink-soft);
  box-shadow: 0 1px 0 rgba(10, 20, 36, 0.04);
}

.control select {
  min-width: 174px;
  padding: 0 34px 0 12px;
}

.file-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  font-size: 0.83rem;
  font-weight: 750;
  cursor: pointer;
}

.file-button {
  color: #fff;
  border-color: var(--electric);
  background: var(--electric);
}

.file-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

#fileInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.84rem;
}

.source-row > div {
  min-width: 0;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  height: 25px;
  margin-right: 9px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--ink);
  background: #fff3df;
  border: 1px solid rgba(255, 159, 67, 0.4);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  min-height: 126px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(10, 20, 36, 0.03);
}

.kpi-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
}

.kpi-title {
  margin: 0;
  color: #28415e;
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
  line-height: 1.2;
  letter-spacing: 0;
}

.kpi-value {
  margin: 13px 0 9px;
  color: var(--ink);
  font-size: clamp(1.45rem, 1.1rem + 1vw, 2.05rem);
  line-height: 1;
  font-weight: 850;
}

.kpi-note {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 0.81rem;
  line-height: 1.35;
}

.delta {
  font-weight: 850;
}

.delta.good {
  color: var(--green);
}

.delta.warn {
  color: var(--orange);
}

.delta.bad {
  color: var(--red);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.chart-panel,
.table-panel,
.method-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.chart-panel {
  min-height: 330px;
  display: flex;
  flex-direction: column;
  grid-column: span 6;
}

.chart-panel.span-4 {
  grid-column: span 4;
}

.chart-panel.span-6 {
  grid-column: span 6;
}

.chart-panel.span-8 {
  grid-column: span 8;
}

.chart-panel.span-12 {
  grid-column: span 12;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 69px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.table-panel h2,
.method-panel h2 {
  margin: 0;
  color: #0b2340;
  font-size: 0.88rem;
  line-height: 1.25;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.chart-body {
  min-height: 250px;
  flex: 1;
  padding: 14px 16px 16px;
}

.chart-svg {
  width: 100%;
  height: 260px;
  display: block;
  overflow: visible;
}

.axis,
.grid-line {
  stroke: #d6e0e8;
  stroke-width: 1;
}

.axis-label,
.tick-label {
  fill: #526477;
  font-size: 11px;
}

.series-actual {
  fill: none;
  stroke: #06284a;
  stroke-width: 3;
}

.series-plan {
  fill: none;
  stroke: #e2a100;
  stroke-width: 2.5;
  stroke-dasharray: 7 6;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 18px;
  height: 4px;
  border-radius: 999px;
  background: var(--ink);
}

.legend-swatch.plan {
  background: repeating-linear-gradient(90deg, #e2a100 0 6px, transparent 6px 10px);
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.74fr) minmax(120px, 1fr) 72px;
  align-items: center;
  gap: 12px;
}

.bar-label {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 20px;
  background: #edf3f7;
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: 3px;
}

.bar-value {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  font-weight: 820;
  text-align: right;
}

.stacked-wrap {
  display: grid;
  gap: 14px;
  padding-top: 22px;
}

.stacked-bar {
  height: 92px;
  display: flex;
  overflow: hidden;
  border-radius: 4px;
  background: #edf3f7;
}

.stacked-segment {
  min-width: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 880;
  font-size: clamp(0.78rem, 1.2vw, 1.18rem);
}

.stacked-axis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  color: var(--muted);
  font-size: 0.76rem;
}

.stacked-axis span:last-child {
  text-align: right;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.mini-stat {
  min-height: 86px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.mini-stat strong {
  display: block;
  color: var(--ink);
  font-size: 1.18rem;
  margin-bottom: 7px;
}

.mini-stat span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.28;
}

.table-panel {
  overflow: hidden;
  margin-bottom: 14px;
}

.table-panel h2,
.method-panel h2 {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #e5edf3;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #36506c;
  background: #f9fbfd;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

td.num,
th.num {
  text-align: right;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 24px;
  padding: 0 9px;
  border-radius: 4px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 850;
}

.badge.low {
  background: var(--green);
}

.badge.medium {
  background: var(--orange);
}

.badge.high {
  background: var(--red);
}

.method-panel {
  padding-bottom: 14px;
  box-shadow: none;
}

#methodNotes {
  display: grid;
  gap: 8px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.45;
}

.note-line {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
}

.note-line strong {
  color: var(--ink-soft);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .chart-panel,
  .chart-panel.span-4,
  .chart-panel.span-6,
  .chart-panel.span-8 {
    grid-column: span 12;
  }
}

@media (max-width: 780px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .brand {
    height: 74px;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    padding: 8px 10px 14px;
  }

  .nav-button {
    width: auto;
    min-width: 164px;
    border-left: 0;
    border-bottom: 3px solid transparent;
    border-radius: var(--radius);
    padding: 0 14px;
  }

  .nav-button.active {
    border-bottom-color: var(--gold);
  }

  .sidebar-footer {
    display: none;
  }

  .main {
    padding: 16px;
  }

  .topbar,
  .source-row {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .control,
  .control select,
  .file-button,
  .ghost-button {
    width: 100%;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .mini-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .bar-value {
    text-align: left;
  }

  .note-line {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* ── Operations Hub: nav groups, Home landing, embedded modules ───────── */
[hidden] { display: none !important; }

.nav-group {
  margin: 16px 0 4px;
  padding: 0 26px;
  color: rgba(255, 255, 255, 0.42);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-hero {
  background: var(--navy);
  color: #fff;
  border-radius: 12px;
  padding: 30px 32px;
  box-shadow: var(--shadow);
}
.home-hero h2 { margin: 0 0 8px; font-size: 1.5rem; font-weight: 800; }
.home-hero p { margin: 0; color: rgba(255, 255, 255, 0.78); max-width: 60ch; line-height: 1.5; }

.home-tiles {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.home-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.home-tile:hover { transform: translateY(-2px); border-color: var(--electric); }
.home-tile-tag {
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--electric); background: rgba(0, 114, 188, 0.1);
  padding: 3px 9px; border-radius: 999px;
}
.home-tile-title { font-size: 1.12rem; font-weight: 800; color: var(--ink); }
.home-tile-desc { font-size: 0.9rem; color: var(--muted); line-height: 1.45; }
.home-tile-go { margin-top: auto; padding-top: 8px; font-weight: 750; color: var(--electric); }

#embedFrame {
  width: 100%;
  height: calc(100vh - 132px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.live-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  color: #c7ebcb; background: rgba(46, 125, 50, 0.18); border: 1px solid rgba(46, 125, 50, 0.45);
  padding: 5px 11px; border-radius: 999px; margin-bottom: 14px;
}
.live-badge--off { color: rgba(255, 255, 255, 0.72); background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.18); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #37d058; box-shadow: 0 0 0 4px rgba(55, 208, 88, 0.18); animation: livePulse 1.8s ease-in-out infinite; }
@keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.status-dot.live { background: #37d058; box-shadow: 0 0 0 5px rgba(55, 208, 88, 0.14); }
.nav-button { transition: background 0.13s ease, color 0.13s ease, border-color 0.13s ease; }
.panel-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head-row h2 { margin: 0; }
a.ghost-button { text-decoration: none; }
.loading { color: var(--muted); padding: 8px 0; }

.rowlink { cursor: pointer; }
.rowlink:hover { background: rgba(0, 114, 188, 0.07); }
.hint { color: var(--electric); font-size: 0.82rem; font-weight: 700; }

.job-modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; }
.job-modal__backdrop { position: absolute; inset: 0; background: rgba(6, 26, 44, 0.55); }
.job-modal__panel { position: relative; background: var(--panel); border-radius: 14px; box-shadow: 0 30px 80px rgba(10, 20, 36, 0.35); width: min(760px, 100%); max-height: 88vh; overflow: auto; padding: 26px 28px; }
.job-modal__close { position: absolute; top: 10px; right: 14px; border: 0; background: transparent; font-size: 1.7rem; line-height: 1; color: var(--muted); cursor: pointer; }
.jm-eyebrow { margin: 0 0 4px; color: var(--electric); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.jm-title { margin: 0 0 2px; font-size: 1.35rem; font-weight: 800; color: var(--ink); }
.jm-sub { margin: 0 0 18px; color: var(--muted); font-size: 0.9rem; }
.jm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.jm-card { background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.jm-h3 { margin: 0 0 12px; font-size: 0.95rem; font-weight: 700; color: var(--ink); }
.jm-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.jm-row:last-child { border-bottom: 0; }
.jm-label { color: var(--ink-soft); font-size: 0.9rem; }
.jm-pct { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
.jm-val { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; min-width: 92px; }
.jm-row.hl .jm-val { color: var(--electric); }
.jm-row.neg .jm-val { color: var(--red); }
.jm-note { margin: 14px 0 0; color: var(--muted); font-size: 0.8rem; line-height: 1.45; }
@media (max-width: 640px) { .jm-grid { grid-template-columns: 1fr; } }

.sample-banner { background: rgba(255, 159, 67, 0.16); color: #8a4b00; border: 1px solid rgba(255, 159, 67, 0.5); border-radius: 8px; padding: 7px 14px; margin-bottom: 14px; font-size: 0.82rem; font-weight: 600; text-align: center; }
.sample-banner b { font-weight: 800; }

.login-screen { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: #04121f; padding: 24px; }
.login-card { width: min(380px, 100%); background: #0d2438; border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); padding: 34px 30px; display: flex; flex-direction: column; gap: 12px; color: #fff; }
.login-logo { height: 32px; width: auto; object-fit: contain; align-self: flex-start; margin-bottom: 8px; }
.login-eyebrow { margin: 0; color: var(--gold); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
.login-title { margin: 0; font-size: 1.5rem; font-weight: 800; color: #fff; }
.login-sub { margin: 0 0 8px; color: rgba(255, 255, 255, 0.65); font-size: 0.88rem; }
.login-field { display: flex; flex-direction: column; gap: 5px; font-size: 0.8rem; font-weight: 700; color: rgba(255, 255, 255, 0.8); }
.login-field input { padding: 10px 12px; border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 8px; font: inherit; font-weight: 500; background: #fff; color: var(--ink); }
.login-field input:focus { outline: none; border-color: var(--electric); box-shadow: 0 0 0 3px rgba(0, 114, 188, 0.25); }
#loginSubmit { margin-top: 10px; padding: 11px; border: 0; border-radius: 8px; background: var(--electric); color: #fff; font-weight: 800; font-size: 0.95rem; cursor: pointer; }
#loginSubmit:hover { background: #0085db; }
#loginSubmit:disabled { opacity: 0.6; cursor: default; }
.login-error { margin: 4px 0 0; color: #ff8a8a; font-size: 0.82rem; font-weight: 600; min-height: 1em; }
