:root {
  --bg: #070a14; --bg2: #0b1020; --panel: rgba(18, 24, 44, 0.72); --panel-solid: #121a30; --line: rgba(148, 163, 214, 0.16);
  --line-strong: rgba(148, 163, 214, 0.3); --text: #eef1fb; --muted: #9aa4c4; --dim: #6c769a;
  --gold: #e8c27a; --gold2: #f5dca6; --violet: #8b7bff; --teal: #3fd2c7; --rose: #ff7a9a; --amber: #ffb547; --green: #4ade80;
  --radius: 18px; --shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.7), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --serif: "Fraunces", Georgia, serif; --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body { background: radial-gradient(1200px 700px at 10% -10%, #1b1f4a 0%, transparent 60%), radial-gradient(900px 600px at 110% 10%, #2a1740 0%, transparent 55%), linear-gradient(180deg, var(--bg2), var(--bg)); background-attachment: fixed; }
.aurora { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.aurora span { position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(90px); opacity: 0.22; animation: drift 26s ease-in-out infinite alternate; }
.aurora span:nth-child(1) { background: #6d5dfc; top: -18vmax; left: -10vmax; }
.aurora span:nth-child(2) { background: #c08a3e; bottom: -22vmax; right: -12vmax; animation-delay: -8s; opacity: 0.16; }
.aurora span:nth-child(3) { background: #1fb5a9; top: 30%; left: 45%; width: 30vmax; height: 30vmax; animation-delay: -15s; opacity: 0.1; }
@keyframes drift { to { transform: translate(6vmax, 4vmax) scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .aurora span { animation: none; } }
#app { position: relative; z-index: 1; min-height: 100vh; }
a { color: var(--gold2); }
button, input, select, textarea { font: inherit; color: inherit; }
.wordmark { font-weight: 600; letter-spacing: 0.02em; font-size: 18px; white-space: nowrap; }
.wordmark b { font-weight: 700; letter-spacing: 0.18em; background: linear-gradient(120deg, var(--gold2), var(--gold) 50%, #c9973f); -webkit-background-clip: text; background-clip: text; color: transparent; margin-right: 6px; }
.boot { min-height: 100vh; display: grid; place-content: center; gap: 22px; justify-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; gap: 48px; align-items: center; max-width: 1240px; margin: 0 auto; padding: 48px 40px; }
.hero h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(34px, 4.6vw, 58px); line-height: 1.04; letter-spacing: -0.02em; margin: 26px 0 18px; }
.hero h1 em { font-style: normal; background: linear-gradient(100deg, var(--gold2), var(--gold) 40%, #b88cff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lede { color: var(--muted); font-size: 17px; max-width: 540px; margin: 0 0 28px; }
.eyebrow { display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold2); background: rgba(232, 194, 122, 0.06); }
.eyebrow::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 12px var(--gold); }
.features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 600px; }
.feature { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(160deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.01)); }
.feature strong { display: block; font-size: 14px; margin-bottom: 2px; }
.feature span { color: var(--muted); font-size: 13px; }
.preview { margin-top: 26px; display: flex; gap: 10px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; border: 1px solid var(--line-strong); color: var(--muted); background: rgba(255, 255, 255, 0.03); white-space: nowrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.auth-card { padding: 30px; }
.tabs { display: flex; gap: 6px; padding: 4px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); margin-bottom: 22px; }
.tabs button { flex: 1; padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 600; }
.tabs button[aria-selected="true"] { background: linear-gradient(180deg, #232d52, #1a2242); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.field-row { display: grid; gap: 14px; }
input, select, textarea { width: 100%; padding: 11px 13px; background: rgba(5, 8, 18, 0.55); border: 1px solid var(--line-strong); border-radius: 11px; outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232, 194, 122, 0.18); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
select option { background: var(--panel-solid); }
textarea { min-height: 96px; resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 11px; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.04); color: var(--text); cursor: pointer; font-weight: 600; font-size: 14px; text-decoration: none; transition: transform 0.12s, background 0.15s, border-color 0.15s; white-space: nowrap; }
.btn:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--gold); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--gold2), var(--gold) 45%, #c4903c); color: #1a1407; border-color: transparent; box-shadow: 0 10px 30px -12px rgba(232, 194, 122, 0.7); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 12px; margin: 18px 0; text-transform: uppercase; letter-spacing: 0.12em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.fine { color: var(--dim); font-size: 12px; margin-top: 14px; }
.error { color: #ffb3c2; background: rgba(255, 122, 154, 0.1); border: 1px solid rgba(255, 122, 154, 0.35); padding: 10px 12px; border-radius: 10px; font-size: 13px; }

/* ---------- console ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 22px 16px; border-right: 1px solid var(--line); background: linear-gradient(180deg, rgba(10, 14, 28, 0.85), rgba(8, 11, 22, 0.6)); backdrop-filter: blur(16px); display: flex; flex-direction: column; gap: 22px; }
.side nav { display: grid; gap: 4px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px; color: var(--muted); text-decoration: none; font-weight: 500; }
.side nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.side nav a[aria-current="page"] { color: var(--text); background: linear-gradient(90deg, rgba(232, 194, 122, 0.14), rgba(139, 123, 255, 0.06)); box-shadow: inset 2px 0 0 var(--gold); }
.side nav a i { width: 8px; height: 8px; border-radius: 3px; background: currentColor; opacity: 0.55; }
.org-box { margin-top: auto; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.025); font-size: 13px; }
.org-box .org-name { font-weight: 600; color: var(--text); }
.org-box .who { color: var(--muted); word-break: break-all; }
main { padding: 28px 34px 60px; max-width: 1280px; width: 100%; }
.topline { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.topline h2 { font-family: var(--serif); font-weight: 600; font-size: 32px; letter-spacing: -0.01em; margin: 0; }
.topline .sub { color: var(--muted); margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.demo-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 18px; border-radius: 12px; border: 1px dashed rgba(232, 194, 122, 0.45); background: rgba(232, 194, 122, 0.07); color: var(--gold2); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 18px 18px 16px; position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; inset: auto -30% -60% auto; width: 160px; height: 160px; border-radius: 50%; background: var(--accent, var(--violet)); opacity: 0.12; filter: blur(30px); }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; }
.stat .v { font-family: var(--serif); font-size: 38px; font-weight: 600; line-height: 1.1; margin-top: 8px; }
.stat .h { color: var(--dim); font-size: 12px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
.panel { padding: 20px; }
.panel h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel h3 small { color: var(--dim); font-weight: 500; font-size: 12px; }
.list { display: grid; gap: 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.02); }
.row.link { cursor: pointer; transition: border-color 0.15s, background 0.15s; text-decoration: none; color: inherit; }
.row.link:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.045); }
.row .t { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.row .m { color: var(--muted); font-size: 13px; }
.row > div { min-width: 0; }
.empty { color: var(--dim); font-size: 14px; padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 80px 1fr 34px; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); text-transform: capitalize; }
.bar .track { height: 9px; border-radius: 99px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.bar .fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--c1, var(--violet)), var(--c2, var(--teal))); }
.bar b { color: var(--text); text-align: right; }
.pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; text-transform: capitalize; border: 1px solid transparent; white-space: nowrap; }
.pill.lead { color: #c7c1ff; background: rgba(139, 123, 255, 0.14); border-color: rgba(139, 123, 255, 0.35); }
.pill.active, .pill.open { color: #8ff0c0; background: rgba(74, 222, 128, 0.12); border-color: rgba(74, 222, 128, 0.3); }
.pill.trial, .pill.pending { color: #9ee9ff; background: rgba(63, 210, 199, 0.12); border-color: rgba(63, 210, 199, 0.32); }
.pill.paused, .pill.high { color: #ffd59a; background: rgba(255, 181, 71, 0.12); border-color: rgba(255, 181, 71, 0.32); }
.pill.churned, .pill.expired, .pill.cancelled, .pill.urgent { color: #ffb3c2; background: rgba(255, 122, 154, 0.12); border-color: rgba(255, 122, 154, 0.32); }
.pill.normal, .pill.low, .pill.resolved, .pill.closed, .pill.manual, .pill.shopify, .pill.stripe { color: var(--muted); background: rgba(255, 255, 255, 0.05); border-color: var(--line-strong); }
.pill.soon { color: #1a1407; background: linear-gradient(135deg, var(--gold2), var(--gold)); }
.toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 170px 170px auto; gap: 10px; margin-bottom: 14px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--dim); font-weight: 600; padding: 0 14px 10px; }
.table td { padding: 13px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: rgba(255, 255, 255, 0.03); }
.table .name { font-weight: 600; }
.table .muted { color: var(--muted); font-size: 13px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.form-grid .span2 { grid-column: span 2; }
.form-grid .span3 { grid-column: 1 / -1; }
details.add { margin-bottom: 14px; }
details.add > summary { list-style: none; cursor: pointer; display: inline-flex; }
details.add > summary::-webkit-details-marker { display: none; }
details.add[open] > summary { margin-bottom: 14px; }
.client-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 22px; margin-bottom: 16px; }
.client-head h2 { font-family: var(--serif); font-size: 30px; margin: 4px 0 6px; font-weight: 600; word-break: break-word; }
.client-head .meta { color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.client-head .controls { display: grid; gap: 10px; min-width: 220px; }
.back { color: var(--muted); text-decoration: none; font-size: 13px; }
.back:hover { color: var(--gold2); }
.timeline { display: grid; gap: 0; position: relative; }
.tl { display: grid; grid-template-columns: 16px 1fr; gap: 12px; padding: 10px 0; }
.tl .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--violet); box-shadow: 0 0 0 4px rgba(139, 123, 255, 0.15); }
.tl.status_change .dot { background: var(--gold); box-shadow: 0 0 0 4px rgba(232, 194, 122, 0.15); }
.tl.call .dot { background: var(--teal); box-shadow: 0 0 0 4px rgba(63, 210, 199, 0.15); }
.tl.email .dot { background: var(--rose); box-shadow: 0 0 0 4px rgba(255, 122, 154, 0.15); }
.tl.system .dot { background: var(--dim); box-shadow: none; }
.tl .when { color: var(--dim); font-size: 12px; }
.tl .body { white-space: pre-wrap; word-break: break-word; }
.inline-select { width: auto; min-width: 118px; padding: 6px 28px 6px 10px; font-size: 13px; border-radius: 9px; }
.import-errors { margin-top: 14px; display: grid; gap: 6px; font-size: 13px; }
.import-errors div { padding: 8px 10px; border-radius: 9px; background: rgba(255, 122, 154, 0.08); border: 1px solid rgba(255, 122, 154, 0.25); }
.ok { color: #8ff0c0; background: rgba(74, 222, 128, 0.1); border: 1px solid rgba(74, 222, 128, 0.3); padding: 10px 12px; border-radius: 10px; font-size: 13px; }
code { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: 0.25s; z-index: 50; padding: 11px 16px; border-radius: 12px; background: #1c2544; border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 14px; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { border-color: rgba(255, 122, 154, 0.5); }
.footer { color: var(--dim); font-size: 12px; margin-top: 40px; }
.mobile-top { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; padding: 28px 18px 40px; gap: 28px; }
  .features { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .mobile-top { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; z-index: 10; padding: 14px 16px 10px; background: rgba(8, 11, 22, 0.88); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
  .mobile-top .bar1 { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
  .mobile-top nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .mobile-top nav a { flex: none; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; }
  .mobile-top nav a[aria-current="page"] { color: #1a1407; background: linear-gradient(135deg, var(--gold2), var(--gold)); border-color: transparent; }
  main { padding: 18px 14px 50px; }
  .topline h2 { font-size: 26px; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar > :first-child { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: auto; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; padding: 6px 0; background: rgba(255, 255, 255, 0.02); }
  .table td { border: 0; padding: 6px 14px; }
  .client-head .controls { min-width: 0; width: 100%; }
  .stat .v { font-size: 30px; }
  .row { flex-wrap: wrap; }
}
