/* ============================================================
   hermes-host-frontend / static/app.css
   Dark navy palette matching hermes-webui (021128 / 1a1a2e / 7aa2ff)
   No external scripts. Inter via Google Fonts (linked from HTML).
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #021128;
  --surface: #1a1a2e;
  --surface-2: #0e1b35;
  --code-bg: #0a1424;

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.14);

  /* Text */
  --text: #e6e9f2;
  --text-dim: #8a93a6;
  --text-mute: #5a6378;

  /* Brand / accent (mirrors webui) */
  --accent: #7aa2ff;
  --accent-2: #5b86e3;
  --accent-soft: rgba(122, 162, 255, 0.14);
  --accent-ring: rgba(122, 162, 255, 0.35);

  /* Caduceus mark gradient stops (lifted from webui) */
  --mark-cyan: #08EBF1;
  --mark-blue: #3889FD;
  --mark-tile-hi: #0D3460;
  --mark-tile-lo: #021128;

  /* Status */
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --warn: #e8a030;
  --warn-bg: rgba(232, 160, 48, 0.12);
  --danger: #ee0555;
  --danger-bg: rgba(238, 5, 85, 0.12);
  --info-bg: rgba(122, 162, 255, 0.12);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace;

  /* Geometry */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.04);

  /* Layout */
  --max: 1200px;
}

/* ------------------------------------------------------------------ */
/* Reset (lightweight)                                                */
/* ------------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img,
svg {
  display: block;
  max-width: 100%;
}

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

button {
  font-family: inherit;
  cursor: pointer;
}

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

/* ------------------------------------------------------------------ */
/* Top bar (shared by all pages)                                      */
/* ------------------------------------------------------------------ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.02), transparent);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.2px;
}
.topbar .brand:hover {
  text-decoration: none;
}
.topbar .brand-mark {
  width: 28px;
  height: 28px;
}
.topbar .brand-name {
  font-size: 15px;
}

.topbar .topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar .user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 13px;
}
.topbar .user-chip strong {
  color: var(--text);
  font-weight: 500;
}

/* ------------------------------------------------------------------ */
/* Main / containers                                                  */
/* ------------------------------------------------------------------ */
main {
  flex: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 36px 28px 64px;
}

main.narrow {
  max-width: 480px;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.2px;
}
.page-sub {
  color: var(--text-dim);
  margin: 0 0 28px;
  font-size: 13px;
}

footer.app-foot {
  padding: 18px 28px;
  border-top: 1px solid var(--border);
  color: var(--text-mute);
  font-size: 12px;
  text-align: center;
}
footer.app-foot code {
  font-family: var(--mono);
  color: var(--text-dim);
}

/* ------------------------------------------------------------------ */
/* Cards                                                              */
/* ------------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-inset);
}
.card + .card {
  margin-top: 20px;
}

/* Dashboard stacks cards inside wrappers (grids, placeholder divs), which
   breaks the .card + .card adjacency above — space ALL direct children of
   #root so the vertical rhythm holds no matter how cards are nested. */
#root > * + * {
  margin-top: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
  text-transform: uppercase;
}
.card-sub {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 2px;
}

/* ------------------------------------------------------------------ */
/* Grid (dashboard 3-card row)                                        */
/* ------------------------------------------------------------------ */
.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}
@media (min-width: 760px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
  .grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* ------------------------------------------------------------------ */
/* Buttons                                                            */
/* ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: #0a1424;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.1px;
  transition: filter 120ms ease, transform 120ms ease, background 120ms ease;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover {
  filter: brightness(1.08);
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border-2);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.04);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: transparent;
  padding: 6px 10px;
}
.btn-ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(238, 5, 85, 0.4);
}
.btn-danger:hover {
  background: var(--danger-bg);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ------------------------------------------------------------------ */
/* Forms                                                              */
/* ------------------------------------------------------------------ */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.2px;
}

