/* =========================================================================
   Admin design system — tokens, shell, primitives. No build step.
   ========================================================================= */
:root {
  --bg: #eef2fa;
  --blob-1: rgba(0, 97, 255, .22);
  --blob-2: rgba(124, 58, 237, .18);
  --blob-3: rgba(26, 193, 165, .16);
  --surface: rgba(255, 255, 255, .66);        /* glass panels */
  --surface-solid: rgba(255, 255, 255, .94);  /* menus, dialogs, fields */
  --surface-2: rgba(255, 255, 255, .5);
  --field: rgba(255, 255, 255, .82);
  --glass: rgba(255, 255, 255, .58);
  --glass-edge: rgba(255, 255, 255, .7);
  --blur: blur(20px) saturate(1.6);
  --border: rgba(15, 35, 75, .09);
  --border-strong: rgba(15, 35, 75, .16);
  --text: #0b1b34;
  --muted: #55657f;
  --faint: #8592a8;
  --brand: #0061ff;
  --brand-600: #0050d6;
  --brand-50: rgba(0, 97, 255, .1);
  --brand-grad: linear-gradient(135deg, #1a73ff 0%, #5b4dff 100%);
  --success: #0f9d6b;
  --success-50: rgba(15, 157, 107, .12);
  --danger: #d93a3a;
  --danger-50: rgba(217, 58, 58, .1);
  --warning: #b86e00;
  --warning-50: rgba(240, 160, 30, .14);
  --info: #2563eb;
  --info-50: rgba(37, 99, 235, .1);
  --violet: #7c3aed;
  --teal: #1ac1a5;
  --radius: 14px;
  --radius-sm: 11px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(11, 27, 52, .04), 0 6px 20px rgba(11, 27, 52, .05);
  --shadow: 0 2px 6px rgba(11, 27, 52, .04), 0 16px 40px rgba(11, 27, 52, .08);
  --shadow-lg: 0 30px 70px rgba(11, 27, 52, .2);
  --sidebar-w: 268px;
  --sidebar-mini: 84px;
  --gap: 14px;
  --topbar-h: 62px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #080e1b;
  --blob-1: rgba(40, 110, 255, .28);
  --blob-2: rgba(124, 58, 237, .22);
  --blob-3: rgba(26, 193, 165, .12);
  --surface: rgba(20, 30, 52, .62);
  --surface-solid: rgba(18, 27, 46, .96);
  --surface-2: rgba(255, 255, 255, .04);
  --field: rgba(10, 17, 32, .6);
  --glass: rgba(18, 27, 46, .6);
  --glass-edge: rgba(255, 255, 255, .08);
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .14);
  --text: #e8eef9;
  --muted: #9eabc3;
  --faint: #6f7d97;
  --brand: #5b95ff;
  --brand-600: #4683f5;
  --brand-50: rgba(91, 149, 255, .16);
  --success-50: rgba(15, 157, 107, .18);
  --danger-50: rgba(217, 58, 58, .18);
  --warning-50: rgba(184, 110, 0, .2);
  --info-50: rgba(37, 99, 235, .2);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 2px 6px rgba(0, 0, 0, .25), 0 16px 40px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 14px/1.5 var(--font); color: var(--text);
  background: var(--bg); min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(42vw 42vw at 8% 4%, var(--blob-1), transparent 70%),
    radial-gradient(38vw 38vw at 96% 10%, var(--blob-2), transparent 70%),
    radial-gradient(46vw 40vw at 60% 104%, var(--blob-3), transparent 70%);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code, pre { font-family: var(--mono); font-size: .85em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.icon { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: .8125rem; }
.center { text-align: center; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 1rem; }
.stack > * + * { margin-top: .875rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- shell ----------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s ease; }
.sidebar {
  position: sticky; top: var(--gap); height: calc(100vh - 2 * var(--gap)); margin: var(--gap) 0 var(--gap) var(--gap);
  overflow-y: auto; overflow-x: hidden; padding: .9rem .7rem 1.5rem; scrollbar-width: thin;
  background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding: 0 0 .6rem; }
.sidebar-brand { display: flex; align-items: center; gap: .65rem; padding: .25rem .4rem; font-weight: 700; color: var(--text); min-width: 0; }
.sidebar-brand:hover { text-decoration: none; }
.sidebar-toggle { flex-shrink: 0; width: 38px; min-height: 38px; border-radius: 12px; }
.brand-mark { display: inline-grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; border-radius: 12px; color: #fff; background: var(--brand-grad); box-shadow: 0 6px 16px rgba(26, 115, 255, .35); }
.nav-group { margin-top: 1rem; }
.nav-group-title { padding: 0 .75rem .4rem; font-size: .6875rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); white-space: nowrap; }
.nav-link {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 12px; margin: 1px 0;
  color: var(--muted); font-weight: 500; transition: background .15s, color .15s; min-width: 0;
}
.sidebar .nav-link { white-space: nowrap; }
.folder-row { display: flex; align-items: center; gap: .2rem; }
.folder-link { flex: 1 1 auto; align-items: flex-start; gap: .5rem; padding: .5rem .55rem; }
.folder-link .icon { margin-top: .15rem; }
.folder-name { flex: 1 1 auto; min-width: 0; overflow-wrap: break-word; line-height: 1.35; }
.folder-link .badge { flex-shrink: 0; }
.folder-link.active .badge { background: rgba(255, 255, 255, .22); color: #fff; border-color: transparent; }
.folder-delete { flex-shrink: 0; width: 26px; padding: 0; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--brand-grad); color: #fff; box-shadow: 0 8px 20px rgba(26, 115, 255, .3); }
.nav-link .badge { margin-left: auto; }
.main { min-width: 0; display: flex; flex-direction: column; overflow-x: clip; }
.topbar {
  position: sticky; top: var(--gap); z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: .65rem;
  margin: var(--gap) var(--gap) 0; padding: 0 .9rem 0 1.1rem;
  background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.topbar-search { flex: 1 1 auto; max-width: 440px; min-width: 0; position: relative; }
.topbar-search .input { padding-left: 2.2rem; border-radius: 999px; background: var(--surface-2); }
.topbar-search .icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--faint); }
.topbar .btn-ghost { border-radius: 12px; }
.content { padding: 1.4rem var(--gap) 2rem calc(var(--gap) + .4rem); width: 100%; max-width: 1500px; }
.content.narrow { max-width: 1000px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.65rem; letter-spacing: -.02em; }
.page-head p { margin: .25rem 0 0; color: var(--muted); }
.page-head > div:last-child:not(:first-child) { display: flex; gap: .5rem; flex-wrap: wrap; }
.breadcrumbs { font-size: .8125rem; color: var(--faint); margin-bottom: .35rem; }
.breadcrumbs a { color: var(--muted); }
.topbar .menu-toggle { display: none; }

/* Collapsed menu: icons only (wide screens). */
.nav-collapsed .shell { grid-template-columns: var(--sidebar-mini) minmax(0, 1fr); }
.nav-collapsed .sidebar { padding-inline: .55rem; }
.nav-collapsed .sidebar-head { flex-direction: column; gap: .6rem; }
.nav-collapsed .sidebar-brand { padding: .2rem 0; }
.nav-collapsed .sidebar-brand span, .nav-collapsed .nav-link span, .nav-collapsed .nav-link .badge { display: none; }
.nav-collapsed .nav-group { margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--border); }
.nav-collapsed .nav-group-title { display: none; }
.nav-collapsed .nav-link { justify-content: center; padding: .6rem; }

/* --- cards ------------------------------------------------------------------ */
.card {
  background: var(--surface); border: 1px solid var(--glass-edge); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.card.glass { background: var(--glass); }
.card-body { padding: 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; font-size: 1rem; }
.card-foot { padding: .9rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card > :first-child:is(.card-head, .toolbar) { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.card + .card { margin-top: 1rem; }
.grid > .card + .card, .grid > * > .card:first-child, .builder > .card + .card, .builder > form.card + .card { margin-top: 0; }
.stat { padding: 1.1rem 1.25rem; display: flex; gap: .9rem; align-items: flex-start; }
.stat > div { min-width: 0; }
.stat-icon { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); flex-shrink: 0; }
.stat-icon.green { background: var(--success-50); color: var(--success); }
.stat-icon.violet { background: rgba(124, 58, 237, .12); color: var(--violet); }
.stat-icon.orange { background: var(--warning-50); color: var(--warning); }
.stat-label { color: var(--muted); font-size: .8125rem; }
.stat-value { font-size: clamp(1.2rem, 2.4vw, 1.65rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; }
.stat-trend { font-size: .75rem; font-weight: 600; }
.stat-trend.up { color: var(--success); } .stat-trend.down { color: var(--danger); }

/* --- forms ------------------------------------------------------------------ */
.field { display: block; }
.field + .field { margin-top: .875rem; }
.label { display: block; font-weight: 600; font-size: .8125rem; margin-bottom: .3rem; color: var(--text); }
.label .req { color: var(--danger); }
.help { display: block; font-size: .75rem; color: var(--faint); margin-top: .3rem; }
.error-text { display: block; font-size: .75rem; color: var(--danger); margin-top: .3rem; }
.input, .select, .textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: .6rem .8rem; min-height: 40px; transition: border-color .15s, box-shadow .15s, background .15s;
}
.textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.textarea.code { font-family: var(--mono); font-size: .8125rem; min-height: 160px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); background: var(--surface-solid); }
.input[readonly] { background: var(--surface-2); }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--danger); }
.input-sm { min-height: 32px; padding: .35rem .55rem; font-size: .8125rem; }
.input-group { display: flex; } .input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.prefix-group { display: flex; align-items: stretch; }
.prefix-group span { display: flex; align-items: center; padding: 0 .6rem; border: 1px solid var(--border-strong); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: .8125rem; white-space: nowrap; }
.prefix-group .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.check { display: flex; align-items: flex-start; gap: .55rem; cursor: pointer; }
.check input { margin-top: .2rem; width: 16px; height: 16px; accent-color: var(--brand); }
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; }
.switch input { appearance: none; width: 40px; height: 22px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .15s; cursor: pointer; flex-shrink: 0; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--brand-grad); }
.switch input:checked::after { transform: translateX(18px); }
.color-field { display: flex; gap: .4rem; align-items: center; }
.color-field input[type=color] { width: 38px; height: 38px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
legend { font-weight: 600; padding: 0 .35rem; }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; align-items: center; padding-top: 1rem; }
.sticky-actions { position: sticky; bottom: var(--gap); z-index: 10; margin: 1rem 0 0; padding: .75rem 1rem; background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--glass-edge); border-radius: var(--radius-lg); box-shadow: var(--shadow); display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }

