/* =============================================================================
   StreamPilot — design system
   ========================================================================== */
:root {
  --accent:        #7c5cff;
  --accent-2:      #4f8cff;
  --accent-cyan:   #22d3ee;
  --grad:          linear-gradient(135deg, #7c5cff 0%, #4f8cff 100%);
  --grad-soft:     linear-gradient(135deg, rgba(124,92,255,.16), rgba(79,140,255,.16));

  --green:  #34d399;  --green-bg:  rgba(52,211,153,.14);
  --amber:  #fbbf24;  --amber-bg:  rgba(251,191,36,.15);
  --red:    #f87171;  --red-bg:    rgba(248,113,113,.15);
  --slate:  #94a3b8;  --slate-bg:  rgba(148,163,184,.15);

  --radius:    18px;
  --radius-sm: 12px;
  --radius-xs: 9px;
  --radius-pill: 999px;
  --radius-ic:   14px;
  --shadow:    0 18px 40px -22px rgba(0,0,0,.7);
  --shadow-lg: 0 30px 70px -30px rgba(0,0,0,.85);
  --ring:      0 0 0 3px rgba(124,92,255,.35);
  --tr:        .2s cubic-bezier(.4,0,.2,1);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---- Dark (default) ---- */
[data-theme="dark"] {
  --bg:        #070a12;
  --bg-glow-1: rgba(124,92,255,.14);
  --bg-glow-2: rgba(34,211,238,.10);
  --surface:   rgba(20,26,40,.72);
  --surface-2: #111726;
  --surface-3: #1a2233;
  --border:    rgba(255,255,255,.07);
  --border-2:  rgba(255,255,255,.12);
  --text:      #eaf0fb;
  --text-dim:  #9aa6be;
  --text-faint:#67728c;
  --input-bg:  rgba(8,12,20,.6);
  --hover:     rgba(255,255,255,.04);
  --accent-text: #a78bfa;
  color-scheme: dark;
}
/* ---- Light ---- */
[data-theme="light"] {
  --bg:        #eef1f8;
  --bg-glow-1: rgba(124,92,255,.18);
  --bg-glow-2: rgba(79,140,255,.14);
  --surface:   rgba(255,255,255,.85);
  --surface-2: #ffffff;
  --surface-3: #f1f4fb;
  --border:    rgba(15,23,42,.09);
  --border-2:  rgba(15,23,42,.16);
  --text:      #141a2b;
  --text-dim:  #5a647e;
  --text-faint:#8a93ab;
  --input-bg:  #ffffff;
  --hover:     rgba(15,23,42,.04);
  --accent-text: #6d28d9;
  --shadow:    0 18px 40px -24px rgba(40,50,90,.45);
  --shadow-lg: 0 30px 70px -32px rgba(40,50,90,.5);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  letter-spacing: -.01em;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vw 60vw at 85% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(50vw 50vw at -10% 110%, var(--bg-glow-2), transparent 60%);
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.02em; }
svg { width: 20px; height: 20px; flex: none; }
code { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: .86em; }
.muted { color: var(--text-dim); }
.sm { font-size: .8rem; }
.nowrap { white-space: nowrap; }
.ta-r { text-align: right; }

/* =============================================================================
   App shell
   ========================================================================== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px; flex: none; padding: 22px 16px;
  display: flex; flex-direction: column; gap: 18px;
  border-right: 1px solid var(--border-2);
  background: var(--surface-2);
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: var(--radius-ic); display: grid; place-items: center;
  color: #fff; background: var(--grad); box-shadow: 0 10px 24px -8px var(--accent);
}
.brand-logo svg { width: 24px; height: 24px; }
.card-head h2 svg { width: 19px; height: 19px; color: var(--accent); flex: none; }
.card-head h2 .brand-tg { display: inline-flex; }
.card-head h2 .brand-tg svg { color: #229ED9; }
.tile-ic { color: var(--accent); }
.tile-ic svg { width: 24px; height: 24px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1.05rem; }
.brand-text span { font-size: .72rem; color: var(--text-dim); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 13px;
  border-radius: var(--radius-sm); color: var(--text-dim); font-weight: 500;
  font-size: .92rem; transition: var(--tr); position: relative;
}
.nav-item svg { width: 19px; height: 19px; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { color: #fff; background: var(--grad); box-shadow: 0 12px 26px -12px var(--accent); }
[data-theme="light"] .nav-item.active { color: #fff; }
.nav-badge {
  margin-left: auto; font-style: normal; font-size: .72rem; font-weight: 700;
  background: var(--red); color: #fff; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--radius-pill); display: grid; place-items: center;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,.25); }

.sidebar-foot { display: flex; flex-direction: column; gap: 12px; }
.tg-pill {
  display: inline-flex; align-items: center; gap: 8px; font-size: .78rem; font-weight: 600;
  padding: 8px 12px; border-radius: var(--radius-pill); border: 1px solid var(--border);
}
.tg-pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.tg-pill.on  { color: var(--green); } .tg-pill.on .dot  { background: var(--green); box-shadow: 0 0 0 4px var(--green-bg); }
.tg-pill.off { color: var(--slate); } .tg-pill.off .dot { background: var(--slate); }
.btn-logout {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: transparent;
  color: var(--text-dim); font: inherit; font-size: .9rem; cursor: pointer; transition: var(--tr);
}
.btn-logout:hover { color: var(--red); border-color: var(--red); background: var(--red-bg); }
.logout-form { margin: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px; padding: 16px 30px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px); border-bottom: 1px solid var(--border-2);
}
.topbar-title h1 { font-size: 1.4rem; }
.topbar-title p { margin: 2px 0 0; font-size: .8rem; color: var(--text-dim); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.content { padding: 28px 30px 60px; max-width: 1280px; width: 100%; margin-inline: auto; }

.menu-toggle { display: none; }

/* Keyboard focus: visible ring on every interactive control */
:where(.btn, .icon-btn, .ftab, .nav-item, .link, .copy-btn, .pw-toggle,
       .btn-logout, .help-dot, .menu-pop button, [data-menu]):focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.btn-primary:focus-visible { box-shadow: 0 14px 28px -14px var(--accent), var(--ring); }
.search-box:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
a:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }

/* =============================================================================
   Buttons / icon buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer;
  transition: var(--tr); white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 14px 28px -14px var(--accent); }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 18px 34px -14px var(--accent); }
.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--border-2); background: var(--surface-3); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 18px; font-size: 1rem; }
.btn-sm { padding: 7px 12px; font-size: .82rem; }
.btn[disabled], .btn.loading { opacity: .65; pointer-events: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer; transition: var(--tr);
}
.icon-btn:hover { border-color: var(--border-2); background: var(--surface-3); color: var(--accent); }
.icon-btn.sm { width: 34px; height: 34px; border-color: transparent; background: transparent; }
.icon-btn.sm svg { width: 17px; height: 17px; }
.icon-btn.sm:hover { background: var(--hover); }

#themeToggle .ic-moon { display: none; }
[data-theme="light"] #themeToggle .ic-sun  { display: none; }
[data-theme="light"] #themeToggle .ic-moon { display: block; }

.link { color: var(--accent-text); font-weight: 600; font-size: .85rem; }
.link:hover { text-decoration: underline; }

/* =============================================================================
   Cards & layout helpers
   ========================================================================== */
.card {
  background: var(--surface); backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
  transition: border-color var(--tr), box-shadow var(--tr), transform var(--tr);
}
.kpi:hover { border-color: var(--border-2); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-head h2 { font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.section-title { font-size: 1.25rem; }
.page-intro p { margin: 4px 0 0; }
.stack { display: flex; flex-direction: column; gap: 22px; }
.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 22px; }

/* =============================================================================
   KPI cards
   ========================================================================== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.kpi { display: flex; align-items: center; gap: 16px; padding: 20px; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 50%; opacity: .12; background: currentColor; }
.kpi-ic { width: 48px; height: 48px; border-radius: var(--radius-ic); display: grid; place-items: center; background: var(--grad-soft); }
.kpi-ic svg { width: 24px; height: 24px; }
.kpi-body { display: flex; flex-direction: column; }
.kpi-value { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.kpi-label { font-size: .82rem; color: var(--text-dim); margin-top: 5px; }
.tone-ok     { color: var(--green); } .tone-ok     .kpi-ic { background: var(--green-bg); }
.tone-warn   { color: var(--amber); } .tone-warn   .kpi-ic { background: var(--amber-bg); }
.tone-danger { color: var(--red); }   .tone-danger .kpi-ic { background: var(--red-bg); }
.tone-all    { color: var(--accent); }
.kpi-value, .kpi-label { color: var(--text); }
.tone-ok .kpi-ic svg { color: var(--green); }
.tone-warn .kpi-ic svg { color: var(--amber); }
.tone-danger .kpi-ic svg { color: var(--red); }
.tone-all .kpi-ic svg, .tone-all .kpi-ic { color: var(--accent); }

/* =============================================================================
   Timeline / bars / lists (dashboard)
   ========================================================================== */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.tl-item { display: flex; gap: 14px; align-items: flex-start; }
.tl-avatar, .avatar {
  width: 40px; height: 40px; border-radius: var(--radius-ic); flex: none; display: grid; place-items: center;
  font-weight: 700; color: #fff; background: var(--grad); font-size: .95rem;
}
.tl-main { flex: 1; min-width: 0; }
.tl-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tl-sub { font-size: .8rem; color: var(--text-dim); margin: 3px 0 8px; }
.progress { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 6px; background: var(--grad); transition: width .6s ease; }

.revenue-card { background: var(--grad); color: #fff; border: none; }
.revenue-card .kpi-label, .revenue-card .muted { color: rgba(255,255,255,.8); }
.revenue { font-size: 2.4rem; font-weight: 800; letter-spacing: -.03em; margin: 6px 0; }

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.bar-top { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: 6px; }
.bar-top b { color: var(--text); }
.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mini-list li { display: flex; align-items: center; gap: 10px; font-size: .88rem; }
.mini-list .muted { margin-left: auto; }
.dot-red { width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex: none; }

/* =============================================================================
   Badges
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: .74rem; font-weight: 700; letter-spacing: .01em; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-active   { color: var(--green); background: var(--green-bg); }
.st-expiring { color: var(--amber); background: var(--amber-bg); }
.st-expired  { color: var(--red);   background: var(--red-bg); }
.st-cancelled{ color: var(--slate); background: var(--slate-bg); }

/* =============================================================================
   Empty states
   ========================================================================== */
.empty { text-align: center; padding: 46px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-ic { width: 64px; height: 64px; border-radius: var(--radius); display: grid; place-items: center; background: var(--grad-soft); color: var(--accent); }
.empty-ic svg { width: 30px; height: 30px; }
.empty p { color: var(--text-dim); margin: 0; max-width: 360px; }
.empty.compact { padding: 22px 14px; gap: 10px; }
.empty.compact .empty-ic { width: 44px; height: 44px; border-radius: var(--radius-sm); }
.empty.compact .empty-ic svg { width: 22px; height: 22px; }
.empty.compact p { font-size: .85rem; }

/* =============================================================================
   Page actions, search, filter tabs
   ========================================================================== */
.page-actions { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-actions .btn { margin-left: auto; }
.page-intro { margin-right: auto; }
.search-box {
  display: flex; align-items: center; gap: 9px; padding: 0 14px; flex: 1; max-width: 420px;
  background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.search-box svg { width: 17px; height: 17px; color: var(--text-dim); }
.search-box input { border: none; background: none; padding: 11px 0; width: 100%; color: var(--text); font: inherit; outline: none; }

.filter-tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.ftab {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-dim);
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; transition: var(--tr);
}
.ftab em { font-style: normal; font-size: .72rem; background: var(--surface-3); color: var(--text-dim); padding: 1px 7px; border-radius: var(--radius-pill); }
.ftab:hover { color: var(--text); border-color: var(--border-2); }
.ftab.active { background: var(--grad); color: #fff; border-color: transparent; }
.ftab.active em { background: rgba(255,255,255,.22); }

/* =============================================================================
   Tables
   ========================================================================== */
.table-card { padding: 8px; }
.table-scroll { overflow-x: auto; border-radius: var(--radius-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th {
  text-align: left; padding: 14px 16px; font-size: .74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-faint); border-bottom: 1px solid var(--border);
}
.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr { transition: background var(--tr); }
.data-table tbody tr:hover { background: var(--hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.cell-client { display: flex; align-items: center; gap: 12px; }
.cell-client strong { display: block; }
.cell-client .muted { display: block; }
.data-table td .muted.sm { display: block; margin-top: 2px; }
.row-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }
.no-results { padding: 40px; text-align: center; color: var(--text-dim); }

/* dropdown menu */
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 180px;
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: 6px; display: none; flex-direction: column;
}
.menu.open .menu-pop { display: flex; animation: pop .14s ease; }
.menu-pop form { margin: 0; }
.menu-pop button {
  width: 100%; text-align: left; padding: 9px 12px; border: none; background: none; color: var(--text);
  font: inherit; font-size: .87rem; border-radius: var(--radius-xs); cursor: pointer;
}
.menu-pop button:hover { background: var(--hover); }
.menu-pop button.danger { color: var(--red); }
.menu-pop button.danger:hover { background: var(--red-bg); }

/* =============================================================================
   Tiles (providers / plans)
   ========================================================================== */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.tile { display: flex; flex-direction: column; gap: 8px; transition: var(--tr); }
.tile:hover { transform: translateY(-3px); border-color: var(--border-2); box-shadow: var(--shadow-lg); }
.tile-head { display: flex; align-items: flex-start; justify-content: space-between; }
.tile-ic { width: 46px; height: 46px; border-radius: var(--radius-ic); display: grid; place-items: center; font-size: 22px; background: var(--grad-soft); }
.tile h3 { font-size: 1.1rem; }
.tile-notes { font-size: .83rem; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-foot { margin-top: auto; padding-top: 8px; }
.chip { display: inline-block; padding: 4px 11px; border-radius: var(--radius-pill); font-size: .76rem; font-weight: 600; color: var(--text-dim); background: var(--surface-3); }
.plan-months { width: 56px; height: 56px; border-radius: 15px; background: var(--grad); color: #fff; display: grid; place-items: center; line-height: 1; }
.plan-months span { font-size: 1.5rem; font-weight: 800; }
.plan-months small { font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.plan-price { font-size: 1.4rem; font-weight: 800; color: var(--accent); letter-spacing: -.02em; }

/* =============================================================================
   Forms
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--text-dim); }
.field > span small { font-weight: 400; color: var(--text-faint); }
input, select, textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--input-bg); color: var(--text); font: inherit; font-size: .92rem; transition: var(--tr); outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2367728c' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 36px; }
[data-theme="light"] select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a93ab' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
.hint { font-size: .78rem; color: var(--text-faint); font-style: normal; }
.hint code { background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.form-foot.split { justify-content: space-between; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }
.check { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; cursor: pointer; font-size: .9rem; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; display: grid; place-items: center; border: none; background: none; color: var(--text-faint); cursor: pointer; border-radius: 8px; }
.pw-toggle:hover { color: var(--accent); }
.pw-toggle svg { width: 18px; height: 18px; }

/* =============================================================================
   Modals
   ========================================================================== */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal::before { content: ""; position: absolute; inset: 0; background: rgba(4,6,12,.6); backdrop-filter: blur(4px); animation: fade .2s ease; }
.modal-card {
  position: relative; width: 100%; max-width: 600px; max-height: 92vh; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); animation: slideUp .24s cubic-bezier(.4,0,.2,1);
}
.modal-card.sm { max-width: 440px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface-2); z-index: 2; }
.modal-head h3 { font-size: 1.15rem; }
.modal-head .icon-btn { font-size: 1.5rem; line-height: 1; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface-2); }
.end-preview input { font-weight: 600; }

/* help / steps */
.help-body { padding-top: 8px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.steps li { display: flex; gap: 14px; }
.step-no { width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: .9rem; }
.steps strong { display: block; margin-bottom: 3px; }
.steps p { margin: 0; font-size: .88rem; color: var(--text-dim); }
.steps a { color: var(--accent); font-weight: 600; }
.steps code, .help-note code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; }
.help-note { margin-top: 20px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--grad-soft); font-size: .87rem; border: 1px solid var(--border); display: flex; align-items: flex-start; gap: 10px; }
.help-note svg { width: 18px; height: 18px; color: var(--accent); flex: none; margin-top: 1px; }

/* Automatic-checks status card */
.auto-card { display: flex; gap: 18px; align-items: flex-start; }
.auto-ic { width: 52px; height: 52px; flex: none; border-radius: var(--radius-ic); background: var(--green-bg); color: var(--green); display: grid; place-items: center; }
.auto-ic svg { width: 26px; height: 26px; }
.auto-body h2 { font-size: 1.15rem; margin-bottom: 6px; }
.auto-body p { margin: 0 0 12px; }
.auto-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.help-dot { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border-2); background: var(--surface-3); color: var(--text-dim); font-size: .76rem; font-weight: 700; cursor: pointer; }
.help-dot:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* =============================================================================
   Settings
   ========================================================================== */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.setting-card.span-full { grid-column: 1 / -1; }
.code-block { margin: 14px 0; }
.code-label { font-size: .78rem; color: var(--text-dim); font-weight: 600; display: block; margin-bottom: 6px; }
.code-row { display: flex; align-items: center; gap: 8px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 4px 4px 14px; }
.code-row code { flex: 1; overflow-x: auto; white-space: nowrap; padding: 8px 0; color: var(--accent-cyan); }
[data-theme="light"] .code-row code { color: #6d28d9; }
.copy-btn { padding: 8px 14px; border: none; border-radius: var(--radius-xs); background: var(--surface-3); color: var(--text); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; transition: var(--tr); }
.copy-btn:hover { background: var(--grad); color: #fff; }

/* =============================================================================
   Toasts
   ========================================================================== */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 13px 18px; border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1px solid var(--border-2); box-shadow: var(--shadow-lg); font-size: .9rem; font-weight: 500;
  max-width: 360px; display: flex; align-items: center; gap: 10px; animation: slideIn .3s cubic-bezier(.4,0,.2,1);
  border-left: 4px solid var(--accent);
}
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warn    { border-left-color: var(--amber); }
.toast.hide { animation: slideOut .3s ease forwards; }

/* =============================================================================
   Login
   ========================================================================== */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; overflow: hidden; }
.login-aurora { position: fixed; inset: 0; z-index: -1; background:
  radial-gradient(40vw 40vw at 25% 30%, rgba(124,92,255,.5), transparent 60%),
  radial-gradient(40vw 40vw at 75% 70%, rgba(34,211,238,.4), transparent 60%),
  radial-gradient(30vw 30vw at 60% 20%, rgba(79,140,255,.4), transparent 60%);
  filter: blur(30px); animation: aurora-in 1.4s ease-out both; }
.login-card {
  width: 100%; max-width: 410px; padding: 40px 36px; text-align: center;
  background: var(--surface); backdrop-filter: blur(20px);
  border: 1px solid var(--border-2); border-radius: 26px; box-shadow: var(--shadow-lg);
  animation: slideUp .4s cubic-bezier(.4,0,.2,1);
}
.login-logo { width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 20px; background: var(--grad); display: grid; place-items: center; color: #fff; box-shadow: 0 16px 36px -12px var(--accent); }
.login-logo svg { width: 34px; height: 34px; }
.login-card h1 { font-size: 1.6rem; }
.login-sub { color: var(--text-dim); margin: 6px 0 28px; font-size: .9rem; }
.login-form { text-align: left; }
.login-form .field { margin-bottom: 18px; }
.login-hint { margin-top: 22px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-3); font-size: .8rem; color: var(--text-dim); display: flex; align-items: center; gap: 10px; text-align: left; }
.login-hint svg { width: 18px; height: 18px; color: var(--amber); }
.login-hint code { background: var(--bg); padding: 1px 6px; border-radius: 5px; color: var(--text); }

.backdrop { display: none; }

/* =============================================================================
   Animations
   ========================================================================== */
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes slideOut { to { opacity: 0; transform: translateX(30px); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes aurora-in { from { opacity: 0; transform: scale(1.12); } to { opacity: 1; transform: none; } }

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

/* =============================================================================
   Responsive
   ========================================================================== */
@media (max-width: 980px) {
  .grid-2 { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 80; transform: translateX(-100%);
    transition: transform .25s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.5); }
  .menu-toggle { display: inline-grid; }
  .content { padding: 20px 16px 50px; }
  .topbar { padding: 14px 16px; }
  .topbar-actions .btn span { display: none; }
  .form-grid { grid-template-columns: 1fr; }
}
/* Subscriber/data table -> stacked cards on phones */
@media (max-width: 720px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody { display: block; }
  .data-table tr {
    display: block; margin-bottom: 14px; padding: 6px 4px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
  }
  .data-table td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 9px 14px; text-align: right; border: none !important;
  }
  .data-table td:not(:last-child) { border-bottom: 1px solid var(--border) !important; }
  .data-table td[data-label]::before {
    content: attr(data-label); text-align: left; flex: none;
    font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-faint); font-weight: 700;
  }
  .data-table td.td-client { justify-content: flex-start; }
  .data-table td.td-actions { justify-content: flex-end; }
  .data-table td .muted.sm { display: inline; margin: 0; }
  .data-table td.nowrap { white-space: normal; }
  .row-actions { justify-content: flex-end; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .auto-card { flex-direction: column; gap: 12px; }
  .login-card { padding: 32px 22px; }
}
