:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #07110f;
  --bg-2: #0c1715;
  --panel: #111f1c;
  --panel-2: #142622;
  --line: #25413b;
  --line-soft: rgba(140, 177, 166, 0.16);
  --ink: #eef7f4;
  --muted: #8ca9a2;
  --green: #1fe08a;
  --red: #ff5d6c;
  --amber: #ffb454;
  --cyan: #54d2ff;
  --blue: #6a8dff;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(31, 224, 138, 0.13), transparent 25%),
    radial-gradient(circle at 88% 20%, rgba(84, 210, 255, 0.09), transparent 30%),
    linear-gradient(140deg, var(--bg), #050908 56%, #10140e);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

html {
  scroll-behavior: smooth;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--line-soft);
  background: rgba(7, 17, 15, 0.88);
  backdrop-filter: blur(18px);
}

.brand-button {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  color: var(--ink);
  background: var(--panel);
  text-align: left;
}

.brand-mark {
  width: 42px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #04100c;
  font-weight: 900;
  background: linear-gradient(135deg, var(--green), var(--cyan));
}

.brand-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.brand-copy strong,
.brand-copy small,
.rail-status span,
.metric span,
.panel-title span,
.alert-meta,
.fine-print,
.profile-card small {
  overflow-wrap: anywhere;
}

