:root {
  color-scheme: dark;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: #07100f;
  color: #edf7f4;
  font-synthesis: none;
  --bg: #07100f;
  --panel: #0d1917;
  --panel-raised: #12221f;
  --panel-soft: #10201d;
  --border: #25413b;
  --border-strong: #356057;
  --text: #edf7f4;
  --muted: #99b2ac;
  --accent: #61d7ad;
  --accent-strong: #8eebc8;
  --danger: #ff8b83;
  --warning: #f1c56d;
  --info: #7fc7ff;
  --focus: #a4f5d8;
  --sidebar: 248px;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 16% 0%, rgb(39 102 84 / 25%), transparent 34rem),
    linear-gradient(160deg, #07100f 0%, #091412 58%, #08100f 100%);
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.boot-state,
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.boot-state {
  align-content: center;
  color: var(--muted);
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.auth-page {
  grid-template-columns: minmax(280px, 520px) minmax(340px, 520px);
  gap: 64px;
  max-width: 1180px;
  margin: 0 auto;
}

.auth-intro h1 {
  max-width: 650px;
  margin: 14px 0 18px;
  font-size: clamp(44px, 6vw, 82px);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.auth-intro p {
  max-width: 520px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.75;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.auth-card,
.panel,
.metric-card,
.state-card,
.dialog-card {
  border: 1px solid var(--border);
  background: rgb(13 25 23 / 94%);
  box-shadow: 0 26px 80px rgb(0 0 0 / 24%);
}

.auth-card {
  padding: 34px;
  border-radius: 24px;
}

.auth-card h2,
.page-title h1,
.panel h2 {
  margin: 0;
}

.auth-card > p,
.page-title p,
.panel-subtitle {
  color: var(--muted);
  line-height: 1.6;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.field label,
.field-label {
  color: #d8e8e4;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea,
.field select,
.toolbar input,
.toolbar select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: #081310;
  color: var(--text);
  padding: 11px 13px;
}

.field textarea {
  min-height: 94px;
  resize: vertical;
}

.help-text {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-primary {
  background: var(--accent);
  color: #052119;
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.button-secondary {
  border-color: var(--border-strong);
  background: #12231f;
  color: var(--text);
}

.button-danger {
  border-color: #713b38;
  background: #351a19;
  color: #ffd7d4;
}

.button-block {
  width: 100%;
  margin-top: 24px;
}

.alert,
.status-strip {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 13px;
  line-height: 1.5;
}

.alert {
  margin-top: 18px;
}

.alert-warning {
  border-color: #5c4b29;
  background: #251f12;
  color: #f4d996;
}

.alert-danger {
  border-color: #663431;
  background: #2a1716;
  color: #ffb4ae;
}

.alert-info {
  border-color: #294f66;
  background: #10212b;
  color: #b5dfff;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgb(7 16 15 / 88%);
  backdrop-filter: blur(18px);
  padding: 26px 18px 18px;
}

.brand {
  padding: 0 10px 22px;
}

.brand strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
  letter-spacing: -0.02em;
}

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

.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 11px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}

.nav a:hover,
.nav a[aria-current="page"] {
  border-color: var(--border);
  background: var(--panel-soft);
  color: var(--text);
}

.nav-icon {
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 17px 10px 2px;
}

.admin-identity {
  overflow: hidden;
}

.admin-identity strong,
.admin-identity span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.sidebar-footer .button {
  width: 100%;
  margin-top: 13px;
}

.workspace {
  min-width: 0;
  padding: 28px clamp(22px, 3vw, 48px) 64px;
}

.topbar {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 28px;
}

.status-pill,
.risk-badge,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 9px;
  background: #0f1d1a;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.status-live {
  border-color: #27624f;
  color: #a3f2d2;
}

.status-polling,
.risk-medium {
  border-color: #68542b;
  color: #f1cf7e;
}

.risk-high {
  border-color: #753d38;
  color: #ffaaa4;
}

.page-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 22px;
}

.page-title h1 {
  font-size: clamp(28px, 4vw, 46px);
  letter-spacing: -0.045em;
}

.page-title p {
  margin: 7px 0 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
}

.metric-card {
  min-height: 134px;
  border-radius: 15px;
  padding: 17px;
}

.metric-card .metric-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-value {
  margin-top: 20px;
  font-size: clamp(27px, 3vw, 38px);
  font-weight: 780;
  letter-spacing: -0.04em;
}

.metric-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.6fr);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  border-radius: 16px;
  padding: 19px;
}

.panel-header,
.toolbar,
.action-row,
.pagination,
.detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel h2 {
  font-size: 16px;
}

.panel-subtitle {
  margin: 6px 0 0;
  font-size: 12px;
}

.queue-list,
.health-list,
.detail-list,
.timeline,
.impact-preview {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}

.queue-list li,
.health-list li,
.detail-list li,
.timeline li,
.impact-preview li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--border);
  padding: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.queue-list strong,
