:root {
  color-scheme: light;
  --navy-950: #06263a;
  --navy-900: #073a5b;
  --navy-800: #0b4d78;
  --blue-100: #eaf4fb;
  --blue-050: #f5f9fc;
  --gold-500: #d8b323;
  --gold-100: #fff4bf;
  --red-600: #b42318;
  --green-700: #087443;
  --text: #102334;
  --muted: #5d6b78;
  --line: #d8e2ea;
  --surface: #ffffff;
  --shadow: 0 18px 45px rgba(6, 38, 58, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: linear-gradient(180deg, #f7fbfd 0%, #eef5fa 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--navy-950), #032033);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  min-height: 92px;
  padding: 18px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand img {
  width: 178px;
  max-width: 100%;
  display: block;
}

.nav-list {
  display: grid;
  gap: 6px;
  padding: 22px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  font-size: 13px;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 13px;
}

.sidebar-footer strong,
.sidebar-footer span {
  display: block;
}

.sidebar-footer span {
  color: rgba(255, 255, 255, 0.72);
}

.user-mark {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--gold-500);
  color: var(--navy-950);
  font-weight: 800;
}

.main {
  width: min(100%, 1480px);
  margin: 0 auto;
  padding: 28px 32px 40px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--navy-950);
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.04;
  letter-spacing: 0;
}

.page-header p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
}

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

.token-control,
.limit-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.token-control input,
.limit-control select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  min-width: 150px;
}

.primary-button,
.secondary-button {
  height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--navy-900);
  background: var(--navy-900);
  color: #fff;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy-900);
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.segment-control {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.segment {
  height: 44px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--navy-900);
  font-weight: 800;
  cursor: pointer;
}

.segment:last-child {
  border-right: 0;
}

.segment.active {
  background: var(--navy-900);
  color: #fff;
}

.status-banner {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 14px;
  font-weight: 700;
}

.status-banner[data-tone="warning"] {
  border-color: #f2d98d;
  background: #fff9e8;
  color: #6f5200;
}

.status-banner[data-tone="error"] {
  border-color: #f4b3ad;
  background: #fff1ef;
  color: var(--red-600);
}

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

.kpi-card,
.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.kpi-card {
  min-height: 124px;
  border-radius: 8px;
  padding: 18px;
}

.kpi-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.kpi-card strong {
  display: block;
  margin-top: 10px;
  color: var(--navy-950);
  font-size: 32px;
  line-height: 1;
}

.kpi-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 700;
}

.warning-card strong {
  color: var(--red-600);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.panel {
  border-radius: 8px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-header.compact {
  align-items: center;
}

h2 {
  color: var(--navy-950);
  font-size: 18px;
  line-height: 1.2;
}

.panel-header p,
.updated-stamp {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  background: #f8fbfd;
  color: #42515f;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td strong,
td span {
  display: block;
}

td strong {
  color: var(--navy-900);
  font-weight: 800;
}

td span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.type-pill,
.health-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  width: fit-content;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--gold-100);
  color: #6c5300;
  font-size: 12px;
  font-weight: 900;
  text-transform: capitalize;
}

.health-pill[data-tone="healthy"] {
  background: #dff8ea;
  color: var(--green-700);
}

.health-pill[data-tone="warning"] {
  background: var(--gold-100);
  color: #6c5300;
}

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

.side-stack {
  display: grid;
  gap: 18px;
  align-content: start;
}

.health-list {
  display: grid;
  gap: 14px;
  padding: 18px 20px 22px;
  margin: 0;
}

.health-list div {
  display: grid;
  gap: 4px;
}

.health-list dt {
  color: var(--navy-950);
  font-size: 13px;
  font-weight: 900;
}

.health-list dd {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.action-list {
  display: grid;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.action-list li {
  display: grid;
  gap: 5px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}

.action-list li:last-child {
  border-bottom: 0;
}

.action-list strong {
  color: var(--navy-950);
  font-size: 13px;
}

.action-list span {
  color: var(--muted);
  font-size: 13px;
}

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

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .brand {
    min-height: 76px;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    padding: 14px;
  }

  .sidebar-footer {
    display: none;
  }

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

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 20px 14px 32px;
  }

  .page-header,
  .toolbar {
    display: grid;
  }

  .header-actions {
    justify-content: stretch;
  }

  .header-actions > *,
  .token-control input {
    width: 100%;
  }

  .segment-control {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .segment {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .segment:last-child {
    border-bottom: 0;
  }

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

  .sidebar {
    grid-template-columns: 1fr;
  }

  .brand {
    justify-content: center;
  }
}

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