/* Neir0n CRM — design tokens + legacy compat */

:root {
    /* Layout */
    --rail-width: 64px;
    --subnav-width: 240px;
    --sidebar-width: 240px; /* legacy */
    --sidebar-collapsed: 64px; /* legacy */
    --transition: 0.2s ease;

    /* Radii (Neir0n scale — lg preset) */
    --r-xs: 8px;
    --r-sm: 14px;
    --r-md: 20px;
    --r-lg: 26px;
    --r-xl: 36px;
    --card-radius: var(--r-lg); /* legacy alias */

    /* Density (1 = cozy) */
    --d: 1;
    --sp-1: calc(4px  * var(--d));
    --sp-2: calc(8px  * var(--d));
    --sp-3: calc(12px * var(--d));
    --sp-4: calc(16px * var(--d));
    --sp-5: calc(20px * var(--d));
    --sp-6: calc(24px * var(--d));
    --sp-7: calc(32px * var(--d));
    --sp-8: calc(40px * var(--d));

    /* Typography */
    --font: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;

    /* Semantic colors (theme-agnostic) */
    --danger:  #F87171;
    --warning: #F59E0B;
    --info:    #60A5FA;
    --success: #4ADE80;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 6px 24px rgba(0,0,0,0.35);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.45);
    --card-shadow: var(--shadow-sm); /* legacy */
    --card-shadow-hover: var(--shadow-md); /* legacy */
}

/* ── Light Theme ── pure white + warm neutrals */
[data-theme-mode="light"] {
    /* Neir0n vocab (preferred in new templates) */
    --bg:        #ffffff;
    --panel:     #ffffff;
    --panel-2:   #f7f7f8;
    --panel-3:   #eef0f4;
    --border:    rgba(16, 24, 40, 0.08);
    --border-2:  rgba(16, 24, 40, 0.14);
    --text:      #0a0a0a;
    --text-2:    #515a70;
    --text-3:    #8a91a3;
    --danger:    #dc2626;
    --warning:   #d97706;
    --info:      #2563eb;
    --success:   #16a34a;
    --ph-stripe-a: rgba(16,24,40,0.035);
    --ph-stripe-b: rgba(16,24,40,0.06);
    --chart-grid: rgba(16,24,40,0.06);
    --shadow-sm: 0 1px 2px rgba(16,24,40,0.04);
    --shadow-md: 0 6px 24px rgba(16,24,40,0.08);
    --shadow-lg: 0 20px 60px rgba(16,24,40,0.12);

    /* Legacy aliases (keep old templates rendering) */
    --bg-page:        var(--bg);
    --bg-sidebar:     var(--panel);
    --bg-card:        var(--panel);
    --bg-card-hover:  var(--panel-2);
    --bg-input:       var(--panel-2);
    --border-color:   var(--border);
    --text-primary:   var(--text);
    --text-secondary: var(--text-2);
    --text-muted:     var(--text-3);
    --sidebar-active-bg:   var(--accent-soft);
    --sidebar-active-text: var(--accent);
}

/* ── Dark Theme ── pure black + near-black surfaces */
[data-theme-mode="dark"] {
    --bg:        #000000;
    --panel:     #0f0f10;
    --panel-2:   #17171a;
    --panel-3:   #1f1f22;
    --border:    rgba(255, 255, 255, 0.06);
    --border-2:  rgba(255, 255, 255, 0.12);
    --text:      #fafafa;
    --text-2:    #a1a1aa;
    --text-3:    #71717a;
    --danger:    #F87171;
    --warning:   #F59E0B;
    --info:      #60A5FA;
    --success:   #4ADE80;
    --ph-stripe-a: rgba(255,255,255,0.03);
    --ph-stripe-b: rgba(255,255,255,0.06);
    --chart-grid: rgba(255,255,255,0.05);

    --bg-page:        var(--bg);
    --bg-sidebar:     var(--panel);
    --bg-card:        var(--panel);
    --bg-card-hover:  var(--panel-2);
    --bg-input:       var(--panel-2);
    --border-color:   var(--border);
    --text-primary:   var(--text);
    --text-secondary: var(--text-2);
    --text-muted:     var(--text-3);
    --sidebar-active-bg:   var(--accent-soft);
    --sidebar-active-text: var(--accent);
}

