/* CRM OS design system. Themes from the lazy-app library: clean-pro (light) and bold-dark (dark), with the CRM OS brand accent.
   Logical properties everywhere (RTL/LTR), 4px spacing scale, semantic tokens, WCAG 2.2 AA contrast, reduced motion. */
@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@400;500;600;700;800&family=Rubik:wght@500;600;700;800;900&display=swap');

:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #F4F5F7; --bg-fx: radial-gradient(1200px 600px at 100% -10%, rgb(43 80 255 / .06), transparent 60%);
  --surface: #FFFFFF; --surface-2: #F3F4F7; --surface-3: #E9EBF0; --overlay: rgb(15 20 32 / .42);
  --text: #0F1420; --muted: #545C6B; --subtle: #848C9C; --line: #E3E6EC; --line-strong: #CDD2DB;
  --accent: #2B50FF; --accent-ink: #FFFFFF; --accent-soft: rgb(43 80 255 / .09); --accent-line: rgb(43 80 255 / .32);
  --spark: #FF6A3D; --spark-soft: rgb(255 106 61 / .12);
  --success: #1E8E55; --success-soft: rgb(30 142 85 / .12); --warning: #B87D00; --warning-soft: rgb(245 183 10 / .16); --danger: #D13438; --danger-soft: rgb(209 52 56 / .1);
  --hero: #0F1420; --on-hero: #FFFFFF;
  --shadow-sm: 0 1px 2px rgb(15 20 32 / .06); --shadow: 0 1px 2px rgb(15 20 32 / .05), 0 8px 24px rgb(15 20 32 / .07); --shadow-lg: 0 24px 60px rgb(15 20 32 / .18);
  --nav-bg: #FFFFFF; --nav-text: #5B6372; --nav-active-bg: var(--accent-soft); --nav-active: var(--accent);
  --focus: 0 0 0 3px rgb(43 80 255 / .35);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0C0C0F; --bg-fx: radial-gradient(1000px 500px at 100% -10%, rgb(140 155 255 / .08), transparent 60%);
  --surface: #16161B; --surface-2: #1D1D24; --surface-3: #26262E; --overlay: rgb(0 0 0 / .6);
  --text: #F4F4F6; --muted: #A6A6B2; --subtle: #7E7E8A; --line: #2A2A32; --line-strong: #3A3A44;
  --accent: #8C9BFF; --accent-ink: #0C0C0F; --accent-soft: rgb(140 155 255 / .14); --accent-line: rgb(140 155 255 / .4);
  --spark: #FF8A63; --spark-soft: rgb(255 138 99 / .14);
  --success: #3DD68C; --success-soft: rgb(61 214 140 / .14); --warning: #FFD15C; --warning-soft: rgb(255 209 92 / .14); --danger: #FF6B6E; --danger-soft: rgb(255 107 110 / .14);
  --hero: #FFE14D; --on-hero: #0C0C0F;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .4); --shadow: 0 10px 30px rgb(0 0 0 / .35); --shadow-lg: 0 30px 70px rgb(0 0 0 / .55);
  --nav-bg: #121217; --nav-text: #A6A6B2; --nav-active-bg: rgb(140 155 255 / .14); --nav-active: #C6CDFF;
  --focus: 0 0 0 3px rgb(140 155 255 / .45);
}
:root {
  --font: 'Heebo', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif; --font-head: 'Rubik', 'Heebo', system-ui, sans-serif; --mono: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --r-sm: 10px; --r: 14px; --r-lg: 20px; --r-xl: 28px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;
  --sidebar: 268px; --topbar: 64px; --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { overflow-x: clip; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--text); background: var(--bg) var(--bg-fx) no-repeat fixed; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: clamp(26px, 3vw, 34px); font-weight: 800; } h2 { font-size: 22px; font-weight: 700; } h3 { font-size: 18px; font-weight: 700; } h4 { font-size: 16px; font-weight: 700; }
