@font-face {
  font-family: "Rift Bold";
  src: url("/fonts/rift-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Maison Neue";
  src: url("/fonts/maison-neue-medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Maison Neue";
  src: url("/fonts/maison-neue-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Maison Neue Mono";
  src: url("/fonts/maison-neue-mono.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #080808;
  --bg-raised: #111111;
  --bg-inset: #050505;
  --fg: #ffffff;
  --fg-muted: #a8a8a8;
  --fg-subtle: #838383;
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.26);
  --accent: #ef0d33;
  --accent-strong: #c10b2a;
  --accent-soft-bg: rgba(239, 13, 51, 0.12);
  --accent-soft-line: rgba(239, 13, 51, 0.45);
  --accent-text: #ff8fa1;
  --focus-ring: #ffffff;
  --font-display: "Rift Bold", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Maison Neue", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "Maison Neue Mono", "SFMono-Regular", "SF Mono", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-weight: 500;
  line-height: 1.5;
}

a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  transition: text-decoration-color 120ms ease;
}

a:hover {
  text-decoration-color: var(--accent);
}

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

button,
input {
  font: inherit;
}

button {
  appearance: none;
  border: 1px solid var(--accent-strong);
  background: var(--accent-strong);
  color: #ffffff;
  border-radius: 2px;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.01em;
}

button:hover {
  background: var(--accent);
  border-color: var(--accent);
}

button.secondary {
  background: transparent;
  color: var(--fg);
  border-color: var(--line-strong);
}

button.secondary:hover {
  background: var(--bg-raised);
  border-color: var(--fg);
}

.subtle-button {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--fg-muted);
  border-radius: 2px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.subtle-button:hover {
  background: var(--bg-raised);
  border-color: var(--fg);
  color: var(--fg);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

code,
pre,
.mono {
  font-family: var(--font-mono);
}

.mono,
.numeric {
  font-variant-numeric: tabular-nums slashed-zero;
  font-feature-settings: "tnum" 1, "zero" 1;
}

h1,
h2,
h3,
.display {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  margin: 0;
}

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3.5rem;
}

.dashboard-shell {
  display: grid;
  gap: 1rem;
}

/* ── Header ──────────────────────────────────────────────────────────── */

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  padding: 1.25rem 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-logo {
  display: block;
  height: 1.75rem;
  width: auto;
}

.brand-copy {
  display: grid;
  gap: 0.2rem;
}

.brand-context {
  margin: 0;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
}

.page-title {
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  line-height: 1;
}

.header-meta {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 0.6rem;
}

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line-strong);
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--fg-muted);
}

.connection-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: currentColor;
}

.connection-badge-live {
  display: none;
  color: var(--fg);
  border-color: var(--fg);
}

.connection-badge-offline {
  color: var(--fg-muted);
}

[data-phx-main].phx-connected .connection-badge-live {
  display: inline-flex;
}

[data-phx-main].phx-connected .connection-badge-offline {
  display: none;
}

.last-refresh {
  margin: 0;
  color: var(--fg-subtle);
  font-size: 0.8rem;
}

.logout-form {
  margin: 0;
}

.logout-button {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
}

/* ── Alerts ──────────────────────────────────────────────────────────── */

.alert {
  border: 1px solid var(--accent-soft-line);
  background: var(--accent-soft-bg);
  padding: 1rem 1.25rem;
}

.alert-title {
  margin: 0;
  color: var(--accent-text);
  font-size: 1rem;
  text-transform: none;
  letter-spacing: normal;
  font-family: var(--font-body);
  font-weight: 700;
}

.alert-copy {
  margin: 0.4rem 0 0;
  color: var(--fg-muted);
}

/* ── Summary tiles ───────────────────────────────────────────────────── */

.summary-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.summary-tile {
  border: 1px solid var(--line);
  background: var(--bg-raised);
  padding: 1rem 1.1rem;
}

