:root {
  --bg: #0b1220;
  --bg-soft: #111a2c;
  --surface: #ffffff;
  --surface-soft: #f5f7fb;
  --border: #e3e8f1;
  --text: #111827;
  --muted: #667085;
  --primary: #2251ff;
  --primary-dark: #183ed0;
  --primary-soft: #edf2ff;
  --good: #0e9f6e;
  --good-soft: #e9fbf4;
  --warn: #d97706;
  --warn-soft: #fff6e5;
  --danger: #d92d20;
  --danger-soft: #fff0ee;
  --info: #2563eb;
  --info-soft: #eef5ff;
  --shadow: 0 18px 50px rgba(15, 23, 42, .08);
  --radius: 18px;
  --sidebar-width: 264px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--surface-soft);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow {
  margin: 0 0 6px;
  color: #667085;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
}
.mobile-only { display: none; }

/* AUTH */
.auth-page {
  background:
    radial-gradient(circle at 15% 20%, rgba(55, 94, 255, .28), transparent 35%),
    radial-gradient(circle at 85% 85%, rgba(0, 190, 160, .16), transparent 35%),
    var(--bg);
  color: #fff;
}

.auth-shell {
  width: min(1120px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 70px;
  align-items: center;
}

.auth-brand h1 {
  max-width: 650px;
  margin: 18px 0 14px;
  font-size: clamp(42px, 6vw, 74px);
  line-height: .98;
  letter-spacing: -.05em;
}

.auth-copy { max-width: 560px; font-size: 17px; line-height: 1.7; color: #aab6ce; }

.brand-mark {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(145deg, #315dff, #173dd8);
  color: #fff;
  font-weight: 900;
  letter-spacing: -.04em;
  box-shadow: 0 16px 45px rgba(34, 81, 255, .32);
}

.brand-mark--small { width: 42px; height: 42px; border-radius: 12px; font-size: 13px; }

.auth-security-note {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  margin-top: 26px;
  color: #b9c4d8;
  font-size: 13px;
}

.auth-card {
  background: #fff;
  color: var(--text);
  border-radius: 26px;
  padding: 38px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .28);
}

.auth-card__head h2 { margin: 3px 0 8px; font-size: 30px; letter-spacing: -.03em; }
.auth-card__head { margin-bottom: 26px; }

.field { display: block; margin: 18px 0; }
.field > span, .field-label {
  display: block;
  margin-bottom: 8px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.field input, .region-select-wrap select {
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 12px;
  background: #fff;
  padding: 12px 14px;
  outline: none;
  transition: .18s ease;
}

.field input:focus, .region-select-wrap select:focus {
  border-color: #84a0ff;
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.password-wrap { position: relative; }
.password-wrap input { padding-right: 70px; }
.password-wrap .icon-button { position: absolute; right: 7px; top: 7px; }

.partner-picker {
  padding: 14px;
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}
.partner-options { display: grid; gap: 8px; }
.partner-option {
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.partner-option:hover { border-color: #9db1ff; background: var(--primary-soft); }
.partner-option strong, .partner-option span { display: block; }
.partner-option span { margin-top: 3px; color: var(--muted); font-size: 12px; }

.auth-footnote {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

/* BUTTONS */
.button, .icon-button {
  border: 0;
  border-radius: 11px;
  transition: .16s ease;
}

.button { padding: 11px 15px; font-weight: 750; }
.button:disabled { opacity: .55; cursor: wait; }
.button--wide { width: 100%; }
.button--primary { background: var(--primary); color: #fff; }
.button--primary:hover { background: var(--primary-dark); }
.button--secondary { background: var(--primary-soft); color: var(--primary); }
.button--secondary:hover { background: #dfe8ff; }
.button--ghost { background: rgba(255,255,255,.08); color: #dce5f5; }
.button--ghost:hover { background: rgba(255,255,255,.14); }

.icon-button {
  background: #f2f4f7;
  color: #344054;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 750;
}

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  margin: 14px 0;
  font-size: 13px;
  line-height: 1.5;
}
.alert--danger { color: #8b1e16; background: var(--danger-soft); border: 1px solid #ffcfc8; }
.alert--warn { color: #854d0e; background: var(--warn-soft); border: 1px solid #fde2a8; }
.alert--info { color: #1d4ed8; background: var(--info-soft); border: 1px solid #cfe0ff; }
.alert--good { color: #087a55; background: var(--good-soft); border: 1px solid #bdebd9; }

/* APP SHELL */
.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: #fff;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 24px;
}
.sidebar__brand strong, .sidebar__brand span { display: block; }
.sidebar__brand strong { font-size: 14px; }
.sidebar__brand span { margin-top: 2px; font-size: 11px; color: #94a3b8; }

.nav { display: grid; gap: 4px; }
.nav-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #aebbd0;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
}
.nav-button:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-button.active { color: #fff; background: rgba(70, 106, 255, .22); }
.nav-icon {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255,255,255,.07);
  font-size: 10px;
  font-weight: 900;
}

.sidebar__footer { margin-top: auto; padding: 16px 6px 0; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.avatar {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #30415d;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}
.sidebar-user__meta { min-width: 0; }
.sidebar-user__meta strong, .sidebar-user__meta span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user__meta strong { font-size: 12px; }
.sidebar-user__meta span { margin-top: 2px; color: #8ea0bc; font-size: 10px; }

.main { margin-left: var(--sidebar-width); min-height: 100vh; padding: 0 34px 26px; }

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(245,247,251,.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(227,232,241,.85);
}
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.topbar__left, .topbar__actions { display: flex; align-items: center; gap: 12px; }
.region-select-wrap span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 10px; font-weight: 700; }
.region-select-wrap select { min-width: 200px; padding: 8px 11px; border-radius: 10px; font-size: 12px; }

.state-stack { display: grid; gap: 8px; margin: 20px 0 0; }

.view { padding-top: 20px; }

.hero-card {
  min-height: 156px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  padding: 28px;
  border-radius: 22px;
  color: #fff;
  background:
    radial-gradient(circle at 80% 10%, rgba(106, 139, 255, .45), transparent 30%),
    linear-gradient(135deg, #111d36, #172c57);
  box-shadow: var(--shadow);
}
.hero-card h2 { margin: 2px 0 6px; font-size: clamp(26px, 4vw, 40px); letter-spacing: -.04em; }
.hero-card .muted { color: #b9c7de; }
.hero-card .eyebrow { color: #9fb2d4; }

.hero-meta { display: grid; grid-template-columns: repeat(3, minmax(90px, 1fr)); gap: 8px; }
.hero-meta > div {
  min-width: 118px;
  padding: 13px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.08);
}
.hero-meta span, .hero-meta strong { display: block; }
.hero-meta span { color: #aabbd6; font-size: 10px; }
.hero-meta strong { margin-top: 5px; font-size: 12px; }

.section-heading {
  margin: 28px 0 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}
.section-heading h2 { margin: 0; font-size: 21px; letter-spacing: -.03em; }
.freshness { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
  background: #98a2b3;
}
.status-dot--good { background: var(--good); box-shadow: 0 0 0 4px rgba(14,159,110,.12); }
.status-dot--warn { background: var(--warn); box-shadow: 0 0 0 4px rgba(217,119,6,.11); }
.status-dot--danger { background: var(--danger); box-shadow: 0 0 0 4px rgba(217,45,32,.1); }

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

.metric-card, .panel, .detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(15,23,42,.035);
}

.metric-card { padding: 18px; }
.metric-card__head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  color: var(--muted); font-size: 11px; font-weight: 750;
}
.metric-card__value {
  margin-top: 12px;
  font-size: 31px;
  font-weight: 850;
  letter-spacing: -.04em;
}
.metric-card__foot { margin-top: 8px; color: var(--muted); font-size: 11px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .03em;
}
.badge--good { color: #087a55; background: var(--good-soft); }
.badge--warn { color: #9a5b08; background: var(--warn-soft); }
.badge--danger { color: #9b291f; background: var(--danger-soft); }
.badge--info { color: #1d4ed8; background: var(--info-soft); }
.badge--neutral { color: #475467; background: #f2f4f7; }

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
  margin-top: 14px;
}
.panel { padding: 20px; min-height: 190px; }
.panel--wide { grid-column: span 2; }
.panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.panel__head h3 { margin: 0; font-size: 15px; }
.panel__head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }

.kv-list { display: grid; gap: 10px; }
.kv-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid #eef1f5;
  font-size: 12px;
}
.kv-row:last-child { border-bottom: 0; }
.kv-row span { color: var(--muted); }
.kv-row strong { text-align: right; }

.detail-card { padding: 22px; }
.detail-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.detail-title-row h2 { margin: 0; font-size: 22px; }
.detail-title-row p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

.data-table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th, .data-table td {
  padding: 11px 10px;
  border-bottom: 1px solid #eef1f5;
  text-align: left;
  white-space: nowrap;
}
.data-table th { color: var(--muted); font-size: 10px; letter-spacing: .04em; text-transform: uppercase; }

.empty {
  min-height: 170px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px;
  color: var(--muted);
  border: 1px dashed #d5dbe5;
  border-radius: 14px;
  background: #fafbfc;
}
.empty strong { display: block; margin-bottom: 5px; color: #344054; }

.app-footer {
  padding: 26px 2px 0;
  display: flex; justify-content: space-between; gap: 14px;
  color: #98a2b3;
  font-size: 10px;
}

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; }
.toast {
  width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 12px;
  background: #101828;
  color: #fff;
  box-shadow: 0 14px 40px rgba(0,0,0,.22);
  font-size: 12px;
}

/* responsive */
.mobile-overlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(3, 8, 20, .55);
}

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .hero-card { align-items: flex-start; flex-direction: column; }
  .hero-meta { width: 100%; }
}

@media (max-width: 820px) {
  .auth-shell { grid-template-columns: 1fr; gap: 32px; padding: 50px 0; }
  .auth-brand h1 { font-size: 50px; }
  .sidebar { transform: translateX(-101%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 0 18px 22px; }
  .mobile-only { display: inline-block; }
  .topbar { min-height: 78px; }
  .topbar__actions { gap: 7px; }
  .region-select-wrap span { display: none; }
  .region-select-wrap select { min-width: 145px; max-width: 42vw; }
}

@media (max-width: 620px) {
  .auth-shell { width: min(100% - 28px, 520px); }
  .auth-brand { padding: 8px 5px 0; }
  .auth-brand h1 { font-size: 42px; }
  .auth-card { padding: 25px 20px; border-radius: 20px; }
  .topbar__actions .button { padding: 9px 10px; font-size: 11px; }
  .topbar h1 { font-size: 20px; }
  .metric-grid, .panel-grid { grid-template-columns: 1fr; }
  .panel--wide { grid-column: span 1; }
  .hero-card { padding: 22px; }
  .hero-meta { grid-template-columns: 1fr; }
  .hero-meta > div { min-width: 0; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .app-footer { flex-direction: column; }
}
