:root {
  --bg: #090811;
  --surface: rgba(23, 20, 38, 0.88);
  --surface-strong: #171426;
  --surface-soft: #211c35;
  --border: rgba(188, 174, 255, 0.14);
  --text: #f5f2ff;
  --muted: #9d98b3;
  --purple: #8c5cff;
  --purple-bright: #aa83ff;
  --blue: #4d8dff;
  --green: #41d69a;
  --red: #ff6174;
  --amber: #ffc45c;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(106, 71, 201, 0.21), transparent 32rem),
    radial-gradient(circle at 95% 10%, rgba(42, 94, 186, 0.13), transparent 28rem),
    var(--bg);
}

button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0.5rem; font-size: clamp(2rem, 4vw, 3.25rem); letter-spacing: -0.055em; }
h2 { margin-bottom: 0.35rem; font-size: 1.25rem; letter-spacing: -0.025em; }
.muted { color: var(--muted); }
.eyebrow {
  margin-bottom: 0.45rem;
  color: var(--purple-bright);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 4vw;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 8, 17, 0.78);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(170, 131, 255, 0.35);
  border-radius: 13px;
  color: var(--purple-bright);
  background: rgba(140, 92, 255, 0.12);
  font-size: 1.15rem;
}
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: 0.12em; }
.brand small { color: var(--muted); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 0.8rem; }
.user-chip { color: var(--muted); font-size: 0.85rem; }

.page-shell { width: min(1180px, 92vw); margin: 0 auto; padding: 3.5rem 0 5rem; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }
.refresh-state { display: flex; align-items: center; gap: 0.55rem; color: var(--muted); font-size: 0.78rem; }
.refresh-state.refresh-error { color: var(--red); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(65, 214, 154, 0.1); }
.refresh-error .pulse { background: var(--red); box-shadow: 0 0 0 5px rgba(255, 97, 116, 0.1); }

.ingest-card, .destination-card, .panel-card {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(27, 23, 45, 0.92), rgba(16, 14, 29, 0.9));
  box-shadow: var(--shadow);
}
.ingest-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1rem; margin-bottom: 1.25rem; padding: 1.25rem 1.4rem; }
.ingest-card h2 { margin-bottom: 0.2rem; }
.ingest-card p:last-child { margin-bottom: 0; }
.ingest-icon { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 15px; color: var(--green); background: rgba(65, 214, 154, 0.09); font-size: 1.45rem; }

