:root {
  color-scheme: dark;
  --bg: #090b0f;
  --surface: rgba(20, 24, 30, 0.88);
  --surface-strong: #171b22;
  --surface-soft: #11151b;
  --surface-raised: #20252e;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text: #f3f5f7;
  --muted: #959dab;
  --subtle: #697180;
  --accent: #53fc18;
  --accent-soft: rgba(83, 252, 24, 0.12);
  --accent-border: rgba(83, 252, 24, 0.28);
  --danger: #ff637e;
  --danger-soft: rgba(255, 99, 126, 0.12);
  --warn: #ffbe55;
  --warn-soft: rgba(255, 190, 85, 0.12);
  --violet: #a78bfa;
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-card: 0 18px 50px rgba(0, 0, 0, 0.28);
  --shadow-accent: 0 12px 35px rgba(83, 252, 24, 0.16);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; text-decoration: none; }

::selection { color: #071006; background: var(--accent); }

.ambient-backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, rgba(9, 11, 15, 0.62) 0%, rgba(9, 11, 15, 0.88) 58%, #090b0f 100%),
    url("/assets/signal-field.png") center top / cover no-repeat;
}

.ambient-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.055) 0.7px, transparent 0.7px);
  background-size: 7px 7px;
  opacity: 0.17;
  mask-image: linear-gradient(to bottom, black, transparent 76%);
}

.app-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  border-bottom: 1px solid var(--border);
}

.topbar-actions,
.brand,
.brand > span,
.workspace-label,
.overview-state,
.account-profile,
.status-dot-label,
.live-feed-label,
.label-row,
.card-heading,
.control-row,
.action-toolbar,
.action-group,
.alert,
.security-note {
  display: flex;
  align-items: center;
}

.brand { gap: 11px; min-width: 0; }
.brand img { flex: 0 0 auto; filter: drop-shadow(0 8px 18px rgba(83, 252, 24, 0.12)); }
.brand > span { align-items: flex-start; flex-direction: column; line-height: 1.18; }
.brand strong { font-size: 0.96rem; letter-spacing: -0.015em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; }
.brand-large { gap: 14px; }
.brand-large strong { font-size: 1.06rem; }

.topbar-actions { gap: 18px; }
.workspace-label { gap: 8px; color: var(--muted); font-size: 0.78rem; }
.secure-dot,
.live-dot,
.status-dot-label > span,
.live-feed-label > span {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(83, 252, 24, 0.09), 0 0 16px rgba(83, 252, 24, 0.4);
}

main { padding: 58px 0 0; }

.page-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: 30px;
}

.page-intro h1,
.auth-copy h1 {
  max-width: 720px;
  margin: 12px 0 10px;
  font-size: clamp(2rem, 4.4vw, 3.7rem);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.page-intro p,
.auth-copy p {
  max-width: 650px;
  margin: 0;
  color: #abb2bd;
  font-size: 1rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #bdc5d0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.overview-state {
  align-items: flex-end;
  flex-direction: column;
  min-width: 150px;
  padding: 14px 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(13, 16, 21, 0.68);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(18px);
}

.overview-state span { color: var(--muted); font-size: 0.68rem; letter-spacing: 0.11em; text-transform: uppercase; }
.overview-state strong { margin-top: 3px; color: var(--accent); font-size: 0.88rem; letter-spacing: 0.06em; }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(310px, 0.85fr);
  gap: 20px;
  align-items: start;
}

.primary-column,
.side-column { display: grid; gap: 20px; min-width: 0; }
.side-column { position: sticky; top: 20px; }

.card,
.auth-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: linear-gradient(145deg, rgba(25, 30, 37, 0.94), rgba(15, 18, 23, 0.94));
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(20px);
}

.card::before,
.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  pointer-events: none;
}

.stage-card { padding: 26px; }
.account-card,
.status-card { padding: 22px; }
.activity-card { margin-top: 20px; padding: 24px; }

.card-heading { justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.card-heading.compact { margin-bottom: 18px; }
.card-heading h2,
.auth-card h2 { margin: 3px 0 0; font-size: 1.12rem; line-height: 1.3; letter-spacing: -0.025em; }
.card-heading p { margin: 6px 0 0; color: var(--muted); font-size: 0.84rem; }
.step-label,
.kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.section-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 1rem;
}

