/* ACP Substrate Dashboard — Dark editorial brand (Sidratnam ACP) */

:root {
  --bg:         #0a0c10;
  --surface:    #131720;
  --surface2:   #1a2030;
  --border:     #252d3d;
  --primary:    #D4A017;
  --primary-dim: rgba(212,160,23,0.15);
  --text:       #e8eaf0;
  --text-muted: #8892a4;
  --text-dim:   #5a6478;
  --green:      #2ecc71;
  --green-dim:  rgba(46,204,113,0.12);
  --red:        #e74c3c;
  --red-dim:    rgba(231,76,60,0.12);
  --blue:       #3498db;
  --blue-dim:   rgba(52,152,219,0.12);
  --amber:      #f39c12;
  --amber-dim:  rgba(243,156,18,0.12);
  --radius:     6px;
  --radius-lg:  10px;
  --font-body:  'Inter', system-ui, sans-serif;
  --font-head:  'Cormorant Garamond', Georgia, serif;
  --transition: 180ms ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}

.header-brand .dot { color: var(--primary); }

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 12px;
}

.main {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 0;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 2px solid transparent;
  text-decoration: none;
}

.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--primary); border-left-color: var(--primary); background: var(--primary-dim); }

.nav-section-label {
  padding: 16px 20px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.content {
  padding: 28px 32px;
  overflow-y: auto;
}

/* ── Tabs (mobile / alternate layout) ────────────────────────── */
.tab-bar {
  display: none;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

/* ── Cards & Panels ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.card-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Stat Grid ────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ── Section heading ──────────────────────────────────────────── */
.section-title {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
}

.section-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  margin-top: -14px;
}

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.badge-green  { background: var(--green-dim);  color: var(--green);  }
.badge-red    { background: var(--red-dim);    color: var(--red);    }
.badge-amber  { background: var(--amber-dim);  color: var(--amber);  }
.badge-blue   { background: var(--blue-dim);   color: var(--blue);   }
.badge-muted  { background: var(--surface2);   color: var(--text-muted); }
.badge-gold   { background: var(--primary-dim); color: var(--primary); }

/* ── Tables ───────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: var(--surface2); }
.data-table tbody tr:last-child td { border-bottom: none; }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.table-title { font-size: 14px; font-weight: 600; color: var(--text); }

/* ── Inputs & Controls ────────────────────────────────────────── */
input[type="text"], input[type="email"], select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--transition);
}

input[type="text"]:focus, input[type="email"]:focus, select:focus, textarea:focus {
  border-color: var(--primary);
}

select option { background: var(--surface2); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #000;
}
.btn-primary:hover { filter: brightness(1.1); }

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface2); }

.btn-danger { background: var(--red-dim); color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Kill switch state panel ──────────────────────────────────── */
.ks-panel {
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid;
  margin-bottom: 24px;
}
.ks-panel.armed   { border-color: var(--amber); background: var(--amber-dim); }
.ks-panel.paused  { border-color: var(--blue);  background: var(--blue-dim);  }
.ks-panel.disarmed { border-color: var(--green); background: var(--green-dim); }
.ks-panel.enforced { border-color: var(--red);   background: var(--red-dim);   }
.ks-panel.unknown  { border-color: var(--border); background: var(--surface2); }

.ks-state-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.ks-state-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.ks-countdown   { font-size: 13px; margin-top: 8px; color: var(--text-muted); }

/* ── Chart ────────────────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  height: 200px;
  width: 100%;
}

/* ── Event log ────────────────────────────────────────────────── */
.event-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.event-item:last-child { border-bottom: none; }
.event-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.event-dot.ok    { background: var(--green); }
.event-dot.error { background: var(--red);   }
.event-dot.warn  { background: var(--amber); }
.event-dot.info  { background: var(--blue);  }
.event-body { flex: 1; min-width: 0; }
.event-type { font-size: 13px; font-weight: 600; color: var(--text); }
.event-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ── Capability list ──────────────────────────────────────────── */
.cap-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.cap-item:last-child { border-bottom: none; }
.cap-check { color: var(--green); font-size: 14px; }

/* ── Menu grid ────────────────────────────────────────────────── */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.menu-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.menu-card-name { font-weight: 600; margin-bottom: 4px; }
.menu-card-price { color: var(--primary); font-size: 15px; font-weight: 700; }
.menu-card-desc { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Empty state ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dim);
}
.empty-state-icon { font-size: 32px; margin-bottom: 12px; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.empty-state-text  { font-size: 13px; }

/* ── Loader ───────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Alert bar ────────────────────────────────────────────────── */
.alert-bar {
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-bar.error   { background: var(--red-dim);   color: var(--red);   }
.alert-bar.warning { background: var(--amber-dim); color: var(--amber); }
.alert-bar.success { background: var(--green-dim); color: var(--green); }

/* ── Footer ───────────────────────────────────────────────────── */
.substrate-footer {
  text-align: center;
  padding: 24px;
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  margin-top: 48px;
}
.substrate-footer a { color: var(--text-muted); text-decoration: none; }
.substrate-footer a:hover { color: var(--primary); }

/* ── Auth page ────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.auth-box h1 {
  font-family: var(--font-head);
  font-size: 26px;
  margin-bottom: 8px;
}
.auth-box p { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.auth-box input { width: 100%; margin-bottom: 14px; }

/* ── Info row ─────────────────────────────────────────────────── */
.info-row {
  display: flex;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); width: 180px; flex-shrink: 0; }
.info-value { color: var(--text); word-break: break-all; }

/* ── Deep links ───────────────────────────────────────────────── */
.deep-link-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.deep-link-item:last-child { border-bottom: none; }
.deep-link-label { color: var(--text-muted); }
.deep-link-url { color: var(--primary); word-break: break-all; }

/* ── Pagination ───────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Auth pages (login / setup / forgot / reset — standalone) ─── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.auth-box {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
}

.auth-box h1 {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.auth-box .auth-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 28px;
}

.auth-box .auth-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-box .auth-link a {
  color: var(--primary);
  text-decoration: none;
}

/* ── Form groups ─────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
}

.form-group input::placeholder {
  color: var(--text-dim);
}

/* ── Modal overlay ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal-box {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
}

.modal-title {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── Button sizes ─────────────────────────────────────────────── */
.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
}

.btn-danger {
  color: var(--red);
}

.btn-danger:hover {
  background: var(--red-dim);
}

/* ── Users table ──────────────────────────────────────────────── */
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.users-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.users-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.users-table tbody tr:hover {
  background: var(--surface2);
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .main { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .tab-bar { display: flex; }
  .content { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
