:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-muted: #eef2ed;
  --text: #171a17;
  --text-soft: #5e675d;
  --text-faint: #8a9387;
  --line: #dfe5dc;
  --line-strong: #c8d2c5;
  --green: #1f8a5b;
  --blue: #2d6cdf;
  --amber: #b7791f;
  --red: #c2413b;
  --ink: #263228;
  --shadow: 0 12px 32px rgba(28, 36, 30, 0.08);
  --radius: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(31, 138, 91, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(31, 138, 91, 0.05) 1px, transparent 1px),
    var(--bg);
  background-size: 40px 40px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  color: #ffffff;
  background: var(--ink);
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--text-soft);
  font-size: 12px;
}

.field-label,
.eyebrow,
.panel-meta {
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.select,
.input,
.textarea,
.month-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  background: #ffffff;
  padding: 9px 11px;
}

.textarea {
  min-height: 104px;
  resize: vertical;
}

.textarea.small {
  min-height: 72px;
}

.nav-list {
  display: grid;
  gap: 4px;
  margin: 24px 0;
}

.nav-link {
  border-radius: var(--radius);
  color: var(--text-soft);
  padding: 9px 10px;
  font-weight: 650;
}

.nav-link.active,
.nav-link:hover {
  color: var(--text);
  background: var(--surface-muted);
}

.sync-status {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  color: var(--text-soft);
  padding: 12px;
  font-size: 13px;
}

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

.topbar,
.section-heading,
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
  line-height: 1.3;
}

.subtitle {
  color: var(--text-soft);
  margin-top: 4px;
}

.toolbar,
.engine-toggle {
  display: inline-flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 4px;
}

.topbar-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.session-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text-soft);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-user a {
  color: var(--green);
}

.session-user strong {
  color: var(--text);
}

.segmented,
.engine-toggle span {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-soft);
  min-width: 48px;
  min-height: 32px;
  padding: 6px 10px;
  font-weight: 700;
}

.segmented.active,
.engine-toggle input:checked + span {
  color: #ffffff;
  background: var(--ink);
}

.engine-toggle label {
  display: block;
}

.engine-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.section-band,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.section-band {
  padding: 20px;
  margin-bottom: 18px;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  margin-bottom: 18px;
}

.section-grid.wide-left {
  grid-template-columns: minmax(0, 1.1fr) 420px;
}

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

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

.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  padding: 14px;
  min-height: 104px;
}

.metric-label {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.metric-value {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 800;
}

.metric-note,
.status-pill {
  color: var(--text-soft);
  font-size: 12px;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  padding: 5px 10px;
  white-space: nowrap;
}

.chart-panel {
  display: grid;
  grid-template-columns: repeat(7, minmax(36px, 1fr));
  gap: 8px;
  align-items: end;
  min-height: 184px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.bar-wrap {
  display: grid;
  gap: 8px;
  align-items: end;
  height: 150px;
}

.bar {
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--green), #8cc6a8);
  min-height: 8px;
}

.bar-label {
  color: var(--text-faint);
  font-size: 11px;
  text-align: center;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.action-list,
.geo-list,
.report-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.action-item,
.geo-item,
.report-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  padding: 12px;
}

.item-title {
  font-weight: 750;
}

.item-meta {
  color: var(--text-soft);
  font-size: 13px;
  margin-top: 4px;
}

.badge-row,
.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-soft);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.badge.good {
  background: rgba(31, 138, 91, 0.12);
  color: var(--green);
}

.badge.warn {
  background: rgba(183, 121, 31, 0.14);
  color: var(--amber);
}

.badge.bad {
  background: rgba(194, 65, 59, 0.12);
  color: var(--red);
}

.form-panel {
  display: grid;
  gap: 10px;
  align-content: start;
}

.check-row label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--text-soft);
  font-weight: 700;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  color: #ffffff;
  background: var(--ink);
  font-weight: 800;
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-panel .brand {
  margin-bottom: 28px;
}

.login-panel h1 {
  margin-top: 8px;
}

.login-panel .subtitle,
.login-panel .form-errors,
.login-panel .empty {
  margin-top: 10px;
}

.login-button {
  width: 100%;
  margin-top: 18px;
}

.form-errors {
  color: var(--red);
  font-size: 13px;
  min-height: 20px;
}

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

.empty,
.loading {
  color: var(--text-soft);
  padding: 18px 0;
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .section-grid,
  .section-grid.wide-left,
  .report-grid {
    grid-template-columns: 1fr;
  }

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

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

  .topbar,
  .section-heading,
  .panel-header {
    display: grid;
  }

  .topbar-actions {
    justify-items: stretch;
  }

  .session-user {
    max-width: none;
  }

  .metric-grid,
  .nav-list {
    grid-template-columns: 1fr;
  }

  .chart-panel {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