/* --- buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-weight: 600;
  min-height: 40px; padding: .55rem 1.05rem; border-radius: 12px; border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s;
  text-decoration: none !important; line-height: 1.2;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-50); }
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 8px 20px rgba(26, 115, 255, .28); }
.btn-primary:hover { box-shadow: 0 10px 26px rgba(26, 115, 255, .4); transform: translateY(-1px); }
.btn-secondary { background: var(--field); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-50); }
.btn-sm { min-height: 32px; padding: .3rem .7rem; font-size: .8125rem; border-radius: 10px; }
.btn-xs { min-height: 26px; padding: .2rem .45rem; font-size: .75rem; }
.btn-icon { min-height: 36px; width: 36px; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.inline-form { display: inline; }

/* --- tables ----------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); padding: .75rem 1rem; border-bottom: 1px solid var(--border); background: transparent; white-space: nowrap; }
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--brand-50); }
.table td.path { min-width: 13rem; max-width: 30rem; overflow-wrap: anywhere; }
.table td.path code { white-space: normal; overflow-wrap: anywhere; }
.table .actions { text-align: right; white-space: nowrap; }
.table a.row-title { font-weight: 600; color: var(--text); }
.table th a { color: inherit; }
.empty { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.empty .icon { color: var(--faint); margin-bottom: .5rem; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .9rem 1.25rem; border-bottom: 1px solid var(--border); }
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; }
.toolbar .search { min-width: 220px; flex: 1 1 220px; max-width: 360px; }
.bulk-bar { padding-block: .6rem; background: var(--surface-2); }
.bulk-bar.has-selection { background: color-mix(in srgb, var(--brand, #2563eb) 8%, var(--surface, #fff)); }
.bulk-bar .select { min-width: 200px; }
th.check, td.check { width: 36px; padding-right: 0; }
.pagination { display: flex; gap: .35rem; align-items: center; justify-content: space-between; padding: .85rem 1.25rem; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: .25rem; }

/* --- badges & alerts -------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 99px; font-size: .72rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.green, .badge.PUBLISHED, .badge.WON, .badge.ACTIVE, .badge.COMPLETED { background: var(--success-50); color: var(--success); border-color: transparent; }
.badge.red, .badge.LOST, .badge.SPAM, .badge.SUSPENDED, .badge.FAILED, .badge.HIGH { background: var(--danger-50); color: var(--danger); border-color: transparent; }
.badge.orange, .badge.DRAFT, .badge.SCHEDULED, .badge.NEGOTIATION, .badge.PROPOSAL, .badge.MEDIUM, .badge.RUNNING { background: var(--warning-50); color: var(--warning); border-color: transparent; }
.badge.blue, .badge.NEW, .badge.CONTACTED, .badge.QUALIFIED, .badge.PROSPECT, .badge.INVITED { background: var(--info-50); color: var(--info); border-color: transparent; }
.badge.ARCHIVED, .badge.INACTIVE, .badge.FORMER, .badge.LOW { background: var(--surface-2); color: var(--muted); }
.alert { display: flex; gap: .6rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid transparent; margin-bottom: 1rem; }
.alert-success { background: var(--success-50); color: var(--success); }
.alert-error { background: var(--danger-50); color: var(--danger); }
.alert-warning { background: var(--warning-50); color: var(--warning); }
.alert-info { background: var(--info-50); color: var(--info); }
.alert span { color: var(--text); }

/* --- tabs ------------------------------------------------------------------- */
.tabs { display: flex; gap: .25rem; margin-bottom: 1.25rem; overflow-x: auto; position: sticky; top: calc(var(--topbar-h) + 2 * var(--gap)); z-index: 20; padding: .3rem; background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--glass-edge); border-radius: var(--radius); box-shadow: var(--shadow-sm); scrollbar-width: none; }
.tab { padding: .5rem .9rem; color: var(--muted); font-weight: 600; border: 0; border-radius: 10px; white-space: nowrap; background: none; cursor: pointer; font-size: inherit; font-family: inherit; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab:hover { background: var(--surface-2); }
.tab.active, .tab[aria-selected="true"] { color: #fff; background: var(--brand-grad); box-shadow: 0 6px 16px rgba(26, 115, 255, .28); }
.tab-panel[hidden] { display: none; }

/* --- dialog & drawer ---------------------------------------------------------- */
dialog { border: 1px solid var(--glass-edge); border-radius: var(--radius-lg); padding: 0; background: var(--surface-solid); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); color: var(--text); box-shadow: var(--shadow-lg); width: min(640px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); }
dialog.wide { width: min(1100px, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(11, 27, 52, .35); backdrop-filter: blur(6px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface-solid); z-index: 2; }
.dialog-head h2 { margin: 0; font-size: 1.05rem; }
.dialog-body { padding: 1.25rem; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); position: sticky; bottom: 0; }

/* --- page builder --------------------------------------------------------------- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.section-list { list-style: none; margin: 0; padding: 0; }
.section-item { display: flex; align-items: center; gap: .75rem; padding: .75rem .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .5rem; }
.section-item.hidden-section { opacity: .6; border-style: dashed; }
.section-item.dragging { opacity: .4; }
.section-item.drop-target { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.drag-handle { cursor: grab; color: var(--faint); display: grid; place-items: center; }
.section-meta { flex: 1 1 auto; min-width: 0; }
.section-meta strong { display: block; }
.section-type-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); flex-shrink: 0; }
.block-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .6rem; }
.block-option { display: flex; gap: .65rem; text-align: left; align-items: flex-start; padding: .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; font: inherit; color: inherit; }
.block-option:hover { border-color: var(--brand); background: var(--brand-50); }
.block-option small { display: block; color: var(--muted); font-size: .75rem; }
.repeater-item { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem; margin-bottom: .6rem; background: var(--surface-2); }
[hidden] { display: none !important; }
/* Form builder: one compact row per field, opened to edit it. */
.field-row { padding: 0; overflow: hidden; background: var(--field); transition: box-shadow .15s, border-color .15s; }
.field-row.is-open { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.field-row.is-off .field-row-title { color: var(--faint); text-decoration: line-through; }
.field-row-head { display: flex; align-items: center; gap: .4rem; padding: .35rem .5rem .35rem .25rem; }
.field-row-toggle { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; padding: .45rem .5rem; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; border-radius: 10px; }
.field-row-toggle:hover { background: var(--surface-2); }
.field-row-caret { color: var(--faint); transition: transform .15s; }
.field-row.is-open .field-row-caret { transform: rotate(90deg); color: var(--brand); }
.field-row-index { color: var(--faint); font-size: .8rem; font-weight: 600; min-width: 1.6rem; }
.field-row-title { font-weight: 600; }
.field-row-actions { display: flex; gap: .15rem; flex-shrink: 0; }
.field-row-body { display: none; padding: .4rem 1rem 1rem; border-top: 1px solid var(--border); }
.field-row.is-open .field-row-body { display: block; }
.field-row-body .grid { margin-top: .6rem; }
.field-row-switches { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.4rem; margin-top: .9rem; }
.field-inline { display: flex; align-items: center; gap: .5rem; }
.field-inline .label { margin: 0; }
.field-inline .select { width: auto; }
.field-row-more { margin-top: .9rem; }
.field-row-more summary { font-size: .8125rem; font-weight: 600; margin: 0; }
.span-3 { grid-column: 1 / -1; }
.repeater-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; gap: .5rem; }
.repeater-item-head strong { font-size: .8125rem; }
.media-input { display: flex; gap: .5rem; align-items: center; }
.media-input .thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); background: var(--surface-2); flex-shrink: 0; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.media-tile-wrap { position: relative; min-width: 0; }
.media-tile-wrap > .media-tile { display: block; height: 100%; }
.media-check { position: absolute; top: 6px; left: 6px; z-index: 2; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: rgba(255, 255, 255, .92); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.media-check input { margin: 0; width: 16px; height: 16px; }
.media-tile { position: relative; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); cursor: pointer; text-align: left; padding: 0; font: inherit; color: inherit; }
.media-tile img, .media-tile .file-ph { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; }
.media-tile .file-ph { display: grid; place-items: center; color: var(--faint); }
.media-tile .cap { padding: .4rem .5rem; font-size: .75rem; }
.media-tile.selected { outline: 3px solid var(--brand); }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 1.5rem; text-align: center; color: var(--muted); }
.dropzone.over { border-color: var(--brand); background: var(--brand-50); }
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: .35rem; max-height: 240px; overflow-y: auto; }
.icon-picker button { height: 42px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; cursor: pointer; color: var(--text); }
.icon-picker button.selected, .icon-picker button:hover { border-color: var(--brand); color: var(--brand); }
.preview-frame { width: 100%; height: 75vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.device-switch { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.device-switch button { border: 0; background: var(--surface); padding: .35rem .6rem; cursor: pointer; color: var(--muted); }
.device-switch button.active { background: var(--brand-50); color: var(--brand); }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: .2rem; padding: .35rem; border: 1px solid var(--border-strong); border-bottom: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: var(--surface-2); }
.rte-toolbar button, .rte-toolbar select { border: 1px solid transparent; background: transparent; border-radius: 6px; min-width: 30px; height: 30px; cursor: pointer; color: var(--text); font: inherit; font-size: .8125rem; }
.rte-toolbar button:hover { background: var(--surface); border-color: var(--border); }
.rte { min-height: 160px; max-height: 520px; overflow-y: auto; padding: .7rem .8rem; border: 1px solid var(--border-strong); border-radius: 0 0 var(--radius-sm) var(--radius-sm); background: var(--field); line-height: 1.6; }
.rte:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.rte img { max-width: 100%; }
.rte table { border-collapse: collapse; } .rte td, .rte th { border: 1px solid var(--border); padding: .3rem .5rem; }

/* --- kanban --------------------------------------------------------------------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: .9rem; overflow-x: auto; padding-bottom: 1rem; align-items: start; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.kanban-col-head { display: flex; justify-content: space-between; align-items: center; padding: .75rem .9rem; border-bottom: 1px solid var(--border); font-weight: 700; }
.kanban-list { padding: .6rem; overflow-y: auto; min-height: 120px; flex: 1; }
.kanban-list.over { background: var(--brand-50); }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .8rem; margin-bottom: .5rem; cursor: grab; box-shadow: var(--shadow-sm); }
.kanban-card:active { cursor: grabbing; }
.kanban-card a { color: var(--text); font-weight: 600; }

/* --- timeline, misc ---------------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.4rem; border-left: 2px solid var(--border); margin-left: .4rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .3rem; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--surface); }
.timeline li:last-child { border-left-color: transparent; }
.dl { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: .45rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .8125rem; } .dl dd { margin: 0; word-break: break-word; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: .5rem; }
.chart .bar { flex: 1; background: linear-gradient(180deg, var(--brand), var(--violet)); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.chart .bar:hover::after { content: attr(data-label); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: .15rem .4rem; border-radius: 4px; font-size: .7rem; white-space: nowrap; margin-bottom: 4px; }
.hbar { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; font-size: .8125rem; }
.hbar .track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--brand); border-radius: 99px; }
.hbar .lbl { width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.hbar .num { width: 40px; text-align: right; font-weight: 600; }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .6rem; }
.quick-action { display: flex; align-items: center; gap: .55rem; padding: .8rem; border: 1px solid var(--glass-edge); border-radius: var(--radius); background: var(--surface); color: var(--text); font-weight: 600; transition: transform .15s, box-shadow .15s; }
.quick-action:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); }
.code-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.avatar { width: 34px; height: 34px; border-radius: 12px; display: inline-grid; place-items: center; background: var(--brand-grad); color: #fff; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--surface-solid); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--glass-edge); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .35rem; z-index: 50; display: none; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; gap: .5rem; align-items: center; width: 100%; padding: .5rem .6rem; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); text-decoration: none; }
.seo-preview { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem; background: var(--surface); }
.seo-preview .t { color: #1a0dab; font-size: 1.05rem; } .seo-preview .u { color: #006621; font-size: .8rem; } .seo-preview .d { color: #4d5156; font-size: .85rem; }
:root[data-theme="dark"] .seo-preview .t { color: #8ab4f8; } :root[data-theme="dark"] .seo-preview .d { color: #bdc1c6; }
.score { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font-weight: 700; border: 3px solid var(--border); }
.score.good { border-color: var(--success); color: var(--success); } .score.ok { border-color: var(--warning); color: var(--warning); } .score.bad { border-color: var(--danger); color: var(--danger); }

/* --- auth --------------------------------------------------------------------------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: .6rem; margin-bottom: 1.25rem; font-size: 1.05rem; }
.auth-card { padding: 1.75rem; }
.auth-title { font-size: 1.35rem; }
.auth-foot { text-align: center; color: var(--faint); font-size: .75rem; margin-top: 1rem; }
.qr-box { display: grid; place-items: center; padding: .5rem; margin: 1rem 0; background: #fff; border-radius: var(--radius); border: 1px solid var(--border); }
.qr-box svg { max-width: 100%; height: auto; }
.secret-key { display: block; margin: .5rem 0; padding: .6rem; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 1rem; letter-spacing: .08em; word-break: break-all; }
.otp { font-size: 1.25rem; letter-spacing: .3em; text-align: center; font-family: var(--mono); }
.recovery-codes { columns: 2; padding-left: 1.25rem; margin: 1rem 0; }
.recovery-codes code { font-size: .95rem; }
details summary { cursor: pointer; color: var(--brand); margin: .5rem 0; }

/* --- responsive ---------------------------------------------------------------------- */
.builder-media { grid-template-columns: 280px minmax(0, 1fr) 300px; }
.builder-media > aside:first-child .card-body { padding: .75rem; }
.builder-aside { grid-template-columns: 320px minmax(0, 1fr); }
@media (max-width: 1280px) {
  .builder-media { grid-template-columns: 270px minmax(0, 1fr); }
  .builder-media > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 1100px) {
  .builder, .builder-aside { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  :root { --gap: 10px; }
  .shell, .nav-collapsed .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; margin: var(--gap); width: min(290px, calc(100vw - 2 * var(--gap)));
    height: calc(100dvh - 2 * var(--gap)); transform: translateX(calc(-100% - 2 * var(--gap))); transition: transform .25s ease;
    background: var(--surface-solid); box-shadow: var(--shadow-lg);
  }
  .nav-collapsed .sidebar { padding-inline: .7rem; }
  .nav-collapsed .sidebar-head { flex-direction: row; }
  .nav-collapsed .sidebar-brand span, .nav-collapsed .nav-link span, .nav-collapsed .nav-group-title { display: revert; }
  .nav-collapsed .nav-group { border-top: 0; padding-top: 0; margin-top: 1rem; }
  .nav-collapsed .nav-link { justify-content: flex-start; padding: .55rem .75rem; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(11, 27, 52, .35); backdrop-filter: blur(4px); z-index: 55; }
  .topbar .menu-toggle { display: inline-flex; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .content { padding: 1rem var(--gap) 1.5rem; }
  .topbar { padding: 0 .5rem; gap: .35rem; }
  .builder-media { grid-template-columns: minmax(0, 1fr); }
  .dl { grid-template-columns: minmax(0, 1fr); } .dl dt { margin-top: .4rem; }
  .table-wrap .table { min-width: 620px; }
  .table-wrap .table:has(td.path) { min-width: 720px; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table th, .table td { padding: .6rem .7rem; }
  .hide-sm { display: none !important; }
  .page-head h1 { font-size: 1.4rem; }
  .page-head > div:last-child:not(:first-child), .page-head > a.btn { width: 100%; }
  .toolbar .input, .toolbar .select, .toolbar .search { width: 100%; max-width: none; flex: 1 1 100%; min-width: 0; }
  .bulk-bar .select { min-width: 0; flex: 1 1 auto; }
  .stat { padding: .9rem; gap: .65rem; }
  .stat-icon { width: 36px; height: 36px; }
  .card-head, .card-body, .toolbar, .pagination { padding-left: 1rem; padding-right: 1rem; }
  dialog, dialog.wide { width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); }
  .form-actions { flex-wrap: wrap; }
  .kanban { grid-auto-columns: minmax(240px, 85vw); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (prefers-reduced-transparency: reduce) {
  .sidebar, .topbar, .card, .tabs, .sticky-actions, dialog, .dropdown-menu { backdrop-filter: none; background: var(--surface-solid); }
}
.icon-details summary { display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .6rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); list-style: none; margin: 0; }
.icon-details summary::-webkit-details-marker { display: none; }
.icon-details[open] .icon-picker { margin-top: .5rem; }
.icon-current { display: inline-grid; place-items: center; min-width: 20px; }

/* Installer */
.install-wrap { max-width: 640px; }
.install-step { font-size: 1rem; margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.install-checks { margin: 1rem 0; font-size: .875rem; }
.install-checks summary { cursor: pointer; font-weight: 600; }
.check-list { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .2rem; }
.check-list .ok { color: var(--success); }
.check-list .bad { color: var(--danger); }

.brand-letter { font-weight: 800; font-size: 1.05rem; line-height: 1; }
