:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-2: #eef4f2;
  --ink: #17312d;
  --muted: #667a74;
  --line: #d9e3df;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --blue: #0369a1;
  --gold: #b7791f;
  --danger: #c2410c;
  --shadow: 0 18px 48px rgba(19, 48, 43, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 20px;
  background: #102723;
  color: #effaf7;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f3c46a;
  color: #102723;
  font-weight: 900;
}

.brand-block h1,
.topbar h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand-block h1 {
  font-size: 17px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #0f766e;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.sidebar .eyebrow {
  color: #9de5db;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-list a {
  color: #d8ebe7;
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 8px;
  transition: 180ms ease;
}

.nav-list a:hover,
.nav-list a.active {
  background: rgba(255, 255, 255, 0.1);
}

.status-panel {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.status-panel small,
.metric-card span,
.analysis-actions small {
  display: block;
  color: var(--muted);
}

.sidebar .status-panel small {
  color: #b9d2cd;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #d97706;
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.18);
}

.status-dot.ok {
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.18);
}

.status-dot.error {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18);
}

.workspace {
  min-width: 0;
  padding: 28px;
}

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

.topbar h2 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.08;
}

.topbar-actions,
.analysis-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.ghost-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 800;
  transition:
    transform 180ms ease,
    background 180ms ease,
    border 180ms ease;
}

.primary-button {
  color: #ffffff;
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-strong);
  transform: translateY(-1px);
}

.ghost-button {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

.sidebar .ghost-button {
  color: #effaf7;
  border-color: rgba(255, 255, 255, 0.18);
}

.icon-button {
  width: 42px;
  padding: 0;
  color: var(--ink);
  background: var(--surface-2);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 18px;
}

.form-panel {
  grid-row: span 2;
}

.national-panel {
  grid-column: 2;
}

.panel,
.metric-card,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel,
.login-panel {
  padding: 20px;
}

.login-panel {
  max-width: 720px;
  display: grid;
  gap: 18px;
  margin: 40px auto;
}

.login-form {
  display: flex;
  gap: 10px;
}

.login-form input {
  flex: 1;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel h3 {
  font-size: 20px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e6f6f3;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.coordinate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: #36534e;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.span-2,
.wide-panel,
.metric-strip {
  grid-column: 1 / -1;
}

.analysis-actions {
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.stack-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.source-status {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: #4e655f;
  font-size: 13px;
  font-weight: 700;
}

.source-status.ok {
  border-color: #8bd7c8;
  background: #ecfdf8;
  color: #0b5f59;
}

.source-status.warning,
.source-status.working {
  border-color: #f0d29a;
  background: #fff8e8;
  color: #8a5b12;
}

.source-status.error {
  border-color: #f2b59d;
  background: #fff1eb;
  color: #9a3412;
}

.toggle-row {
  margin-top: 14px;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 9px;
  row-gap: 2px;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

.toggle-row small {
  grid-column: 2;
  color: var(--muted);
  font-weight: 700;
}

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

.metric-card {
  padding: 18px;
}

.metric-card small {
  color: var(--muted);
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin: 6px 0 4px;
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.insight-grid h4 {
  margin: 0 0 8px;
}

.insight-grid ul {
  margin: 0;
  padding-left: 18px;
  color: #4e655f;
}

.insight-grid li + li {
  margin-top: 8px;
}

.market-visual {
  display: grid;
  gap: 18px;
}

.range-track {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, #b7eadf, #0f766e, #0369a1);
}

.range-track span {
  position: absolute;
  top: 22px;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
}

.bar-chart {
  min-height: 180px;
  display: grid;
  grid-template-columns: repeat(24, minmax(4px, 1fr));
  align-items: end;
  gap: 5px;
  padding-top: 28px;
}

.bar {
  min-height: 8px;
  border-radius: 5px 5px 0 0;
  background: #0f766e;
}

.slides {
  display: grid;
  gap: 16px;
}

.slide {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 8px;
  padding: 36px;
  background: #102723;
  color: #f6fbfa;
  overflow: hidden;
}

.slide:nth-child(even) {
  background: #f7f3ea;
  color: #17312d;
  border: 1px solid #e3d6bd;
}

.slide .eyebrow {
  color: #f3c46a;
}

.slide:nth-child(even) .eyebrow {
  color: var(--gold);
}

.slide h3 {
  max-width: 880px;
  font-size: clamp(32px, 5vw, 64px);
  line-height: 1.02;
}

.slide p {
  max-width: 840px;
  font-size: clamp(18px, 2vw, 26px);
  line-height: 1.35;
}

.slide-footer {
  display: flex;
  justify-content: space-between;
  color: currentColor;
  opacity: 0.72;
  font-weight: 800;
}

.empty-slide {
  min-height: 240px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 13px 15px;
  border-radius: 8px;
  color: #ffffff;
  background: #102723;
  box-shadow: var(--shadow);
  transform: translateY(140%);
  transition: transform 200ms ease;
  z-index: 20;
}

.toast.visible {
  transform: translateY(0);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

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

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

  .form-panel {
    grid-row: auto;
  }

  .national-panel {
    grid-column: auto;
  }

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

@media (max-width: 700px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .panel-header,
  .analysis-actions,
  .login-form,
  .stack-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .field-grid,
  .coordinate-grid,
  .metric-strip,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}

@media print {
  @page {
    size: landscape;
    margin: 0;
  }

  body {
    background: #ffffff;
  }

  .sidebar,
  .topbar,
  .dashboard-grid > :not(.presentation-panel),
  .no-print,
  .toast {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .dashboard-grid,
  .presentation-panel,
  .slides {
    display: block;
    padding: 0;
    margin: 0;
  }

  .presentation-panel {
    border: 0;
    box-shadow: none;
  }

  .slide {
    min-height: 100vh;
    border-radius: 0;
    page-break-after: always;
  }
}
