:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d9e0e7;
  --text: #18212b;
  --muted: #657282;
  --accent: #176b5f;
  --accent-strong: #0f5148;
  --danger: #a03a2f;
  --warn: #8a5a00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

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

h1 {
  font-size: 24px;
  font-weight: 720;
}

h2 {
  font-size: 17px;
  font-weight: 700;
}

h3 {
  margin-top: 22px;
  margin-bottom: 10px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
}

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

.accuracy-summary {
  margin-top: 8px !important;
  color: var(--accent-strong) !important;
  font-weight: 600;
}

.accuracy-panel {
  margin: 16px 28px 0;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

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

.accuracy-note {
  margin-top: 12px;
  color: var(--muted);
}

.metric-card.accent {
  border-color: #b9d7ce;
  background: #eef8f4;
}

.status {
  align-self: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  white-space: nowrap;
}

.status.ok {
  color: var(--accent-strong);
  border-color: #b9d7ce;
  background: #eef8f4;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

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

.panel {
  padding: 18px;
}

.input-panel {
  align-self: start;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: auto;
}

.workspace {
  display: grid;
  gap: 18px;
}

form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #cbd4dd;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid #b7d7d0;
  border-color: var(--accent);
}

.primary,
.secondary {
  min-height: 42px;
  border-radius: 6px;
  font-weight: 720;
  cursor: pointer;
}

.primary {
  border: 0;
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
}

.secondary {
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent-strong);
}

.secondary:hover {
  background: #eef8f4;
}

.divider {
  height: 1px;
  margin: 18px 0;
  background: var(--line);
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.metric-card {
  display: grid;
  gap: 6px;
  padding: 16px;
  min-height: 86px;
}

.metric-card .metric-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.metric-card strong {
  font-size: 21px;
  line-height: 1.1;
}

.help-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid #b7c3cf;
  border-radius: 50%;
  background: #f7f9fb;
  color: #4d5d6c;
  font: 700 11px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: help;
  flex-shrink: 0;
}

.help-tip:hover,
.help-tip:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: #eef8f4;
  outline: none;
}

.help-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: min(280px, 70vw);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1f2a33;
  color: #f4f7fa;
  font: 400 12px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: left;
  white-space: normal;
  box-shadow: 0 8px 24px rgba(24, 33, 43, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 40;
}

.help-tip::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1f2a33;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
  z-index: 41;
}

.help-tip:hover::after,
.help-tip:hover::before,
.help-tip:focus-visible::after,
.help-tip:focus-visible::before {
  opacity: 1;
  visibility: visible;
}

/* Keep tooltips inside the viewport on the leftmost cards. */
.accuracy-grid .metric-card:first-child .help-tip::after,
.forecast-grid .metric-card:first-child .help-tip::after {
  left: 0;
  transform: none;
}

.accuracy-grid .metric-card:first-child .help-tip::before,
.forecast-grid .metric-card:first-child .help-tip::before {
  left: 8px;
  transform: none;
}

/* And on the rightmost cards. */
.accuracy-grid .metric-card:last-child .help-tip::after,
.forecast-grid .metric-card:last-child .help-tip::after {
  left: auto;
  right: 0;
  transform: none;
}

.accuracy-grid .metric-card:last-child .help-tip::before,
.forecast-grid .metric-card:last-child .help-tip::before {
  left: auto;
  right: 8px;
  transform: none;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.section-head a {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.muted-text {
  margin-bottom: 12px;
  color: var(--muted);
}

#mapFrame {
  width: 100%;
  height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8edf2;
}

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

.env-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.env-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.env-item strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow: auto;
}

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

.environment-table-wrap {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.product-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.environment-table {
  min-width: 640px;
}

.environment-table thead th {
  background: #f8fafc;
}

.env-category-row th,
.env-category-row td {
  background: #fbfcfd;
  font-weight: 720;
}

.env-category-row[aria-expanded="true"] th,
.env-category-row[aria-expanded="true"] td {
  border-bottom-color: #c7d2dc;
}

.env-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 720;
  text-align: left;
}

.env-toggle:hover {
  color: var(--accent-strong);
}

.env-category-title {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
}

.env-toggle-icon {
  width: 14px;
  color: var(--accent-strong);
}

.env-detail-row th {
  padding-left: 28px;
  font-weight: 650;
}

.env-detail-row th,
.env-detail-row td {
  background: #ffffff;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

tbody th {
  color: var(--text);
}

@media (max-width: 1100px) {
  .layout,
  .forecast-grid {
    grid-template-columns: 1fr;
  }

  .input-panel {
    position: static;
    max-height: none;
  }

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

@media (max-width: 620px) {
  .topbar {
    display: grid;
    padding: 16px;
  }

  .layout {
    padding: 12px;
  }

  .field-grid,
  .env-grid {
    grid-template-columns: 1fr;
  }
}