.input,
.select {
  width: 100%;
  padding: 10px 12px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input::placeholder {
  color: var(--text-mute);
}
.input:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.input.input-mono {
  font-family: var(--mono);
  font-size: 13px;
}

textarea.input {
  min-height: 90px;
  resize: vertical;
}

.field-hint {
  font-size: 11px;
  color: var(--text-mute);
}
.field-error {
  font-size: 12px;
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: 6px;
  padding: 6px 10px;
  margin-top: 2px;
  display: none;
}
.field-error.show {
  display: block;
}
.field.has-error .input {
  border-color: var(--danger);
}

/* Password reveal button (dashboard webui password) */
.password-wrap {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.password-wrap .input {
  flex: 1;
}

/* Inline checkbox row */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.checkbox-row input[type='checkbox'] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Status badges                                                      */
/* ------------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.success {
  background: var(--success-bg);
  color: var(--success);
}
.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}
.badge.danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.badge.muted {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
}

/* ------------------------------------------------------------------ */
/* Hero (landing)                                                     */
/* ------------------------------------------------------------------ */
.hero {
  text-align: center;
  padding: 64px 16px 32px;
}
.hero .mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 22px;
}
.hero h1 {
  font-size: clamp(28px, 4vw, 42px);
  margin: 0 0 14px;
  letter-spacing: -0.6px;
  font-weight: 600;
  line-height: 1.18;
}
.hero .tag {
  color: var(--text-dim);
  font-size: 16px;
  max-width: 560px;
  margin: 0 auto 28px;
}
.hero .cta-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.terminal-mock {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 36px auto 0;
  max-width: 640px;
  color: var(--text-dim);
  text-align: left;
  white-space: pre;
  overflow-x: auto;
  line-height: 1.7;
}
.terminal-mock .acc {
  color: var(--accent);
}
.terminal-mock .ok {
  color: var(--success);
}
.terminal-mock .dim {
  color: var(--text-mute);
}

/* ------------------------------------------------------------------ */
/* Steps (landing)                                                    */
/* ------------------------------------------------------------------ */
.steps {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
  margin-top: 48px;
}
@media (min-width: 760px) {
  .steps {
    grid-template-columns: repeat(3, 1fr);
  }
}
.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
}
.step .step-num {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}
.step h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}
.step p {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

/* ------------------------------------------------------------------ */
/* Signup provisioning state                                          */
/* ------------------------------------------------------------------ */
.provision {
  margin-top: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 28px;
  text-align: center;
  transition: opacity 280ms ease;
}
.provision h2 {
  margin: 14px 0 4px;
  font-size: 18px;
  font-weight: 600;
}
.provision p {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

.spinner-ring {
  display: inline-block;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid var(--border-2);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.progress-track {
  width: 100%;
  max-width: 420px;
  height: 6px;
  border-radius: 99px;
  background: var(--code-bg);
  overflow: hidden;
  margin: 22px auto 0;
  display: flex;
  gap: 4px;
  padding: 0;
}
.progress-track .seg {
  flex: 1;
  height: 100%;
  background: var(--border);
  border-radius: 2px;
  transition: background 320ms ease;
}
.progress-track .seg.done {
  background: var(--accent);
}
.progress-track .seg.active {
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

.ready {
  display: none;
  text-align: center;
  padding: 32px;
  border: 1px solid rgba(34, 197, 94, 0.4);
  background: linear-gradient(180deg, var(--success-bg), transparent 80%);
  border-radius: var(--radius);
  margin-top: 28px;
}
.ready.show {
  display: block;
  animation: fade-in 360ms ease;
}
.ready h2 {
  margin: 14px 0 4px;
  font-size: 22px;
  font-weight: 600;
  color: var(--success);
}
.ready p {
  margin: 0 0 22px;
  color: var(--text-dim);
  font-size: 13px;
}
.ready .open-url {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mute);
  display: block;
  margin-top: 12px;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ------------------------------------------------------------------ */
/* Tables (admin)                                                     */
/* ------------------------------------------------------------------ */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface-2);
}
.table tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}
.table .mono {
  font-family: var(--mono);
  font-size: 12px;
}
.table .actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  /* Avoid a stray horizontal scrollbar when the table fits but has
     fractional-pixel width (seen on macOS Safari/Chrome). */
  scrollbar-width: thin;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ------------------------------------------------------------------ */
/* Tabs (admin)                                                       */
/* ------------------------------------------------------------------ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  /* 4 tabs always fit on desktop; allow wrap on very narrow phones
     instead of reserving a horizontal scrollbar. */
  overflow-x: visible;
  flex-wrap: wrap;
}
.tab-btn {
  background: none;
  border: none;
  padding: 10px 14px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab-btn:hover {
  color: var(--text);
}
.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
  animation: fade-in 180ms ease;
}

/* ------------------------------------------------------------------ */
/* Misc helpers                                                       */
/* ------------------------------------------------------------------ */
.empty-state {
  padding: 32px 18px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.015);
}
.empty-state strong {
  color: var(--text);
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
}

.kv {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 14px;
  font-size: 13px;
}
.kv dt {
  color: var(--text-dim);
  font-size: 12px;
}
.kv dd {
  margin: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

.health-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.health-cell {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.health-cell .label {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.health-cell .val {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}

.flash {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.flash.error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(238, 5, 85, 0.3);
}
.flash.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.flash.info {
  background: var(--info-bg);
  color: var(--accent);
  border: 1px solid var(--accent-soft);
}

.copy-input {
  display: flex;
  gap: 8px;
}
.copy-input .input {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
}

.invite-pill {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--code-bg);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Mobile tweaks                                                       */
/* ------------------------------------------------------------------ */
@media (max-width: 540px) {
  .topbar {
    padding: 12px 18px;
  }
  main {
    padding: 24px 16px 48px;
  }
  .card {
    padding: 16px;
  }
  .hero {
    padding: 36px 12px 16px;
  }
  .table th,
  .table td {
    padding: 8px;
  }
}

/* ------------------------------------------------------------------ */
/* Reduced motion                                                     */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ------------------------------------------------------------------ */
/* Mobile ergonomics                                                  */
/* ------------------------------------------------------------------ */
/* iOS Safari auto-zooms any focused input smaller than 16px and never
   zooms back out — keep mobile inputs at 16px so the page doesn't jump
   when tapping a field. */
@media (max-width: 540px) {
  .input,
  .select {
    font-size: 16px;
  }
}

/* ~44px touch targets on phones (Apple HIG) for the dense admin-table
   buttons (Suspend/Delete/Revoke). */
@media (pointer: coarse) {
  .btn-sm {
    padding: 9px 12px;
  }
}

/* Safe areas: viewport-fit=cover is set; keep the footer clear of the
   iPhone home indicator. */
footer.app-foot {
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}