.field { min-width: 0; }
.field.grow { flex: 1 1 340px; }
.field label,
.label-row label { display: block; margin: 0 0 7px; color: #cbd1d9; font-size: 0.76rem; font-weight: 650; }
.field small { display: block; margin-top: 6px; color: var(--subtle); font-size: 0.68rem; }

input[type="text"],
input[type="number"],
input[type="password"],
textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: rgba(7, 9, 12, 0.66);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea { min-height: 94px; resize: vertical; line-height: 1.5; }
input::placeholder,
textarea::placeholder { color: #5e6674; }
input:hover,
textarea:hover { border-color: rgba(255, 255, 255, 0.22); }
input:focus,
textarea:focus {
  border-color: rgba(83, 252, 24, 0.6);
  background: rgba(9, 12, 15, 0.92);
  box-shadow: 0 0 0 4px rgba(83, 252, 24, 0.08);
}

.control-row { align-items: flex-end; gap: 12px; }
.align-field { min-height: 46px; }
.field-grid { display: grid; gap: 13px; margin-top: 18px; }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.message-field { margin-bottom: 4px; }
.label-row { justify-content: space-between; }
.char-counter { color: var(--muted); font-size: 0.7rem; font-variant-numeric: tabular-nums; }
.char-counter.near-limit { color: var(--warn); }

.input-suffix { position: relative; }
.input-suffix input { padding-right: 48px; }
.input-suffix > span {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--subtle);
  font-size: 0.7rem;
  transform: translateY(-50%);
  pointer-events: none;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--text);
  background: var(--surface-raised);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn.primary { color: #071006; background: var(--accent); box-shadow: var(--shadow-accent); }
.btn.primary:hover:not(:disabled) { background: #76ff46; box-shadow: 0 14px 40px rgba(83, 252, 24, 0.24); }
.btn.secondary { border-color: var(--border-strong); background: #252b35; }
.btn.ghost { color: var(--muted); background: transparent; }
.btn.ghost:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.btn.ghost-bordered { border-color: var(--border); color: #c1c7d0; background: rgba(255, 255, 255, 0.025); }
.btn.ghost-bordered:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); background: rgba(255, 255, 255, 0.055); }
.btn.danger { border-color: rgba(255, 99, 126, 0.24); color: #ff9cad; background: var(--danger-soft); }
.btn.danger:hover:not(:disabled) { border-color: rgba(255, 99, 126, 0.4); background: rgba(255, 99, 126, 0.18); }
.btn:disabled { opacity: 0.36; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.is-loading { color: transparent; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  color: var(--text);
  animation: spin 650ms linear infinite;
}
.btn.primary.is-loading::after { color: #071006; }
.btn-wide { width: 100%; }
.btn-compact { min-height: 36px; padding: 8px 12px; }
.inline { display: inline; }

.channel-info {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 13px;
  align-items: center;
  min-height: 78px;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(8, 10, 13, 0.48);
}

.channel-info.empty { grid-template-columns: auto 1fr; }
.channel-placeholder-icon,
.channel-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--subtle);
  background: rgba(255, 255, 255, 0.035);
}
.channel-info strong { display: block; font-size: 0.86rem; }
.channel-info small { display: block; margin-top: 2px; color: var(--muted); font-size: 0.72rem; }
.channel-state { padding: 5px 8px; border-radius: 999px; font-size: 0.65rem; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; }
.channel-state.live { color: #ffb4c1; background: var(--danger-soft); }
.channel-state.offline { color: #a8afba; background: rgba(255, 255, 255, 0.055); }

.helper-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  padding: 11px 13px;
  border: 1px solid rgba(167, 139, 250, 0.16);
  border-radius: 11px;
  color: #b7b0d0;
  background: rgba(167, 139, 250, 0.055);
}
.helper-banner > span { display: grid; width: 18px; height: 18px; flex: 0 0 auto; place-items: center; border: 1px solid rgba(167, 139, 250, 0.3); border-radius: 50%; font-size: 0.65rem; font-weight: 800; }
.helper-banner p { margin: 0; font-size: 0.71rem; }

.action-toolbar { justify-content: space-between; gap: 12px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.action-group { gap: 8px; flex-wrap: wrap; }

.status-dot-label { gap: 8px; color: var(--muted); font-size: 0.68rem; font-weight: 700; }
.status-dot-label.is-offline > span { background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 99, 126, 0.08); }
.status-dot-label.is-offline { color: #c0a0a7; }

.account-profile { gap: 12px; margin-bottom: 15px; padding: 13px; border: 1px solid var(--border); border-radius: var(--radius-md); background: rgba(7, 9, 12, 0.42); }
.avatar { width: 42px; height: 42px; flex: 0 0 auto; border: 1px solid var(--border-strong); border-radius: 12px; object-fit: cover; }
.avatar-fallback { display: grid; place-items: center; color: #071006; background: var(--accent); font-weight: 800; }
.account-profile small { display: block; color: var(--muted); font-size: 0.68rem; }
.account-profile strong { display: block; max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.account-copy { margin: -3px 0 16px; font-size: 0.78rem; }

.status-chip {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.62rem;
  letter-spacing: 0.07em;
}
.status-chip.status-running { border-color: var(--accent-border); color: var(--accent); background: var(--accent-soft); }
.status-chip.status-rate_limited { border-color: rgba(255, 190, 85, 0.3); color: var(--warn); background: var(--warn-soft); }
.status-chip.status-paused { border-color: rgba(167, 139, 250, 0.3); color: #c6b8ff; background: rgba(167, 139, 250, 0.1); }
.status-chip.status-error,
.status-chip.status-auth_expired { border-color: rgba(255, 99, 126, 0.3); color: #ff9cad; background: var(--danger-soft); }

.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.metric { min-height: 76px; padding: 11px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: rgba(7, 9, 12, 0.46); }
.metric.featured { background: linear-gradient(145deg, rgba(83, 252, 24, 0.11), rgba(83, 252, 24, 0.035)); border-color: rgba(83, 252, 24, 0.17); }
.metric span { display: block; color: var(--muted); font-size: 0.66rem; }
.metric strong { display: block; margin-top: 7px; font-size: 1.18rem; font-variant-numeric: tabular-nums; }
.metric.featured strong { color: var(--accent); }

.status-details { margin: 17px 0 0; }
.status-details > div { display: grid; grid-template-columns: minmax(94px, 0.8fr) minmax(0, 1.2fr); gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.status-details dt { color: var(--muted); font-size: 0.69rem; }
.status-details dd { min-width: 0; margin: 0; overflow-wrap: anywhere; text-align: right; color: #cbd1d9; font-size: 0.7rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.alert,
.toast { gap: 9px; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 0.76rem; }
.alert { margin: 14px 0 0; }
.alert > span { display: grid; width: 18px; height: 18px; flex: 0 0 auto; place-items: center; border-radius: 50%; font-size: 0.66rem; font-weight: 900; }
.alert.error { border-color: rgba(255, 99, 126, 0.27); color: #ffb0bd; background: var(--danger-soft); }
.alert.error > span { color: #26060c; background: var(--danger); }
.alert.success { border-color: var(--accent-border); color: #c7ffb4; background: var(--accent-soft); }
.alert.success > span { color: #071006; background: var(--accent); }
.alert.warn { border-color: rgba(255, 190, 85, 0.28); color: #ffdba2; background: var(--warn-soft); }
.page-alert { width: fit-content; margin: -10px 0 22px; }
.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 20;
  max-width: min(440px, calc(100% - 32px));
  color: var(--text);
  background: rgba(25, 30, 37, 0.96);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
  animation: toast-in 180ms ease both;
}
.toast.success { border-color: var(--accent-border); }
.toast.error { border-color: rgba(255, 99, 126, 0.35); }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.live-feed-label { gap: 8px; color: var(--muted); font-size: 0.68rem; }
.live-feed-label > span { width: 6px; height: 6px; animation: pulse 1.8s ease infinite; }
.logs { max-height: 340px; margin: 0; padding: 0; overflow-y: auto; list-style: none; scrollbar-color: #343b46 transparent; }
.logs li { display: grid; grid-template-columns: 7px 74px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 8px; border-top: 1px solid var(--border); color: #bcc3cd; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.7rem; }
.logs li:first-child { border-top: 0; }
.logs .t { color: var(--subtle); font-variant-numeric: tabular-nums; }
.log-indicator { width: 6px; height: 6px; margin-top: 5px; border-radius: 50%; background: #657080; }
.logs .success .log-indicator { background: var(--accent); box-shadow: 0 0 10px rgba(83, 252, 24, 0.4); }
.logs .error .log-indicator { background: var(--danger); }
.logs .warn .log-indicator { background: var(--warn); }
.logs .success .log-message { color: #c7eabd; }
.logs .error .log-message { color: #eab2bc; }
.logs .warn .log-message { color: #e7cda4; }
.logs .log-empty { grid-template-columns: auto 1fr; justify-content: center; padding: 34px 10px; color: var(--subtle); text-align: center; }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 26px 2px 42px; color: var(--subtle); font-size: 0.67rem; }
footer span:first-child { color: #8f97a4; font-weight: 700; }

/* Authentication */
.auth-body { display: grid; min-height: 100vh; place-items: center; overflow-x: hidden; }
.auth-shell { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr); width: min(1020px, calc(100% - 40px)); min-height: 600px; border: 1px solid var(--border); border-radius: 28px; background: rgba(8, 10, 13, 0.62); box-shadow: 0 30px 100px rgba(0, 0, 0, 0.48); backdrop-filter: blur(18px); }
.auth-story { display: flex; flex-direction: column; justify-content: space-between; min-width: 0; padding: 42px; border-right: 1px solid var(--border); }
.auth-copy { margin: auto 0; padding: 58px 0; }
.auth-copy h1 { max-width: 560px; font-size: clamp(2.5rem, 5vw, 4.5rem); }
.auth-copy p { max-width: 520px; }
.trust-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0; padding: 0; list-style: none; }
.trust-list li { padding-top: 12px; border-top: 1px solid var(--border); color: #adb4bf; font-size: 0.7rem; }
.trust-list li span { display: block; margin-bottom: 5px; color: var(--accent); font-size: 0.62rem; font-weight: 800; }
.auth-card { align-self: center; margin: 34px; padding: 30px; }
.auth-card-heading { display: flex; align-items: center; gap: 12px; }
.auth-card-heading h2 { font-size: 1.2rem; }
.auth-helper { margin: 16px 0 20px; font-size: 0.77rem; }
.auth-form { display: grid; gap: 15px; }
.auth-form .btn { margin-top: 4px; min-height: 48px; }
.security-note { justify-content: center; gap: 8px; margin: 20px 0 0; color: var(--subtle); font-size: 0.67rem; }
.security-note span { color: var(--accent); font-size: 0.5rem; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.82); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }

@media (max-width: 980px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .side-column { position: static; grid-template-columns: minmax(280px, 0.75fr) minmax(0, 1.25fr); }
  .field-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-shell { grid-template-columns: 1fr; width: min(640px, calc(100% - 32px)); margin: 28px 0; }
  .auth-story { min-height: 420px; border-right: 0; border-bottom: 1px solid var(--border); }
  .auth-card { width: auto; }
}

@media (max-width: 700px) {
  .app-shell { width: min(100% - 24px, 620px); }
  .topbar { min-height: 68px; }
  .workspace-label { display: none; }
  main { padding-top: 36px; }
  .page-intro { align-items: flex-start; flex-direction: column; gap: 18px; }
  .page-intro h1 { font-size: clamp(2rem, 11vw, 3rem); }
  .overview-state { align-items: flex-start; width: 100%; }
  .side-column { grid-template-columns: 1fr; }
  .field-grid.three { grid-template-columns: 1fr; }
  .action-toolbar { align-items: stretch; flex-direction: column; }
  .action-group .btn { flex: 1 1 auto; }
  .stage-card,
  .activity-card { padding: 20px; }
  footer { flex-direction: column; }
}

@media (max-width: 520px) {
  .brand small { display: none; }
  .brand strong { font-size: 0.86rem; }
  .topbar-actions { gap: 6px; }
  .btn-compact { font-size: 0.72rem; }
  .control-row { align-items: stretch; flex-direction: column; }
  .field.grow { flex-basis: auto; }
  .control-row .btn { width: 100%; }
  .card-heading { align-items: flex-start; }
  .action-group { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .action-group .btn { width: 100%; }
  .status-details > div { grid-template-columns: 1fr; gap: 3px; }
  .status-details dd { text-align: left; }
  .logs li { grid-template-columns: 7px 58px minmax(0, 1fr); gap: 7px; font-size: 0.64rem; }
  .auth-shell { width: min(100% - 20px, 460px); margin: 10px 0; border-radius: 22px; }
  .auth-story { min-height: 380px; padding: 26px; }
  .auth-copy { padding: 45px 0; }
  .auth-copy h1 { font-size: 2.55rem; }
  .trust-list { grid-template-columns: 1fr; gap: 7px; }
  .trust-list li { display: flex; gap: 8px; padding-top: 7px; }
  .trust-list li span { margin: 0; }
  .auth-card { margin: 10px; padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
