/* Roamdesk — telecom roam console
   Palette: ink / panel / copper / lagoon / paper / mute
   Type: Outfit (UI) + IBM Plex Mono (data)
   Signature: copper MCC country chips + horizontal CDR ticket tape */

:root {
  --ink: #0b1220;
  --panel: #121c2e;
  --panel-2: #18233a;
  --line: #24334f;
  --line-soft: #1a2740;
  --copper: #d4894a;
  --copper-dim: #a86a36;
  --lagoon: #5ec8c0;
  --lagoon-dim: #3a8f89;
  --paper: #e8edf5;
  --mute: #8a9bb5;
  --danger: #e06b6b;
  --ok: #6dce8b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --rail: 248px;
  --font-ui: "Outfit", system-ui, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(212, 137, 74, 0.08), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(94, 200, 192, 0.06), transparent 50%),
    var(--ink);
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

.app {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  min-height: 100vh;
}

/* —— Rail —— */
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.5rem 1.1rem;
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(18, 28, 46, 0.95), rgba(11, 18, 32, 0.98));
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0 0.35rem;
}

.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9px;
  background:
    conic-gradient(from 210deg, var(--copper), var(--lagoon), var(--copper));
  box-shadow: inset 0 0 0 3px var(--ink), 0 0 0 1px var(--line);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 4px;
  background: var(--ink);
}

.brand-name {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.05rem;
}

.brand-sub {
  font-family: var(--font-data);
  font-size: 0.7rem;
  color: var(--mute);
  letter-spacing: 0.04em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--mute);
  border-radius: 10px;
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-item:hover {
  color: var(--paper);
  background: rgba(255, 255, 255, 0.03);
}

.nav-item.is-active {
  color: var(--paper);
  background: var(--panel-2);
  border-color: var(--line);
  box-shadow: inset 3px 0 0 var(--copper);
}

.nav-kicker {
  font-family: var(--font-data);
  font-size: 0.68rem;
  color: var(--copper);
  min-width: 1.4rem;
}

.rail-foot {
  margin-top: auto;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, 0.15);
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-data);
  font-size: 0.72rem;
}

.status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--mute);
  box-shadow: 0 0 0 3px rgba(138, 155, 181, 0.15);
}

.status.is-ok .status-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(109, 206, 139, 0.18);
}

.status.is-bad .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(224, 107, 107, 0.18);
}

.rail-note {
  margin: 0.45rem 0 0;
  font-size: 0.75rem;
  color: var(--mute);
}

/* —— Stage —— */
.stage {
  padding: 1.5rem 1.75rem 2.5rem;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.4rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line-soft);
}

.eyebrow {
  margin: 0 0 0.2rem;
  font-family: var(--font-data);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lagoon);
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2.4vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.topbar-meta {
  font-family: var(--font-data);
  font-size: 0.75rem;
  color: var(--mute);
  text-align: right;
}

.account-menu {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-data);
  font-size: 0.72rem;
  color: var(--mute);
}

.view[hidden] {
  display: none !important;
}

/* —— Stats —— */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: linear-gradient(165deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.1rem;
  min-height: 6.2rem;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--mute);
  margin-bottom: 0.55rem;
}

.stat-value {
  font-family: var(--font-data);
  font-size: 1.35rem;
  font-weight: 550;
  letter-spacing: -0.02em;
  word-break: break-word;
}

.stat-card.accent .stat-value {
  color: var(--copper);
}

.split {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.15rem;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.85rem;
  gap: 0.75rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
}

.panel-hint {
  font-family: var(--font-data);
  font-size: 0.68rem;
  color: var(--mute);
}

/* Country list — signature MCC chips */
.country-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 320px;
  overflow: auto;
}

.country-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: center;
}

.mcc-chip {
  font-family: var(--font-data);
  font-size: 0.78rem;
  font-weight: 600;
  min-width: 3.1rem;
  text-align: center;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  color: #1a1208;
  background: linear-gradient(135deg, #e2a66a, var(--copper));
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
}

.bar-track {
  height: 0.45rem;
  border-radius: 99px;
  background: var(--line-soft);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--lagoon-dim), var(--lagoon));
}

.country-meta {
  font-family: var(--font-data);
  font-size: 0.68rem;
  color: var(--mute);
  text-align: right;
  white-space: nowrap;
}