.summary-tile-label {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-tile-value {
  margin: 0.4rem 0 0;
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 2vw, 2rem);
  line-height: 1.05;
}

.summary-tile-value-unavailable {
  color: var(--fg-subtle);
  font-family: var(--font-body);
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.summary-tile-detail {
  margin: 0.4rem 0 0;
  color: var(--fg-subtle);
  font-size: 0.85rem;
}

.summary-tile-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
  color: var(--accent-text);
  font-size: 0.82rem;
  font-weight: 700;
}

/* ── Sections ────────────────────────────────────────────────────────── */

.section {
  border: 1px solid var(--line);
  background: var(--bg-raised);
  padding: 1.15rem 1.25rem;
}

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

.section-title {
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.section-copy {
  margin: 0.35rem 0 0;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.section-note {
  margin: 0.5rem 0 0;
  color: var(--fg-subtle);
  font-size: 0.78rem;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
}

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

.data-table-running {
  table-layout: fixed;
  min-width: 960px;
}

.data-table-projects {
  table-layout: fixed;
  min-width: 800px;
}

.data-table th {
  padding: 0 0.6rem 0.7rem 0;
  text-align: left;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line-strong);
}

.data-table td {
  padding: 0.85rem 0.6rem 0.85rem 0;
  border-top: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.92rem;
}

.row-emphasis td {
  background: var(--accent-soft-bg);
}

.issue-stack,
.session-stack,
.detail-stack,
.token-stack {
  display: grid;
  gap: 0.24rem;
  min-width: 0;
}

.prefix-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.prefix-tag {
  display: inline-flex;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--line-strong);
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.2;
}

/* ── Status badges: color is always paired with text + a distinct dot shape ── */

.state-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 1.75rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--line-strong);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1;
}

.state-dot {
  width: 0.5rem;
  height: 0.5rem;
  flex: none;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: currentColor;
}

.state-badge-warning {
  border-color: var(--line-strong);
  color: var(--fg-muted);
}

.state-badge-warning .state-dot {
  background: transparent;
}

.state-badge-danger {
  border-color: var(--accent-soft-line);
  background: var(--accent-soft-bg);
  color: var(--accent-text);
}

.issue-id {
  font-family: var(--font-mono);
  font-weight: 500;
}

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

.subtle {
  color: var(--fg-subtle);
}

.unavailable-state {
  margin: 1rem 0 0;
  padding: 0.75rem 0.9rem;
  border: 1px dashed var(--line-strong);
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.empty-state {
  margin: 1rem 0 0;
  color: var(--fg-subtle);
}

.show-all-button {
  margin-top: 0.85rem;
}

@media (max-width: 767px) {
  .app-shell {
    padding: 1rem 0.85rem 2rem;
  }

  .dashboard-header {
    flex-direction: column;
  }

  .header-meta {
    justify-items: start;
    width: 100%;
  }

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

@media (min-width: 768px) {
  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1440px) {
  .app-shell {
    padding: 2rem 1rem 4rem;
  }
}

/* ── Login ───────────────────────────────────────────────────────────── */

.login-shell {
  min-height: 100vh;
  display: grid;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: min(24rem, 100%);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  padding: 2rem;
  display: grid;
  gap: 1.25rem;
}

.login-brand {
  display: grid;
  gap: 0.85rem;
  justify-items: start;
}

.login-brand-logo {
  height: 1.6rem;
  width: auto;
}

.login-title {
  font-size: 1.5rem;
}

.login-error {
  margin: 0;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--accent-soft-line);
  background: var(--accent-soft-bg);
  color: var(--accent-text);
  font-size: 0.9rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field-label {
  color: var(--fg-muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-input {
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--fg);
  padding: 0.65rem 0.75rem;
  border-radius: 2px;
  width: 100%;
}

.field-input:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
  border-color: var(--fg);
}

.login-submit {
  width: 100%;
}