p { margin: 0; } a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
.ltr, bdi.ltr, [data-ltr] { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .subtle { color: var(--subtle); } .small { font-size: 14px; } .tiny { font-size: 12.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: var(--r-sm); font-weight: 700; }
.skip:focus { top: 12px; }
.row { display: flex; align-items: center; gap: var(--s3); } .row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; } .row.end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; gap: var(--s3); } .grow { flex: 1; min-width: 0; } .gap1 { gap: var(--s1); } .gap2 { gap: var(--s2); } .gap4 { gap: var(--s4); } .gap6 { gap: var(--s6); }
.stack > * + * { margin-block-start: var(--s4); }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[dir="ltr"] .ellipsis, [dir="rtl"] .ellipsis { unicode-bidi: plaintext; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; } .icon.lg { width: 24px; height: 24px; } .icon.xl { width: 32px; height: 32px; }
[dir="rtl"] .flip { transform: scaleX(-1); }

/* ---------- buttons */
.btn { --b: var(--surface); --bc: var(--line-strong); --bt: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 1px solid var(--bc); border-radius: 12px; background: var(--b); color: var(--bt); font-weight: 700; font-size: 15px; cursor: pointer; white-space: nowrap; transition: transform .12s var(--ease), box-shadow .15s, background .15s; text-decoration: none !important; }
.btn:hover { box-shadow: var(--shadow-sm); background: color-mix(in srgb, var(--b) 92%, var(--text)); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { --b: var(--accent); --bc: var(--accent); --bt: var(--accent-ink); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 28%, transparent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.dark { --b: var(--hero); --bc: var(--hero); --bt: var(--on-hero); }
.btn.ghost { --b: transparent; --bc: transparent; } .btn.ghost:hover { background: var(--surface-2); box-shadow: none; }
.btn.danger { --b: var(--danger); --bc: var(--danger); --bt: #fff; }
.btn.soft { --b: var(--accent-soft); --bc: transparent; --bt: var(--accent); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.lg { min-height: 54px; padding: 0 26px; font-size: 17px; border-radius: 14px; }
.btn.icon-only { width: 44px; padding: 0; } .btn.sm.icon-only { width: 36px; }
.btn.block { width: 100%; }
.btn .spinner { width: 16px; height: 16px; }
.spinner { display: inline-block; width: 22px; height: 22px; border: 2.5px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 700; font-size: 14px; color: var(--text); }
.field .req { color: var(--danger); margin-inline-start: 2px; }
.field .help { font-size: 13px; color: var(--muted); }
.field .err { font-size: 13.5px; color: var(--danger); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.input, .select, .textarea { width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); color: var(--text); transition: border .15s, box-shadow .15s; }
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--subtle); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.field.invalid .input, .field.invalid .select, .field.invalid .textarea { border-color: var(--danger); }
.input[readonly] { background: var(--surface-2); }
.input-group { display: flex; align-items: stretch; } .input-group .input { border-start-end-radius: 0; border-end-end-radius: 0; } .input-group .btn { border-start-start-radius: 0; border-end-start-radius: 0; }
.search { position: relative; } .search .icon { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--subtle); pointer-events: none; } .search .input { padding-inline-start: 42px; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 36px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--surface-3); position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: inset-inline-start .2s var(--ease); }
.switch input:checked { background: var(--accent); } .switch input:checked::after { inset-inline-start: 21px; }
.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { min-height: 36px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4) var(--s5); }
.grid-form .full { grid-column: 1 / -1; }
.choice-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-chips button { min-height: 40px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.choice-chips button[aria-pressed="true"] { border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--surface)); color: var(--text); box-shadow: inset 0 0 0 1px var(--c, var(--accent)); }
.choice-chips .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--accent)); }

