:root {
  --navy: #172033;
  --navy-2: #222c42;
  --blue: #2f6bff;
  --blue-soft: #edf3ff;
  --green: #1f8a70;
  --red: #d65454;
  --amber: #b7791f;
  --text: #1f2937;
  --muted: #667085;
  --line: #e6e9ef;
  --bg: #f5f7fa;
  --white: #ffffff;
  --shadow: 0 16px 45px rgba(23, 32, 51, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

button, input { font: inherit; }

button { cursor: pointer; }

.is-hidden { display: none !important; }

.eyebrow {
  display: block;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.eyebrow.light { color: rgba(255,255,255,.68); }

.muted { color: var(--muted); }

.strong { font-weight: 700; }

.right { text-align: right; }

/* Login */
.login-page {
  min-height: 100vh;
  background: var(--white);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 44%) 1fr;
}

.login-brand-panel {
  padding: clamp(42px, 7vw, 96px);
  background:
    radial-gradient(circle at 20% 15%, rgba(47,107,255,.28), transparent 32%),
    linear-gradient(145deg, #111827 0%, #172033 55%, #202b43 100%);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-brand-panel h1 {
  margin: 12px 0 18px;
  font-size: clamp(42px, 5.3vw, 76px);
  line-height: .96;
  letter-spacing: -.055em;
}

.login-brand-panel p {
  max-width: 460px;
  color: rgba(255,255,255,.66);
  font-size: 17px;
  line-height: 1.6;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--blue);
  font-weight: 900;
  letter-spacing: -.04em;
}

.brand-mark-large {
  width: 62px;
  height: 62px;
  border-radius: 17px;
  font-size: 19px;
}

.login-security-note {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.62);
  font-size: 13px;
}

.security-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 5px rgba(74,222,128,.10);
}

.login-form-panel {
  display: grid;
  place-items: center;
  padding: 42px;
}

.login-card { width: min(430px, 100%); }

.login-card h2 {
  margin: 10px 0 8px;
  color: var(--navy);
  font-size: 34px;
  letter-spacing: -.035em;
}

.login-form {
  margin-top: 32px;
  display: grid;
  gap: 20px;
}

.login-form label > span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
}

.login-form input,
.custom-filter input,
.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  outline: none;
  transition: .2s ease;
}

.login-form input {
  height: 52px;
  padding: 0 15px;
  border-radius: 12px;
}

.login-form input:focus,
.custom-filter input:focus,
.search-box:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(47,107,255,.10);
}

.password-field { position: relative; }

.password-field input { padding-right: 52px; }

.icon-button {
  position: absolute;
  right: 8px;
  top: 7px;
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  border-radius: 9px;
}

.primary-button,
.secondary-button,
.logout-button {
  border: 0;
  border-radius: 11px;
  font-weight: 750;
}

.primary-button {
  min-height: 52px;
  padding: 0 20px;
  background: var(--blue);
  color: white;
  box-shadow: 0 12px 28px rgba(47,107,255,.22);
}

.primary-button:disabled { opacity: .65; cursor: wait; }

.form-message {
  min-height: 22px;
  font-size: 13px;
}

.form-message.error {
  padding: 11px 13px;
  color: #a42d2d;
  background: #fff0f0;
  border-radius: 9px;
}

.login-footnote {
  margin-top: 25px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* Dashboard */
.dashboard-page { background: var(--bg); }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
  padding: 24px 16px 18px;
  background: var(--navy);
  color: white;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 28px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand > div:last-child {
  display: grid;
  gap: 2px;
}

.sidebar-brand strong { font-size: 16px; }
.sidebar-brand span { color: rgba(255,255,255,.52); font-size: 12px; }

.sidebar-nav {
  display: grid;
  gap: 5px;
  padding-top: 22px;
}

.nav-item {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 13px;
  border: 0;
  border-radius: 11px;
  color: rgba(255,255,255,.62);
  background: transparent;
  text-align: left;
  transition: .18s ease;
}

.nav-item:hover { background: rgba(255,255,255,.06); color: white; }
.nav-item.active { background: var(--blue); color: white; }

.nav-icon {
  width: 22px;
  text-align: center;
  font-size: 17px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 18px 8px 0;
  border-top: 1px solid rgba(255,255,255,.08);
}

.connection-status {
  margin-bottom: 13px;
  color: rgba(255,255,255,.50);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.connection-status span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
}

.logout-button {
  width: 100%;
  padding: 10px 12px;
  color: rgba(255,255,255,.72);
  background: rgba(255,255,255,.06);
}

.main-area { min-width: 0; }

.topbar {
  min-height: 82px;
  padding: 18px clamp(20px, 3vw, 38px);
  background: white;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.topbar h1 {
  margin: 3px 0 0;
  color: var(--navy);
  font-size: 22px;
  letter-spacing: -.02em;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: right;
}

.topbar-user > div:first-child {
  display: grid;
  gap: 2px;
}

.topbar-user strong { font-size: 13px; }
.topbar-user span { color: var(--muted); font-size: 11px; }

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
}

.menu-button {
  display: none;
  border: 0;
  background: var(--bg);
  border-radius: 9px;
  width: 40px;
  height: 40px;
}

.content {
  padding: clamp(20px, 3vw, 38px);
  max-width: 1680px;
  margin: 0 auto;
}

.filter-card,
.panel,
.kpi-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.filter-card {
  margin-bottom: 20px;
  padding: 17px 20px;
  display: grid;
  gap: 14px;
}

.filter-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.filter-heading strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
  color: var(--navy);
}

