/* REIGNFLOW 5.8.4 — calm, accessible B2B interface */
:root {
  --rf-brand: #2563eb;
  --rf-brand-strong: #1d4ed8;
  --rf-brand-soft: #eff6ff;
  --rf-navy: #0b1220;
  --rf-canvas: #f3f6fb;
  --rf-surface: #ffffff;
  --rf-ink: #0f172a;
  --rf-muted: #64748b;
  --rf-line: #dbe3ef;
  --rf-success: #047857;
  --rf-warning: #b45309;
  --rf-danger: #b91c1c;
  --rf-radius: 14px;
  --rf-radius-lg: 20px;
  --rf-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px rgba(15, 23, 42, .06);
  --rf-shadow-lg: 0 24px 70px rgba(2, 8, 23, .18);
}

html { color-scheme: light; }
html.dark { color-scheme: dark; }
body {
  background: var(--rf-canvas);
  color: var(--rf-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}

.rf-skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 9999;
  transform: translateY(-160%);
  border-radius: 10px;
  background: #fff;
  color: #172554;
  padding: 10px 14px;
  font-weight: 700;
  box-shadow: var(--rf-shadow-lg);
}
.rf-skip-link:focus { transform: none; }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid rgba(37, 99, 235, .34) !important;
  outline-offset: 2px !important;
}

input, select, textarea {
  min-height: 42px;
  border-color: var(--rf-line) !important;
  background-color: var(--rf-surface) !important;
  color: var(--rf-ink) !important;
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
textarea { min-height: 92px; }
input:hover, select:hover, textarea:hover { border-color: #a9b8cc !important; }
input:focus, select:focus, textarea:focus {
  border-color: var(--rf-brand) !important;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .11) !important;
}
label { color: #334155 !important; font-weight: 600 !important; }
button, a { -webkit-tap-highlight-color: transparent; }
button { min-height: 40px; }
button:disabled { cursor: not-allowed; opacity: .56; }

/* Authentication: focused single-task screen */
.ct-auth-wrap,
#admin-login {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 18% 8%, rgba(96, 165, 250, .28), transparent 32%),
    radial-gradient(circle at 88% 92%, rgba(14, 165, 233, .18), transparent 34%),
    linear-gradient(145deg, #081224 0%, #102a56 54%, #0b4d78 100%) !important;
}
.ct-auth-wrap::before,
#admin-login::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .2;
  background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(to bottom, #000, transparent 78%);
}
.ct-auth-wrap > div {
  width: min(448px, calc(100vw - 32px));
}
.ct-auth-wrap > div,
#admin-login > form { position: relative; z-index: 1; }
.ct-auth-card,
#login-page,
#forgot-page,
#register-page,
#admin-login-form {
  border: 1px solid rgba(255,255,255,.78) !important;
  border-radius: 24px !important;
  background: rgba(255,255,255,.96) !important;
  box-shadow: var(--rf-shadow-lg) !important;
  backdrop-filter: blur(18px);
}
.ct-auth-wrap h1 { letter-spacing: .12em; }
.ct-auth-wrap h2, #admin-login h1 { color: var(--rf-ink) !important; }
#auth-screens input, #admin-login input {
  background: #fff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}
#auth-screens input::placeholder, #admin-login input::placeholder { color: #94a3b8; }
#auth-screens.hidden { display: none !important; }

/* Shell */
#app > aside, #admin-app > aside {
  width: 268px !important;
  background: linear-gradient(180deg, #081222 0%, #0b172b 100%) !important;
  box-shadow: 10px 0 40px rgba(2, 8, 23, .08);
}
#app > main, #admin-app > main { margin-left: 268px !important; min-width: 0; }
#demo-banner {
  position: fixed !important;
  inset: 0 0 auto 268px;
  width: auto !important;
  min-height: 34px;
  z-index: 65 !important;
}
#app:has(#demo-banner) > main { padding-top: 34px; }
#app:has(#demo-banner) > main > header { top: 34px !important; }
#app > main > header, #admin-app > main > header {
  border-color: rgba(203, 213, 225, .72) !important;
  background: rgba(255,255,255,.88) !important;
  backdrop-filter: blur(16px);
}
#app > main > div, #admin-app > main > div { max-width: 1540px; margin-inline: auto; }
#admin-app {
  --rf-surface: #ffffff;
  --rf-ink: #0f172a;
  --rf-muted: #64748b;
  --rf-line: #dbe3ef;
}
#admin-app > main { background: #f3f6fb !important; color: #0f172a !important; }
#admin-app > main > header,
#admin-app .bg-white {
  background: #fff !important;
  color: #0f172a !important;
}
#admin-app :where(.text-slate-900, .text-slate-800) { color: #0f172a !important; }
#admin-app :where(.text-slate-700, .text-slate-600) { color: #475569 !important; }
#admin-app .text-slate-500 { color: #64748b !important; }
#admin-app .text-slate-400 { color: #64748b !important; }

.rf-logo-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, #60a5fa, #2563eb 55%, #1d4ed8);
  box-shadow: 0 8px 22px rgba(37, 99, 235, .38);
}
.rf-brand-logo-shell {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(147, 197, 253, .55);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(255,255,255,.98), rgba(239,246,255,.94));
  box-shadow: 0 9px 24px rgba(37, 99, 235, .16);
  animation: rfLogoFloat 5s ease-in-out infinite;
}
.rf-brand-logo {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
}
.rf-brand-logo-shell--auth {
  width: 74px;
  height: 74px;
  margin: 0 auto 16px;
  border-radius: 23px;
  box-shadow: 0 18px 42px rgba(37, 99, 235, .20);
}
.rf-brand-logo-shell--auth .rf-brand-logo { width: 60px; height: 60px; }
.sidebar-link, .nav-link, .sidebar-group {
  border: 1px solid transparent;
  color: #aebbd0 !important;
  transition: color .16s ease, background-color .16s ease, border-color .16s ease, transform .16s ease;
}
.sidebar-link:hover, .nav-link:hover, .sidebar-group:hover {
  color: #fff !important;
  background: rgba(148,163,184,.10) !important;
  transform: translateX(2px);
}
.sidebar-link.active, .nav-link.active {
  color: #fff !important;
  border-color: rgba(147,197,253,.22) !important;
  background: linear-gradient(90deg, rgba(37,99,235,.38), rgba(37,99,235,.12)) !important;
  box-shadow: inset 3px 0 #60a5fa;
}