/* Pulse chart */
.pulse {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  height: 180px;
  padding-top: 0.5rem;
}

.pulse-bar {
  flex: 1;
  min-width: 0;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--copper), rgba(212, 137, 74, 0.25));
  position: relative;
  transition: opacity 0.15s;
}

.pulse-bar:hover {
  opacity: 0.85;
}

.pulse-bar::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--font-data);
  font-size: 0.62rem;
  color: var(--paper);
  background: #0a101c;
  border: 1px solid var(--line);
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}

.pulse-bar:hover::after {
  opacity: 1;
}

/* Ticket tape */
.tape-panel {
  overflow: hidden;
}

.tape {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  scroll-snap-type: x mandatory;
}

.ticket {
  flex: 0 0 auto;
  width: 210px;
  scroll-snap-align: start;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.8rem;
  background:
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 10px,
      rgba(94, 200, 192, 0.03) 10px,
      rgba(94, 200, 192, 0.03) 11px
    ),
    var(--panel-2);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.ticket:hover {
  border-color: var(--copper);
  transform: translateY(-2px);
}

.ticket-id {
  font-family: var(--font-data);
  font-size: 0.68rem;
  color: var(--mute);
}

.ticket-mrt {
  font-family: var(--font-data);
  font-weight: 600;
  font-size: 1rem;
  margin: 0.3rem 0 0.45rem;
}

.ticket-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--mute);
}

.ticket-row strong {
  color: var(--paper);
  font-weight: 500;
  font-family: var(--font-data);
  font-size: 0.72rem;
}

/* Filters + tables */
.filters {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 0.9rem;
  padding: 1rem 1.05rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(24, 35, 58, 0.55), rgba(18, 28, 46, 0.95));
  color-scheme: dark;
}

.filter-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.filter-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.filter-hint {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--mute);
}

.filter-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.75rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, 0.16);
}

.filter-section-label {
  font-family: var(--font-data);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lagoon);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--mute);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.chip:hover {
  color: var(--paper);
  border-color: var(--mute);
}

.chip.is-active {
  color: #1a1208;
  background: linear-gradient(180deg, #e0a05c, var(--copper));
  border-color: var(--copper-dim);
  font-weight: 600;
}

.date-range {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.55rem 0.65rem;
}

.date-sep {
  color: var(--mute);
  padding-bottom: 0.65rem;
  font-family: var(--font-data);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  font-size: 0.72rem;
  color: var(--mute);
  min-width: 0;
}

.field.wide {
  grid-column: span 2;
}

.field > span {
  font-weight: 500;
}

.control {
  border: 1px solid var(--line);
  background: var(--ink);
  border-radius: 9px;
  padding: 0.55rem 0.6rem;
  font-family: var(--font-data);
  font-size: 0.8rem;
  color: var(--paper);
  outline: none;
  min-height: 2.35rem;
  width: 100%;
}

.control:focus {
  border-color: var(--lagoon);
  box-shadow: 0 0 0 3px rgba(94, 200, 192, 0.15);
}

.control::placeholder {
  color: #5d6d86;
}

/* Native date/time pickers on dark UI */
input[type="date"].control,
input[type="time"].control {
  color-scheme: dark;
  min-width: 9.5rem;
}

input[type="date"].control::-webkit-calendar-picker-indicator,
input[type="time"].control::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.85;
  filter: invert(0.85);
}

select.control {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--mute) 50%),
    linear-gradient(135deg, var(--mute) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) 55%,
    calc(100% - 9px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 1.6rem;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 9px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  font-weight: 550;
  font-size: 0.85rem;
}

