body.admin-body {
  background: radial-gradient(circle at 20% 20%, #eef2ff 0, #f8fafc 35%, #f8fafc 100%);
  color: #0f172a;
  min-height: 100vh;
  font-family: 'Open Sans', sans-serif;
  margin: 0;
}

* {
  box-sizing: border-box;
}

h1,
h2,
h3,
p,
ul {
  margin-top: 0;
}

.admin-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid #0b1b32;
  background: linear-gradient(135deg, #0f172a, #102540);
  color: #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #e2e8f0;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-logo img {
  height: 40px;
  width: auto;
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}

.admin-brand .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(120deg, #0ea5e9, #06b6d4);
  display: inline-block;
}

.admin-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-links a {
  color: #e2e8f0;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}

.pill-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #fff;
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 10px 25px rgba(14, 165, 233, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pill-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(14, 165, 233, 0.3);
}

.pill-button.secondary {
  background: #0f172a;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.2);
}

.auth-wrapper {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 3rem 1.5rem 4rem;
}

.auth-card {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 2rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

.auth-card h1 {
  font-family: 'Oswald', sans-serif;
  letter-spacing: 0.01em;
}

.auth-card p {
  margin-top: 0.4rem;
  color: #475569;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-field label {
  font-weight: 700;
  color: #0f172a;
}

.form-field input {
  padding: 0.85rem 0.9rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
  background: #f8fafc;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}

.form-field input:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15);
  background: #fff;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.subtle-link {
  color: #0f172a;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: #cbd5e1;
}

.form-hint {
  font-size: 0.9rem;
  color: #64748b;
  margin-top: 0.5rem;
}

.admin-main {
  flex: 1;
  padding: 2.25rem 1.5rem 3.5rem;
}

.admin-layout {
  width: min(1250px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.admin-body.is-loading-live .admin-layout > * {
  display: none !important;
}

.admin-body.is-loading-live .admin-layout::before {
  content: "";
  display: inline-block;
  width: 42px;
  height: 42px;
  border: 4px solid #dbeafe;
  border-top-color: #0ea5e9;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  justify-self: start;
}

.admin-body.is-loading-live .admin-layout::after {
  content: "Loading current KPI data...";
  display: block;
  background: #fff;
  border: 1px solid #dbe3ee;
  border-radius: 14px;
  padding: 1.25rem;
  color: #0f172a;
  font-weight: 800;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
}

.admin-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-header .eyebrow {
  letter-spacing: 0.08em;
  color: #0ea5e9;
  text-transform: uppercase;
}

.admin-hero {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #e2e8f0;
  border-radius: 18px;
  padding: 1.5rem 1.75rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-hero h1 {
  font-family: 'Oswald', sans-serif;
  letter-spacing: 0.01em;
}

.status-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.meta-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.95rem;
}

.live-status.fresh {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(134, 239, 172, 0.45);
}

.live-status.loading {
  background: rgba(14, 165, 233, 0.18);
  border-color: rgba(125, 211, 252, 0.45);
}

.live-status.stale {
  background: rgba(251, 146, 60, 0.18);
  border-color: rgba(253, 186, 116, 0.5);
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  background: #0f172a;
  padding: 0.75rem;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.15);
}

.tab-group {
  display: grid;
  gap: 0.4rem;
  align-content: start;
  padding: 0.35rem;
  border: 1px solid rgba(226, 232, 240, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.tab-group-label {
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 0.25rem;
}

.tab-group-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tab-button {
  appearance: none;
  border: 1px solid rgba(226, 232, 240, 0.4);
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.tab-button:hover {
  transform: translateY(-1px);
}

.tab-button.is-active {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  border-color: #38bdf8;
  color: #fff;
  box-shadow: 0 10px 25px rgba(14, 165, 233, 0.35);
}

.tab-loading {
  align-self: center;
  color: #cbd5e1;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.45rem 0.65rem;
}

.dashboard-loading-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #fff;
  border: 1px solid #dbe3ee;
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
}

.dashboard-loading-card h2 {
  font-family: 'Oswald', sans-serif;
  margin-bottom: 0.25rem;
}

.dashboard-loading-card p {
  color: #64748b;
  margin-bottom: 0;
}

.loading-spinner {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 4px solid #dbeafe;
  border-top-color: #0ea5e9;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-spinner.is-paused {
  animation-play-state: paused;
  opacity: 0.55;
}

.error-state {
  align-items: start;
  border-color: #fed7aa;
  background: #fff7ed;
}

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

.dashboard-panel {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
}

.dashboard-panel.is-active {
  display: flex;
}

.spotlight {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #e2e8f0;
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: 0 18px 45px rgba(14, 165, 233, 0.25);
  display: grid;
  gap: 0.65rem;
}

.spotlight h2, .spotlight h3 {
  font-family: 'Oswald', sans-serif;
}

.progress-wrap {
  display: grid;
  gap: 0.6rem;
}

.progress-row {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.75rem;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.progress-bar {
  margin-top: 0.45rem;
  height: 10px;
  width: 100%;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(135deg, #bef264, #22c55e);
  border-radius: 999px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: #fff;
  border-radius: 16px;
  padding: 1.25rem;
  border: 1px solid #e5e7eb;
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.06);
  display: grid;
  gap: 0.35rem;
}

.kpi-card h3 {
  font-family: 'Oswald', sans-serif;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: #0f172a;
}

.kpi-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
}

.badge.good {
  background: #ecfeff;
  color: #0f172a;
  border: 1px solid #0ea5e9;
}

.badge.caution {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fb923c;
}

.badge.alert {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.badge.poor {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fda4af;
}

.badge.critical {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.kpi-target {
  color: #475569;
  font-size: 0.95rem;
}

.section-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  padding: 1.5rem;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
  display: grid;
  gap: 0.75rem;
}

.list-grid {
  display: grid;
  gap: 0.5rem;
}

.list-grid li {
  list-style: none;
  padding: 0.5rem 0;
  border-bottom: 1px dashed #e2e8f0;
}

.list-grid li:last-child {
  border-bottom: none;
}

.user-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.user-chip {
  padding: 0.35rem 0.6rem;
  border-radius: 10px;
  background: #e2e8f0;
  font-weight: 700;
}

@media (max-width: 900px) {
  .admin-topbar {
    padding: 1rem 1.25rem;
  }

  .admin-main {
    padding: 1.75rem 1.25rem 3rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

@media (max-width: 600px) {
  .auth-card {
    padding: 1.5rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

.data-table {
  display: grid;
  gap: 0.75rem;
}

.data-row {
  display: grid;
  grid-template-columns: 1.2fr 0.6fr 0.6fr 0.8fr 0.9fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}

.data-row.header {
  background: #0f172a;
  color: #e2e8f0;
  border: none;
  box-shadow: none;
  font-weight: 700;
}

.data-row input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  font: inherit;
}

.data-row.has-override {
  border-color: #0ea5e9;
  box-shadow: 0 8px 20px rgba(14, 165, 233, 0.12);
}

.badge.fresh {
  background: #ecfdf3;
  color: #166534;
  border: 1px solid #86efac;
}

.badge.stale {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fb923c;
}

.badge.expired {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.section-divider {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed #cbd5e1;
}

@media (max-width: 900px) {
  .data-row {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  z-index: 50;
}

.modal[hidden] {
  display: none !important;
}

.modal-dialog {
  background: #fff;
  width: min(720px, 100%);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 1rem;
}

.modal-close {
  align-self: start;
  justify-self: end;
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}

.history-wrapper h3 {
  margin-bottom: 0.25rem;
}

.history-list {
  display: grid;
  gap: 0.5rem;
}

.history-row {
  display: flex;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f8fafc;
}

.history-refs h4 {
  margin-bottom: 0.35rem;
}

.history-refs ul {
  padding-left: 1rem;
}

.compact-list li {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto minmax(220px, 2fr);
  gap: 0.75rem;
  align-items: center;
}

.compact-list li span:last-child {
  color: #64748b;
  font-size: 0.92rem;
}

.data-row [data-name] {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: #cbd5e1;
}

.history-chart {
  display: grid;
  gap: 0.35rem;
}

.history-chart-row {
  display: grid;
  grid-template-columns: 1.2fr 4fr 0.8fr;
  gap: 0.5rem;
  align-items: center;
}

.history-bar {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.history-bar-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
}

.dashboard-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0;
}

.dashboard-title-row h2 {
  max-width: 850px;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  line-height: 1.2;
  color: #0f172a;
}

.live-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 1rem;
}

.live-metric-card {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid #dbe3ee;
  border-radius: 14px;
  padding: 1rem;
  min-height: 170px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
  display: grid;
  gap: 0.35rem;
}

.metric-accent {
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: var(--accent, #1f4e79);
}

.metric-period {
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-left: 0.25rem;
}

.live-metric-card h3 {
  font-family: 'Oswald', sans-serif;
  font-size: 1.08rem;
  color: #172033;
  margin-left: 0.25rem;
}

.live-metric-value {
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  font-weight: 900;
  color: #0f172a;
  line-height: 1;
  margin-left: 0.25rem;
}

.metric-context {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-left: 0.25rem;
}

.metric-context span {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 0.35rem;
  align-items: baseline;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-size: 0.85rem;
}

.metric-context strong {
  color: #64748b;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.metric-note {
  color: #64748b;
  font-size: 0.9rem;
  margin: 0.2rem 0 0 0.25rem;
}

.live-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 1rem;
}

.live-chart-card,
.live-table-card {
  background: #fff;
  border: 1px solid #dbe3ee;
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.chart-header h3,
.live-table-card h3 {
  font-family: 'Oswald', sans-serif;
  font-size: 1.1rem;
  color: #0f172a;
}

.chart-header span {
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.mini-chart {
  display: grid;
  gap: 0.55rem;
}

.mini-chart-row {
  display: grid;
  grid-template-columns: minmax(92px, 1.2fr) minmax(120px, 3fr) minmax(70px, auto);
  gap: 0.65rem;
  align-items: center;
}

.mini-chart-label,
.mini-chart-value {
  font-size: 0.86rem;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-chart-value {
  justify-self: end;
  font-weight: 800;
  color: #0f172a;
}

.mini-chart-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.mini-chart-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1f4e79, #0ea5e9);
}

.lineish .mini-chart-fill {
  background: linear-gradient(90deg, #0f766e, #22c55e);
}

.diverging-chart {
  display: grid;
  gap: 0.6rem;
}

.diverging-row {
  display: grid;
  grid-template-columns: minmax(92px, 1.2fr) minmax(150px, 3fr) minmax(70px, auto);
  gap: 0.65rem;
  align-items: center;
}

.diverging-track {
  position: relative;
  height: 14px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.zero-line {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 50%;
  width: 2px;
  background: #0f172a;
  opacity: 0.45;
  z-index: 2;
}

.diverging-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
}

.diverging-fill.positive {
  background: linear-gradient(90deg, #16a34a, #86efac);
}

.diverging-fill.negative {
  background: linear-gradient(90deg, #fca5a5, #dc2626);
}

.live-table-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

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

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

.responsive-table th,
.responsive-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

.responsive-table th {
  background: #f1f5f9;
  color: #334155;
  font-weight: 900;
  position: sticky;
  top: 0;
}

.responsive-table td {
  color: #172033;
}

.responsive-table td:first-child {
  padding-left: calc(0.75rem + (var(--indent, 0) * 1.15rem));
  white-space: nowrap;
}

.responsive-table tr.is-section td {
  background: #f8fafc;
  color: #0f172a;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.responsive-table tr.is-bold td {
  font-weight: 800;
}

.responsive-table tr.is-total td {
  border-top: 2px solid #cbd5e1;
  border-bottom-color: #cbd5e1;
  background: #f1f5f9;
  font-weight: 900;
}

.responsive-table tr.is-total td:last-child,
.responsive-table tr.is-bold td:last-child {
  color: #0f172a;
}

.empty-state {
  color: #64748b;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 1rem;
}

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

  .dashboard-title-row {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .mini-chart-row,
  .diverging-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .mini-chart-value {
    justify-self: start;
  }
}
