:root {
  --navy: #0B2D5B;
  --navy-mid: #0D3568;
  --teal: #00A8B5;
  --teal-bright: #00B4C6;
  --bg: #F4F8FC;
  --surface: #FFFFFF;
  --surface-soft: #EEF4FA;
  --border: #DCE6F2;
  --text: #0F233E;
  --text-muted: #5A6F89;
  --success: #0E9F6E;
  --warning: #D97706;
  --danger: #DC2626;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.app-shell {
  max-width: 1040px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
}

.top-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 24px rgba(11, 45, 91, 0.16);
}

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

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #fff;
  padding: 3px;
  object-fit: contain;
}

.brand-text h1 {
  font-size: 1.25rem;
  letter-spacing: 0.06em;
  font-weight: 800;
}

.brand-text p {
  font-size: 0.88rem;
  color: #CFE6F7;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.pill-teal {
  background: rgba(0, 180, 198, 0.22);
  color: #9FF6FF;
  border: 1px solid rgba(0, 180, 198, 0.45);
}

.pill-navy {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
}

.tab-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 5px;
  gap: 6px;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: var(--navy);
  color: #fff;
}

.main-content {
  flex: 1;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

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

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 2px 10px rgba(11, 45, 91, 0.04);
}

.card + .card,
.stack > * + * {
  margin-top: 14px;
}

.card-title {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.metric-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--navy);
}

.metric-unit {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 4px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.badge-ok { background: #E6F7F1; color: var(--success); }
.badge-warn { background: #FEF3C7; color: var(--warning); }
.badge-danger { background: #FEE2E2; color: var(--danger); }
.badge-info { background: #E0F7FA; color: #007A85; }
.badge-neutral { background: var(--surface-soft); color: var(--navy); }

.progress-track {
  width: 100%;
  height: 10px;
  background: var(--surface-soft);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--navy));
  transition: width 0.3s ease;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--surface-soft);
  gap: 12px;
}

.kv-row:last-child {
  border-bottom: none;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
}

.btn-teal {
  background: var(--teal);
  color: #fff;
}

.btn-secondary {
  background: var(--surface-soft);
  color: var(--navy);
}

.segmented {
  display: inline-flex;
  background: var(--surface-soft);
  border-radius: 10px;
  padding: 3px;
  gap: 4px;
}

.segmented button {
  border: none;
  background: transparent;
  padding: 7px 12px;
  border-radius: 8px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.segmented button.active {
  background: var(--navy);
  color: #fff;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #CBD5E1;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.switch input:checked + .slider {
  background: var(--teal);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

.subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.list-item {
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.list-item + .list-item {
  margin-top: 8px;
}

.step-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.step-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
}

.app-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 8px 0 4px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(11, 45, 91, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal.hidden {
  display: none;
}

.modal-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-chip {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--navy);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 600px) {
  .tab-btn {
    font-size: 0.82rem;
    padding: 9px 4px;
  }
}