.btn.primary {
  background: linear-gradient(180deg, #e0a05c, var(--copper));
  border-color: var(--copper-dim);
  color: #1a1208;
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn.btn-compact {
  padding: 0.15rem 0.45rem;
  font-size: 0.72rem;
  min-height: auto;
  line-height: 1.2;
}
.btn.user-locate-al.is-on-map {
  opacity: 0.75;
  border-color: var(--lagoon, #5ec8c0);
  color: var(--lagoon, #5ec8c0);
}
.btn.ghost {  background: transparent;
  color: var(--mute);
}

.btn.ghost:hover {
  color: var(--paper);
  border-color: var(--mute);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.row-actions .btn {
  padding: 4px 10px;
  font-size: 0.85em;
  white-space: nowrap;
}

.linkish {
  border: 0;
  background: none;
  color: var(--lagoon);
  cursor: pointer;
  font-family: var(--font-data);
  font-size: 0.72rem;
  padding: 0;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--panel);
  max-height: calc(100vh - 280px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-data);
  font-size: 0.76rem;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  background: #162033;
  color: var(--mute);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.65rem;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.data-table th.sortable:hover {
  color: var(--paper);
  background: #1a2740;
}

.data-table th.sortable.indexed::after {
  content: " ▢";
  font-size: 0.55rem;
  opacity: 0.45;
  color: var(--copper);
}

.data-table th.sortable.is-asc::after,
.data-table th.sortable.is-desc::after {
  opacity: 1;
  color: var(--lagoon);
  font-size: 0.7rem;
}

.data-table th.sortable.is-asc::after {
  content: " ↑";
}

.data-table th.sortable.is-desc::after {
  content: " ↓";
}

.data-table th.sortable.indexed.is-asc::after {
  content: " ↑◆";
}

.data-table th.sortable.indexed.is-desc::after {
  content: " ↓◆";
}

.sort-hint {
  font-family: var(--font-data);
  font-size: 0.68rem;
  color: var(--mute);
  margin: 0.35rem 0 0;
}

.data-table td {
  padding: 0.62rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}

.data-table tbody tr:hover {
  background: rgba(94, 200, 192, 0.06);
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  border: 1px solid var(--line);
}

.badge.ok {
  color: var(--ok);
  border-color: rgba(109, 206, 139, 0.35);
  background: rgba(109, 206, 139, 0.08);
}

.badge.bad {
  color: var(--danger);
  border-color: rgba(224, 107, 107, 0.35);
  background: rgba(224, 107, 107, 0.08);
}

.cell-stack {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}

.cell-main {
  color: var(--paper);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.cell-sub {
  font-size: 0.65rem;
  color: var(--mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.kv-val .decoded {
  display: block;
  color: var(--lagoon);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.kv-val .raw-muted {
  color: var(--mute);
  font-size: 0.72rem;
}

.kv-key {
  line-height: 1.3;
}

.mcc-chip.wide {
  min-width: auto;
  padding: 0.3rem 0.5rem;
  font-size: 0.72rem;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  font-family: var(--font-data);
  font-size: 0.75rem;
  color: var(--mute);
}

.pager .btn {
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
}

.empty,
.error-banner {
  padding: 1.5rem;
  text-align: center;
  color: var(--mute);
  font-family: var(--font-data);
  font-size: 0.8rem;
}

.error-banner {
  color: var(--danger);
}

/* Authentication + administration */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.login-card {
  width: min(420px, 100%);
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(165deg, var(--panel-2), var(--panel));
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 1.65rem 0 0.25rem;
  font-size: 1.45rem;
}

.login-form,
.compact-form,
.audit-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.login-form {
  flex-direction: column;
  margin-top: 1.25rem;
}

.login-form label,
.compact-form label,
.audit-filters label {
  display: flex;
  flex: 1 1 10rem;
  flex-direction: column;
  gap: 0.32rem;
  color: var(--mute);
  font-size: 0.74rem;
}

.login-form input,
.compact-form input,
.compact-form select,
.audit-filters input {
  width: 100%;
  min-height: 2.35rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.55rem 0.6rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-data);
  outline: none;
}

.login-form input:focus,
.compact-form input:focus,
.compact-form select:focus,
.audit-filters input:focus {
  border-color: var(--lagoon);
  box-shadow: 0 0 0 3px rgba(94, 200, 192, 0.15);
}

.compact-form,
.audit-filters {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.audit-filters {
  align-items: end;
  margin-bottom: 0.9rem;
}

.status-good { color: var(--ok); }
.status-muted { color: var(--mute); }
.mono { font-family: var(--font-data); }

/* Drawer */
.drawer {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--paper);
  width: min(560px, 94vw);
  max-height: 86vh;
  padding: 0;
  box-shadow: var(--shadow);
}

.drawer::backdrop {
  background: rgba(5, 8, 14, 0.65);
  backdrop-filter: blur(3px);
}

.drawer-inner {
  margin: 0;
  padding: 1.1rem 1.15rem 1.25rem;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line-soft);
}

.drawer-head h2 {
  margin: 0;
  font-family: var(--font-data);
  font-size: 1.05rem;
  font-weight: 600;
}

.kv-grid {
  display: grid;
  grid-template-columns: minmax(120px, 38%) 1fr;
  gap: 0.45rem 0.75rem;
  font-size: 0.8rem;
}

.kv-key {
  color: var(--mute);
  font-family: var(--font-data);
  font-size: 0.72rem;
}

.kv-val {
  font-family: var(--font-data);
  word-break: break-all;
}

.skeleton {
  opacity: 0.55;
}

@media (max-width: 1100px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .split {
    grid-template-columns: 1fr;
  }
  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .field.wide {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .filter-grid {
    grid-template-columns: 1fr;
  }
  .field.wide {
    grid-column: span 1;
  }
  .date-sep {
    display: none;
  }
}

/* Schema docs */
.schema-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.schema-intro {
  margin: 0;
  color: var(--mute);
  font-size: 0.88rem;
  line-height: 1.5;
  max-width: 70ch;
}

.schema-root {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.schema-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.schema-card-head {
  padding: 1rem 1.1rem 0.85rem;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.schema-card-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.schema-card-head .table-name {
  font-family: var(--font-data);
  font-size: 0.72rem;
  color: var(--copper);
  margin-top: 0.2rem;
}

.schema-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.schema-pill {
  font-family: var(--font-data);
  font-size: 0.68rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--mute);
  background: rgba(0, 0, 0, 0.15);
}

.schema-pill strong {
  color: var(--paper);
  font-weight: 550;
}

.schema-body {
  padding: 0.9rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.schema-summary {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--paper);
}

.schema-block h3 {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--lagoon);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font-data);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-list li {
  font-size: 0.78rem;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  color: var(--paper);
}

.caution-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--mute);
  font-size: 0.82rem;
  line-height: 1.5;
}

.caution-list li {
  margin-bottom: 0.25rem;
}

.analysis-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.analysis-item {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: rgba(0, 0, 0, 0.12);
}

.analysis-item h4 {
  margin: 0 0 0.3rem;
  font-size: 0.88rem;
}

.analysis-item p {
  margin: 0.15rem 0;
  font-size: 0.78rem;
  color: var(--mute);
  line-height: 1.45;
}

.analysis-item .idx-hint {
  color: var(--copper);
  font-family: var(--font-data);
  font-size: 0.72rem;
}

.schema-table-wrap {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  max-height: 420px;
}

.schema-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.schema-table th {
  position: sticky;
  top: 0;
  background: #162033;
  color: var(--mute);
  text-align: left;
  padding: 0.55rem 0.6rem;
  font-weight: 500;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
  z-index: 1;
}

.schema-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  color: var(--paper);
}

.schema-table tr:hover td {
  background: rgba(94, 200, 192, 0.05);
}

.schema-table .col-name {
  font-family: var(--font-data);
  color: var(--lagoon);
  white-space: nowrap;
}

.schema-table .col-type {
  font-family: var(--font-data);
  font-size: 0.72rem;
  color: var(--mute);
  white-space: nowrap;
}

.idx-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-family: var(--font-data);
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid rgba(212, 137, 74, 0.4);
  color: var(--copper);
  background: rgba(212, 137, 74, 0.1);
}

.idx-badge.no {
  border-color: var(--line);
  color: var(--mute);
  background: transparent;
}

.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
}

.index-card {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  background: var(--panel-2);
}

.index-card .idx-name {
  font-family: var(--font-data);
  font-size: 0.8rem;
  color: var(--copper);
  font-weight: 600;
}

.index-card .idx-cols {
  font-family: var(--font-data);
  font-size: 0.72rem;
  color: var(--paper);
  margin: 0.3rem 0;
}

.index-card .idx-purpose {
  font-size: 0.75rem;
  color: var(--mute);
  line-height: 1.4;
}

.rel-box {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  background: rgba(94, 200, 192, 0.04);
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--paper);
}

.detail-mini-map {
  height: min(42vh, 320px);
  min-height: 240px;
  margin-top: 0.55rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0a101c;
  z-index: 0;
}

/* Clickable user ids */
.user-link {
  color: var(--lagoon);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(94, 200, 192, 0.35);
  text-underline-offset: 2px;
  font-family: var(--font-data);
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-family: var(--font-data);
}

.user-link:hover {
  color: #8ee0d9;
  text-decoration-color: var(--lagoon);
}

/* User 360 dialog */
.user-dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--paper);
  width: min(1280px, 98vw);
  max-height: 96vh;
  height: min(960px, 96vh);
  padding: 0;
  box-shadow: var(--shadow);
}