/* ── Accent Colors ──
   Purple matches the brand on https://neir0n.com (primary #c471ed).
   Default is set in base.html (data-accent="purple"). Every accent also
   provides --accent-soft (tinted hover/background) and --accent-ink
   (readable text on the solid accent fill). */
[data-accent="green"]  { --accent: #4d7c5e; --accent-strong: #3a6448; --accent-light: #e8f0eb; --accent-dark: #1a3324; --accent-soft: rgba(77,124,94,0.14);  --accent-text: #fff; --accent-ink: #0b1f13; }
[data-accent="blue"]   { --accent: #3b72c4; --accent-strong: #2856a0; --accent-light: #e6eef8; --accent-dark: #162d50; --accent-soft: rgba(59,114,196,0.14); --accent-text: #fff; --accent-ink: #0a1220; }
[data-accent="purple"] { --accent: #5b21b6; --accent-strong: #4c1d95; --accent-light: #ede9fe; --accent-dark: #2e1065; --accent-soft: rgba(91,33,182,0.12);  --accent-text: #fff; --accent-ink: #ffffff; }
[data-accent="orange"] { --accent: #c47a3b; --accent-strong: #a0602a; --accent-light: #f8ede6; --accent-dark: #4e2d16; --accent-soft: rgba(196,122,59,0.14); --accent-text: #fff; --accent-ink: #1f1306; }
[data-accent="red"]    { --accent: #c44b4b; --accent-strong: #a03535; --accent-light: #f8e6e6; --accent-dark: #4e1616; --accent-soft: rgba(196,75,75,0.14);  --accent-text: #fff; --accent-ink: #1f0909; }
[data-accent="teal"]   { --accent: #3ba3a3; --accent-strong: #2a7a7a; --accent-light: #e6f5f5; --accent-dark: #164040; --accent-soft: rgba(59,163,163,0.14); --accent-text: #fff; --accent-ink: #0b1f1f; }

/* ── Base ── */
* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-feature-settings: 'ss01', 'cv11';
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
    line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── App frame: rail (icons) + subnav (labels) + content ── */
.app {
    display: grid;
    grid-template-columns: 0 var(--subnav-width) 1fr;
    min-height: 100vh;
    transition: grid-template-columns .25s ease;
}
.app > .rail {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform .25s ease, opacity .2s ease;
}
.app[data-subnav="collapsed"] {
    grid-template-columns: var(--rail-width) 0 1fr;
}
.app[data-subnav="collapsed"] .subnav {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}
.app[data-subnav="collapsed"] .rail {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

/* ── Icon rail (64px, shown only when subnav collapsed) ── */
.rail {
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 0;
    gap: 6px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}
.rail .logo {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    margin-bottom: 14px;
}
.rail-btn {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border-radius: var(--r-sm);
    color: var(--text-3);
    background: transparent;
    border: 0;
    position: relative;
    transition: color .15s, background .15s;
    text-decoration: none;
    cursor: pointer;
}
.rail-btn:hover { color: var(--text); background: var(--panel-2); }
.rail-btn.active { color: var(--accent); background: var(--accent-soft); }
.rail-btn svg { width: 20px; height: 20px; }
.rail-sep { flex: 1; }

/* ── Sub-nav (240px, labels + badges) ── */
.subnav {
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform .25s ease, opacity .2s ease;
}
.subnav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px 16px;
}
.subnav-title {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-3);
    font-weight: 700;
}
.subnav-close,
.subnav-expand {
    background: transparent;
    border: 0;
    color: var(--text-3);
    padding: 4px;
    border-radius: 6px;
    cursor: pointer;
    display: grid;
    place-items: center;
}
.subnav-close:hover,
.subnav-expand:hover { color: var(--text); background: var(--panel-2); }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--text-2);
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 500;
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    text-decoration: none;
    transition: background .15s, color .15s;
    cursor: pointer;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item.active {
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
}
.nav-item.active svg { color: var(--accent-ink); }
.nav-badge {
    margin-left: auto;
    background: var(--panel-3);
    color: var(--text-2);
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 999px;
    font-weight: 700;
}
.nav-item.active .nav-badge { background: rgba(0,0,0,0.18); color: var(--accent-ink); }

/* ── Phase 1 / NAV-01 — children sub-group under «Курс» group ── */
.nav-children {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 4px 0 6px 16px;
    padding-left: 10px;
    border-left: 2px solid var(--panel-2);
}
.nav-child {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    color: var(--text-2);
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.nav-child:hover { background: var(--panel-2); color: var(--text); }
.nav-child.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
}
.nav-child.phase-locked {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.nav-group {
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-3);
    font-weight: 700;
    padding: 14px 12px 6px;
}

/* ── Legacy sidebar (keep for old login/standalone screens) ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    transition: width var(--transition);
    overflow: hidden;
    flex-shrink: 0;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar .nav-text { opacity: 1; transition: opacity var(--transition); white-space: nowrap; }
.sidebar.collapsed .nav-text { opacity: 0; width: 0; overflow: hidden; }
.sidebar .logo-text { transition: opacity var(--transition); }
.sidebar.collapsed .logo-text { opacity: 0; width: 0; overflow: hidden; }
.sidebar .nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px; font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
    text-decoration: none;
}
.sidebar.collapsed .nav-link { justify-content: center; padding: 10px; }
.sidebar .nav-link:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.sidebar .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
}
.sidebar .collapse-btn {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}
.sidebar .collapse-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.sidebar.collapsed .collapse-btn svg { transform: rotate(180deg); }

/* ── Content ── */
.content {
    padding: 18px 24px 40px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

/* ── Top bar ── */
.topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
}
.topbar .search {
    position: relative;
    flex: 1;
    max-width: 520px;
}
.topbar .search input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
}
.topbar .search input:focus { border-color: var(--accent); }
.topbar .search input::placeholder { color: var(--text-3); }
.topbar .search svg {
    position: absolute; left: 14px; top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--text-3);
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text-2);
    position: relative;
    cursor: pointer;
    transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot {
    position: absolute; top: 9px; right: 9px;
    width: 8px; height: 8px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid var(--panel);
}
.user-pill {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 12px 4px 4px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 999px;
}
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--accent), var(--accent-strong) 70%, transparent);
    display: grid; place-items: center;
    color: var(--accent-ink);
    font-weight: 700;
    font-size: 12px;
}

