* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #edf3f8 0%, #f9f4ec 100%);
  color: #1b2a38;
  overflow-x: hidden;
  overflow-y: auto;
}

.shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px;
  overflow-x: hidden;
  overflow-y: visible;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 16px;
  overflow: visible;
}

.topbar h1,
.hero h2,
.panel h3 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: #6a7b8c;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.muted {
  color: #5e6d7a;
}

.nav {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.nav a,
button,
.button-link {
  border: 0;
  border-radius: 12px;
  padding: 8px 16px;
  background: #173b63;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav a.active,
button.secondary {
  background: #dfe7ee;
  color: #173b63;
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(23, 59, 99, 0.08);
  border-radius: 20px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: 0 14px 32px rgba(33, 52, 72, 0.08);
  overflow: visible;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(242, 247, 251, 0.98) 100%);
  overflow: visible;
}

.hero-actions,
.upload-form,
.sheet-form,
.filter-actions,
.section-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.hero-actions {
  justify-content: flex-end;
  width: min(560px, 100%);
}

.upload-form {
  flex: 1 1 360px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.upload-form input[type="file"] {
  min-width: 0;
  width: 100%;
  padding: 8px 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f8fb 100%);
  border: 1px solid #cfdbe7;
  border-radius: 14px;
}

.hero-actions form:last-child {
  flex: 0 0 auto;
}

.preview-export-tools {
  width: auto;
}

.preview-export-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.preview-export-form input[type="text"] {
  width: 150px;
  border: 1px solid #ccd7e2;
  border-radius: 12px;
  padding: 8px 12px;
  background: #fff;
}

.controls {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0%, rgba(245, 249, 252, 0.97) 100%);
  overflow: visible;
}

.topbar h1 {
  font-size: 28px;
  line-height: 1.1;
}

.hero h2 {
  font-size: 24px;
  line-height: 1.15;
}

.hero .muted,
.controls .eyebrow,
.controls strong {
  line-height: 1.3;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.metric-card span {
  display: block;
  color: #6a7b8c;
  margin-bottom: 8px;
}

.metric-card strong {
  font-size: 28px;
}

.metric-card-strong {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(240, 247, 252, 0.96) 100%);
}

.overview-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  background: linear-gradient(135deg, #173b63 0%, #285a85 50%, #e6a74d 100%);
  color: #fff;
}

.overview-hero .muted,
.overview-hero .eyebrow {
  color: rgba(255, 255, 255, 0.82);
}

.projection-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  background: linear-gradient(135deg, #122f4d 0%, #1f5077 55%, #c8d8e8 100%);
  color: #fff;
}

.projection-hero .muted,
.projection-hero .eyebrow {
  color: rgba(255, 255, 255, 0.82);
}

.analysis-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.two-column-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 20px;
}

.state-master-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
}

.projection-workbook-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.9fr);
  gap: 20px;
  align-items: start;
}

.workbook-side-stack {
  display: grid;
  gap: 20px;
  justify-items: center;
}

.workbook-info-panel {
  align-self: start;
}

.workbook-action-stack {
  display: grid;
  gap: 12px;
}

.centered-workbook-stack {
  display: grid;
  gap: 20px;
  margin-top: 20px;
  width: 100%;
}

.centered-workbook-panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.workbook-panel {
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0%, rgba(241, 247, 252, 0.97) 100%);
  width: 100%;
}

.sheet-box {
  border: 1px solid #d7e3ed;
  border-radius: 18px;
  background: #fcfdff;
  overflow: hidden;
  width: 100%;
}

.sheet-box-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: linear-gradient(180deg, #edf4f9 0%, #e4edf6 100%);
  color: #4d6477;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid #d7e3ed;
}

.box-scroll {
  max-height: 520px;
  overflow: auto;
  overscroll-behavior: contain;
}

.box-scroll-short {
  max-height: 280px;
}

