:root {
  color-scheme: dark;
  --bg: #08101d;
  --bg-soft: #0d1728;
  --surface: rgba(15, 23, 42, 0.94);
  --surface-2: rgba(20, 32, 54, 0.95);
  --surface-3: rgba(255, 255, 255, 0.06);
  --ink: #f8fafc;
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(96, 165, 250, 0.35);
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --success: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --info: #0ea5e9;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  --radius: 8px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 16, 29, 0.96);
  color: #fff;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.system-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 42px;
  padding: 0 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 54px;
}

.brand-logo {
  width: 112px;
  height: 34px;
  object-fit: contain;
}

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

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.system-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.env-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-left: 1px solid rgba(255, 255, 255, 0.22);
  padding: 0 12px;
  color: #dbeafe;
  font-size: 0.82rem;
  font-weight: 800;
}

.nav-list {
  display: flex;
  gap: 0;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.92);
  scrollbar-width: thin;
}

.subnav-list {
  display: flex;
  gap: 6px;
  min-height: 38px;
  padding: 6px 14px;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  background: rgba(12, 22, 40, 0.92);
  box-shadow: inset 0 -1px 0 var(--line);
  scrollbar-width: thin;
}

.nav-item,
.subnav-item,
.ghost-button,
.primary-button,
.secondary-button,
.table-action {
  border: 0;
  border-radius: 6px;
  min-height: 38px;
  padding: 0 12px;
  font-weight: 700;
}

.nav-item {
  background: transparent;
  color: #cbd5e1;
  border-radius: 0;
  min-width: max-content;
  text-align: center;
}

.nav-item:hover,
.nav-item.active {
  background: var(--accent);
  color: #fff;
}

.subnav-item {
  min-width: max-content;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: #cbd5e1;
}

.subnav-item:hover,
.subnav-item.active {
  border-color: var(--line-strong);
  background: rgba(37, 99, 235, 0.18);
  color: #fff;
}

.ghost-button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

.ghost-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.ghost-button.danger {
  color: #ffd5d5;
}

.main-content {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 16, 29, 0.42);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 3px;
  color: #60a5fa;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 2vw, 2.2rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.05rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 0.96rem;
}

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

.search-box {
  display: grid;
  gap: 4px;
  min-width: min(340px, 40vw);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.search-box input,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111c31;
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}

.search-box input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.clock {
  min-width: 76px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 10px 12px;
  text-align: center;
  font-weight: 800;
}

.workspace {
  padding: 24px 28px 38px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0;
  border-top: 3px solid var(--accent);
  pointer-events: none;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.8rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.4fr);
  gap: 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel.tight {
  padding: 0;
  overflow: hidden;
}

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

.panel-header h2 {
  margin-bottom: 0;
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

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

.field label,
.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.2);
}

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

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--ink);
}

.secondary-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

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

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: var(--surface);
}

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

th {
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  font-size: 0.92rem;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: rgba(5, 150, 105, 0.18);
  color: #86efac;
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.status.warn {
  background: rgba(217, 119, 6, 0.18);
  color: #fbbf24;
}

.status.info {
  background: rgba(14, 165, 233, 0.18);
  color: #7dd3fc;
}

.status.danger {
  background: rgba(220, 38, 38, 0.18);
  color: #fca5a5;
}

.table-action {
  min-height: 32px;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--ink);
  white-space: nowrap;
}

.table-action.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.stack {
  display: grid;
  gap: 18px;
}

.log-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.log-list li {
  border-left: 4px solid var(--accent);
  padding: 2px 0 2px 10px;
  color: var(--muted);
}

.log-list strong {
  display: block;
  color: var(--ink);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 32px));
  border-radius: var(--radius);
  background: #111c31;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

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

.nowrap {
  white-space: nowrap;
}

@media (max-width: 980px) {
  .system-bar {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 14px;
  }

  .system-actions {
    width: 100%;
    flex-wrap: wrap;
    margin-left: 0;
  }

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

  .search-box {
    min-width: 0;
  }

  .metrics,
  .grid-2,
  .grid-3,
  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar,
  .workspace {
    padding-left: 14px;
    padding-right: 14px;
  }

  .brand {
    align-items: flex-start;
  }

  .metrics {
    gap: 10px;
  }

  .metric {
    padding: 12px;
  }
}
