/* ==========================================================================
   Xool Media Manifest Control — design tokens
   Palette: deep ink navy ground, three signal accents (amber / green / red)
   instead of a single accent, so status reads at a glance like a real
   network-ops console. Data (IDs, domains, counts) sets in a mono face;
   UI chrome sets in a grotesque sans. Status is rendered as a small
   rotated "ink stamp" rather than a generic colored pill.
   ========================================================================== */

:root {
  --ink-950: #0d1015;
  --ink-900: #12161c;
  --ink-800: #181d26;
  --ink-700: #1f2530;
  --ink-600: #262d3a;
  --ink-500: #384156;
  --line: #262d3a;
  --line-soft: #1f2530;

  --text-hi: #e9ecf2;
  --text-mid: #b6bdcc;
  --text-lo: #7c8496;

  --amber: #f0a63d;
  --amber-dim: #6b5127;
  --green: #3fcf8e;
  --green-dim: #1f4d3c;
  --red: #ff6b6b;
  --red-dim: #572a2a;

  --radius-sm: 4px;
  --radius-md: 7px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', Consolas, monospace;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink-900);
  color: var(--text-hi);
  font-family: var(--font-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

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

/* ---------------- Top bar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 20px;
  height: 60px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-950);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--amber);
  color: var(--ink-950);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 14px; }
.brand-sub { font-size: 11px; color: var(--text-lo); font-family: var(--font-mono); letter-spacing: 0.04em; }

.ticker {
  display: flex;
  gap: 26px;
  flex: 1;
  overflow-x: auto;
  padding: 4px 0;
}

.ticker-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 68px;
}

.ticker-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-lo);
}

.ticker-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 17px;
  color: var(--text-hi);
}

.ticker-value--ok { color: var(--green); }
.ticker-value--warn { color: var(--amber); }
.ticker-value--bad { color: var(--red); }

.sellers-link {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-mid);
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.sellers-link:hover { border-color: var(--amber); color: var(--amber); }
.arrow { display: inline-block; }

/* ---------------- Body grid ---------------- */

.body-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  flex: 1;
  min-height: 0;
}

.sidenav {
  border-right: 1px solid var(--line);
  background: var(--ink-950);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-mid);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
}

.nav-index {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-lo);
}

.nav-item:hover { background: var(--ink-800); color: var(--text-hi); }

.nav-item.is-active {
  background: var(--ink-800);
  color: var(--amber);
  box-shadow: inset 2px 0 0 var(--amber);
}
.nav-item.is-active .nav-index { color: var(--amber); }

.nav-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-footnote {
  font-size: 11px;
  color: var(--text-lo);
  line-height: 1.5;
  margin: 0;
}

/* ---------------- Content / panels ---------------- */

.content {
  padding: 26px 30px 40px;
  min-width: 0;
  overflow-x: auto;
}

.panel { display: none; }
.panel.is-active { display: block; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.panel-head h1 {
  font-size: 20px;
  margin: 0 0 4px;
  font-weight: 700;
}

.panel-sub {
  margin: 0;
  color: var(--text-lo);
  font-size: 12.5px;
  max-width: 56ch;
}

/* ---------------- Buttons ---------------- */

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn--primary { background: var(--amber); color: var(--ink-950); }
.btn--primary:hover { background: #f6b959; }

.btn--ghost { background: transparent; border-color: var(--line); color: var(--text-mid); }
.btn--ghost:hover { border-color: var(--text-mid); color: var(--text-hi); }

.btn--full { width: 100%; }

.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--danger-text { background: none; border: none; color: var(--red); cursor: pointer; font-size: 12px; padding: 5px 8px; }
.btn--danger-text:hover { text-decoration: underline; }

/* ---------------- Tables ---------------- */

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--ink-800);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.data-table th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-lo);
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-950);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }

.mono { font-family: var(--font-mono); }
.col-actions { text-align: right; }

.empty-row {
  text-align: center;
  color: var(--text-lo);
  padding: 30px 14px !important;
  font-size: 13px;
}

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------------- Stamp (signature status element) ---------------- */

.stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--text-lo);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  color: var(--text-lo);
  transform: rotate(-8deg);
}

.stamp--valid { border-color: var(--green); color: var(--green); }
.stamp--missing { border-color: var(--amber); color: var(--amber); }
.stamp--unreachable { border-color: var(--red); color: var(--red); }
.stamp--none { border-style: dashed; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.badge--on { background: var(--green-dim); color: var(--green); }
.badge--off { background: var(--ink-600); color: var(--text-lo); }
.badge--confidential { background: var(--amber-dim); color: var(--amber); }

/* ---------------- Ledger layout ---------------- */

.ledger-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  min-height: 400px;
}

.ledger-pub-list {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--ink-800);
  overflow-y: auto;
  max-height: 560px;
}

.ledger-pub-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.ledger-pub-item:hover { background: rgba(255,255,255,0.03); }
.ledger-pub-item.is-active { background: var(--ink-700); box-shadow: inset 2px 0 0 var(--amber); }

.ledger-pub-item .name {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ledger-pub-item .sid {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-lo);
}

.ledger-detail {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--ink-800);
  padding: 20px;
}

.log-entry {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.log-entry:last-child { border-bottom: none; }

.log-entry .when {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-lo);
  min-width: 150px;
}

.log-entry .msg { font-size: 12.5px; color: var(--text-mid); }
.log-entry .msg strong { color: var(--text-hi); }

/* ---------------- Modals ---------------- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.72);
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-overlay.is-open { display: flex; }

.modal {
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 420px;
  padding: 22px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal--wide { max-width: 640px; }

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-head h2 { font-size: 16px; margin: 0; }
.modal-head #snippet-seller-id { font-family: var(--font-mono); color: var(--amber); }

.modal-close {
  background: none;
  border: none;
  color: var(--text-lo);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--text-hi); }

#publisher-form, #seat-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-mid);
  font-weight: 500;
}

.optional { color: var(--text-lo); font-weight: 400; font-size: 11px; }

input[type="text"], select {
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--text-hi);
  font-family: var(--font-mono);
  font-size: 12.5px;
}
input[type="text"]:focus, select:focus { border-color: var(--amber); }

.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-hi);
}
.checkbox-row input { width: 15px; height: 15px; }

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

.snippet-box {
  background: var(--ink-950);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-hi);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
}

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink-700);
  border: 1px solid var(--line);
  color: var(--text-hi);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.is-error { border-color: var(--red); color: var(--red); }
.toast.is-success { border-color: var(--green); color: var(--green); }

/* ---------------- Responsive ---------------- */

@media (max-width: 860px) {
  .body-grid { grid-template-columns: 1fr; }
  .sidenav {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
  }
  .nav-footer { display: none; }
  .ledger-layout { grid-template-columns: 1fr; }
  .content { padding: 18px; }
}