.workbook-side-stack .workbook-panel {
  max-width: 760px;
}

.workbook-footer {
  margin-top: 14px;
  justify-content: center;
}

.compact-table table {
  min-width: 100%;
}

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

.state-list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  background: #f7fafc;
  border: 1px solid #dbe6ef;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.state-list-item:hover,
.state-list-item.active {
  transform: translateY(-1px);
  border-color: #8fb4d4;
  box-shadow: 0 10px 22px rgba(23, 59, 99, 0.08);
}

.state-list-item strong,
.state-list-item span {
  display: block;
}

.state-list-item span {
  color: #617487;
  font-size: 13px;
  margin-top: 4px;
}

.state-list-meta {
  text-align: right;
}

.focus-state-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.focus-kpi {
  padding: 14px 16px;
  border-radius: 16px;
  background: #f4f8fb;
  border: 1px solid #dbe6ef;
}

.focus-kpi span {
  display: block;
  font-size: 13px;
  color: #637587;
  margin-bottom: 6px;
}

.focus-kpi strong {
  font-size: 20px;
}

.rto-focus-list {
  display: grid;
  gap: 14px;
}

.rto-focus-card {
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(180deg, #fbfdff 0%, #eef5fb 100%);
  border: 1px solid #dbe6ef;
}

.rto-focus-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.rto-focus-top strong,
.rto-focus-top span {
  display: block;
}

.rto-focus-top span {
  color: #617487;
  font-size: 13px;
  margin-top: 4px;
}

.focus-count-bar {
  width: 100%;
}

.rto-focus-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.rto-focus-metrics span {
  display: block;
  font-size: 12px;
  color: #617487;
  margin-bottom: 5px;
}

.rto-focus-metrics strong {
  font-size: 16px;
}

.state-box-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.state-box {
  border-radius: 20px;
  padding: 18px;
  background: linear-gradient(180deg, #fbfdff 0%, #eef5fb 100%);
  border: 1px solid #d9e4ee;
}

.state-box h4 {
  margin: 0;
  font-size: 22px;
}

.state-box-top,
.state-box-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.state-pill {
  background: #173b63;
  color: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
}

.state-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 18px 0;
}

.state-metrics span {
  display: block;
  color: #637587;
  margin-bottom: 6px;
  font-size: 13px;
}

.state-metrics strong {
  font-size: 18px;
}

.mini-chart {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.mini-chart-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: center;
}

.mini-chart-row label {
  margin: 0;
  font-size: 13px;
  color: #536576;
}

.mini-bar {
  height: 10px;
  border-radius: 999px;
  background: #d9e7f2;
  overflow: hidden;
}

.mini-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2d6ca2 0%, #4a96d4 100%);
}

.mini-bar.profit span {
  background: linear-gradient(90deg, #14805e 0%, #33b07f 100%);
}

.mini-bar.customer span {
  background: linear-gradient(90deg, #d48b2a 0%, #ebb357 100%);
}

.flash-stack {
  margin-bottom: 20px;
}

.flash {
  padding: 12px 16px;
  border-radius: 14px;
  margin-bottom: 10px;
}

.flash.success {
  background: #e8f7ec;
  color: #1d6a35;
}

.flash.error {
  background: #fdecec;
  color: #8a2130;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid #e6edf3;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f4f8fb;
  position: sticky;
  top: 0;
}

input[type="file"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid #ccd7e2;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  align-items: end;
}

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

.chip {
  background: #edf3f8;
  color: #173b63;
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .topbar,
  .hero,
  .controls,
  .overview-hero,
  .projection-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions {
    width: 100%;
    justify-content: stretch;
  }

  .upload-form {
    grid-template-columns: 1fr;
  }

  .projection-workbook-grid,
  .state-master-layout,
  .two-column-layout {
    grid-template-columns: 1fr;
  }

  .rto-focus-top {
    grid-template-columns: 1fr;
  }
}