.health-list strong,
.detail-list strong {
  color: var(--text);
}

.toolbar {
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar input {
  max-width: 360px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  background: #0b1714;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #10201c;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
  padding: 0;
  font-weight: 720;
}

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

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.state-card {
  display: grid;
  place-items: center;
  min-height: 360px;
  border-radius: 18px;
  padding: 36px;
  text-align: center;
}

.state-card h2 {
  margin: 14px 0 8px;
}

.state-card p {
  max-width: 540px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.state-icon {
  font-size: 34px;
}

.state-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.feature-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0c1816;
  padding: 17px;
}

.feature-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.feature-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-top: 18px;
}

.split-grid h3,
.danger-zone h3 {
  margin: 0;
  font-size: 14px;
}

.danger-zone {
  margin-top: 18px;
  border-top: 1px solid #713b38;
  padding-top: 18px;
}

.danger-link {
  color: var(--danger);
}

.detail-json {
  max-width: 68%;
  overflow-wrap: anywhere;
  text-align: right;
  white-space: normal;
}

.action-row {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 17px;
}

.timeline li {
  display: grid;
  grid-template-columns: 155px minmax(0, 1fr);
  justify-content: initial;
}

.timeline time {
  color: var(--muted);
  font-size: 11px;
}

.timeline strong,
.timeline span {
  display: block;
}

.timeline span {
  margin-top: 4px;
  color: var(--muted);
}

.audit-viewport {
  position: relative;
  height: min(62vh, 620px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #091411;
}

.audit-spacer {
  position: relative;
  width: 100%;
}

.audit-window {
  position: absolute;
  inset: 0 0 auto;
}

.audit-row {
  display: grid;
  grid-template-columns: 150px minmax(150px, 0.7fr) minmax(200px, 1fr) minmax(
      240px,
      1.4fr
    );
  align-items: center;
  gap: 14px;
  height: 72px;
  border-bottom: 1px solid var(--border);
  padding: 0 14px;
  font-size: 12px;
}

.audit-row:hover {
  background: #10201c;
}

.audit-metadata {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pagination {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

dialog {
  width: min(560px, calc(100vw - 32px));
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}

dialog::backdrop {
  background: rgb(0 0 0 / 72%);
  backdrop-filter: blur(4px);
}

.dialog-card {
  border-radius: 18px;
  padding: 23px;
}

.dialog-card h2 {
  margin: 0;
}

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

.checkbox-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.checkbox-row input {
  margin-top: 3px;
}

.skeleton {
  overflow: hidden;
  background: #13241f;
  border-radius: 8px;
  min-height: 18px;
  position: relative;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent,
    rgb(255 255 255 / 7%),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

.skeleton-title {
  width: 220px;
  height: 42px;
}

.skeleton-subtitle {
  width: 360px;
  margin-top: 12px;
}

.skeleton-value {
  width: 54%;
  height: 34px;
  margin-top: 24px;
}

.panel-spaced {
  margin-top: 14px;
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

.mobile-header {
  display: none;
}

@media (max-width: 1060px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .detail-layout,
  .split-grid {
    grid-template-columns: 1fr;
  }

  .auth-page {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

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

  .brand,
  .sidebar-footer {
    display: none;
  }

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

  .nav a {
    flex: 0 0 auto;
  }

  .workspace {
    padding: 18px 15px 46px;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
  }

  .topbar {
    justify-content: flex-start;
    overflow-x: auto;
    margin-bottom: 20px;
  }

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

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

  .audit-row {
    grid-template-columns: 130px minmax(190px, 1fr);
  }

  .audit-row > :nth-child(n + 3) {
    display: none;
  }
}

@media (max-width: 500px) {
  .auth-page {
    padding: 20px;
  }

  .auth-card {
    padding: 24px;
  }

  .auth-intro h1 {
    font-size: 48px;
  }

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