.user-dialog::backdrop {
  background: rgba(5, 8, 14, 0.7);
  backdrop-filter: blur(3px);
}

.user-dialog-inner {
  padding: 1.1rem 1.15rem 1.25rem;
  max-height: 96vh;
  height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.user-dialog.map-expanded .user-dialog-inner {
  overflow: hidden;
}

.user-dialog.map-expanded .user-body > :not(#user-cell-panel) {
  display: none;
}

.user-dialog.map-expanded #user-cell-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.user-dialog.map-expanded #user-cell-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.user-dialog.map-expanded .user-map-shell {
  flex: 1;
  min-height: 0;
}

.user-dialog.map-expanded #user-map {
  height: 100%;
  min-height: 60vh;
}

.user-sub {
  margin: 0.25rem 0 0;
  font-family: var(--font-data);
  font-size: 0.75rem;
  color: var(--mute);
}

.user-body {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 0.5rem;
}

.user-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}

.user-stat {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: var(--panel-2);
}

.user-stat .lbl {
  font-size: 0.7rem;
  color: var(--mute);
  margin-bottom: 0.25rem;
}

.user-stat .val {
  font-family: var(--font-data);
  font-size: 1.05rem;
  font-weight: 550;
}

.insight-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.insight {
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 0.82rem;
  line-height: 1.45;
  border: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, 0.12);
}