/* ---------- surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card.pad { padding: var(--s6); } .card.pad-sm { padding: var(--s4); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s5) var(--s6) 0; }
.card-body { padding: var(--s5) var(--s6) var(--s6); }
.panel { background: var(--surface-2); border-radius: var(--r); padding: var(--s4); }
.divider { height: 1px; background: var(--line); margin: var(--s4) 0; border: 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 99px; font-size: 12.5px; font-weight: 800; white-space: nowrap; color: color-mix(in srgb, var(--c, var(--subtle)) 80%, var(--text)); background: color-mix(in srgb, var(--c, var(--subtle)) 15%, transparent); }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--subtle)); }
.badge.plain::before { display: none; }
.badge.sandbox { --c: var(--warning); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); font-size: 12.5px; font-weight: 700; color: var(--muted); }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; font-weight: 800; font-size: 14px; color: #fff; background: var(--c, var(--accent)); }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; } .avatar.lg { width: 48px; height: 48px; font-size: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s4); }
.kpi { position: relative; padding: var(--s5); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.kpi .k-label { font-size: 14px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kpi .k-value { font-family: var(--font-head); font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .k-foot { font-size: 13px; color: var(--muted); margin-top: 4px; }
.kpi.hero { background: var(--hero); color: var(--on-hero); border-color: transparent; }
.kpi.hero .k-label, .kpi.hero .k-foot { color: color-mix(in srgb, var(--on-hero) 70%, transparent); }
.kpi .k-icon { position: absolute; inset-inline-end: 16px; top: 16px; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.kpi.hero .k-icon { background: rgb(255 255 255 / .12); color: var(--on-hero); }
.trend { font-weight: 800; font-size: 13px; } .trend.up { color: var(--success); } .trend.down { color: var(--danger); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; } .progress > i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--accent)); transition: width .6s var(--ease); }
.banner { display: flex; align-items: center; gap: var(--s3); padding: 12px 16px; border-radius: var(--r); background: var(--warning-soft); color: var(--text); font-size: 14.5px; }
.banner.info { background: var(--accent-soft); } .banner.danger { background: var(--danger-soft); } .banner.success { background: var(--success-soft); }
.banner .icon { color: var(--warning); } .banner.info .icon { color: var(--accent); } .banner.danger .icon { color: var(--danger); } .banner.success .icon { color: var(--success); }

/* ---------- app layout */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.app.collapsed { --sidebar: 76px; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 16px 12px; background: var(--nav-bg); border-inline-end: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; font-family: var(--font-head); font-weight: 900; font-size: 19px; color: var(--text); text-decoration: none !important; }
.brand img, .brand svg { width: 34px; height: 34px; flex: none; }
.org-switch { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; text-align: start; }
.nav-sec { margin-top: 10px; padding: 0 10px 4px; font-size: 12px; font-weight: 800; letter-spacing: .04em; color: var(--subtle); text-transform: uppercase; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: 12px; color: var(--nav-text); font-weight: 600; font-size: 15px; text-decoration: none !important; position: relative; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-active); font-weight: 800; }
.nav-link .count { margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--spark); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.nav-link .dot-c { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.app.collapsed .nav-link span, .app.collapsed .nav-sec, .app.collapsed .brand span, .app.collapsed .org-switch .grow, .app.collapsed .sidebar-foot .grow { display: none; }
.app.collapsed .nav-link { justify-content: center; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s3); height: var(--topbar); padding: 0 var(--s6); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.topbar .search-trigger { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--subtle); cursor: pointer; font-size: 15px; }
.topbar .search-trigger kbd { margin-inline-start: auto; }
kbd { white-space: nowrap; font-family: var(--mono); font-size: 12px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--muted); }
#main:focus, #main:focus-visible { box-shadow: none; outline: none; }
.content { padding: var(--s6); width: 100%; max-width: 1480px; margin-inline: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s6); }
.page-head .crumbs { display: flex; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.page-head .crumbs a { color: var(--muted); }
.page-head p { color: var(--muted); margin-top: 6px; max-width: 70ch; }
.toolbar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s4); }
.bottom-nav { display: none; }
.mobile-only { display: none; }
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 300px; transform: translateX(110%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); }
  [dir="ltr"] .sidebar { transform: translateX(-110%); }
  .app:not(.drawer-open) .sidebar { visibility: hidden; }
  .app.drawer-open .sidebar { transform: none; visibility: visible; }
  .app.drawer-open::after { content: ''; position: fixed; inset: 0; background: var(--overlay); z-index: 25; }
  .app.collapsed .nav-link span, .app.collapsed .nav-sec, .app.collapsed .brand span { display: initial; }
  .topbar { padding: 0 var(--s4); } .content { padding: var(--s4); padding-bottom: 96px; }
  .mobile-only { display: inline-flex; } .desktop-only { display: none !important; }
  .topbar .search-trigger kbd { display: none; }
  .bottom-nav { position: fixed; inset-inline: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 22; display: flex; justify-content: space-around; padding: 6px; border-radius: 22px; background: var(--nav-bg); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
  .bottom-nav a { display: grid; justify-items: center; gap: 2px; min-width: 60px; min-height: 52px; padding: 6px 8px; border-radius: 16px; font-size: 11.5px; font-weight: 700; color: var(--nav-text); text-decoration: none !important; place-content: center; }
  .bottom-nav a[aria-current="page"] { color: var(--nav-active); background: var(--nav-active-bg); }
  .grid-form { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 26px; }
}