/* ── Page heading ── */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    min-height: 48px;
}
.page-head > div:first-child { min-width: 0; flex: 1 1 auto; }
.page-head h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 4px;
    letter-spacing: -0.01em;
    line-height: 1.25;
}
.page-head .sub {
    color: var(--text-3);
    font-size: 13px;
}

/* ── Card primitive (new) ── */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-6);
}
.card-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    min-height: 36px;
}
.card-head > div:first-child { min-width: 0; }
.card-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}
.card-sub {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 2px;
}

/* ── Stat tile ── */
.stat {
    background: var(--panel-2);
    border-radius: var(--r-md);
    padding: 14px;
    border: 1px solid var(--border);
}
.stat-icon-new {
    width: 32px; height: 32px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid; place-items: center;
    margin-bottom: 10px;
}
.stat-icon-new svg { width: 16px; height: 16px; }
.stat-value-new { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.stat-label-new { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.stat-delta {
    font-size: 11px;
    color: var(--accent);
    margin-top: 6px;
    font-weight: 600;
    display: inline-flex; align-items: center; gap: 3px;
}
.stat-delta.neg { color: var(--danger); }

/* ── Button primitive (new) ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--r-md);
    font-weight: 600;
    font-size: 13px;
    border: 1px solid transparent;
    background: var(--panel-2);
    color: var(--text);
    cursor: pointer;
    transition: filter .15s, transform .1s;
    text-decoration: none;
    font-family: inherit;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost   { background: transparent; border-color: var(--border-2); color: var(--text-2); }
.btn-ghost:hover { color: var(--text); background: var(--panel-2); filter: none; }

/* ── Chip accent variants (new) ── */
.chip.a-mint   { background: var(--accent-soft); color: var(--accent-strong); }
.chip.a-warn   { background: rgba(245,158,11,0.14); color: var(--warning); }
.chip.a-danger { background: rgba(248,113,113,0.14); color: var(--danger); }
.chip.a-info   { background: rgba(96,165,250,0.14); color: var(--info); }
.chip.a-ok     { background: rgba(74,222,128,0.14); color: var(--success); }

/* ── Table (new primitive) ── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td {
    text-align: left;
    padding: 14px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.tbl th {
    font-weight: 600;
    color: var(--text-3);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--panel-2); }

/* ── Progress bar ── */
.pbar {
    height: 6px;
    background: var(--panel-3);
    border-radius: 999px;
    overflow: hidden;
    min-width: 80px;
}
.pbar > span {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
}

/* ── Grid helpers ── */
.grid-main { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
@media (max-width: 1200px) {
    .grid-main, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.muted { color: var(--text-3); }
.mono  { font-family: var(--font-mono); }
.kpi   { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.sep   { height: 1px; background: var(--border); margin: 8px 0; }

/* ── Cards ── */
.card-custom {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition);
}
.card-custom:hover {
    box-shadow: var(--card-shadow-hover);
}
.card-custom .card-inner {
    padding: 20px;
}
.card-custom .card-inner-sm {
    padding: 16px;
}

/* ── Stats ── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: var(--card-shadow);
}
.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-light);
    color: var(--accent);
}
[data-theme-mode="dark"] .stat-card .stat-icon {
    background: var(--accent-dark);
}
.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}
.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}
.stat-card .stat-sub {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Buttons ── */
.btn-accent {
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: 10px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-accent:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}
.btn-soft {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-soft:hover {
    background: var(--bg-card-hover);
}
.btn-sm-custom {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 8px;
}

/* ── Inputs ── */
.input-custom {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 14px;
    color: var(--text-primary);
    width: 100%;
    outline: none;
    transition: border-color var(--transition);
}
.input-custom:focus {
    border-color: var(--accent);
}
.input-custom::placeholder {
    color: var(--text-muted);
}
textarea.input-custom {
    resize: vertical;
    min-height: 80px;
}
select.input-custom {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

/* ── Badges ── */
.badge-custom {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    line-height: 20px;
}
.badge-hot { background: #fef3c7; color: #92400e; }
.badge-warm { background: #ffedd5; color: #9a3412; }
.badge-cold { background: #dbeafe; color: #1e40af; }
.badge-client { background: #d1fae5; color: #065f46; }
.badge-repeat { background: #ede9fe; color: #5b21b6; }
.badge-new { background: #fef9c3; color: #854d0e; }
.badge-answered { background: #d1fae5; color: #065f46; }
.badge-on_screen { background: #dbeafe; color: #1e40af; }
.badge-deferred { background: #f3f4f6; color: #6b7280; }
.badge-hidden { background: #fee2e2; color: #991b1b; }
[data-theme-mode="dark"] .badge-hot { background: #78350f; color: #fde68a; }
[data-theme-mode="dark"] .badge-warm { background: #7c2d12; color: #fed7aa; }
[data-theme-mode="dark"] .badge-cold { background: #1e3a5f; color: #93c5fd; }
[data-theme-mode="dark"] .badge-client { background: #064e3b; color: #6ee7b7; }
[data-theme-mode="dark"] .badge-repeat { background: #3b0764; color: #c4b5fd; }
[data-theme-mode="dark"] .badge-new { background: #713f12; color: #fde68a; }
[data-theme-mode="dark"] .badge-answered { background: #064e3b; color: #6ee7b7; }
[data-theme-mode="dark"] .badge-on_screen { background: #1e3a5f; color: #93c5fd; }
[data-theme-mode="dark"] .badge-deferred { background: #374151; color: #9ca3af; }
[data-theme-mode="dark"] .badge-hidden { background: #7f1d1d; color: #fca5a5; }

/* ── Chip toggle (analytics filters) ── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.chip:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
}
.chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.chip.active:hover {
    opacity: 0.92;
}
.chip-ghost {
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
}
.chip-ghost:hover {
    border-style: solid;
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Preset cards (quick templates) ── */
.preset-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    min-height: 76px;
    width: 100%;
}
.preset-tile:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
}
.preset-tile .preset-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.preset-tile .preset-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}
.preset-tile .preset-icon {
    font-size: 18px;
    line-height: 1;
    margin-bottom: 2px;
}

/* ── Loading shimmer ── */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.shimmer {
    background: linear-gradient(90deg,
        var(--bg-input) 0%,
        var(--bg-card-hover) 50%,
        var(--bg-input) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: 8px;
    color: transparent !important;
}

/* ── KPI hero (analytics total) ── */
.kpi-hero {
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
}
.kpi-hero .kpi-value {
    font-size: clamp(40px, 6vw, 64px);
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.kpi-hero .kpi-label {
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}
.kpi-hero .kpi-sub {
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Collapsible block (data table) ── */
details.collapsible > summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 16px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 12px;
    transition: background var(--transition);
}
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::before {
    content: "▸";
    transition: transform var(--transition);
    color: var(--text-muted);
}
details.collapsible[open] > summary::before {
    transform: rotate(90deg);
}
details.collapsible > summary:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

/* ── Tables ── */
.table-custom {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}
.table-custom th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border-color);
}
.table-custom th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background var(--transition), color var(--transition);
    position: relative;
}
.table-custom th.sortable:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}
.table-custom th.sortable:active {
    background: var(--bg-card-hover);
}
.table-custom th.sortable::after {
    content: "↕";
    margin-left: 6px;
    font-size: 11px;
    opacity: 0.55;
    display: inline-block;
    transition: opacity var(--transition), color var(--transition);
}
.table-custom th.sortable:hover::after {
    opacity: 1;
    color: var(--text-primary);
}
.table-custom th.sort-asc::after,
.table-custom th.sort-desc::after {
    opacity: 1;
    color: var(--accent);
    font-weight: 700;
}
.table-custom th.sort-asc::after {
    content: "↑";
}
.table-custom th.sort-desc::after {
    content: "↓";
}
.table-custom td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}
.table-custom tbody tr {
    transition: background var(--transition);
}
.table-custom tbody tr:hover {
    background: var(--bg-card-hover);
}
.table-custom tbody tr:last-child td {
    border-bottom: none;
}

/* ── Toggle ── */
.toggle-custom {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: var(--border-color);
    cursor: pointer;
    transition: background var(--transition);
}
.toggle-custom.active {
    background: var(--accent);
}
.toggle-custom .toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: transform var(--transition);
}
.toggle-custom.active .toggle-knob {
    transform: translateX(20px);
}

/* ── Search ── */
.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 8px 16px;
}
.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 14px;
    flex: 1;
}
.search-box input::placeholder {
    color: var(--text-muted);
}

/* ── Tabs ── */
.tabs-custom {
    display: flex;
    gap: 4px;
    background: var(--bg-input);
    border-radius: 12px;
    padding: 4px;
}
.tabs-custom a {
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition);
}
.tabs-custom a:hover {
    color: var(--text-primary);
}
.tabs-custom a.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* ── Kanban ── */
.kanban-col {
    background: var(--bg-input);
    border-radius: 16px;
    min-height: 200px;
}
.kanban-col-header {
    padding: 14px 16px;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 14px;
    margin: 8px;
    box-shadow: var(--card-shadow);
    cursor: grab;
    transition: box-shadow var(--transition);
}
.kanban-card:hover {
    box-shadow: var(--card-shadow-hover);
}
.kanban-card.dragging {
    opacity: 0.4;
}

/* ── Progress ── */
.progress-custom {
    height: 6px;
    border-radius: 3px;
    background: var(--bg-input);
    overflow: hidden;
}
.progress-custom .progress-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.3s ease;
}

/* ── Utility ── */
.text-accent { color: var(--accent); }
.bg-accent { background: var(--accent); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.border-theme { border-color: var(--border-color); }
.rounded-card { border-radius: var(--card-radius); }

/* ── Composer (broadcast) ── */
.composer-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px 0;
    border-bottom: 1px solid var(--border-color);
}
.composer-section:last-child { border-bottom: none; }
.composer-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-primary);
    max-width: 260px;
}
.attachment-chip.removed {
    opacity: 0.4;
    text-decoration: line-through;
}
.attachment-chip .attachment-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.attachment-chip .attachment-remove {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    background: none;
    border: none;
}
.attachment-chip .attachment-remove:hover { color: #991b1b; }

/* ── Row-card (dense horizontal list rows for scheduled & history) ── */
.row-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.row-card:hover {
    border-color: var(--text-muted);
    box-shadow: var(--card-shadow);
}
.row-card .row-time {
    flex-shrink: 0;
    min-width: 130px;
}
.row-card .row-time-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.row-card .row-main {
    flex: 1;
    min-width: 0;
}
.row-card .row-text {
    font-size: 14px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.row-card .row-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.row-card .row-actions {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
}

/* ── Icon button ── */
.icon-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.icon-btn:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

/* ── Editor/Preview tabs ── */
.editor-pane { display: block; }
.editor-pane[hidden] { display: none; }
.preview-surface {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px;
    min-height: 200px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
}