.insight.info {
  border-color: rgba(94, 200, 192, 0.3);
}

.insight.warn {
  border-color: rgba(212, 137, 74, 0.45);
  color: #f0d0b0;
}

.user-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.user-panel {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: rgba(0, 0, 0, 0.12);
  min-width: 0;
}

.user-panel h3 {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
  color: var(--lagoon);
  font-family: var(--font-data);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* —— Standalone decoder workbench —— */
.decode-workbench {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.decode-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(115deg, rgba(212, 137, 74, 0.11), transparent 42%),
    linear-gradient(180deg, var(--panel-2), var(--panel));
}

.decode-intro .eyebrow {
  margin-bottom: 0.3rem;
}

.decode-intro h2 {
  margin: 0;
  font-size: 1.25rem;
}

.decode-intro p:not(.eyebrow) {
  max-width: 45rem;
  margin: 0.35rem 0 0;
  color: var(--mute);
  font-size: 0.83rem;
}

.decode-flow {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 0.45rem;
  padding: 0.55rem 0.65rem;
  color: var(--copper);
  border: 1px solid rgba(212, 137, 74, 0.38);
  border-radius: 8px;
  background: rgba(11, 18, 32, 0.55);
  font-family: var(--font-data);
  font-size: 0.62rem;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

.decode-flow i {
  width: 1.15rem;
  height: 1px;
  background: linear-gradient(90deg, var(--copper), var(--lagoon));
  position: relative;
}

.decode-flow i::after {
  content: "";
  position: absolute;
  right: 0;
  top: -2px;
  width: 4px;
  height: 4px;
  border-top: 1px solid var(--lagoon);
  border-right: 1px solid var(--lagoon);
  transform: rotate(45deg);
}

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

.decode-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(24, 35, 58, 0.82), rgba(18, 28, 46, 0.98));
}

.decode-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.decode-card h3 {
  margin: 0.12rem 0 0;
  color: var(--paper);
  font-size: 1.02rem;
}

.decode-code {
  margin: 0;
  color: var(--copper);
  font-family: var(--font-data);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
}

.decode-badge {
  flex: 0 0 auto;
  padding: 0.22rem 0.42rem;
  border: 1px solid rgba(212, 137, 74, 0.42);
  border-radius: 999px;
  color: #f0c397;
  font-family: var(--font-data);
  font-size: 0.62rem;
}

.decode-badge.lagoon {
  border-color: rgba(94, 200, 192, 0.4);
  color: var(--lagoon);
}

