/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e5e7eb;
  --border-soft: #eef0f3;
  --text: #12151c;
  --text-muted: #667085;
  --text-faint: #98a2b3;
  --accent: #2f4bdb;
  --accent-dark: #2338a8;
  --accent-ink: #ffffff;
  --accent-soft: #edf0fe;
  --accent-soft-border: #d7deff;
  --success: #067647;
  --success-soft: #e7f6ef;
  --warning: #b54708;
  --warning-soft: #fff4e5;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 4px 12px rgba(16,24,40,.04);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.12);
  --sidebar-w: 252px;
  --topbar-h: 68px;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root.auto-dark {
    --bg: #0b0d12;
    --surface: #12151c;
    --surface-2: #171b23;
    --border: #262b36;
    --border-soft: #1d222c;
    --text: #f2f4f7;
    --text-muted: #98a2b3;
    --text-faint: #667085;
    --accent-soft: #171d3e;
    --accent-soft-border: #2a3470;
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.01em; font-weight: 650; }
table { border-collapse: collapse; width: 100%; }
::selection { background: var(--accent-soft-border); color: var(--accent-dark); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem;
  background: var(--text); color: var(--surface); z-index: 9999;
  border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-xs { gap: 6px; } .gap-sm { gap: 10px; } .gap-md { gap: 16px; } .gap-lg { gap: 28px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

/* =============================================================
   4. Buttons
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
  border: 1px solid transparent; transition: transform .15s var(--ease-out), box-shadow .15s var(--ease-out), background .15s var(--ease-out), border-color .15s var(--ease-out);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(47,75,219,.24); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { border-color: var(--text-faint); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fde2df; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* =============================================================
   5. Cards, badges, forms
   ============================================================= */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }
.card-hover { transition: box-shadow .2s var(--ease-out), border-color .2s var(--ease-out), transform .2s var(--ease-out); }
.card-hover:hover { box-shadow: var(--shadow); border-color: var(--text-faint); transform: translateY(-1px); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1.6;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-accent { background: var(--accent-soft); color: var(--accent-dark); }
.badge-caution { background: #fef9c3; color: #854d0e; }
:root.auto-dark .badge-caution { background: #3f3512; color: #fde047; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 12.5px; color: var(--text-muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 14.5px; transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 90px; }
.input-file {
  border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 28px 16px; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.input-file:hover, .input-file.is-drag { border-color: var(--accent); background: var(--accent-soft); }

.divider { height: 1px; background: var(--border); border: 0; }

/* Demo mode banner */
.demo-banner {
  background: var(--warning-soft); color: var(--warning); font-size: 13px; font-weight: 600;
  padding: 9px 16px; text-align: center; border-bottom: 1px solid #fbe4c1;
}
.demo-tag {
  display: inline-flex; align-items: center; gap: 6px; background: var(--warning-soft); color: var(--warning);
  font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 6px; letter-spacing: .02em;
}

/* Toasts */
.toast-stack { position: fixed; top: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 10px; max-width: 340px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  border-radius: var(--radius-sm); padding: 13px 16px; font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start;
  animation: toast-in .25s var(--ease-out);
}
.toast.error { border-color: #f3c6c1; }
.toast.success { border-color: #b7e4cd; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(16,20,30,.5); display: flex; align-items: center; justify-content: center;
  z-index: 998; padding: 20px; backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); max-width: 460px; width: 100%;
  box-shadow: var(--shadow-lg); padding: 28px; max-height: 90vh; overflow-y: auto;
  animation: modal-in .2s var(--ease-out);
}
@keyframes modal-in { from { opacity: 0; transform: scale(.97) translateY(6px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }

/* =============================================================
   6. Tables
   ============================================================= */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.table { width: 100%; font-size: 13.5px; min-width: 560px; }
.table th {
  text-align: left; padding: 12px 16px; font-weight: 600; color: var(--text-muted); font-size: 12.5px;
  text-transform: uppercase; letter-spacing: .03em; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--surface-2); }
.table .cell-strong { font-weight: 600; }
.table-empty { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 14px; }

/* =============================================================
   7. Landing: header, hero, sections
   ============================================================= */
.site-header {
  position: sticky; top: 0; z-index: 50; background: rgba(246,247,251,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 72px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16.5px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #6a7bff);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 14px;
}
.nav-links { display: none; gap: 30px; font-size: 14.5px; font-weight: 500; color: var(--text-muted); }
.nav-links a:hover { color: var(--text); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.mobile-menu-btn { display: flex; }
@media (min-width: 960px) {
  .nav-links { display: flex; }
  .mobile-menu-btn { display: none; }
}
.mobile-nav {
  border-top: 1px solid var(--border-soft); background: var(--surface); padding: 14px 24px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.mobile-nav a { padding: 10px 4px; font-size: 15px; font-weight: 500; border-radius: 8px; }
.mobile-nav a:hover { background: var(--surface-2); }

.hero { padding: 76px 0 40px; }
.hero-inner { max-width: 720px; margin: 0 auto; text-align: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 7px; background: var(--accent-soft); color: var(--accent-dark);
  border: 1px solid var(--accent-soft-border); padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 650;
  margin-bottom: 22px;
}
.hero h1 { font-size: clamp(2.1rem, 4.2vw, 3.3rem); margin-bottom: 18px; }
.hero h1 span { color: var(--accent); }
.hero p.lead { font-size: 17.5px; color: var(--text-muted); max-width: 560px; margin: 0 auto 30px; }
.hero-ctas { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.hero-note { font-size: 13px; color: var(--text-faint); }

.trust-strip { padding: 26px 0 60px; }
.trust-strip ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 28px 40px; font-size: 13px; color: var(--text-muted); }
.trust-strip li { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.trust-strip svg { color: var(--success); flex-shrink: 0; }

.section { padding: 68px 0; }
.section-head { max-width: 620px; margin: 0 auto 44px; text-align: center; }
.section-head h2 { font-size: clamp(1.6rem, 3vw, 2.15rem); margin-bottom: 12px; }
.section-head p { color: var(--text-muted); font-size: 15.5px; }

.feature-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.feature-card { padding: 24px; }
.feature-icon {
  width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; margin-bottom: 16px;
}
.feature-card h3 { font-size: 16px; margin-bottom: 7px; }
.feature-card p { font-size: 14px; color: var(--text-muted); }

/* Before/after */
.compare { display: grid; gap: 22px; grid-template-columns: 1fr; max-width: 900px; margin: 0 auto; }
@media (min-width: 720px) { .compare { grid-template-columns: 1fr 1fr; } }
.compare-panel { padding: 22px; }
.compare-panel h3 { font-size: 14px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.doc-mock { border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); padding: 18px; font-size: 12.5px; line-height: 1.9; color: var(--text-muted); }
.doc-mock .redact { background: #1a1d24; color: transparent; border-radius: 3px; padding: 0 2px; user-select: none; }
.doc-mock .flag { background: var(--warning-soft); color: var(--warning); border-radius: 3px; padding: 0 3px; }
.doc-mock .clean { background: var(--success-soft); color: var(--success); border-radius: 3px; padding: 0 3px; }

/* Pricing */
.pricing-grid { display: grid; gap: 20px; grid-template-columns: 1fr; max-width: 980px; margin: 0 auto; }
@media (min-width: 860px) { .pricing-grid { grid-template-columns: repeat(3, 1fr); align-items: stretch; } }
.plan-card { padding: 28px; display: flex; flex-direction: column; position: relative; }
.plan-card.is-featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.plan-badge {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff;
  font-size: 11.5px; font-weight: 700; padding: 4px 12px; border-radius: 999px; white-space: nowrap;
}
.plan-name { font-size: 15px; font-weight: 650; color: var(--text-muted); margin-bottom: 6px; }
.plan-price { font-size: 34px; font-weight: 750; margin-bottom: 2px; }
.plan-price span { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.plan-credits { font-size: 13.5px; color: var(--text-muted); margin-bottom: 20px; }
.plan-features { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; flex: 1; }
.plan-features li { display: flex; gap: 9px; font-size: 13.5px; align-items: flex-start; }
.plan-features svg { color: var(--success); flex-shrink: 0; margin-top: 2px; }

.faq-list { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.faq-item { padding: 4px 4px; }
.faq-item summary { padding: 16px 4px; font-weight: 600; font-size: 14.5px; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 20px; color: var(--text-muted); font-weight: 400; }
.faq-item[open] summary::after { content: "–"; }
.faq-item p { padding: 0 4px 16px; color: var(--text-muted); font-size: 14px; }

.cta-band { background: linear-gradient(135deg, var(--accent), #1c2e9e); border-radius: var(--radius-lg); padding: 52px 32px; text-align: center; color: #fff; }
.cta-band h2 { color: #fff; margin-bottom: 12px; }
.cta-band p { color: rgba(255,255,255,.82); margin-bottom: 26px; }
.cta-band .btn-secondary { background: #fff; border: none; }

.site-footer { border-top: 1px solid var(--border-soft); padding: 44px 0 30px; margin-top: 20px; }
.footer-grid { display: grid; gap: 30px; grid-template-columns: 1fr; margin-bottom: 30px; }
@media (min-width: 720px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; } }
.footer-col h4 { font-size: 13px; margin-bottom: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.footer-col ul { display: flex; flex-direction: column; gap: 9px; font-size: 13.5px; }
.footer-col a:hover { color: var(--accent); }
.footer-bottom { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--text-faint); padding-top: 22px; border-top: 1px solid var(--border-soft); }

/* Legal pages */
.legal-doc { max-width: 720px; margin: 0 auto; padding: 60px 0 90px; }
.legal-doc h1 { margin-bottom: 8px; }
.legal-doc .updated { color: var(--text-faint); font-size: 13px; margin-bottom: 36px; }
.legal-doc h2 { font-size: 18px; margin: 32px 0 12px; }
.legal-doc p, .legal-doc li { color: var(--text-muted); font-size: 14.5px; margin-bottom: 10px; }
.legal-doc ul { list-style: disc; padding-left: 22px; }

/* =============================================================
   8. Auth pages
   ============================================================= */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 960px) { .auth-shell { grid-template-columns: 1fr 1fr; } }
.auth-side {
  display: none; background: linear-gradient(160deg, #161b3d, #223 55%, var(--accent-dark));
  color: #fff; padding: 56px; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
@media (min-width: 960px) { .auth-side { display: flex; } }
.auth-side blockquote { font-size: 19px; line-height: 1.5; max-width: 420px; font-weight: 500; }
.auth-side cite { display: block; margin-top: 16px; font-size: 13.5px; opacity: .7; font-style: normal; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-tabs { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 26px; }
.auth-tab { flex: 1; text-align: center; padding: 9px; border-radius: 6px; font-size: 13.5px; font-weight: 600; color: var(--text-muted); }
.auth-tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-error { background: var(--danger-soft); color: var(--danger); font-size: 13px; padding: 10px 13px; border-radius: 8px; display: none; }
.auth-error.is-visible { display: block; }
.auth-foot { text-align: center; font-size: 13px; color: var(--text-faint); margin-top: 22px; }

/* =============================================================
   9. App shell (dashboard)
   ============================================================= */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40; transition: transform .25s var(--ease-out);
}
.app-sidebar-head { padding: 20px 20px 16px; display: flex; align-items: center; gap: 10px; }
.app-sidebar-close { display: flex; margin-left: auto; }
@media (min-width: 960px) { .app-sidebar-close { display: none; } }
.app-nav { flex: 1; overflow-y: auto; padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.app-nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--text-muted); transition: background .15s, color .15s;
}
.app-nav-link svg { flex-shrink: 0; width: 18px; height: 18px; }
.app-nav-link:hover { background: var(--surface-2); color: var(--text); }
.app-nav-link.is-active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 650; }
.app-nav-gap { height: 14px; }
.app-sidebar-foot { padding: 14px; border-top: 1px solid var(--border-soft); }
.plan-pill {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12.5px;
}

.app-main { flex: 1; min-width: 0; }
@media (min-width: 960px) { .app-main { margin-left: var(--sidebar-w); } }
.app-topbar {
  height: var(--topbar-h); border-bottom: 1px solid var(--border); background: rgba(246,247,251,.9); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 0 20px;
}
.sidebar-toggle { display: flex; }
@media (min-width: 960px) { .sidebar-toggle { display: none; } }
.topbar-search {
  flex: 1; max-width: 380px; display: flex; align-items: center; gap: 9px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; color: var(--text-faint); font-size: 13.5px;
}
.topbar-search input { border: 0; background: none; flex: 1; color: var(--text); font-size: 13.5px; }
.topbar-search input:focus { outline: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.credits-pill {
  display: flex; align-items: center; gap: 7px; background: var(--accent-soft); border: 1px solid var(--accent-soft-border);
  color: var(--accent-dark); font-weight: 650; font-size: 13px; padding: 7px 13px; border-radius: 999px;
}
.icon-btn { position: relative; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 999px; color: var(--text-muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-dot { position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--bg); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: flex;
  align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.profile-menu-wrap { position: relative; }
.profile-menu-btn { display: flex; align-items: center; gap: 8px; }
.dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 220px; padding: 8px; z-index: 60;
}
.dropdown a, .dropdown button { display: flex; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px; font-size: 13.5px; gap: 9px; align-items: center; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); }
.dropdown .divider { margin: 6px 0; }

.sidebar-overlay { position: fixed; inset: 0; background: rgba(16,20,30,.4); z-index: 39; }
@media (min-width: 960px) { .app-sidebar { transform: none !important; } .sidebar-overlay { display: none !important; } }
@media (max-width: 959.98px) { .app-sidebar { transform: translateX(-100%); } .app-sidebar.is-open { transform: none; } }

.app-view { padding: 26px 20px 60px; max-width: 1180px; margin: 0 auto; }
.app-view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.app-view-head h1 { font-size: 21px; }
.app-view-head p { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }

.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); margin-bottom: 22px; }
@media (min-width: 720px) { .stat-grid { grid-template-columns: repeat(5, 1fr); } }
.stat-card { padding: 16px 18px; }
.stat-card .label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; margin-bottom: 8px; }
.stat-card .value { font-size: 24px; font-weight: 700; }
.stat-card .value small { font-size: 13px; font-weight: 500; color: var(--text-muted); }

.quick-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); margin-bottom: 26px; }
@media (min-width: 720px) { .quick-grid { grid-template-columns: repeat(4, 1fr); } }
.quick-action { padding: 16px; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.quick-action .qi { width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.quick-action strong { font-size: 13.5px; }

.panel-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-title h2 { font-size: 15.5px; }

.tool-grid { display: grid; gap: 22px; grid-template-columns: 1fr; }
@media (min-width: 1080px) { .tool-grid { grid-template-columns: 1.1fr .9fr; align-items: start; } }
.cost-line {
  display: flex; align-items: center; justify-content: space-between; background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13.5px; color: var(--accent-dark); font-weight: 600;
}
.result-box { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 20px; text-align: center; }

.tool-shortcuts { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .tool-shortcuts { grid-template-columns: repeat(2, 1fr); } }

/* Template gallery + document wizard */
.template-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.template-card { padding: 20px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; text-align: left; }
.template-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.template-card h3 { font-size: 15px; }
.template-card p { font-size: 13px; color: var(--text-muted); flex: 1; }
.template-card .btn { margin-top: 4px; }

.wizard-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.wizard-steps { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-faint); font-weight: 600; }
.wizard-steps .step { display: flex; align-items: center; gap: 6px; }
.wizard-steps .num { width: 20px; height: 20px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 11px; }
.wizard-steps .step.is-active { color: var(--accent-dark); }
.wizard-steps .step.is-active .num { background: var(--accent); border-color: var(--accent); color: #fff; }
.wizard-steps .sep { width: 18px; height: 1px; background: var(--border); }

.dynamic-form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .dynamic-form-grid.two-col { grid-template-columns: 1fr 1fr; } }
.dynamic-form-grid .field-full { grid-column: 1 / -1; }

.doc-preview {
  white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; line-height: 1.7; color: var(--text);
  background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: 40px 36px; min-height: 420px;
  box-shadow: var(--shadow-sm); max-width: 720px; margin: 0 auto;
}
:root.auto-dark .doc-preview { color: #1a1d24; }
.doc-preview:focus { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Progress state machine visuals */
[data-state] .state-idle, [data-state] .state-working, [data-state] .state-done, [data-state] .state-error,
[data-state] .state-subiendo, [data-state] .state-analizando { display: none; }
[data-state="idle"] .state-idle { display: block; }
[data-state="working"] .state-working { display: block; }
[data-state="done"] .state-done { display: block; }
[data-state="error"] .state-error { display: block; }
[data-state="subiendo"] .state-subiendo { display: block; }
[data-state="analizando"] .state-analizando { display: block; }

/* Archivo: filters + search */
.archivo-toolbar { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.archivo-search {
  display: flex; align-items: center; gap: 9px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 13px; max-width: 420px;
}
.archivo-search input { border: 0; background: none; flex: 1; font-size: 14px; color: var(--text); }
.archivo-search input:focus { outline: none; }
.filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pill {
  padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted); transition: all .15s var(--ease-out);
}
.filter-pill:hover { border-color: var(--text-faint); color: var(--text); }
.filter-pill.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-type-select { max-width: 220px; }
.archivo-row { cursor: pointer; }

/* Drawer (ficha de documento) */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(16,20,30,.45); z-index: 80; display: flex; justify-content: flex-end;
}
.drawer {
  width: 100%; max-width: 460px; height: 100%; background: var(--surface); box-shadow: var(--shadow-lg);
  overflow-y: auto; animation: drawer-in .22s var(--ease-out); display: flex; flex-direction: column;
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 20px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.drawer-head-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.drawer-body { padding: 20px 22px 40px; display: flex; flex-direction: column; gap: 24px; }
.drawer-section h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); margin-bottom: 12px; }
.drawer-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; font-size: 13.5px; }
.drawer-info-grid .label { color: var(--text-muted); font-size: 12px; margin-bottom: 2px; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.assoc-item, .history-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.assoc-item:last-child, .history-item:last-child { border-bottom: 0; }
.assoc-item { cursor: pointer; }
.assoc-item:hover .assoc-name { color: var(--accent); }
.history-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; }
.note-item { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.note-item .note-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.note-item .note-date { font-size: 11.5px; color: var(--text-faint); }
.note-item .note-actions { display: flex; gap: 8px; }
.note-item .note-actions button { font-size: 12px; color: var(--text-muted); }
.note-item .note-actions button:hover { color: var(--accent); }
.note-item textarea { width: 100%; margin-top: 6px; }

@media (max-width: 539.98px) {
  .drawer { max-width: 100%; }
  .drawer-info-grid { grid-template-columns: 1fr; }
}

/* Alertas */
.alert-summary-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); margin-bottom: 22px; }
@media (min-width: 720px) { .alert-summary-grid { grid-template-columns: repeat(4, 1fr); } }
.alert-summary-card {
  padding: 16px 18px; text-align: left; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius); cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.alert-summary-card:hover { border-color: var(--text-faint); transform: translateY(-1px); }
.alert-summary-card.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.alert-summary-card .label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; margin-bottom: 8px; }
.alert-summary-card .value { font-size: 24px; font-weight: 700; }

.alert-card { padding: 16px 18px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; cursor: pointer; }
.alert-card.is-managed { opacity: .55; }
.alert-card .grow { min-width: 180px; }
.alert-urgency-dot { font-size: 15px; line-height: 1; flex-shrink: 0; }
.alert-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }

.alert-config-grid { display: grid; gap: 22px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .alert-config-grid { grid-template-columns: 1fr 1fr; } }
.checkbox-row { display: flex; align-items: center; gap: 9px; padding: 9px 4px; font-size: 14px; cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Findings checklist (anonimizar) */
.finding-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: border-color .15s, background .15s;
}
.finding-row:hover { border-color: var(--text-faint); background: var(--surface-2); }
.finding-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; }
.finding-tag { min-width: 150px; flex-shrink: 0; }
.finding-value { font-family: var(--mono); font-size: 12.5px; color: var(--text-muted); word-break: break-word; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--accent-soft-border); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Upgrade / checkout modal card */
.mock-card-input {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2);
  font-family: var(--mono); font-size: 14px; letter-spacing: 1.5px; color: var(--text-faint);
}

/* Config / account view */
.settings-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 960px) { .settings-grid { grid-template-columns: 2fr 1fr; } }

/* Responsive helpers */
.only-mobile { display: block; } .only-desktop { display: none; }
@media (min-width: 960px) { .only-mobile { display: none; } .only-desktop { display: block; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .spinner { animation-duration: 1.4s; }
}