/* ---------- tables */
.table-wrap { overflow: auto; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); max-height: calc(100vh - 230px); }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; }
table.data th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: start; font-size: 13px; font-weight: 800; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
table.data th button { all: unset; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
table.data th button:focus-visible { box-shadow: var(--focus); border-radius: 6px; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; max-width: 340px; }
table.data tbody tr { cursor: pointer; transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.selected { background: var(--accent-soft); }
table.data td.sel, table.data th.sel { width: 44px; padding-inline-end: 0; }
table.data td.title { font-weight: 700; }
table.data tbody tr:last-child td { border-bottom: 0; }
@media (max-width: 720px) {
  table.data.cards thead { display: none; }
  table.data.cards, table.data.cards tbody, table.data.cards tr, table.data.cards td { display: block; width: 100%; max-width: none; }
  table.data.cards tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.data.cards td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; }
  table.data.cards td::before { content: attr(data-label); font-size: 13px; color: var(--muted); font-weight: 700; flex: none; }
  table.data.cards td.title { font-size: 16.5px; } table.data.cards td.title::before { display: none; }
  table.data.cards td.sel { position: absolute; inset-inline-end: 8px; width: auto; } table.data.cards tr { position: relative; }
  .table-wrap { max-height: none; }
}
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: var(--s3); color: var(--muted); font-size: 14px; }

/* ---------- kanban */
.kanban { display: flex; gap: var(--s4); overflow-x: auto; padding-bottom: var(--s3); scroll-snap-type: x proximity; align-items: flex-start; }
.k-col { flex: 0 0 300px; scroll-snap-align: start; background: var(--surface-2); border-radius: var(--r-lg); padding: 12px; border: 1px solid var(--line); max-height: calc(100vh - 220px); display: flex; flex-direction: column; }
.k-col.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.k-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 12px; font-weight: 800; }
.k-head .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--subtle)); } .k-head .cnt { margin-inline-start: auto; color: var(--muted); font-size: 13px; }
.k-list { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 40px; }
.k-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow-sm); cursor: grab; transition: box-shadow .15s, transform .15s; }
.k-card:hover { box-shadow: var(--shadow); } .k-card.dragging { opacity: .5; transform: rotate(-1deg); }
.k-card .t { font-weight: 700; margin-bottom: 6px; } .k-card .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--muted); }

