:root {
  --ink: #17151f;
  --muted: #667085;
  --line: #e7e7ee;
  --bg: #f6f6f9;
  --surface: #ffffff;
  --purple-900: #24125d;
  --purple-800: #2d176e;
  --purple-700: #39208a;
  --purple-100: #ede9ff;
  --cyan: #2dd4bf;
  --gold: #b78a2d;
  --red: #b42318;
  --red-bg: #fee4e2;
  --amber: #b7791f;
  --amber-bg: #fff4d5;
  --green: #047857;
  --green-bg: #dcfce7;
  --shadow: 0 18px 42px rgba(16, 24, 40, 0.09);
  --soft-shadow: 0 8px 24px rgba(16, 24, 40, 0.07);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 26px;
  height: 100vh;
  padding: 24px 18px;
  background: linear-gradient(180deg, #17151f 0%, var(--purple-900) 100%);
}

.brand-card {
  display: grid;
  place-items: center;
  min-height: 128px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: var(--soft-shadow);
}

.brand-card img {
  width: min(188px, 100%);
  height: auto;
  display: block;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-link,
.admin-link,
.ghost-button,
.status-action {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.side-link {
  min-height: 44px;
  padding: 12px 14px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 700;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.side-link:hover,
.side-link.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  transform: translateX(2px);
}

.side-link svg,
.ghost-button svg,
.status-action svg,
.sync-chip svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
}

.side-summary {
  margin-top: auto;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.side-summary span,
.side-summary small {
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.side-summary strong {
  display: block;
  margin: 6px 0 14px;
  font-size: 1rem;
}

.admin-link {
  width: 100%;
  justify-content: center;
  min-height: 38px;
  border-radius: 10px;
  background: #ffffff;
  color: var(--purple-800);
  font-size: 0.85rem;
  font-weight: 800;
}

.main-content {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 32px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow,
.section-label {
  display: block;
  margin-bottom: 7px;
  color: var(--purple-700);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: clamp(2rem, 3vw, 3.15rem);
  line-height: 1.04;
}

h2 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 1.18rem;
}

.topbar p {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.ghost-button,
.sync-chip,
.status-action {
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--purple-800);
  font-weight: 800;
  box-shadow: var(--soft-shadow);
}

.sync-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.kpi-grid,
.dashboard-grid,
.split-grid {
  display: grid;
  gap: 18px;
}

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

.kpi-card,
.panel,
.hero-status {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--soft-shadow);
}

.kpi-card {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 126px;
  padding: 22px;
  animation: rise 420ms ease both;
}

.kpi-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 15px;
  background: var(--purple-100);
  color: var(--purple-800);
}

.kpi-icon svg {
  width: 25px;
  height: 25px;
  stroke-width: 2.3;
}

.kpi-card small {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.kpi-card strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 2rem;
  line-height: 1;
}

.kpi-card.highlight {
  background: linear-gradient(135deg, var(--purple-800), var(--purple-900));
}

.kpi-card.highlight small,
.kpi-card.highlight strong {
  color: #ffffff;
}

.kpi-card.highlight .kpi-icon {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.kpi-card.risk .kpi-icon {
  background: var(--amber-bg);
  color: var(--amber);
}

.hero-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding: 26px;
  background: linear-gradient(135deg, var(--purple-800), #17151f);
  color: #ffffff;
}

.hero-status span {
  display: block;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-status strong {
  display: block;
  margin: 6px 0 8px;
  font-size: clamp(1.45rem, 3vw, 2.3rem);
  line-height: 1.16;
}

.hero-status p {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.75);
}

.hero-status.danger {
  background: linear-gradient(135deg, #8f1d16, var(--red));
}

.status-action {
  flex: 0 0 auto;
  background: #ffffff;
  color: var(--purple-800);
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(330px, 0.75fr);
  margin-bottom: 18px;
}

.split-grid {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
  margin-bottom: 18px;
}

.panel {
  padding: 22px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.chart-box {
  height: 320px;
}

.chart-box.compact {
  height: 240px;
}

.status-row,
.metric-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.status-row span,
.metric-pair div {
  padding: 14px;
  border-radius: 14px;
  background: #f8f8fb;
  color: var(--muted);
  font-weight: 700;
}

.status-row b,
.metric-pair strong {
  display: block;
  color: var(--ink);
  font-size: 1.35rem;
}

.critical-list {
  display: grid;
  gap: 10px;
}

.critical-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: border 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.critical-item:hover {
  border-color: rgba(57, 32, 138, 0.35);
  box-shadow: var(--soft-shadow);
  transform: translateY(-1px);
}

.critical-item strong,
.critical-item small {
  display: block;
}

.critical-item small {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 600;
}

.status-token,
.risk-pill,
.safe-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.status-token.expired,
.risk-pill {
  background: var(--red-bg);
  color: var(--red);
}

.status-token.due_30 {
  background: var(--amber-bg);
  color: var(--amber);
}

.safe-pill {
  background: var(--green-bg);
  color: var(--green);
}

.empty-state {
  padding: 18px;
  border-radius: 14px;
  background: #f8f8fb;
  color: var(--muted);
  font-weight: 700;
}

.table-tools {
  display: flex;
  gap: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(360px, 100%);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
}

.search-box svg {
  width: 18px;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-height: 42px;
  border: 0;
  outline: 0;
  color: var(--ink);
}

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

.data-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.data-table th {
  padding: 13px 14px;
  background: #f8f8fb;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
}

.data-table td {
  padding: 15px 14px;
  border-top: 1px solid var(--line);
  color: #3f3d4a;
  font-size: 0.92rem;
  font-weight: 650;
}

.data-table td strong,
.data-table td small {
  display: block;
}

.data-table td small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 600;
}

.data-table tbody tr {
  transition: background 160ms ease;
}

.data-table tbody tr:hover {
  background: #f4f1ff;
}

.row-risk {
  box-shadow: inset 4px 0 0 var(--amber);
}

.row-safe {
  box-shadow: inset 4px 0 0 var(--green);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #ffffff;
  color: var(--purple-800);
  cursor: pointer;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
}

.modal.open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 21, 31, 0.56);
}

.modal-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(620px, 100%);
  height: 100%;
  padding: 24px;
  overflow-y: auto;
  background: #ffffff;
  box-shadow: -18px 0 42px rgba(16, 24, 40, 0.18);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.modal-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.detail-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8f8fb;
}

.detail-card span,
.training-row small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-card strong {
  display: block;
  margin-top: 4px;
}

.training-list {
  display: grid;
  gap: 9px;
}

.training-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.training-row strong {
  display: block;
  margin-top: 4px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
  }

  .brand-card {
    min-height: 96px;
  }

  .brand-card img {
    width: 160px;
  }

  .side-nav {
    display: flex;
    overflow-x: auto;
  }

  .side-link {
    flex: 0 0 auto;
  }

  .side-summary {
    display: none;
  }

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

@media (max-width: 920px) {
  .main-content {
    padding: 22px;
  }

  .topbar,
  .hero-status,
  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .dashboard-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }

  .status-action {
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .main-content,
  .sidebar {
    padding: 16px;
  }

  .kpi-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .kpi-card,
  .panel,
  .hero-status {
    border-radius: 15px;
  }

  .chart-box {
    height: 280px;
  }

  .chart-box.compact {
    height: 230px;
  }

  .modal-panel {
    padding: 18px;
  }
}
