/* Self-hosted variable fonts (SIL Open Font License), served from /static so the CSP stays 'self'. */
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-display: swap; font-weight: 200 800; src: url("fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2-variations"); }
@font-face { font-family: "Plus Jakarta Sans"; font-style: normal; font-display: swap; font-weight: 200 800; src: url("fonts/plus-jakarta-sans-latin-wght-normal.woff2") format("woff2-variations"); }

:root {
  --font-body: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Bricolage Grotesque", "Plus Jakarta Sans", system-ui, sans-serif;
  --bg: #f7f6fe;
  --surface: #ffffff;
  --surface-2: #f6f5fd;
  --border: #e7e5f4;
  --text: #1c1838;
  --muted: #6b6889;
  --primary: #5b4cf0;
  --primary-hover: #4a3be0;
  --primary-soft: #efedff;
  --accent: #c026d3;
  --spark: #f97316;
  --gradient: linear-gradient(120deg, #5b4cf0 0%, #9333ea 55%, #db2777 100%);
  --night: linear-gradient(180deg, #1c1745 0%, #2a1f66 100%);
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(28 24 56 / 0.04), 0 8px 28px rgb(76 59 224 / 0.07);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
h1, h2, h3, .brand, .stat-value, .eyebrow, .clock, .paywall-price { font-family: var(--font-display); }
h1, h2, h3 { font-weight: 700; }
code { font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--text); letter-spacing: -0.01em; }
.brand:hover { color: var(--text); }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; color: #fff; background: var(--gradient); box-shadow: 0 6px 16px rgb(147 51 234 / 0.35); }
.tag { font-size: 11px; font-weight: 600; color: var(--primary); background: var(--primary-soft); padding: 2px 7px; border-radius: 999px; margin-left: 4px; }

/* App shell */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar { background: var(--night); color: #fff; border-right: 0; padding: 22px 14px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 0 8px; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar .brand, .sidebar .brand:hover { color: #fff; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: rgb(255 255 255 / 0.68); font-weight: 600; transition: background .15s, color .15s; }
.sidebar nav a:hover { background: rgb(255 255 255 / 0.08); color: #fff; }
.sidebar nav a.active { background: var(--gradient); color: #fff; box-shadow: 0 6px 18px rgb(147 51 234 / 0.35); }
.sidebar .muted { color: rgb(255 255 255 / 0.6); }
.sidebar .btn-ghost { color: rgb(255 255 255 / 0.8); border-color: rgb(255 255 255 / 0.2); }
.sidebar .btn-ghost:hover { background: rgb(255 255 255 / 0.1); color: #fff; }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; }
.user { display: flex; align-items: center; gap: 10px; padding: 0 8px; min-width: 0; }
.user > div { display: grid; min-width: 0; }
.user strong { font-size: 13px; }
.user .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--gradient); color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0; }
main { padding: 32px 40px; max-width: 1240px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -0.03em; }
.subtitle { margin: 4px 0 0; color: var(--muted); }
.paywall { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgb(15 23 42 / 0.45); backdrop-filter: blur(4px); }
.paywall-card { max-width: 440px; width: 100%; padding: 28px; display: grid; gap: 12px; text-align: center; }
.paywall-card h2 { margin: 0; font-size: 22px; }
.paywall-card p { margin: 0; color: var(--muted); }
.paywall-price { font-weight: 700; color: var(--text) !important; }
.clock { font-size: 16px; font-weight: 600; color: var(--primary); background: var(--primary-soft); padding: 8px 14px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.narrow { max-width: 760px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card, .card + section, section + .card, .narrow > * + * { margin-top: 16px; }
.card-head { padding: 18px 22px; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; font-size: 15px; }
.card-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.card-body { padding: 18px 22px; }
.card-foot { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-foot .alert { margin: 0 auto 0 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 16px 0; }
#subscription { margin-bottom: 16px; }
.stats .card { margin: 0; }
.stat { padding: 18px 20px; display: grid; gap: 4px; position: relative; overflow: hidden; color: inherit; }
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--gradient); }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-value { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; }
.stat-expiring::before { background: #f59e0b; }
.stat-expired::before { background: #f87171; }
.stat-renewed::before { background: #34d399; }
a.stat:hover { color: inherit; border-color: var(--primary-soft); }

/* Dashboard lists */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-grid .card { margin: 0; }
.span-all { grid-column: 1 / -1; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list li > div:first-child { display: grid; gap: 2px; }
.list .muted { font-size: 12.5px; }
.list-end { display: flex; align-items: center; gap: 12px; }
.days { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }

/* Import dropzone */
.dropzone { display: flex; align-items: center; gap: 16px; padding: 18px 22px; border: 1.5px dashed #d7dbea; background: var(--surface); flex-wrap: wrap; }
.dropzone-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.dropzone-text { display: grid; gap: 2px; flex: 1; min-width: 220px; }
.dropzone-text span { color: var(--muted); font-size: 12.5px; }
input[type="file"] { font: inherit; color: var(--muted); max-width: 260px; }
input[type="file"]::file-selector-button { font: inherit; margin-right: 10px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }

/* Table */
.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--surface-2); padding: 12px 16px; border-bottom: 1px solid var(--border); }
td { padding: 13px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
td.wrap { white-space: normal; min-width: 240px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfe; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.inline-form { display: flex; gap: 6px; }
.inline-form input { width: 150px; padding: 6px 10px; }

/* Documents */
.doc { display: flex; align-items: center; gap: 4px; }
.doc form { margin: 0; }
.doc-link { display: inline-flex; align-items: center; gap: 6px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.icon-btn svg { width: 16px; height: 16px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-active { background: var(--primary-soft); color: var(--primary); }
.badge-expiring { background: var(--warn-soft); color: var(--warn); }
.badge-expired { background: var(--danger-soft); color: var(--danger); }
.badge-renewed { background: var(--ok-soft); color: var(--ok); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: background .15s, border-color .15s, box-shadow .15s, opacity .15s, transform .15s, filter .15s; white-space: nowrap; }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 6px 18px rgb(147 51 234 / 0.3); }
.btn-primary:hover { color: #fff; filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 10px 24px rgb(147 51 234 / 0.35); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: #fbd5d5; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(0.92); }
/* In-page confirmation: the first click opens the panel, the second confirms. No browser dialogs. */
.confirm { display: inline-block; position: relative; }
.confirm > summary { list-style: none; cursor: pointer; }
.confirm > summary::-webkit-details-marker { display: none; }
.confirm-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; padding: 10px 12px; max-width: 360px;
  background: var(--danger-soft); border: 1px solid #fbd5d5; border-radius: 10px; font-size: 13px; color: var(--text); }
.btn-block { width: 100%; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn.htmx-request { opacity: 0.6; pointer-events: none; }

/* Alerts */
.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; border: 1px solid transparent; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: #c8f0dd; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #fbd5d5; }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: #fde9b8; }
.alert-warn a { color: inherit; text-decoration: underline; }

/* Forms */
.stack { display: grid; gap: 14px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; padding: 20px 22px; }
.stack .fields { padding: 0; }
.field { display: grid; gap: 6px; font-weight: 500; font-size: 13px; }
.field small { color: var(--muted); font-weight: 400; }
.field-row { display: flex; justify-content: space-between; }
.field-row a { font-weight: 500; }
input:not([type="file"]):not([type="checkbox"]), select, textarea { font: inherit; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 100%; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgb(91 76 240 / 0.18); }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--muted); }
.check input { margin-top: 3px; accent-color: var(--primary); }
.captcha { display: flex; gap: 10px; align-items: center; }
.captcha img { border-radius: 9px; border: 1px solid var(--border); background: #fff; flex-shrink: 0; }
.plan { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.plan > div { display: flex; align-items: center; gap: 10px; }

/* Auth pages */
body.auth { background: radial-gradient(circle at 12% 0%, rgb(91 76 240 / 0.16) 0, transparent 45%), radial-gradient(circle at 92% 100%, rgb(219 39 119 / 0.12) 0, transparent 42%), var(--bg); }
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 40px 16px; }
.auth-card { width: 100%; max-width: 440px; padding: 32px; }
.auth-card h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.auth-card .subtitle { margin-bottom: 22px; }
.auth-foot { color: var(--muted); margin: 0; }

/* Public site */
body.public { background: radial-gradient(ellipse 60% 50% at 10% 0%, rgb(91 76 240 / 0.18), transparent 70%), radial-gradient(ellipse 50% 45% at 95% 8%, rgb(219 39 119 / 0.14), transparent 70%), radial-gradient(ellipse 45% 40% at 60% 38%, rgb(249 115 22 / 0.08), transparent 70%), var(--bg); background-repeat: no-repeat; }
.topnav { display: flex; justify-content: space-between; align-items: center; padding: 18px 40px; max-width: 1200px; margin: 0 auto; }
.topnav nav { display: flex; align-items: center; gap: 24px; }
.topnav nav a:not(.btn) { color: var(--muted); font-weight: 500; }
.topnav nav a:not(.btn):hover { color: var(--text); }
.public-main { max-width: 1200px; margin: 0 auto; padding: 24px 40px 64px; }
.hero { text-align: center; padding: 72px 0 56px; max-width: 760px; margin: 0 auto; }
.hero-logo { display: block; width: min(420px, 100%); height: auto; margin: 0 auto 28px; animation: fade-in 0.9s ease-out both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .hero-logo { animation: none; } }
.hero h1 { font-size: 64px; font-weight: 800; line-height: 1.02; letter-spacing: -0.04em; margin: 16px 0 20px; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 18px; color: var(--muted); margin: 0 0 30px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.eyebrow { display: inline-block; font-size: 13px; font-weight: 700; letter-spacing: 0.02em; color: var(--accent); background: #fdf0ff; padding: 5px 12px; border-radius: 999px; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 24px; }
.feature { padding: 28px; transition: transform .2s, box-shadow .2s; }
.feature:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgb(91 76 240 / 0.14); }
.feature h3 { margin: 18px 0 6px; font-size: 20px; letter-spacing: -0.01em; }
.feature p { margin: 0; color: var(--muted); }
.feature-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--gradient); color: #fff; box-shadow: 0 8px 20px rgb(147 51 234 / 0.3); }
.pricing { margin-top: 56px; display: flex; justify-content: center; }
.pricing-card { text-align: center; padding: 40px; max-width: 520px; width: 100%; }
.pricing-card { border: 2px solid transparent; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--gradient) border-box; }
.pricing-card h2 { margin: 14px 0 6px; font-size: 34px; font-weight: 800; letter-spacing: -0.03em; }
.legal { max-width: 780px; margin: 0 auto; padding: 40px 48px; }
.legal h1 { margin-top: 0; letter-spacing: -0.02em; }
.legal h2 { font-size: 17px; margin-top: 28px; }
.legal p { color: #475569; }
.footer { border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 28px 40px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.footer-inner nav { display: flex; gap: 20px; }
.footer-inner nav a { color: var(--muted); }
.footer-inner p { margin: 0 0 0 auto; font-size: 13px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 12px 16px; gap: 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar nav { display: flex; flex-wrap: wrap; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .sidebar-foot .user { display: none; }
  main, .public-main { padding: 20px 16px; }
  .topnav, .footer-inner { padding: 16px; }
  .topnav nav { gap: 12px; }
  .topnav nav a[href^="/#"] { display: none; }
  .hero h1 { font-size: 42px; }
  .page-head h1 { font-size: 26px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .dash-grid, .features, .fields { grid-template-columns: 1fr; }
  .legal { padding: 24px; }
  .footer-inner p { margin: 0; }
}

/* Contract add/edit and bulk actions */
.table-actions { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 0 0 12px; flex-wrap: wrap; }
.editor { margin-bottom: 16px; }
.search-bar { display: flex; gap: 12px; align-items: center; padding: 12px 16px; margin: 16px 0 12px; flex-wrap: wrap; }
.search-field { flex: 1; min-width: 200px; }
.row-actions { display: flex; gap: 6px; align-items: flex-start; }
td.select, th.select { width: 32px; }
textarea { resize: vertical; min-height: 80px; }
td.multiline { white-space: pre-line; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.badge-archived { background: var(--surface-2); color: var(--muted); }
.sms-new { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.channels { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
.channels legend { padding: 0; margin-bottom: 6px; font-weight: 500; font-size: 13px; width: 100%; }
.channels .check { color: var(--text); }
.badge-channel { background: var(--surface-2); color: var(--muted); margin-right: 4px; }
.badge-channel::before { display: none; }
.notice { padding: 8px 14px; font-size: 13px; }