/* ---------- calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.cal .dow { padding: 10px; font-size: 13px; font-weight: 800; color: var(--muted); background: var(--surface-2); text-align: center; }
.cal .day { min-height: 112px; padding: 6px; border-top: 1px solid var(--line); border-inline-start: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.cal .day:nth-child(7n + 1) { border-inline-start: 0; }
.cal .day .d { font-size: 13px; font-weight: 700; color: var(--muted); } .cal .day.today .d { color: var(--accent-ink); background: var(--accent); border-radius: 99px; width: 26px; height: 26px; display: grid; place-items: center; }
.cal .day.other { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.cal .ev { font-size: 12.5px; font-weight: 700; padding: 3px 7px; border-radius: 7px; background: var(--accent-soft); color: var(--text); cursor: pointer; text-align: start; border: 0; }
@media (max-width: 720px) { .cal .day { min-height: 70px; } .cal .ev { font-size: 11px; padding: 2px 4px; } }

/* ---------- gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s4); }
.g-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; cursor: pointer; box-shadow: var(--shadow-sm); }
.g-card .cover { aspect-ratio: 16/9; background: linear-gradient(135deg, var(--accent-soft), var(--spark-soft)); display: grid; place-items: center; color: var(--accent); }
.g-card .body { padding: 14px; }

/* ---------- tabs, menus, dialogs, toasts */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: var(--s5); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button, .tabs a { padding: 12px 14px; border: 0; background: none; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; display: inline-flex; align-items: center; gap: 8px; }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.menu { position: fixed; z-index: 70; min-width: 220px; padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: pop .14s var(--ease); }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px; background: none; cursor: pointer; text-align: start; color: var(--text); font-weight: 600; text-decoration: none !important; }
.menu button:hover, .menu button:focus-visible, .menu a:hover { background: var(--surface-2); }
.menu .danger { color: var(--danger); } .menu hr { border: 0; height: 1px; background: var(--line); margin: 6px 4px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
dialog.modal { border: 0; padding: 0; border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); }
dialog.modal.wide { width: min(880px, calc(100vw - 24px)); } dialog.modal.xl { width: min(1180px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: var(--overlay); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: pop .18s var(--ease); display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 24px 8px; }
.modal-body { padding: 8px 24px 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 24px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.drawer { position: fixed; inset-block: 0; inset-inline-end: 0; z-index: 60; width: min(640px, 100vw); background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .22s var(--ease); }
@keyframes slide { from { transform: translateX(-30px); opacity: 0; } }
[dir="ltr"] .drawer { animation-name: slide-ltr; } @keyframes slide-ltr { from { transform: translateX(30px); opacity: 0; } }
.drawer-backdrop { position: fixed; inset: 0; z-index: 59; background: var(--overlay); }
.toasts { position: fixed; z-index: 90; inset-block-end: 20px; inset-inline-start: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }
[dir="rtl"] .toasts { transform: translateX(50%); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 14px 10px 18px; border-radius: 14px; background: var(--hero); color: var(--on-hero); box-shadow: var(--shadow-lg); font-weight: 600; animation: pop .18s var(--ease); max-width: min(560px, calc(100vw - 24px)); }
.toast.error { background: var(--danger); color: #fff; } .toast button { background: none; border: 0; color: inherit; font-weight: 800; cursor: pointer; text-decoration: underline; }
@media (max-width: 960px) { .toasts { inset-block-end: 96px; } }

/* ---------- states */
.empty { text-align: center; padding: 56px 24px; border-radius: var(--r-lg); border: 1.5px dashed var(--line-strong); background: color-mix(in srgb, var(--surface) 70%, transparent); }
.empty .e-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty h3 { margin-bottom: 6px; } .empty p { color: var(--muted); max-width: 46ch; margin: 0 auto 18px; }
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 10px; min-height: 14px; }
.skel::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent); transform: translateX(-100%); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.error-state { padding: 40px; text-align: center; } .error-state .e-icon { background: var(--danger-soft); color: var(--danger); }

/* ---------- record page */
.rec-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--s6); align-items: start; }
@media (max-width: 1100px) { .rec-layout { grid-template-columns: minmax(0, 1fr); } }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; }
.kv.one { grid-template-columns: minmax(0, 1fr); }
.kv .k { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 3px; } .kv .v { font-size: 16px; word-break: break-word; }
.kv .v.empty-v { color: var(--subtle); }
@media (max-width: 720px) { .kv { grid-template-columns: minmax(0, 1fr); } }
.stage-bar { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; }
.stage-bar button { flex: 1 0 auto; min-height: 40px; padding: 0 16px; border: 0; background: var(--surface-2); color: var(--muted); font-weight: 700; cursor: pointer; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%); }
[dir="rtl"] .stage-bar button { clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 50%, 100% 100%, 12px 100%, 0 50%); }
.stage-bar button.done { background: color-mix(in srgb, var(--c, var(--accent)) 22%, var(--surface-2)); color: var(--text); }
.stage-bar button.current { background: var(--c, var(--accent)); color: #fff; }
.stage-bar button:disabled { cursor: default; opacity: .7; }
.timeline { display: flex; flex-direction: column; gap: 14px; }
.timeline .ev { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; font-size: 14px; }
.timeline .ev .dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.chip-ref { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; text-decoration: none !important; margin: 2px; }
.chip-ref.muted { background: var(--surface-2); color: var(--muted); }

/* ---------- builder (studio / dnd) */
.builder { display: grid; grid-template-columns: 280px minmax(0, 1fr) 340px; gap: var(--s4); align-items: start; }
@media (max-width: 1200px) { .builder { grid-template-columns: minmax(0, 1fr); } }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: grab; font-weight: 600; font-size: 14.5px; }
.palette-item:hover { border-color: var(--accent-line); }
.drop-zone { min-height: 64px; border: 1.5px dashed var(--line-strong); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; transition: background .15s, border .15s; }
.drop-zone.over { border-color: var(--accent); background: var(--accent-soft); }
.dnd-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.dnd-item.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.dnd-item .handle { cursor: grab; color: var(--subtle); display: grid; place-items: center; }
.dnd-item.dragging { opacity: .45; }
.type-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.dash-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); }
.dash-grid .w { min-height: 160px; } .dash-grid .w.w2 { grid-column: span 2; } .dash-grid .w.w3 { grid-column: span 3; } .dash-grid .w.w4 { grid-column: 1 / -1; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dash-grid .w.w3, .dash-grid .w.w4 { grid-column: 1 / -1; } }
@media (max-width: 640px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } .dash-grid .w.w2 { grid-column: auto; } }
.widget { height: 100%; padding: var(--s5); display: flex; flex-direction: column; gap: 10px; }
.widget .w-title { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.widget .w-big { font-family: var(--font-head); font-size: 38px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ---------- charts */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .bar { transition: opacity .15s; } .chart .bar:hover, .chart .bar:focus { opacity: .8; outline: none; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; } .chart .area { fill: var(--accent-soft); }
.chart .pt { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart-tip { position: fixed; z-index: 95; pointer-events: none; padding: 8px 12px; border-radius: 10px; background: var(--hero); color: var(--on-hero); font-size: 13px; font-weight: 700; box-shadow: var(--shadow); white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 13px; color: var(--muted); } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; background: var(--c); }

/* ---------- AI */
.ai-surface { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 9%, var(--surface)), color-mix(in srgb, var(--spark) 7%, var(--surface))); border: 1px solid var(--accent-line); }
.chat { display: flex; flex-direction: column; gap: 14px; }
.bubble { max-width: 82%; padding: 12px 16px; border-radius: 18px; white-space: pre-wrap; line-height: 1.55; }
.bubble.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-end-end-radius: 6px; }
.bubble.ai { align-self: flex-start; background: var(--surface-2); border-end-start-radius: 6px; }
.change-list { display: flex; flex-direction: column; gap: 8px; }
.change { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.change .ci { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--success-soft); color: var(--success); }

