:root {
  color-scheme: dark;
  --bg: #07110f;
  --surface: rgb(255 255 255 / 9%);
  --surface-strong: rgb(255 255 255 / 14%);
  --line: rgb(255 255 255 / 18%);
  --line-strong: rgb(255 255 255 / 30%);
  --text: #f4fbf8;
  --muted: #a9bab6;
  --faint: #72847f;
  --primary: #72f2cf;
  --primary-strong: #28c8a6;
  --blue: #9bd3ff;
  --violet: #c7b7ff;
  --amber: #ffd166;
  --red: #ff6b6b;
  --shadow: 0 24px 90px rgb(0 0 0 / 40%);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
}

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, rgb(114 242 207 / 13%), transparent 30%),
    radial-gradient(circle at 80% 18%, rgb(155 211 255 / 11%), transparent 34%),
    linear-gradient(135deg, #07110f 0%, #101820 46%, #11131a 100%);
  color: var(--text);
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(90deg, rgb(255 255 255 / 4%) 1px, transparent 1px),
    linear-gradient(0deg, rgb(255 255 255 / 3%) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgb(0 0 0 / 54%), transparent 78%);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgb(114 242 207 / 64%);
  outline-offset: 2px;
}

.glass,
.liquid-surface {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgb(255 255 255 / 15%), rgb(255 255 255 / 7%)),
    rgb(8 18 18 / 38%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(145%);
}

.glass::before,
.liquid-surface::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 28%), transparent 30%),
    linear-gradient(315deg, rgb(155 211 255 / 10%), transparent 45%);
  opacity: 0.75;
}

.glass > *,
.liquid-surface > * {
  position: relative;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 36px);
  padding: 18px;
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 8px;
  background: linear-gradient(135deg, rgb(114 242 207 / 34%), rgb(199 183 255 / 22%));
  color: var(--text);
  font-weight: 800;
}

.brand-block h1,
.brand-block p,
.topbar h2,
.topbar p {
  margin: 0;
}

.brand-block h1 {
  font-size: 18px;
  line-height: 1.2;
}

.brand-block p,
.eyebrow,
.timestamp {
  color: var(--muted);
  font-size: 12px;
}

.page-nav {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.nav-button,
.ghost-button,
.ghost-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  text-align: left;
}

.nav-button,
.ghost-button {
  width: 100%;
}

.nav-button:hover,
.ghost-button:hover,
.ghost-inline:hover {
  background: rgb(255 255 255 / 9%);
  color: var(--text);
}

.nav-button.active {
  background: rgb(114 242 207 / 16%);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgb(114 242 207 / 24%);
}

.ghost-button {
  margin-top: auto;
}

.main-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
}

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

.topbar h2 {
  font-size: 24px;
  line-height: 1.2;
}

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

.primary-button {
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #05221c;
  font-weight: 760;
  padding: 0 16px;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.content-grid {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
}

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

.metric-card {
  min-height: 132px;
  padding: 16px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin: 12px 0 4px;
  font-size: 28px;
  font-weight: 760;
  line-height: 1.1;
  word-break: break-word;
}

.metric-sub {
  color: var(--faint);
  font-size: 12px;
}

.panel {
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
}

.panel-title {
  margin: 0;
  font-size: 15px;
}

.panel-body {
  padding: 14px;
}

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

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 10px;
}

.status-grid.compact {
  grid-template-columns: minmax(120px, 160px) minmax(0, 1fr);
  align-items: center;
}

.status-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 7%);
  padding: 0 12px;
}

.status-tile span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.status-name {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 650;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  color: #061d18;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.badge.ok {
  background: var(--primary);
}

.badge.warn {
  background: var(--amber);
}

.badge.danger {
  background: var(--red);
  color: #260606;
}

.table-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.table-search,
.table-size,
.jump-page,
.modal-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.table-search input,
.table-size select,
.jump-page input,
.modal-field input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 9%);
  color: var(--text);
  padding: 0 10px;
}

.table-size select {
  min-width: 78px;
}

.table-count {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 8px;
  background: rgb(0 0 0 / 13%);
}

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

th,
td {
  border-bottom: 1px solid rgb(255 255 255 / 10%);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

td.numeric,
th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.th-button {
  min-height: 28px;
  width: 100%;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: inherit;
}

.th-button.asc::after {
  content: " ↑";
}

.th-button.desc::after {
  content: " ↓";
}

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

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 0 0;
}

.pager button,
.action-button {
  min-width: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 8%);
  color: var(--text);
  padding: 0 12px;
}

.pager button:hover,
.action-button:hover {
  background: rgb(255 255 255 / 14%);
}

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

.pager span {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.jump-page {
  grid-template-columns: auto 64px;
  align-items: center;
}

.bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgb(255 255 255 / 10%);
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--blue));
}

.action-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 2px 6px 2px 0;
  white-space: nowrap;
}

.danger-button {
  border-color: rgb(255 107 107 / 48%);
  background: rgb(255 107 107 / 14%);
  color: #ffd4d4;
}

.result-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
}

.result-box {
  max-height: 440px;
  overflow: auto;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 8px;
  background: rgb(0 0 0 / 28%);
  color: #d9e8e4;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.compact-pre {
  max-height: 180px;
}

.empty-state {
  color: var(--muted);
  padding: 26px;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 56%);
  padding: 18px;
}

.modal {
  width: min(100%, 520px);
  padding: 18px;
}

.modal h3 {
  margin: 0;
  font-size: 20px;
}

.modal-sub {
  color: var(--muted);
  line-height: 1.6;
}

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

.ghost-inline {
  border: 1px solid var(--line);
  min-width: 88px;
}

.auth-body {
  display: grid;
  place-items: center;
}

.auth-shell {
  width: min(100%, 440px);
  padding: 18px;
}

.login-panel {
  padding: 22px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.login-form input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 10%);
  color: var(--text);
  padding: 0 12px;
}

.login-form button {
  border-radius: 8px;
  background: var(--primary);
  color: #05221c;
  font-weight: 800;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

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

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

  .sidebar {
    min-height: auto;
  }

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

  .ghost-button {
    margin-top: 14px;
  }

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

@media (max-width: 640px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .topbar-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-nav,
  .metric-grid,
  .two-column,
  .table-toolbar {
    grid-template-columns: 1fr;
  }

  .status-grid.compact {
    grid-template-columns: 1fr;
  }

  .metric-value {
    font-size: 24px;
  }

  .pager {
    align-items: stretch;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .jump-page {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 680px;
  }
}

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