.brand-copy small,
.fine-print,
.panel-title span,
.alert-meta,
.flow-row small,
.profile-card small {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.ghost,
.chip {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active,
.chip:hover,
.chip.active,
.ghost:hover {
  color: var(--ink);
  border-color: var(--line-soft);
  background: rgba(255, 255, 255, 0.06);
}

.rail-status {
  margin-top: auto;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 18px rgba(255, 180, 84, 0.7);
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 18px rgba(31, 224, 138, 0.7);
}

.main {
  min-width: 0;
  padding: 24px;
}

.auth-view,
.workspace {
  min-height: calc(100vh - 48px);
}

.auth-view {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 430px);
  align-items: center;
  gap: 24px;
}

.auth-hero {
  min-height: 560px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(7, 17, 15, 0.1), rgba(7, 17, 15, 0.78)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 82px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 82px),
    linear-gradient(135deg, #10211d, #0b1017 60%, #21180b);
  box-shadow: var(--shadow);
}

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

h1 {
  max-width: 720px;
  font-size: clamp(2.15rem, 6vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(1.5rem, 3.8vw, 2.35rem);
  line-height: 1.05;
}

h3 {
  font-size: 1rem;
}

.auth-hero p:not(.eyebrow),
.fine-print {
  line-height: 1.55;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.auth-card,
.panel,
.metric,
.state-card,
.alert-card,
.flow-row,
.watch-item {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(17, 31, 28, 0.82);
  box-shadow: 0 14px 48px rgba(0, 0, 0, 0.18);
}

.auth-card {
  padding: 22px;
  display: grid;
  gap: 16px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.auth-tab {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.auth-tab.active {
  color: #04100c;
  background: var(--green);
}

.auth-message {
  display: none;
  min-height: 42px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.auth-message.error,
.auth-message.success {
  display: flex;
}

.auth-message.error {
  color: #ffd9de;
  border-color: rgba(255, 93, 108, 0.45);
  background: rgba(255, 93, 108, 0.12);
}

.auth-message.success {
  color: #cdfce7;
  border-color: rgba(31, 224, 138, 0.42);
  background: rgba(31, 224, 138, 0.11);
}

.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.text-button {
  min-height: 36px;
  border: 0;
  padding: 0;
  color: var(--green);
  background: transparent;
  font-weight: 900;
}

.text-button:hover {
  color: #65f2b2;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--ink);
  background: #081310;
}

input:focus {
  outline: 3px solid rgba(31, 224, 138, 0.16);
  border-color: rgba(31, 224, 138, 0.7);
}

.primary {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #04100c;
  font-weight: 900;
  background: var(--green);
}

.primary:hover {
  background: #65f2b2;
}

.primary:disabled {
  cursor: wait;
  color: rgba(4, 16, 12, 0.58);
  background: rgba(31, 224, 138, 0.55);
}

.compact {
  min-height: 40px;
}

.hidden {
  display: none;
}

.workspace {
  max-width: 1360px;
  margin: 0 auto;
}

.boot-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.boot-card {
  width: min(420px, 100%);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px;
  text-align: center;
}

.boot-card h1 {
  margin: 0;
  font-size: 1.35rem;
}

body:not(.booting) .boot-view,
body.booting .auth-view,
body.booting .workspace {
  display: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

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

.live-indicator {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.82rem;
  font-weight: 800;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 16px rgba(255, 180, 84, 0.55);
}

.live-indicator[data-status="live"] .pulse-dot,
.live-indicator[data-status="syncing"] .pulse-dot {
  background: var(--green);
  box-shadow: 0 0 18px rgba(31, 224, 138, 0.75);
}

.live-indicator[data-status="syncing"] .pulse-dot {
  animation: pulse 1.1s infinite;
}

.live-indicator[data-status="offline"] .pulse-dot,
.live-indicator[data-status="degraded"] .pulse-dot,
.live-indicator[data-status="stale"] .pulse-dot {
  background: var(--red);
  box-shadow: 0 0 18px rgba(255, 93, 108, 0.55);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

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

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

.terminal-cell {
  min-height: 72px;
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(31, 224, 138, 0.08), transparent),
    rgba(17, 31, 28, 0.72);
}

.terminal-cell span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.terminal-cell strong {
  display: block;
  margin-top: 8px;
  font-size: 1.15rem;
}

.metric {
  padding: 16px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.75rem, 3vw, 2.6rem);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.secondary-grid {
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
}

.panel {
  padding: 16px;
  min-width: 0;
}

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

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

.state-card {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.state-card header,
.alert-card header,
.flow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.alert-heading {
  display: grid;
  gap: 3px;
}

.alert-ticker {
  font-size: 1.28rem;
  letter-spacing: 0;
}

.alert-status-stack {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.alert-time {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.ticker {
  font-size: 1.35rem;
  font-weight: 900;
}

.pill {
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.pill.bull {
  color: #03100b;
  background: var(--green);
}

.pill.bear {
  background: var(--red);
}

.pill.watch {
  color: #150d01;
  background: var(--amber);
}

.pill.containment {
  color: #06100f;
  background: var(--cyan);
}

.pill.expansion {
  color: #f7f2ff;
  background: var(--blue);
}

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

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

.pressure-row span {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 7px 9px;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.78rem;
  font-weight: 800;
}

.zone {
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.zone span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.zone strong {
  display: block;
  margin-top: 4px;
}

.alert-feed,
.flow-list,
.watchlist,
.admin-list,
.category-activity,
.snapshot-list {
  display: grid;
  gap: 10px;
}

.alert-feed {
  max-height: 640px;
  overflow: auto;
  padding-right: 3px;
}

.alert-card {
  padding: 13px;
  display: grid;
  gap: 10px;
  border-left: 3px solid rgba(255, 255, 255, 0.12);
}

.alert-card.bull {
  border-left-color: var(--green);
}

.alert-card.bear {
  border-left-color: var(--red);
}

.alert-card.watch {
  border-left-color: var(--amber);
}

.alert-card.containment {
  border-left-color: var(--cyan);
}

.alert-card.expansion {
  border-left-color: var(--blue);
}

.alert-card.stale,
.state-card.stale,
.flow-row.stale {
  opacity: 0.64;
}

.alert-card.stale {
  border-left-color: var(--amber);
}

.alert-card p {
  color: var(--ink);
  line-height: 1.45;
}

.alert-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.78rem;
}

.alert-ticker {
  display: block;
  font-size: 1.2rem;
}

.alert-route {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

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

.alert-pressure span,
.pressure-row span {
  line-height: 1.45;
}

.alert-pressure span,
.focus-line {
  min-height: 32px;
  display: flex;
  align-items: center;
  padding: 7px 9px;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.78rem;
  font-weight: 800;
}

.focus-line {
  color: var(--ink);
}

.category-card,
.snapshot-item,
.watch-summary-card {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.category-card {
  padding: 13px;
  display: grid;
  gap: 10px;
}

.category-card header,
.snapshot-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-card header span,
.category-card p,
.snapshot-item small,
.watch-item small {
  color: var(--muted);
}

.category-meter {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.category-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--cyan));
}

.snapshot-item {
  min-height: 58px;
  padding: 10px 12px;
}

.snapshot-item > div {
  min-width: 0;
  flex: 1;
}

.snapshot-dot {
  width: 11px;
  height: 36px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.snapshot-dot.bull {
  background: var(--green);
}

.snapshot-dot.bear {
  background: var(--red);
}

.snapshot-dot.watch {
  background: var(--amber);
}

.snapshot-dot.containment {
  background: var(--cyan);
}

.snapshot-dot.expansion {
  background: var(--blue);
}

.expanded {
  min-height: 460px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  text-align: center;
}

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

.flow-row {
  min-height: 62px;
  padding: 11px;
}

.flow-row strong {
  display: block;
}

.flow-score {
  font-weight: 900;
  color: var(--green);
}

.row-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.watch-item {
  min-height: 58px;
  padding: 11px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.watch-item.active-flow {
  border-color: rgba(31, 224, 138, 0.48);
  background:
    linear-gradient(90deg, rgba(31, 224, 138, 0.09), transparent),
    rgba(17, 31, 28, 0.82);
}

.watch-summary-card {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
}

.watch-summary-card strong {
  width: 44px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #04100c;
  background: var(--green);
}

.watch-summary-card span {
  color: var(--muted);
}

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

.profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
}

.profile-card > span {
  width: 48px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #04100c;
  font-weight: 900;
  background: var(--cyan);
}

.toggle-row {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
}

.toggle-row input {
  width: 22px;
  min-height: 22px;
  accent-color: var(--green);
}

.admin-form {
  display: grid;
  gap: 14px;
}

.admin-list span {
  padding: 11px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.operator-panel {
  grid-column: 1 / -1;
}

.access-panel {
  grid-column: 1 / -1;
}

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

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

.operator-tile {
  min-height: 92px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.operator-tile span,
.operator-tile small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.operator-tile strong {
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.operator-errors {
  margin-top: 12px;
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255, 180, 84, 0.08);
}

.operator-errors span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.invite-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px auto;
  gap: 10px;
}

.access-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.access-row {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.access-row > div:first-child {
  min-width: 0;
}

.access-row strong,
.access-row small {
  display: block;
  overflow-wrap: anywhere;
}

.access-row small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.access-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.access-badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.78rem;
  font-weight: 900;
}

.danger {
  border-color: rgba(255, 93, 108, 0.42);
  color: var(--red);
}

.muted-row {
  opacity: 0.78;
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    height: auto;
    position: sticky;
    z-index: 10;
    padding: 10px;
    gap: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .brand-button,
  .rail-status {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
  }

  .nav-item {
    min-height: 38px;
    padding: 0 5px;
    text-align: center;
    font-size: clamp(0.62rem, 2.45vw, 0.8rem);
  }

  .main {
    padding: 14px max(14px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .auth-view {
    min-height: calc(100vh - 74px);
    grid-template-columns: 1fr;
  }

  .auth-hero {
    min-height: 300px;
  }

  .metric-grid,
  .terminal-strip,
  .dashboard-grid,
  .state-grid,
  .flow-columns,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .operator-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .invite-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar,
  .topbar-actions,
  .row-form {
    align-items: stretch;
    flex-direction: column;
    display: flex;
  }

  .zones {
    grid-template-columns: 1fr;
  }

  .pressure-row {
    grid-template-columns: 1fr;
  }

  .alert-pressure {
    grid-template-columns: 1fr;
  }

  .auth-hero {
    min-height: 220px;
    padding: 18px;
  }

  .alert-card {
    padding: 12px;
  }

  .alert-card header {
    align-items: start;
  }

  .alert-status-stack {
    justify-items: start;
  }

  .operator-grid {
    grid-template-columns: 1fr;
  }

  .access-row {
    align-items: stretch;
    flex-direction: column;
  }

  .access-actions {
    justify-content: flex-start;
  }

  button,
  .primary,
  .ghost,
  input {
    min-height: 46px;
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.72;
  }
  50% {
    transform: scale(1.45);
    opacity: 1;
  }
}