/* Content rhythm and cards */
.page > :first-child { scroll-margin-top: 90px; }
.ct-kpi-card, .rf-card {
  border-color: var(--rf-line) !important;
  border-radius: var(--rf-radius-lg) !important;
  background: var(--rf-surface) !important;
  box-shadow: var(--rf-shadow);
}
.ct-kpi-card {
  min-height: 124px;
  padding: 20px;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.ct-kpi-card:hover { transform: translateY(-2px); border-color: #bfdbfe !important; box-shadow: 0 18px 42px rgba(15,23,42,.10); }
.ct-kpi-card .v { color: #102a56; background: none !important; font-variant-numeric: tabular-nums; }
.ct-kpi-card .l { color: var(--rf-muted); letter-spacing: .01em; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
thead { background: #f8fafc; }
th { color: #475569; font-size: 12px; letter-spacing: .02em; text-transform: uppercase; }
th, td { border-bottom: 1px solid #e8edf4; padding: 12px 14px; text-align: left; }
tbody tr { transition: background-color .14s ease; }
tbody tr:hover { background: #f5f9ff !important; }

/* Guided setup */
.rf-setup {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
  gap: 20px;
  margin-bottom: 24px;
  padding: 24px;
  overflow: hidden;
  border: 1px solid #bfdbfe;
  border-radius: 22px;
  background: linear-gradient(135deg, #ffffff 0%, #f5f9ff 58%, #eef6ff 100%);
  box-shadow: var(--rf-shadow);
  position: relative;
}
.rf-setup::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -80px;
  top: -110px;
  border-radius: 999px;
  background: rgba(96,165,250,.15);
}
.rf-setup__eyebrow { color: var(--rf-brand); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.rf-setup__title { margin: 6px 0 8px; color: #102a56; font-size: clamp(20px, 2vw, 28px); font-weight: 800; letter-spacing: -.025em; }
.rf-setup__copy { max-width: 62ch; color: #526278; }
.rf-steps { display: grid; gap: 9px; position: relative; z-index: 1; }
.rf-step {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: rgba(255,255,255,.84);
  padding: 8px 10px;
  text-align: left;
}
.rf-step:hover { border-color: #93c5fd; background: #fff; }
.rf-step__num { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 10px; background: var(--rf-brand-soft); color: var(--rf-brand); font-weight: 800; }
.rf-step__text strong { display: block; color: #1e293b; font-size: 13px; }
.rf-step__text span { color: #64748b; font-size: 11px; }
.rf-step__arrow { color: #94a3b8; }

.rf-status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #fde68a;
  border-radius: 12px;
  background: #fffbeb;
  color: #92400e;
  padding: 10px 13px;
  font-size: 13px;
}
.rf-status-banner[data-mode="production"] { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }

.rf-mobile-menu {
  display: none;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--rf-line);
  border-radius: 12px;
  background: #fff;
  color: #334155;
}
.rf-sidebar-backdrop { display: none; }

/* Live regions and modal semantics */
#toast { pointer-events: none; }
#toast.hidden { display: none !important; }
.toast-item { border: 1px solid rgba(255,255,255,.14); box-shadow: 0 18px 45px rgba(2,8,23,.24); }
[role="dialog"] > :last-child { box-shadow: var(--rf-shadow-lg); }

@media (max-width: 1024px) {
  #app > main > header, #admin-app > main > header {
    display: flex !important;
    align-items: center;
    gap: 12px;
  }
  #app > main > header > div { flex: 1 1 auto; min-width: 0; }
  #app > aside, #admin-app > aside {
    transform: translateX(-105%);
    transition: transform .22s ease;
    z-index: 80;
  }
  body.rf-nav-open #app > aside, body.rf-nav-open #admin-app > aside { transform: translateX(0); }
  #app > main, #admin-app > main { margin-left: 0 !important; }
  #demo-banner { left: 0; }
  .rf-mobile-menu { display: grid; }
  .rf-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(2,8,23,.55);
    backdrop-filter: blur(2px);
  }
  body.rf-nav-open .rf-sidebar-backdrop { display: block; }
  .rf-setup { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  #app > main > header > div { padding-inline: 16px !important; }
  #app > main > div, #admin-app > main > div { padding: 18px 14px 32px !important; }
  .ct-auth-wrap { padding: 14px !important; }
  .ct-auth-card, #login-page, #forgot-page, #register-page, #admin-login-form { border-radius: 18px !important; padding: 22px !important; }
  .rf-setup { padding: 18px; }
  .rf-step { grid-template-columns: 32px 1fr; }
  .rf-step__arrow { display: none; }
  .ct-kpi-card { min-height: 112px; padding: 16px; }
  .ct-kpi-card .v { font-size: 23px; }
  table { min-width: 680px; }
}

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

@media (prefers-contrast: more) {
  :root { --rf-line: #94a3b8; }
  .sidebar-link, .nav-link, .sidebar-group { color: #d7e0ee !important; }
}
