:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #65717a;
  --line: #dfe5e8;
  --accent: #197a6e;
  --accent-dark: #115a51;
  --warn: #b75b08;
  --danger: #b42318;
  --good: #16804d;
  --shadow: 0 16px 40px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: #e9eff1;
  color: var(--ink);
}

button.secondary:hover {
  background: #dae3e6;
}

button.danger {
  background: var(--danger);
}

button.full {
  width: 100%;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: #102126;
  color: #f7fbfb;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: #e5b84b;
  color: #102126;
  font-size: 26px;
  font-weight: 900;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p {
  color: #b9c9cc;
  font-size: 13px;
}

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

.nav-item {
  justify-content: flex-start;
  width: 100%;
  background: transparent;
  color: #d7e5e7;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #21363c;
}

.bot-status {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.status-row {
  display: flex;
  justify-content: space-between;
  color: #c8d7da;
  font-size: 14px;
}

.status-row strong {
  color: #fff;
}

.main {
  min-width: 0;
  padding: 28px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h2,
h3 {
  margin: 0;
}

h2 {
  font-size: 32px;
}

h3 {
  font-size: 18px;
}

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

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.notice {
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid #c7d9dd;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: #eef7f6;
  color: #24444b;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric,
.panel,
.slot-card,
.queue-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.link-button {
  min-height: auto;
  background: transparent;
  color: var(--accent);
  padding: 0;
}

.link-button:hover {
  background: transparent;
  color: var(--accent-dark);
}

.slot-list,
.queue-list {
  display: grid;
  gap: 10px;
}

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

.slot-card,
.queue-card {
  padding: 14px;
}

.slot-card.empty {
  border-style: dashed;
  background: #fbfcfc;
  color: var(--muted);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.token-name {
  font-weight: 900;
}

.token-meta,
.mini {
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: #edf3f4;
  color: #31454b;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.pill.good {
  background: #e6f5ee;
  color: var(--good);
}

.pill.warn {
  background: #fff1df;
  color: var(--warn);
}

.pill.danger {
  background: #fde8e5;
  color: var(--danger);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.detail {
  padding: 8px;
  border-radius: 6px;
  background: #f4f7f8;
}

.detail span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0f4f5;
  color: #44575d;
  font-size: 13px;
}

.token-check-layout {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

label {
  display: grid;
  gap: 6px;
  color: #32464c;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd9dc;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px;
}

form {
  display: grid;
  gap: 14px;
}

.form-pair,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.toggle-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.toggle-row input {
  width: auto;
}

.risk-result {
  margin-top: 12px;
  padding: 14px;
  border-radius: 8px;
  background: #f3f7f8;
  color: #30464c;
}

.risk-result.empty {
  color: var(--muted);
}

dialog {
  width: min(680px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(16, 33, 38, 0.28);
}

dialog::backdrop {
  background: rgba(16, 33, 38, 0.45);
}

.dialog-form menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.dialog-summary {
  margin: 0;
  padding: 12px;
  border-radius: 6px;
  background: #f4f7f8;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  transform: translateY(120%);
  border-radius: 8px;
  background: #102126;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
}

.toast.show {
  transform: translateY(0);
}

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

  .sidebar {
    position: static;
  }

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

  .topbar,
  .split,
  .token-check-layout,
  .slot-list.large,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

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

  .top-actions button {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  h2 {
    font-size: 26px;
  }

  .form-pair,
  .settings-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}
