:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #162032;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --amber: #f59e0b;
  --emerald: #10b981;
  --red: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.tabular {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-emerald { color: var(--emerald); }
.text-amber { color: var(--amber); }
.text-red { color: var(--red); }

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }

.stack-md { display: flex; flex-direction: column; gap: 14px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 20px;
}

.auth-brand p {
  margin: 2px 0 0;
  font-size: 13px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--amber);
  color: #0f172a;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.sidebar {
  width: 260px;
  background: var(--surface-alt);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-btn {
  text-align: left;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  min-height: 42px;
}

.nav-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-btn.active {
  color: #0f172a;
  background: var(--amber);
}

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface-alt);
}

.breadcrumb {
  font-weight: 700;
  font-size: 16px;
}

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

.online-readout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--emerald);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--emerald);
}

.content {
  padding: 24px;
  max-width: 1320px;
  width: 100%;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

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

.card-header h2, .card-header h3, .card h2 {
  margin: 0;
  font-size: 16px;
}

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

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kpi-label {
  font-size: 12.5px;
  color: var(--muted);
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toolbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.search-input, input, select, textarea {
  background: #0f172a;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
}

.search-input {
  min-width: 240px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.field span, .field-label {
  font-weight: 600;
  color: #cbd5e1;
  font-size: 13px;
  margin: 0;
}

.segmented {
  display: inline-flex;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--text);
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--amber);
  color: #0f172a;
}

.btn-secondary {
  background: #0f172a;
  border-color: var(--border);
  color: var(--text);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-sm {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
}

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

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

.data-table th, .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.65);
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.data-table th.num, .data-table td.num {
  text-align: right;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

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

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

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

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}

.toggle-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  margin: 14px 24px 0;
  padding: 11px 16px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #6ee7b7;
  font-size: 13px;
  font-weight: 600;
}

.toast.error {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.error-text {
  margin: 0;
  color: #fca5a5;
  font-size: 13px;
}

.notice-text {
  margin: 0;
  font-size: 13px;
  color: #cbd5e1;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
}

.code-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

code {
  background: #0f172a;
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 12px;
}

pre.code-block {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  margin: 0;
  color: #cbd5e1;
}

.reveal-box {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: 10px;
  padding: 14px;
}

@media (max-width: 960px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .nav-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .kpi-grid, .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .grid-7 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
