/* ========================================================================
   Relay control plane — UI styles (Step 3c)
   ======================================================================== */

:root {
  --bg: #0a0a0c;
  --surface: #131316;
  --surface-hi: #1c1c20;
  --border: #25252a;
  --border-hi: #34343a;
  --text: #e8e6df;
  --muted: #87847b;
  --muted-hi: #a8a59a;
  --accent: #6c84ff;
  --accent-hi: #8499ff;
  --accent-dim: #2a3470;
  --accent-glow: rgba(108, 132, 255, 0.18);
  --success: #7fb77e;
  --warning: #d4a23a;
  --error: #c75a5a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Instrument Sans', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 90% 50% at 50% -10%, var(--accent-glow), transparent 60%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.9  0 0 0 0 0.87  0 0 0 0 0.8  0 0 0 0.04 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-attachment: fixed;
}

.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 28px;
}
.shell-narrow { max-width: 460px; }

/* Hidden helper */
.hidden { display: none !important; }

/* ----------------------------------------------------------------------
   Marquee / top bar
   ---------------------------------------------------------------------- */

.marquee {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 38px;
  animation: fadeUp 0.5s ease-out both;
  flex-wrap: wrap;
}
.marquee .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
  align-self: center;
  flex-shrink: 0;
}
.marquee .label { color: var(--text); }
.marquee .sep { color: var(--border-hi); }
.marquee .meta { color: var(--muted); }
.marquee .logout-link {
  text-decoration: none;
  border-bottom: 1px dotted var(--muted);
  transition: color 0.15s, border-color 0.15s;
}
.marquee .logout-link:hover { color: var(--accent); border-color: var(--accent); }

/* ----------------------------------------------------------------------
   Headings
   ---------------------------------------------------------------------- */

.heading {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 500;
  font-size: 38px;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin-bottom: 8px;
  animation: fadeUp 0.5s 0.05s ease-out both;
}
.heading .accent { color: var(--accent); font-style: italic; font-weight: 400; }

.lede {
  color: var(--muted-hi);
  font-size: 15px;
  font-style: italic;
  margin-bottom: 36px;
  animation: fadeUp 0.5s 0.1s ease-out both;
  max-width: 52ch;
}

.section { margin-bottom: 36px; animation: fadeUp 0.5s 0.15s ease-out both; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted-hi);
  margin-bottom: 14px;
}
.section-header .section-heading { margin-bottom: 0; }

.section-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.actions-help {
  font-size: 12px;
  font-style: italic;
  color: var(--muted);
}

/* ----------------------------------------------------------------------
   Forms
   ---------------------------------------------------------------------- */

.form { animation: fadeUp 0.5s 0.15s ease-out both; }
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.field input,
.field select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 14px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 14px;
  border-radius: 2px;
  transition: border-color 0.18s, background 0.18s;
}
.field select { padding-right: 30px; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%23a8a59a' d='M6 8L2 4h8z'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-hi);
}
.field input::placeholder { color: var(--muted); opacity: 0.5; }
.field-help {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  font-style: italic;
}

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

.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 14px 22px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  cursor: pointer;
  border-radius: 2px;
  text-decoration: none;
  transition: background 0.15s, transform 0.04s;
  text-align: center;
}
.btn:hover:not(:disabled) { background: var(--accent-hi); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { background: var(--accent-dim); color: var(--muted); cursor: not-allowed; }
.btn-block { display: block; width: 100%; margin-top: 8px; }
.btn-small { padding: 9px 14px; font-size: 11px; letter-spacing: 0.15em; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface);
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted-hi);
  width: 32px; height: 32px;
  border-radius: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-icon:hover { color: var(--accent); border-color: var(--accent); background: var(--surface); }
.btn-icon-danger:hover { color: var(--error); border-color: var(--error); }

.btn-copy {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 5px 10px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s;
}
.btn-copy:hover { color: var(--accent); border-color: var(--accent); }
.btn-copy.copied { color: var(--success); border-color: var(--success); }

/* ----------------------------------------------------------------------
   Cards
   ---------------------------------------------------------------------- */

.dash-grid { display: grid; gap: 14px; }
.dash-grid.two-col { grid-template-columns: 1fr; }
@media (min-width: 600px) {
  .dash-grid.two-col { grid-template-columns: 1fr 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
}
.card.with-action { padding-right: 90px; }

.card-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.card-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 14px;
  word-break: break-all;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

/* ----------------------------------------------------------------------
   Destinations list
   ---------------------------------------------------------------------- */

.dest-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dest-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
  transition: opacity 0.15s, border-color 0.15s;
}
.dest-item::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--success);
}
.dest-item.disabled::before { background: var(--border-hi); }
.dest-item.disabled { opacity: 0.55; }
.dest-item.disabled .dest-url { color: var(--muted); }

.dest-main {
  flex: 1;
  min-width: 0;
}
.dest-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text);
  margin-bottom: 4px;
}
.dest-url {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted-hi);
  word-break: break-all;
  line-height: 1.4;
}

.dest-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-hi);
  border-radius: 12px;
  transition: background 0.18s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  height: 14px;
  width: 14px;
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.18s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

.empty {
  text-align: center;
  padding: 32px 24px;
  color: var(--muted);
  font-style: italic;
  font-size: 14px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 2px;
}

/* ----------------------------------------------------------------------
   Modal
   ---------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay[aria-hidden="false"] {
  display: flex;
  animation: fadeIn 0.15s ease-out;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border-hi);
  border-radius: 4px;
  padding: 28px;
  max-width: 460px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
}

.modal-title {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}

.modal-status {
  margin-top: 12px;
  font-size: 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--muted);
  display: none;
}
.modal-status.visible { display: block; }
.modal-status.error { color: #f0a8a8; }
.modal-status.ok { color: #b0d6af; }

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

@media (max-width: 480px) {
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}

/* ----------------------------------------------------------------------
   Status strip
   ---------------------------------------------------------------------- */

.status {
  margin-top: 22px;
  padding: 11px 14px;
  border-left: 2px solid var(--border-hi);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted-hi);
  background: var(--surface);
  display: none;
}
.status.visible { display: block; animation: fadeUp 0.2s ease-out; }
.status.error   { color: #f0a8a8; border-color: var(--error); }
.status.ok      { color: #b0d6af; border-color: var(--success); }

/* ----------------------------------------------------------------------
   Footer
   ---------------------------------------------------------------------- */

.footnote {
  margin-top: 26px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.footnote a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-dim);
  transition: border-color 0.15s;
}
.footnote a:hover { border-color: var(--accent); }

/* ----------------------------------------------------------------------
   Animations
   ---------------------------------------------------------------------- */

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse  { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ----------------------------------------------------------------------
   Mobile
   ---------------------------------------------------------------------- */

@media (max-width: 540px) {
  .shell { padding: 32px 18px; }
  .heading { font-size: 30px; }
  .marquee {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 10px;
  }
  .card.with-action { padding-right: 16px; padding-bottom: 56px; }
  .btn-copy { top: auto; bottom: 14px; right: 14px; }
  .dest-item { flex-wrap: wrap; }
  .dest-actions { width: 100%; justify-content: flex-end; }
  .section-header { flex-wrap: wrap; gap: 10px; }
}