.quick-filters {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.quick-filters button {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.quick-filters button.active {
  color: var(--blue);
  border-color: rgba(47,107,255,.25);
  background: var(--blue-soft);
}

.custom-filter {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.custom-filter label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.custom-filter input {
  height: 38px;
  padding: 0 10px;
  border-radius: 9px;
}

.secondary-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  color: var(--navy);
  background: white;
}

.dashboard-section { display: none; }
.dashboard-section.active { display: block; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

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

.kpi-card {
  padding: 20px;
  min-height: 136px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 3px 15px rgba(23,32,51,.025);
}

.primary-kpi {
  background: linear-gradient(135deg, #2458dd, #2f6bff);
  border-color: transparent;
  color: white;
}

.primary-kpi .kpi-label,
.primary-kpi .kpi-meta { color: rgba(255,255,255,.72); }

.warning-kpi { border-top: 3px solid #f0a93b; }

.kpi-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kpi-value {
  margin: 8px 0;
  color: var(--navy);
  font-size: clamp(24px, 2vw, 31px);
  line-height: 1.05;
  font-weight: 820;
  letter-spacing: -.035em;
}

.primary-kpi .kpi-value { color: white; }

.kpi-meta {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.kpi-meta.positive { color: var(--green); font-weight: 750; }
.kpi-meta.negative { color: var(--red); font-weight: 750; }

.dashboard-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.dashboard-grid.two-one { grid-template-columns: 1.65fr .75fr; }
.dashboard-grid.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.panel {
  padding: 20px;
  box-shadow: 0 3px 15px rgba(23,32,51,.025);
  overflow: hidden;
}

.panel-head {
  min-height: 44px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 15px;
}

.panel-head h3 {
  margin: 4px 0 0;
  color: var(--navy);
  font-size: 17px;
  letter-spacing: -.02em;
}

.chart-wrap {
  position: relative;
  height: 320px;
}

.donut-wrap { height: 320px; }

.highlight-list { display: grid; }

.highlight-item {
  min-height: 69px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.highlight-item:last-child { border-bottom: 0; }

.highlight-item > div { display: grid; gap: 4px; }
.highlight-item span { font-size: 12px; font-weight: 750; }
.highlight-item small { color: var(--muted); line-height: 1.35; }
.highlight-item strong { color: var(--navy); font-size: 17px; text-align: right; }

.section-heading {
  margin: 9px 0 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 15px;
}

.section-heading h2 {
  margin: 4px 0 0;
  font-size: 28px;
  color: var(--navy);
  letter-spacing: -.035em;
}

.table-scroll {
  width: 100%;
  overflow: auto;
}

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

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

th {
  color: var(--muted);
  text-align: left;
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

tbody tr:hover { background: #fafbfc; }

.pill {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 10px;
  font-weight: 800;
}

.empty-cell {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.search-box {
  width: min(330px, 100%);
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.search-box input {
  height: 100%;
  padding: 0;
  border: 0;
  box-shadow: none !important;
}

.info-note {
  padding: 14px 16px;
  border: 1px solid #f2dfbd;
  background: #fff9ec;
  color: #805d20;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.55;
}

.insight-list { display: grid; }

.insight-item {
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: start;
}

.insight-item:last-child { border-bottom: 0; }

.insight-item > span {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 10px;
  font-weight: 900;
}

.insight-item.alert > span {
  color: #9a6112;
  background: #fff3d6;
}

.insight-item p {
  margin: 3px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 12px;
}

.insight-item p strong { color: var(--navy); }

.coverage-panel { margin-bottom: 40px; }

.coverage-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.coverage-grid > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 6px;
}

.coverage-grid strong { font-size: 12px; color: var(--navy); }
.coverage-grid span { font-size: 11px; color: var(--muted); line-height: 1.45; }

.error-banner {
  margin-bottom: 18px;
  padding: 14px 16px;
  color: #a42d2d;
  background: #fff0f0;
  border: 1px solid #f2caca;
  border-radius: 12px;
  font-size: 13px;
}

.app-loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: var(--muted);
}

.loader {
  width: 34px;
  height: 34px;
  border: 3px solid #dfe4ed;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid.compact { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid.two-one { grid-template-columns: 1fr; }
  .coverage-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand-panel { min-height: 330px; padding: 38px 28px; }
  .login-brand-panel h1 { font-size: 48px; }
  .login-form-panel { padding: 44px 24px; }

  .app-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 250px;
    transform: translateX(-105%);
    transition: .22s ease;
    box-shadow: 20px 0 50px rgba(0,0,0,.18);
  }

  .sidebar-open .sidebar { transform: translateX(0); }

  .menu-button { display: grid; place-items: center; }

  .topbar { padding: 15px 18px; justify-content: flex-start; }
  .topbar-user { margin-left: auto; }
  .topbar-user > div:first-child { display: none; }

  .content { padding: 18px; }

  .dashboard-grid.equal { grid-template-columns: 1fr; }
  .coverage-grid { grid-template-columns: 1fr; }
}

@media (max-width: 580px) {
  .kpi-grid,
  .kpi-grid.compact { grid-template-columns: 1fr; }

  .filter-heading { align-items: flex-start; }
  .filter-heading .secondary-button { white-space: nowrap; font-size: 11px; }

  .custom-filter { display: grid; grid-template-columns: 1fr 1fr; }
  .custom-filter .secondary-button { grid-column: 1 / -1; }

  .section-heading { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }

  .chart-wrap { height: 285px; }
}