/* ---------- command palette */
.cmdk { position: fixed; inset: 0; z-index: 80; display: grid; place-items: start center; padding-top: 10vh; background: var(--overlay); }
.cmdk-box { width: min(680px, calc(100vw - 24px)); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .16s var(--ease); }
.cmdk-box .input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; min-height: 60px; font-size: 17px; padding-inline-start: 52px; }
.cmdk-results { max-height: 60vh; overflow-y: auto; padding: 8px; }
.cmdk-results .grp { padding: 10px 12px 4px; font-size: 12px; font-weight: 800; color: var(--subtle); }
.cmdk-results a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--text); text-decoration: none !important; }
.cmdk-results a:hover, .cmdk-results a.active { background: var(--accent-soft); }

/* ---------- auth & wizard */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.auth-side { position: relative; overflow: hidden; background: var(--hero); color: var(--on-hero); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
[data-theme="dark"] .auth-side { background: #16161B; color: #F4F4F6; }
.auth-side h2 { font-size: clamp(28px, 3.2vw, 44px); font-weight: 900; line-height: 1.08; }
.auth-side .glow { position: absolute; width: 520px; height: 520px; border-radius: 50%; background: radial-gradient(circle, rgb(43 80 255 / .55), transparent 65%); inset-inline-end: -160px; bottom: -160px; filter: blur(10px); }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: min(440px, 100%); }
@media (max-width: 900px) { .auth { grid-template-columns: minmax(0, 1fr); } .auth-side { display: none; } }
.steps { display: flex; gap: 8px; margin-bottom: 24px; } .steps i { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-3); } .steps i.on { background: var(--accent); }
.choice-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.choice-card { text-align: start; padding: 18px; border-radius: 18px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; display: flex; flex-direction: column; gap: 8px; transition: border .15s, box-shadow .15s, transform .15s; }
.choice-card:hover { border-color: var(--accent-line); transform: translateY(-2px); box-shadow: var(--shadow); }
.choice-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.choice-card .cc-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--c, var(--accent)) 14%, transparent); color: var(--c, var(--accent)); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
@media print { .sidebar, .topbar, .bottom-nav, .toolbar, .btn { display: none !important; } .app { display: block; } body { background: #fff; } }