.decode-form {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  margin-top: 0.85rem;
}

.decode-form .field {
  flex: 1;
}

.decode-form .btn {
  min-height: 2.35rem;
  white-space: nowrap;
}

.decode-input {
  font-family: var(--font-data);
  letter-spacing: 0.025em;
}

textarea.decode-input {
  min-height: 2.35rem;
  max-height: 6.5rem;
  resize: vertical;
  line-height: 1.35;
}

.decode-result {
  min-height: 6.4rem;
  margin-top: 0.85rem;
  padding: 0.75rem;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--mute);
  background: rgba(0, 0, 0, 0.12);
  font-size: 0.78rem;
}

.decode-result.is-error {
  border-color: rgba(224, 107, 107, 0.65);
  color: #f1adad;
}

.decode-result.is-loading {
  border-color: rgba(94, 200, 192, 0.5);
  color: var(--lagoon);
}

.decode-result-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.35rem 0.7rem;
  margin: 0;
  font-family: var(--font-data);
}

.decode-result-grid dt {
  color: var(--mute);
}

.decode-result-grid dd {
  min-width: 0;
  margin: 0;
  color: var(--paper);
  overflow-wrap: anywhere;
}

.decode-result-grid dd.emphasis {
  color: var(--copper);
  font-size: 0.9rem;
}

.decode-result-note {
  margin: 0.65rem 0 0;
  color: var(--mute);
  font-size: 0.73rem;
}

.decode-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.decode-result a {
  color: var(--lagoon);
}

.decode-location-title {
  margin: 0 0 0.55rem;
  color: var(--paper);
  font-family: var(--font-data);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .decode-intro {
    align-items: flex-start;
    flex-direction: column;
  }
  .decode-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .decode-form {
    align-items: stretch;
    flex-direction: column;
  }
  .decode-form .btn {
    width: 100%;
  }
  .decode-flow {
    width: 100%;
    justify-content: space-between;
  }
}

.user-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.user-panel-head h3 {
  margin: 0;
}

.user-mini-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-data);
  font-size: 0.72rem;
}

.user-mini-table th,
.user-mini-table td {
  text-align: left;
  padding: 0.35rem 0.3rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

.user-mini-table th {
  color: var(--mute);
  font-weight: 500;
  font-size: 0.65rem;
  text-transform: uppercase;
}

/* Geographic viz: wide aspect, enough height (data-viz: maps need room) */
#user-cell-panel {
  border-color: rgba(94, 200, 192, 0.25);
}

.user-map-shell {
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #0a101c;
  min-height: min(48vh, 420px);
}

#user-map {
  height: min(48vh, 420px);
  min-height: 320px;
  width: 100%;
  border-radius: 0;
  border: 0;
  background: #0a101c;
  z-index: 0;
}

.user-map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin: 0.55rem 0 0.65rem;
}

.user-map-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.1rem;
  margin-top: 0.55rem;
  font-family: var(--font-data);
  font-size: 0.72rem;
  color: var(--mute);
}

.user-map-meta strong {
  color: var(--paper);
  font-weight: 550;
}

.path-arrow {
  background: transparent !important;
  border: 0 !important;
  color: #5ec8c0;
  font-size: 12px;
  opacity: 0.85;
  text-shadow: 0 0 4px #0a101c;
  pointer-events: none;
}
.path-arrow span {
  display: inline-block;
  line-height: 16px;
}
.leaflet-interactive.path-traveler,
.path-traveler {
  filter: drop-shadow(0 0 4px rgba(240, 193, 75, 0.9));
}
#user-map-anim-label {
  min-height: 1.1em;
  color: var(--lagoon, #5ec8c0);
}

.user-spark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 56px;
  margin-top: 0.35rem;
}

.user-spark span {
  flex: 1;
  min-width: 4px;
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(180deg, var(--copper), rgba(212, 137, 74, 0.25));
  opacity: 0.9;
}

.user-spark span:hover {
  opacity: 1;
  outline: 1px solid var(--lagoon);
}

@media (max-width: 900px) {
  .user-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .user-split {
    grid-template-columns: 1fr;
  }
  #user-map,
  .user-map-shell {
    min-height: 280px;
    height: 40vh;
  }
}

