/* Zaggify SaaS: accounts, plans, billing, public site, locked features */
:root {
  --plan-free: #5D6E84;
  --plan-starter: #2B6AA8;
  --plan-pro: #5B4BC4;
  --plan-agency: #13233A;
  --meter-ok: var(--brand);
  --meter-near: #D9822B;
  --meter-full: #C62E2E;
}
[data-theme="dark"] {
  --plan-free: #95A6BB;
  --plan-starter: #8BBCEB;
  --plan-pro: #A99CFF;
  --plan-agency: #E6EDF5;
  --meter-near: #F2A65A;
  --meter-full: #FF7070;
}

/* ---------- Plan badges & user chip ---------- */
.plan-badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 750; letter-spacing: .06em; border: 1.5px solid currentColor; line-height: 1.5; white-space: nowrap; }
.plan-badge.plan-free { color: var(--plan-free); }
.plan-badge.plan-starter { color: var(--plan-starter); }
.plan-badge.plan-pro { color: var(--plan-pro); background: color-mix(in srgb, var(--plan-pro) 10%, transparent); }
.plan-badge.plan-agency { color: var(--surface); background: var(--plan-agency); border-color: var(--plan-agency); }
.avatar { border-radius: 50%; object-fit: cover; flex: none; }
.avatar.initials { display: inline-grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; font-size: .85rem; }
.user-chip { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.user-chip-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.user-chip-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip-text a { text-decoration: none; }
.user-links { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.user-links form { display: inline; }
.topbar-plan { text-decoration: none; }

/* ---------- Banners & alerts ---------- */
.banner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .92rem; }
.banner form { margin: 0; }
.banner.info { background: var(--brand-soft); color: var(--ink); border: 1px solid var(--brand-line); }
.banner.error { background: var(--error-bg); color: var(--ink); border: 1px solid color-mix(in srgb, var(--error) 35%, transparent); }
.banner.warn { background: var(--warning-bg); color: var(--ink); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); }
.alert.warn { background: var(--warning-bg); color: var(--warning); }
.field-error { color: var(--error); font-size: .84rem; font-weight: 600; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--error) !important; box-shadow: 0 0 0 1px var(--error); }
.center { text-align: center; }
.issue-actions.center { justify-content: center; }
.stack.tight { gap: 8px; }
.grid.two.tight { gap: 12px; }
.field.end { justify-content: flex-end; }
.btn.danger { background: var(--error); border-color: var(--error); color: #fff; }
.btn.danger:hover { filter: brightness(.95); color: #fff; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .9rem; }

/* ---------- Auth pages ---------- */
body.auth { min-height: 100vh; background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), transparent), var(--bg); }
.auth-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; gap: 18px; outline: none; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.3rem; color: var(--ink); text-decoration: none; }
.auth-card.wide { width: min(520px, 100%); }
.auth-card h1 { margin-top: 0; }
.auth-card .stack { margin-top: 10px; }
.auth-switch { margin: 16px 0 6px; text-align: center; }
.auth-legal { font-size: .82rem; color: var(--muted); }
.btn.google { background: var(--surface); border: 1px solid var(--line); color: var(--ink); gap: 10px; min-height: 46px; font-size: .95rem; }
.btn.google:hover { border-color: var(--brand-line); background: var(--surface-2); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .85rem; margin: 16px 0 6px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.setup-steps li { margin-bottom: 8px; }

/* ---------- Public site ---------- */
body.public { background: var(--bg); }
.site-wrap { width: min(1180px, 100%); margin: 0 auto; padding: 0 20px; }
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.site-header .site-wrap { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.site-brand { display: flex; align-items: center; gap: 9px; font-weight: 750; font-size: 1.2rem; color: var(--ink); text-decoration: none; margin-right: auto; }
.site-nav { display: flex; align-items: center; gap: 18px; }
.site-nav a:not(.btn) { color: var(--ink-2); text-decoration: none; font-weight: 560; }
.site-nav a:not(.btn):hover, .site-nav a[aria-current="page"] { color: var(--brand-ink); }
.site-nav form { margin: 0; }
.site-nav-toggle { display: none; }
.site-main { outline: none; min-height: 60vh; padding-bottom: 40px; }
.site-main > .alert { width: min(1180px, calc(100% - 40px)); margin: 16px auto 0; }
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 22px 0; font-size: .88rem; color: var(--muted); }
.site-footer .site-wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer span { display: inline-flex; align-items: center; gap: 8px; }
.site-footer nav { display: flex; gap: 16px; }
.landing-hero { padding: 64px 0 40px; background: linear-gradient(180deg, var(--brand-soft), transparent); }
.hero-grid { display: grid; grid-template-columns: 1.25fr .9fr; gap: 40px; align-items: center; }
.landing-hero h1 { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.02em; }
.eyebrow { color: var(--brand-ink); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0 10px; }
.hero-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.hero-score { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.hero-score span { font-size: 3rem; font-weight: 800; color: var(--passed); }
.hero-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hero-list li { display: flex; gap: 10px; align-items: center; font-size: .92rem; }
.features { padding: 40px 20px; }
.features h2, .how h2, .matrix h2 { font-size: 1.6rem; text-align: center; margin-bottom: 24px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.feature h3 { margin-bottom: 6px; }
.feature p { color: var(--ink-2); margin: 0; }
.how { padding: 20px 20px 40px; }
.steps { list-style: none; counter-reset: s; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.steps li { counter-increment: s; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.steps li::before { content: counter(s); width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }
.steps span { color: var(--ink-2); font-size: .92rem; }
.legal { padding: 30px 20px; max-width: 820px; }
.legal h2 { margin-top: 22px; font-size: 1.15rem; }

/* ---------- Pricing ---------- */
.pricing-head { text-align: center; padding-top: 40px; padding-bottom: 10px; }
.pricing-head .lede { margin: 0 auto 18px; max-width: 640px; }
.billing-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface); }
.billing-toggle label { position: relative; }
.billing-toggle input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.billing-toggle span { display: block; padding: 7px 18px; border-radius: 999px; font-weight: 650; font-size: .92rem; color: var(--ink-2); }
.billing-toggle input:checked + span { background: var(--brand); color: #fff; }
[data-theme="dark"] .billing-toggle input:checked + span { color: #0B1726; }
.billing-toggle input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.billing-toggle.small span { padding: 4px 12px; font-size: .82rem; }
.save-note { color: var(--passed); font-weight: 650; font-size: .9rem; margin-top: 10px; }
.pricing-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; padding-top: 20px; padding-bottom: 30px; align-items: stretch; }
.price-card { position: relative; display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px 20px; }
.price-card.popular { border: 2px solid var(--plan-pro); box-shadow: 0 10px 30px color-mix(in srgb, var(--plan-pro) 18%, transparent); }
.price-card.current { outline: 2px dashed var(--brand-line); outline-offset: 3px; }
.popular-badge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--plan-pro); color: #fff; font-size: .72rem; font-weight: 800; letter-spacing: .08em; padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
[data-theme="dark"] .popular-badge { color: #120F2A; }
.price-card h2 { font-size: 1rem; letter-spacing: .1em; margin: 0; }
.plan-tagline { color: var(--muted); font-size: .9rem; margin: 0; min-height: 2.6em; }
.price { margin: 6px 0 0; display: flex; align-items: baseline; gap: 4px; }
.price .amount { font-size: 2.3rem; font-weight: 800; letter-spacing: -.02em; }
.price .per { color: var(--muted); font-weight: 600; }
.price-sub { color: var(--muted); font-size: .84rem; margin: 0 0 6px; min-height: 2.4em; }
.plan-items { list-style: none; padding: 0; margin: 6px 0 14px; display: grid; gap: 7px; font-size: .92rem; flex: 1; align-content: start; }
.plan-items li { display: flex; gap: 8px; align-items: flex-start; }
.plan-items li::before { content: "✓"; color: var(--passed); font-weight: 800; flex: none; }
.plan-items li.no { color: var(--muted); }
.plan-items li.no::before { content: "✕"; color: var(--muted); }
.plan-desc { color: var(--muted); font-size: .82rem; margin: 6px 0 0; }
.matrix { padding-bottom: 40px; }
.compare-table th[scope="row"] { font-weight: 600; text-align: left; }
.compare-table .yes { color: var(--passed); font-weight: 800; }
.compare-table .no { color: var(--muted); }

/* ---------- Dashboard ---------- */
.welcome { padding: 26px; }
.welcome-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.welcome-head h1 { margin: 0; }
.welcome .url-row { margin: 10px 0; }
.plan-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 0; }
.plan-card .card-head > div:first-child { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 6px 0 10px; }
.meter { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 12px; }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; font-size: .88rem; color: var(--ink-2); }
.meter-top strong { color: var(--ink); font-size: 1rem; }
.meter-track { height: 8px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--meter-ok); border-radius: 999px; transition: width .3s ease; }
.meter-near .meter-fill { background: var(--meter-near); }
.meter-near .meter-top strong { color: var(--meter-near); }
.meter-full .meter-fill { background: var(--meter-full); }
.meter-full .meter-top strong { color: var(--meter-full); }
.meter-off .meter-top strong { color: var(--muted); font-weight: 600; font-size: .82rem; }
.project-list { list-style: none; margin: 0; padding: 0; }
.project-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.project-row:last-child { border-bottom: 0; }
.project-row.archived { opacity: .85; }
.project-main { display: flex; flex-direction: column; min-width: 0; }
.project-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.project-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: flex-start; }
.project-actions form { margin: 0; }
.inline-menu { position: relative; }
.inline-menu > summary { list-style: none; }
.inline-menu > summary::-webkit-details-marker { display: none; }
.inline-menu-body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: min(320px, 86vw); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 14px; display: grid; gap: 14px; }
.add-site { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.add-site h3 { margin-bottom: 8px; }
.limit-card, .select-card { border-left: 4px solid var(--meter-near); }
.payment-issue { border-left: 4px solid var(--error); }
.locked-panel h2 { margin-top: 12px; }
.locked-inline { display: block; }
.row-locked td { color: var(--muted); }
.upsell-line { font-size: .88rem; color: var(--ink-2); margin: 8px 0 0; }
.scan-upgrade { margin-top: 10px; }
.inline-field.grow { flex: 1; min-width: 240px; }
.inline-field.grow select { flex: 1; max-width: 100%; }

/* ---------- Locked AI ---------- */
.ai-fab.locked { background: var(--surface); color: var(--ink); border: 1px solid var(--brand-line); }
.ai-locked { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.ai-locked .plan-items { flex: none; }
.ai-messages.readonly { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.ai-lock-card { margin-top: 12px; padding: 12px 14px; border: 1px dashed var(--brand-line); border-radius: 10px; background: var(--brand-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ai-lock-card p { margin: 0; font-size: .9rem; }
.ai-lock-card strong { display: block; }
.btn.ai.locked { opacity: .9; border-style: dashed; }
.btn.ai.locked::after { content: "🔒"; font-size: .75em; margin-left: 2px; }

/* ---------- Upgrade modal ---------- */
.upgrade-modal .modal-box { max-width: 460px; }
.upgrade-modal h2 { margin-bottom: 4px; }
.upgrade-modal .price { margin-bottom: 8px; }
.upgrade-modal .plan-items { margin-bottom: 0; }
.upgrade-modal .modal-actions { justify-content: stretch; flex-wrap: wrap; }
.upgrade-modal .modal-actions .btn { flex: 1; }

/* ---------- Billing & checkout ---------- */
.plan-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.plan-option { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); }
.plan-option.current { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.plan-option .price .amount { font-size: 1.6rem; }
.checkout-card { max-width: 560px; margin: 20px auto; padding: 26px; }
.checkout-card.center { text-align: center; }
.checkout-plan { border: 1px solid var(--line-2); border-radius: 12px; padding: 16px; margin: 12px 0 16px; background: var(--surface-2); }

/* ---------- Admin & account ---------- */
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 18px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.subnav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 600; }
.subnav a.active, .subnav a:hover { background: var(--brand-soft); color: var(--brand-ink); }
.dash-stats.wide { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.inline-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.profile-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.danger-zone { border-color: color-mix(in srgb, var(--error) 35%, var(--line)); }
.price-form { border: 1px solid var(--line-2); border-radius: 10px; padding: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .pricing-grid { grid-template-columns: repeat(2, 1fr); }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .site-nav-toggle { display: inline-grid; }
  .site-nav { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 20px 16px; box-shadow: var(--shadow); }
  .site-nav.open { display: flex; }
  .site-nav a:not(.btn) { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
  .site-nav .btn, .site-nav form .btn { margin-top: 10px; width: 100%; }
  .topbar-plan { margin-left: auto; }
  .brand-mini { margin-right: 0 !important; }
}
@media (max-width: 640px) {
  .pricing-grid, .feature-grid, .steps { grid-template-columns: 1fr; }
  .price-card.popular { margin-top: 10px; }
  .project-row { grid-template-columns: auto 1fr; }
  .project-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .project-actions .btn { flex: 1; }
  .inline-menu { flex: 1; }
  .inline-menu > summary { width: 100%; }
  .inline-menu-body { left: 0; right: auto; width: min(320px, calc(100vw - 32px)); }
  .meters { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 22px 18px; }
  .grid.two.tight { grid-template-columns: 1fr; }
  .landing-hero { padding-top: 36px; }
  .banner .btn { width: 100%; }
  .billing-toggle span { padding: 7px 14px; }
}
@media (max-width: 380px) {
  .meters { grid-template-columns: 1fr; }
}
@media print {
  .site-header, .site-footer, .banner { display: none !important; }
}
