:root {
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-soft: #fafbf8;
  --ink: #16211c;
  --muted: #65716b;
  --line: #dce3dd;
  --green: #155f45;
  --green-2: #2e8a67;
  --green-soft: #e6f2eb;
  --gold: #c79a24;
  --gold-soft: #f6edce;
  --red: #b84a42;
  --red-soft: #f5dfdc;
  --blue: #27547a;
  --blue-soft: #e4eef5;
  --shadow: 0 16px 36px rgba(26, 43, 35, 0.08);
  --shadow-strong: 0 24px 70px rgba(26, 43, 35, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(21, 95, 69, 0.08), rgba(39, 84, 122, 0.03) 340px, transparent 620px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

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

.app-shell {
  width: min(1500px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0 116px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(22, 33, 28, 0.08);
}

.logo-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 94px;
  padding: 8px 14px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(22, 33, 28, 0.1);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(26, 43, 35, 0.06);
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  font-size: 3.25rem;
  line-height: 0.95;
  letter-spacing: 0;
}

.brand-copy p {
  max-width: 620px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

h2 {
  font-size: 1.02rem;
  line-height: 1.2;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 178px;
  min-height: 42px;
  padding: 0 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(26, 43, 35, 0.06);
}

.status-dot {
  width: 9px;
  height: 9px;
  background: var(--gold);
  border-radius: 50%;
}

.status-pill.ready .status-dot {
  background: var(--green);
}

.status-pill.error .status-dot {
  background: var(--red);
}

.executive-strip {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  gap: 12px;
  margin: 20px 0 14px;
}

.executive-card {
  min-height: 112px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.executive-card.primary {
  background: linear-gradient(135deg, #ffffff, #f2f8f4);
  border-color: rgba(21, 95, 69, 0.24);
}

.executive-label,
.kpi-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.executive-value {
  margin-top: 9px;
  font-size: 1.45rem;
  font-weight: 850;
  line-height: 1.08;
}

.executive-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

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

.kpi-card,
.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi-card {
  display: grid;
  align-content: space-between;
  min-height: 126px;
  padding: 15px;
}

.kpi-card.good {
  border-color: rgba(21, 95, 69, 0.26);
}

.kpi-card.warn {
  border-color: rgba(199, 154, 36, 0.38);
}

.kpi-card.risk {
  border-color: rgba(184, 74, 66, 0.3);
}

.kpi-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.kpi-signal {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}

.kpi-card.warn .kpi-signal {
  background: var(--gold);
}

.kpi-card.risk .kpi-signal {
  background: var(--red);
}

.kpi-value {
  margin-top: 10px;
  font-size: 2.08rem;
  font-weight: 880;
  line-height: 1;
  letter-spacing: 0;
}

.kpi-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.kpi-progress {
  position: relative;
  width: 100%;
  height: 5px;
  margin-top: 12px;
  overflow: hidden;
  background: #edf1ed;
  border-radius: 999px;
}

.kpi-progress::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--progress, 100%);
  max-width: 100%;
  background: var(--green);
  border-radius: inherit;
  content: "";
}

.kpi-card.warn .kpi-progress::after {
  background: var(--gold);
}

.kpi-card.risk .kpi-progress::after {
  background: var(--red);
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.panel {
  min-width: 0;
  padding: 18px;
}

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

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

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

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

.panel-header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.chart-panel canvas {
  display: block;
  width: 100%;
  height: 315px;
}

.chart-panel.wide canvas {
  height: 350px;
}

.map-panel {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(246, 249, 246, 0.96)),
    var(--surface);
}

.chart-panel.map-panel canvas {
  height: 500px;
}

.icon-button,
.close-button {
  position: relative;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.icon-button span::before,
.icon-button span::after {
  position: absolute;
  width: 7px;
  height: 7px;
  content: "";
  border-color: var(--green);
}

.icon-button span::before {
  top: 7px;
  right: 7px;
  border-top: 2px solid;
  border-right: 2px solid;
}

.icon-button span::after {
  bottom: 7px;
  left: 7px;
  border-bottom: 2px solid;
  border-left: 2px solid;
}

.close-button::before,
.close-button::after {
  position: absolute;
  top: 12px;
  left: 7px;
  width: 12px;
  height: 2px;
  background: var(--ink);
  content: "";
}

.close-button::before {
  transform: rotate(45deg);
}

.close-button::after {
  transform: rotate(-45deg);
}

.icon-button:hover,
.close-button:hover {
  border-color: var(--green);
  box-shadow: 0 8px 18px rgba(21, 95, 69, 0.12);
}

.insight-list {
  display: grid;
  gap: 10px;
}

.insight {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.insight strong {
  display: block;
  margin-bottom: 6px;
  font-size: 0.92rem;
}

.insight p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.insight.positive {
  background: var(--green-soft);
  border-color: rgba(21, 95, 69, 0.2);
}

.insight.attention {
  background: var(--gold-soft);
  border-color: rgba(199, 154, 36, 0.28);
}

.insight.risk {
  background: var(--red-soft);
  border-color: rgba(184, 74, 66, 0.22);
}

.table-panel {
  margin-top: 16px;
}

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

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

.smartbar {
  display: flex;
  gap: 8px;
}

.bottom-smartbar {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  z-index: 30;
  width: min(980px, calc(100% - 32px));
  min-height: 66px;
  margin: 0 auto;
  padding: 8px;
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(220, 227, 221, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow-strong);
  backdrop-filter: blur(14px);
}

.smart-chip {
  display: grid;
  grid-template-columns: 40px minmax(92px, 1fr);
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  min-width: 158px;
  min-height: 50px;
  padding: 8px 10px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.smart-chip:hover,
.smart-chip.active {
  border-color: rgba(21, 95, 69, 0.42);
  box-shadow: 0 8px 22px rgba(21, 95, 69, 0.12);
  transform: translateY(-1px);
}

.smart-chip strong {
  grid-column: 2;
  font-size: 0.88rem;
  line-height: 1.1;
}

.smart-chip span {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.2;
}

.smart-visual {
  grid-row: 1 / 3;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 3px;
  width: 40px;
  height: 34px;
  padding: 5px;
  background: var(--green-soft);
  border-radius: 6px;
}

.smart-visual i {
  display: block;
  width: 7px;
  min-height: 7px;
  border-radius: 3px 3px 1px 1px;
}

.smart-visual i:nth-child(1) {
  height: var(--bar-a, 40%);
  background: var(--green);
}

.smart-visual i:nth-child(2) {
  height: var(--bar-b, 72%);
  background: var(--gold);
}

.smart-visual i:nth-child(3) {
  height: var(--bar-c, 56%);
  background: var(--blue);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  padding: 24px;
}

.modal.open {
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 33, 28, 0.64);
}

.modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(1220px, 100%);
  height: min(800px, calc(100vh - 48px));
  padding: 18px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.3);
}

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

.modal-header p {
  margin-top: 4px;
  color: var(--muted);
}

#modal-canvas {
  width: 100%;
  height: 100%;
  min-height: 420px;
}

.loading-state,
.error-state {
  padding: 24px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: minmax(280px, 380px) 1fr;
  }

  .status-pill {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .executive-strip {
    grid-template-columns: 1fr;
  }

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

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

  .map-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1500px);
    padding-top: 12px;
    padding-bottom: 116px;
  }

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

  .chart-panel,
  .panel.wide,
  .executive-panel,
  .map-panel {
    grid-column: 1 / -1;
  }

  .logo-frame {
    height: 78px;
  }

  h1 {
    font-size: 2.35rem;
  }

  .chart-panel canvas,
  .chart-panel.wide canvas {
    height: 300px;
  }

  .chart-panel.map-panel canvas {
    height: 520px;
  }

  .bottom-smartbar {
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: calc(100% - 20px);
  }

  .smart-chip {
    min-width: 148px;
  }

  .modal {
    padding: 10px;
  }

  .modal-panel {
    height: calc(100vh - 20px);
    padding: 14px;
  }
}