/* Lifecycle analytics charts (CSS/SVG — no extra deps) */
.viz-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.viz-panel {
  min-height: 220px;
}

.chart-line {
  position: relative;
  height: 200px;
  margin-top: 0.5rem;
  border-radius: 10px;
  background:
    linear-gradient(to top, rgba(255, 255, 255, 0.03) 1px, transparent 1px) 0 0 / 100% 25%,
    var(--ink);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}

.chart-line svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-bars-v {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 180px;
  margin-top: 0.5rem;
  padding: 0.5rem 0.4rem 0;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  background: var(--ink);
}

.chart-bars-v .bar {
  flex: 1;
  min-width: 0;
  border-radius: 4px 4px 1px 1px;
  background: linear-gradient(180deg, var(--lagoon), rgba(94, 200, 192, 0.25));
  position: relative;
  transition: opacity 0.12s;
}

.chart-bars-v .bar.is-peak {
  background: linear-gradient(180deg, #e2a66a, var(--copper));
}

.chart-bars-v .bar:hover {
  opacity: 0.85;
}

.chart-bars-v .bar-label {
  position: absolute;
  bottom: -1.1rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-data);
  font-size: 0.58rem;
  color: var(--mute);
  white-space: nowrap;
}

.chart-bars-h {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.chart-bars-h .row {
  display: grid;
  grid-template-columns: 4.5rem 1fr 3.5rem;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.78rem;
}

.chart-bars-h .row .name {
  font-family: var(--font-data);
  font-size: 0.72rem;
  color: var(--mute);
}

.chart-bars-h .track {
  height: 0.55rem;
  border-radius: 99px;
  background: var(--line-soft);
  overflow: hidden;
}

.chart-bars-h .fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--lagoon-dim), var(--lagoon));
}

.chart-bars-h .val {
  font-family: var(--font-data);
  font-size: 0.72rem;
  text-align: right;
  color: var(--paper);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.45rem;
  font-family: var(--font-data);
  font-size: 0.68rem;
  color: var(--mute);
}

.chart-legend i {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
  margin-right: 0.25rem;
  vertical-align: -1px;
}

.lc-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.lc-timeline .seg {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.5rem;
  align-items: center;
}

.lc-timeline .seg .when {
  font-family: var(--font-data);
  font-size: 0.7rem;
  color: var(--mute);
}

.lc-timeline .seg .bar {
  height: 1.1rem;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(94, 200, 192, 0.35), var(--copper));
  min-width: 4px;
  position: relative;
}

.lc-timeline .seg .bar span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 0.4rem;
  font-family: var(--font-data);
  font-size: 0.62rem;
  color: #1a1208;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}

@media (max-width: 1100px) {
  .viz-grid {
    grid-template-columns: 1fr;
  }
}

/* Map view */
.map-layout {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 280px);
  gap: 0.85rem;
  min-height: 0;
}

.map-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.roam-map {
  flex: 1;
  min-height: 480px;
  background: #0a101c;
  z-index: 0;
}

.map-footnote {
  margin: 0;
  padding: 0.55rem 0.75rem;
  font-size: 0.72rem;
  color: var(--mute);
  border-top: 1px solid var(--line-soft);
  font-family: var(--font-data);
  line-height: 1.4;
}

.map-side {
  max-height: 560px;
  overflow: auto;
}

.map-side .country-list {
  max-height: none;
}

/* Leaflet dark-ish controls */
.leaflet-container {
  font-family: var(--font-ui);
  background: #0a101c;
}

.leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.leaflet-popup-tip {
  background: var(--panel);
}

.leaflet-popup-content {
  margin: 0.65rem 0.75rem;
  font-size: 0.8rem;
  line-height: 1.4;
}

.leaflet-popup-content strong {
  color: var(--copper);
}

.bubble-label {
  background: transparent;
  border: 0;
  box-shadow: none;
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 600;
  color: var(--paper);
  text-shadow: 0 1px 2px #000;
}

@media (max-width: 1100px) {
  .map-layout {
    grid-template-columns: 1fr;
  }
  .map-side {
    max-height: 280px;
  }
}

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
  }
  .rail {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .nav {
    flex-direction: row;
    overflow-x: auto;
  }
  .nav-item {
    white-space: nowrap;
  }
  .rail-foot {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