.destination-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.destination-card { padding: 1.5rem; overflow: hidden; }
.card-heading { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.9rem; }
.platform-mark { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 15px; font-size: 1.15rem; font-weight: 900; }
.platform-youtube { color: #fff; background: #ed344b; }
.platform-facebook { color: #fff; background: #3076eb; font-family: Arial, sans-serif; font-size: 1.55rem; }
.status-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 88px; padding: 0.45rem 0.7rem; border-radius: 999px; font-size: 0.72rem; font-weight: 800; }
.status-active { color: #7ff0bf; background: rgba(65, 214, 154, 0.12); border: 1px solid rgba(65, 214, 154, 0.22); }
.status-idle { color: #aaa4bb; background: rgba(157, 152, 179, 0.08); border: 1px solid rgba(157, 152, 179, 0.13); }
.metrics-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.6rem; margin: 1.35rem 0; }
.metrics-row div { padding: 0.85rem; border: 1px solid rgba(255, 255, 255, 0.05); border-radius: 14px; background: rgba(255, 255, 255, 0.025); }
.metrics-row span, .configuration-line span { display: block; margin-bottom: 0.3rem; color: var(--muted); font-size: 0.67rem; letter-spacing: 0.08em; text-transform: uppercase; }
.metrics-row strong { font-size: 0.95rem; }
.configuration-line { display: flex; justify-content: space-between; align-items: center; padding: 0.85rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.configuration-line span { margin: 0; }
.configuration-line strong { color: #d9d1f7; font-size: 0.82rem; }
.action-row { display: flex; gap: 0.7rem; margin-top: 1rem; }
.action-row form { flex: 1; }
.action-row .button { width: 100%; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; padding: 0.72rem 1rem; border: 1px solid transparent; border-radius: 12px; cursor: pointer; font-weight: 800; transition: transform 160ms ease, border-color 160ms ease, background 160ms ease; }
.button:hover { transform: translateY(-1px); }
.button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid rgba(140, 92, 255, 0.28); outline-offset: 2px; }
.button:disabled { cursor: not-allowed; opacity: 0.45; transform: none; }
.button-primary { color: white; background: linear-gradient(135deg, var(--purple), #6b43d7); box-shadow: 0 8px 30px rgba(107, 67, 215, 0.22); }
.button-secondary { color: #e9e2ff; border-color: rgba(140, 92, 255, 0.28); background: rgba(140, 92, 255, 0.1); }
.button-danger { color: #ff9aa7; border-color: rgba(255, 97, 116, 0.25); background: rgba(255, 97, 116, 0.08); }
.button-ghost { color: #c9c2d9; border-color: var(--border); background: rgba(255, 255, 255, 0.025); }
.button-small { min-height: 36px; padding: 0.55rem 0.75rem; font-size: 0.78rem; }
.button-wide { width: 100%; }

.credentials-panel { margin-top: 1rem; border-radius: 14px; background: rgba(5, 5, 11, 0.28); }
.credentials-panel summary { padding: 0.85rem 1rem; cursor: pointer; color: #c8c1da; font-size: 0.8rem; font-weight: 800; }
.credentials-panel[open] summary { border-bottom: 1px solid var(--border); }
.credentials-panel form { padding: 1rem; }
.form-stack { display: grid; gap: 1rem; }
.form-stack label > span { display: block; margin-bottom: 0.45rem; color: #cfc9de; font-size: 0.77rem; font-weight: 700; }
input { width: 100%; min-height: 44px; padding: 0.72rem 0.8rem; border: 1px solid var(--border); border-radius: 11px; color: var(--text); background: rgba(6, 5, 13, 0.58); }
input::placeholder { color: #6f6980; }
.checkbox-row { display: flex; align-items: center; gap: 0.6rem; }
.checkbox-row input { width: 17px; min-height: 17px; accent-color: var(--purple); }
.checkbox-row span { margin: 0 !important; }
.form-note { margin: 0; color: var(--muted); font-size: 0.72rem; line-height: 1.55; }

.lower-grid { display: grid; grid-template-columns: minmax(280px, 0.75fr) minmax(0, 1.25fr); gap: 1.25rem; margin-top: 1.25rem; }
.panel-card { padding: 1.5rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; }
.compact-form { grid-template-columns: 1fr; }
.audit-list { display: grid; max-height: 390px; gap: 0.15rem; overflow: auto; }
.audit-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.75rem; padding: 0.75rem 0.25rem; border-bottom: 1px solid rgba(255, 255, 255, 0.045); }
.audit-item strong, .audit-item span { display: block; }
.audit-item strong { font-size: 0.78rem; }
.audit-item span, .audit-item time { color: var(--muted); font-size: 0.67rem; }
.audit-result { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.audit-success { background: var(--green); }
.audit-failed, .audit-locked { background: var(--red); }

.flash-stack { display: grid; gap: 0.6rem; margin-bottom: 1rem; }
.flash { padding: 0.85rem 1rem; border: 1px solid var(--border); border-radius: 12px; font-size: 0.82rem; }
.flash-success { color: #91efc8; border-color: rgba(65, 214, 154, 0.2); background: rgba(65, 214, 154, 0.08); }
.flash-error { color: #ff9aa7; border-color: rgba(255, 97, 116, 0.2); background: rgba(255, 97, 116, 0.08); }
.flash-warning { color: #ffd489; border-color: rgba(255, 196, 92, 0.2); background: rgba(255, 196, 92, 0.08); }

.login-page { overflow-x: hidden; }
.login-shell { display: grid; grid-template-columns: 1.1fr 0.9fr; min-height: 100vh; }
.login-brand { position: relative; display: flex; flex-direction: column; justify-content: center; padding: 8vw; overflow: hidden; }
.login-brand::before { content: ""; position: absolute; inset: 12% -20% auto 16%; height: 65%; border: 1px solid rgba(140, 92, 255, 0.18); border-radius: 50%; transform: rotate(-18deg); box-shadow: 0 0 140px rgba(140, 92, 255, 0.14); }
.login-brand > * { position: relative; z-index: 1; }
.login-emblem { display: grid; width: 72px; height: 72px; margin-bottom: 2rem; place-items: center; border: 1px solid rgba(170, 131, 255, 0.35); border-radius: 23px; color: var(--purple-bright); background: rgba(140, 92, 255, 0.1); font-size: 2rem; }
.login-brand h1 { max-width: 650px; font-size: clamp(3rem, 7vw, 6.7rem); line-height: 0.88; }
.login-brand h1 span { color: var(--purple-bright); }
.login-copy { max-width: 470px; color: var(--muted); font-size: 1.05rem; line-height: 1.7; }
.signal-line { display: flex; align-items: flex-end; gap: 5px; height: 24px; margin-top: 2rem; }
.signal-line span { width: 4px; border-radius: 99px; background: var(--purple); animation: signal 1.3s ease-in-out infinite alternate; }
.signal-line span:nth-child(1) { height: 30%; }
.signal-line span:nth-child(2) { height: 70%; animation-delay: 100ms; }
.signal-line span:nth-child(3) { height: 100%; animation-delay: 200ms; }
.signal-line span:nth-child(4) { height: 55%; animation-delay: 300ms; }
@keyframes signal { to { opacity: 0.35; transform: scaleY(0.65); } }
.login-card { display: flex; flex-direction: column; justify-content: center; gap: 1.5rem; max-width: 590px; width: 100%; margin: auto; padding: clamp(2rem, 7vw, 5rem); border-left: 1px solid var(--border); background: rgba(17, 15, 29, 0.72); backdrop-filter: blur(24px); }
.login-card h2 { font-size: 2rem; }
.login-security { margin: 0; color: var(--muted); font-size: 0.72rem; text-align: center; }
.login-security span { color: var(--green); }

@media (max-width: 900px) {
  .destination-grid, .lower-grid { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 42vh; padding: 3rem 8vw; }
  .login-brand h1 { font-size: clamp(2.8rem, 13vw, 5rem); }
  .login-card { min-height: 58vh; max-width: none; border-top: 1px solid var(--border); border-left: 0; }
}

@media (max-width: 620px) {
  .page-shell { width: min(94vw, 1180px); padding-top: 2rem; }
  .topbar { padding: 0 3vw; }
  .user-chip { display: none; }
  .hero-row { align-items: flex-start; flex-direction: column; }
  .ingest-card { grid-template-columns: auto 1fr; }
  .ingest-card .status-pill { grid-column: 1 / -1; }
  .card-heading { grid-template-columns: auto 1fr; }
  .card-heading .status-pill { grid-column: 1 / -1; }
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .audit-item { grid-template-columns: auto 1fr; }
  .audit-item time { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

