/* ==========================================================================
   Direct Generator — Design System "Lilac Console"
   Product SaaS · lavender canvas · violet→coral focus gradient.
   Refs: step-in-context.tilda.ws + BrainAI dashboard language.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ---- Tokens ---------------------------------------------------------- */
:root {
    /* Canvas & surfaces — cool lavender, не warm */
    --bg-canvas:    #F4EEFB;
    --bg-elev-0:    #FAF6FE;
    --bg-elev-1:    #FFFFFF;
    --bg-inset:     #EBE1F7;
    --bg-sidebar:   #F0E7FA;

    /* Borders — барели видимые, violet-undertone */
    --border-soft:  #ECE3F7;
    --border-hard:  #DCCEF0;
    --border-focus: #B89CEE;

    /* Ink — deep violet-black, не сажа */
    --ink-1:        #1B1330;
    --ink-2:        #453866;
    --ink-3:        #7A6D95;
    --ink-4:        #B5ABC9;

    /* Brand — violet ось */
    --brand:        #7839F2;
    --brand-hover:  #5F1ED8;
    --brand-ink:    #FFFFFF;
    --brand-soft:   #EDE1FF;
    --brand-softer: #F6EFFE;
    --brand-glow:   rgba(120, 57, 242, 0.22);
    --brand-ring:   rgba(120, 57, 242, 0.14);

    /* Accent gradient — primary CTA language */
    --grad-primary:
        linear-gradient(135deg, #8B4CFF 0%, #B347E5 42%, #FF7A5C 100%);
    --grad-primary-hover:
        linear-gradient(135deg, #7127EF 0%, #A22CD6 42%, #FF6040 100%);
    --grad-soft:
        linear-gradient(135deg, #EEE4FF 0%, #FBE4DB 100%);
    --grad-hero:
        radial-gradient(1200px 700px at 0% -20%, rgba(120, 57, 242, 0.16), transparent 55%),
        radial-gradient(900px 600px at 100% -10%, rgba(255, 120, 90, 0.10), transparent 55%),
        linear-gradient(180deg, var(--bg-canvas) 0%, #FAF6FE 100%);

    /* Status — muted SaaS palette, не светофор */
    --ok:           #1F9D6F;
    --ok-soft:      #DDF3E8;
    --ok-ink:       #0E5A3F;
    --warn:         #C77A18;
    --warn-soft:    #FCEBD2;
    --warn-ink:     #6E420B;
    --err:          #D94A3A;
    --err-soft:     #FBDDD7;
    --err-ink:      #7A2518;
    --info:         #3E6DCC;
    --info-soft:    #DDE7F8;
    --info-ink:     #203F7E;

    /* Radii — заметно скруглённые, SaaS-мягкость */
    --r-xs: 8px;
    --r-sm: 12px;
    --r-md: 16px;
    --r-lg: 20px;
    --r-xl: 28px;
    --r-pill: 999px;

    /* Shadows — ambient violet, не чёрный drop */
    --shadow-card:
        0 1px 0 rgba(27, 19, 48, 0.03),
        0 1px 3px rgba(120, 57, 242, 0.05),
        0 6px 16px -8px rgba(120, 57, 242, 0.10);
    --shadow-float:
        0 1px 0 rgba(27, 19, 48, 0.04),
        0 12px 32px -16px rgba(120, 57, 242, 0.22),
        0 4px 10px -4px rgba(120, 57, 242, 0.08);
    --shadow-brand:
        0 10px 24px -12px rgba(120, 57, 242, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
    --shadow-grad:
        0 10px 28px -10px rgba(179, 71, 229, 0.45),
        0 4px 12px -4px rgba(255, 122, 92, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.20);

    /* Type */
    --font-body:    'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', 'SF Mono', Consolas, monospace;

    /* Высота .rep-top-sticky (h1 18 + sub 11 + paddings + line-heights ≈ 76).
       Используется для расчёта top: var(--rep-top-h) у sticky-шапок таблиц,
       чтобы они залипали ПОД верхней панелью, а не уезжали вместе с .tbl-scroll. */
    --rep-top-h:    76px;
}

/* ---- Base ------------------------------------------------------------- */
html, body {
    background-color: var(--bg-canvas);
    color: var(--ink-2);
    font-family: var(--font-body);
    font-feature-settings: "ss01", "ss02", "cv11";
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    background-image: var(--grad-hero);
    background-attachment: fixed;
    min-height: 100vh;
}

header, footer { position: relative; z-index: 1; }

/* ---- Typography ------------------------------------------------------- */
h1, h2, h3, .display, .h-display {
    font-family: var(--font-display);
    color: var(--ink-1);
    font-weight: 700;
    letter-spacing: -0.022em;
    line-height: 1.08;
}

h1, .h-display-xl {
    font-size: clamp(38px, 4.6vw, 58px);
    font-weight: 800;
    letter-spacing: -0.028em;
    line-height: 1.02;
}
h2, .h-display-lg {
    font-size: clamp(26px, 3vw, 34px);
    letter-spacing: -0.022em;
}
h3, .h-display-md {
    font-size: 20px;
    letter-spacing: -0.014em;
    font-weight: 700;
}

.h-ui {
    font-family: var(--font-body);
    font-weight: 600;
    color: var(--ink-1);
    letter-spacing: -0.01em;
}

.eyebrow {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--brand);
}

.num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum", "zero", "ss01";
    letter-spacing: -0.02em;
}
.num-xl {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: clamp(28px, 3vw, 36px);
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--ink-1);
    line-height: 1;
}

.text-ink-1 { color: var(--ink-1); }
.text-ink-2 { color: var(--ink-2); }
.text-ink-3 { color: var(--ink-3); }
.text-ink-4 { color: var(--ink-4); }
.text-brand { color: var(--brand); }

.text-gradient {
    background: var(--grad-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

a { color: inherit; }
a.link {
    color: var(--ink-1);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: var(--border-hard);
    transition: color 140ms ease, text-decoration-color 140ms ease;
}
a.link:hover { text-decoration-color: var(--brand); color: var(--brand); }

/* ---- Buttons ---------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 20px;
    border-radius: var(--r-pill);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    letter-spacing: -0.005em;
    cursor: pointer;
    border: 1px solid transparent;
    transition:
        transform 140ms cubic-bezier(.2,.8,.2,1),
        background 180ms ease,
        border-color 180ms ease,
        box-shadow 220ms ease,
        color 180ms ease,
        filter 180ms ease;
    white-space: nowrap;
    user-select: none;
    line-height: 1;
    position: relative;
    overflow: hidden;
}
.btn:active { transform: translateY(1px) scale(0.995); }
.btn:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
}

/* Primary — gradient violet→coral (BrainAI CTA language) */
.btn-primary {
    background: var(--grad-primary);
    color: #fff;
    box-shadow: var(--shadow-grad);
    border: none;
}
.btn-primary:hover {
    background: var(--grad-primary-hover);
    filter: brightness(1.04);
    transform: translateY(-1px);
}

/* Solid — плоский violet, вторичный уровень */
.btn-solid {
    background: var(--brand);
    color: #fff;
    box-shadow: var(--shadow-brand);
}
.btn-solid:hover {
    background: var(--brand-hover);
    transform: translateY(-1px);
}

/* Secondary — белая pill, тёмный текст (как на step-in-context hero) */
.btn-secondary {
    background: #fff;
    color: var(--ink-1);
    border-color: var(--border-hard);
    box-shadow: 0 1px 2px rgba(27, 19, 48, 0.04);
}
.btn-secondary:hover {
    border-color: var(--brand);
    color: var(--brand);
}

/* Ghost — без фона */
.btn-ghost {
    background: transparent;
    color: var(--ink-2);
}
.btn-ghost:hover {
    background: var(--brand-softer);
    color: var(--brand);
}

/* Soft — бледный violet fill */
.btn-soft {
    background: var(--brand-soft);
    color: var(--brand-hover);
}
.btn-soft:hover {
    background: #E1D0FE;
    color: var(--brand-hover);
}

.btn-danger {
    background: var(--err-soft);
    color: var(--err-ink);
}
.btn-danger:hover { background: #F5C6BD; }

.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-lg { height: 52px; padding: 0 26px; font-size: 15px; }
.btn-xl { height: 60px; padding: 0 32px; font-size: 16px; border-radius: var(--r-pill); }

.btn .btn-icon {
    display: inline-flex;
    width: 16px;
    height: 16px;
    flex: none;
}
.btn-icon-only { padding: 0; width: 42px; }
.btn-icon-only.btn-sm { width: 34px; }

/* ---- Cards ------------------------------------------------------------ */
.card {
    background: var(--bg-elev-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 24px;
    box-shadow: var(--shadow-card);
    position: relative;
}
.card-flat {
    background: var(--bg-elev-0);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 20px;
}
.card-lavender {
    background: var(--brand-softer);
    border: 1px solid var(--brand-soft);
    border-radius: var(--r-md);
    padding: 20px;
}
.card-gradient {
    background: var(--grad-soft);
    border: 1px solid var(--brand-soft);
    border-radius: var(--r-md);
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.card-gradient::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(600px 300px at 100% 0%, rgba(255, 122, 92, 0.12), transparent 60%);
    pointer-events: none;
}
.card-interactive {
    transition: border-color 180ms ease, transform 180ms ease, box-shadow 220ms ease;
    cursor: pointer;
}
.card-interactive:hover {
    border-color: var(--border-hard);
    transform: translateY(-2px);
    box-shadow: var(--shadow-float);
}

/* ---- Metric card (BrainAI-style KPI) ---------------------------------- */
.metric {
    background: var(--bg-elev-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 20px 22px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}
.metric .metric-label {
    font-size: 12px;
    color: var(--ink-3);
    font-weight: 500;
    letter-spacing: 0.01em;
}
.metric .metric-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 30px;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--ink-1);
    line-height: 1;
}
.metric .metric-delta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
}
.metric-delta.up   { color: var(--ok); }
.metric-delta.down { color: var(--err); }

/* ---- Pills & badges --------------------------------------------------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--r-pill);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.5;
    border: 1px solid transparent;
    white-space: nowrap;
}
.pill-ok    { background: var(--ok-soft);   color: var(--ok-ink);   }
.pill-warn  { background: var(--warn-soft); color: var(--warn-ink); }
.pill-err   { background: var(--err-soft);  color: var(--err-ink);  }
.pill-info  { background: var(--info-soft); color: var(--info-ink); }
.pill-brand { background: var(--brand-soft);color: var(--brand-hover); }
.pill-ghost { background: var(--bg-inset);  color: var(--ink-2); border-color: var(--border-soft); }
.pill-grad  {
    background: var(--grad-primary);
    color: #fff;
    border: none;
}

.pill-dot::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    margin-right: 2px;
}

/* ---- Chip (tag-like, interactive — bulk editor sidebar) --------------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 13px;
    border-radius: var(--r-pill);
    background: var(--bg-elev-1);
    border: 1px solid var(--border-soft);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
    transition: all 140ms ease;
    cursor: pointer;
    line-height: 1.2;
}
.chip:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-softer);
}
.chip.is-active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    box-shadow: var(--shadow-brand);
}
.chip .chip-num {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-4);
    font-weight: 500;
    padding: 1px 6px;
    background: var(--bg-inset);
    border-radius: var(--r-pill);
}
.chip.is-active .chip-num {
    color: #fff;
    background: rgba(255,255,255,0.22);
}
.chip:hover .chip-num { color: var(--brand); background: var(--brand-soft); }

/* Chip axis tinting — каждая ось кластеризации в своей пастели,
   чтобы глаз быстро ловил тип тега в общем облаке. */
.chip-axis-stem  { background: var(--brand-softer); border-color: #D9C7F7; color: var(--brand-hover); }
.chip-axis-stem  .chip-num { background: rgba(120,57,242,.10); color: var(--brand); }
.chip-axis-stem:hover { background: #E2D2FA; border-color: var(--brand); color: var(--brand); }

.chip-axis-verb  { background: var(--info-soft); border-color: #BFD2F0; color: var(--info-ink); }
.chip-axis-verb  .chip-num { background: #FFFFFF; color: var(--info); }
.chip-axis-verb:hover { background: #C8D7F2; border-color: var(--info); color: var(--info-ink); }

.chip-axis-char  { background: var(--warn-soft); border-color: #F2D49C; color: var(--warn-ink); }
.chip-axis-char  .chip-num { background: #FFFFFF; color: var(--warn); }
.chip-axis-char:hover { background: #F8DDB1; border-color: var(--warn); color: var(--warn-ink); }

.chip-axis-cond  { background: var(--ok-soft); border-color: #B5E2C9; color: var(--ok-ink); }
.chip-axis-cond  .chip-num { background: #FFFFFF; color: var(--ok); }
.chip-axis-cond:hover { background: #C8EBD6; border-color: var(--ok); color: var(--ok-ink); }

.chip-axis-geo   { background: #D9EEF2; border-color: #A8D6E0; color: #14525E; }
.chip-axis-geo   .chip-num { background: #FFFFFF; color: #1A8095; }
.chip-axis-geo:hover { background: #C2E4EB; border-color: #1A8095; color: #14525E; }

.chip-axis-brand { background: #F4DCEC; border-color: #E2B0D2; color: #66224F; }
.chip-axis-brand .chip-num { background: #FFFFFF; color: #A93D88; }
.chip-axis-brand:hover { background: #ECC8DE; border-color: #A93D88; color: #66224F; }

/* Eyebrow-метка оси — подкрашиваем чтобы заголовок и его чипы перекликались. */
.eyebrow-axis-stem  { color: var(--brand); }
.eyebrow-axis-verb  { color: var(--info-ink); }
.eyebrow-axis-char  { color: var(--warn-ink); }
.eyebrow-axis-cond  { color: var(--ok-ink); }
.eyebrow-axis-geo   { color: #14525E; }
.eyebrow-axis-brand { color: #66224F; }

/* ---- Pipeline stepper ------------------------------------------------- */
.pipeline-bar {
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 8px;
    background: var(--bg-elev-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-card);
    overflow-x: auto;
}
.step-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-3);
    position: relative;
    white-space: nowrap;
    transition: all 180ms ease;
    text-decoration: none;
}
.step-link:hover { background: var(--brand-softer); color: var(--ink-1); }
.step-link .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--r-pill);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--border-hard);
    background: var(--bg-elev-1);
    color: var(--ink-3);
    flex: none;
    transition: all 180ms ease;
}
.step-link.is-done .step-num { background: var(--ok); border-color: var(--ok); color: #fff; }
.step-link.is-done             { color: var(--ok-ink); }
.step-link.is-running .step-num{
    background: var(--grad-primary);
    border-color: transparent;
    color: #fff;
    animation: pulse 1.6s ease-in-out infinite;
}
.step-link.is-running          { color: var(--brand-hover); }
.step-link.is-error .step-num  { background: var(--err); border-color: var(--err); color: #fff; }
.step-link.is-error            { color: var(--err-ink); }
.step-link.is-active {
    background: var(--ink-1);
    color: #fff;
}
.step-link.is-active .step-num {
    background: transparent;
    border-color: rgba(255,255,255,0.35);
    color: #fff;
}
.step-link.is-active.is-done .step-num { background: var(--ok); border-color: var(--ok); }
.step-link.is-active.is-running .step-num { background: var(--grad-primary); border-color: transparent; }

.step-link.is-locked {
    color: var(--ink-4);
    cursor: not-allowed;
    opacity: 0.55;
    pointer-events: auto;
}
.step-link.is-locked .step-num {
    background: transparent;
    border-color: var(--border-hard);
    color: var(--ink-4);
    font-size: 11px;
}
.step-link.is-locked:hover { background: transparent; color: var(--ink-4); }

.btn.is-disabled, .btn-secondary.is-disabled, .btn-primary.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: auto;
    user-select: none;
}

.step-sep {
    width: 14px;
    align-self: center;
    border-top: 1px dashed var(--border-hard);
    margin: 0 2px;
}
.step-badge-fix {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--err);
    box-shadow: 0 0 0 2px var(--bg-elev-1);
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--brand-glow); }
    50%      { box-shadow: 0 0 0 7px transparent; }
}

/* ---- Metric ribbon (top cost/tokens) ---------------------------------- */
.ribbon {
    display: inline-flex;
    align-items: center;
    gap: 18px;
    padding: 9px 18px;
    background: var(--bg-elev-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-pill);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-2);
    box-shadow: var(--shadow-card);
}
.ribbon .sep { width: 1px; height: 14px; background: var(--border-hard); }
.ribbon b { color: var(--ink-1); font-weight: 600; }

/* ---- Section heading -------------------------------------------------- */
.section-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 24px;
}
.section-head .eyebrow { color: var(--brand); }

/* ---- Form controls ---------------------------------------------------- */
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"],
textarea, select {
    width: 100%;
    background: var(--bg-elev-1);
    border: 1px solid var(--border-hard);
    border-radius: var(--r-sm);
    padding: 11px 14px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--ink-1);
    transition: border-color 160ms ease, box-shadow 220ms ease;
}
input::placeholder, textarea::placeholder { color: var(--ink-4); }
input:hover:not(:focus), textarea:hover:not(:focus), select:hover:not(:focus) {
    border-color: var(--border-focus);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-ring);
}
textarea { line-height: 1.55; min-height: 104px; }
label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 7px;
    letter-spacing: 0.01em;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }

/* ---- Navigation ------------------------------------------------------- */
.site-header {
    position: relative;
    z-index: 10;
    border-bottom: 1px solid var(--border-soft);
    background: color-mix(in srgb, var(--bg-canvas) 80%, transparent);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
}
.brand-mark {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.018em;
    color: var(--ink-1);
}
.brand-mark .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--grad-primary);
    box-shadow: 0 0 0 3px var(--brand-soft);
    flex: none;
}
.nav-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-3);
    text-decoration: none;
    padding: 7px 12px;
    border-radius: var(--r-xs);
    transition: all 140ms ease;
}
.nav-link:hover { color: var(--ink-1); background: var(--brand-softer); }
.nav-link.is-active { color: var(--brand); background: var(--brand-soft); }

/* ---- Sidebar (BrainAI-style) ------------------------------------------ */
.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-soft);
    padding: 20px 14px;
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 140ms ease;
    margin-bottom: 2px;
}
.sidebar-item:hover { background: #fff; color: var(--ink-1); }
.sidebar-item.is-active {
    background: #fff;
    color: var(--brand);
    box-shadow: var(--shadow-card);
}
.sidebar-item .sidebar-icon {
    width: 16px;
    height: 16px;
    flex: none;
    opacity: 0.7;
}
.sidebar-item.is-active .sidebar-icon { opacity: 1; }

/* ---- Tables ----------------------------------------------------------- */
table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-elev-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    overflow: hidden;
}
table.data th, table.data td {
    text-align: left;
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-soft);
}
table.data th {
    background: var(--bg-elev-0);
    color: var(--ink-3);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--brand-softer); }
table.data td.num {
    text-align: right;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--ink-1);
}

/* ---- Dividers --------------------------------------------------------- */
.rule {
    height: 1px;
    background: var(--border-soft);
    border: 0;
    margin: 24px 0;
}
.rule-dash {
    height: 1px;
    border: 0;
    border-top: 1px dashed var(--border-hard);
    margin: 20px 0;
}

/* ---- Scrollbar -------------------------------------------------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-hard);
    border-radius: var(--r-pill);
    border: 2px solid var(--bg-canvas);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* ---- Code / pre ------------------------------------------------------- */
pre, code {
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.55;
}
pre {
    background: var(--bg-elev-0);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-sm);
    padding: 14px 16px;
    color: var(--ink-2);
    overflow: auto;
}
code {
    padding: 1px 6px;
    background: var(--bg-inset);
    border-radius: 4px;
    color: var(--ink-1);
}

/* ---- Details / disclosure -------------------------------------------- */
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
    content: "›";
    display: inline-block;
    margin-right: 8px;
    transition: transform 160ms ease;
    color: var(--ink-3);
    font-family: var(--font-mono);
}
details[open] > summary::before { transform: rotate(90deg); }

.meta-inline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-3);
}
.meta-inline .dot-sep { width: 2px; height: 2px; border-radius: 50%; background: var(--ink-4); }

/* ---- Empty state ------------------------------------------------------ */
.empty {
    padding: 56px 24px;
    text-align: center;
    border: 1px dashed var(--border-hard);
    border-radius: var(--r-md);
    background: var(--bg-elev-0);
}
.empty h3 { margin-bottom: 8px; }
.empty p { color: var(--ink-3); font-size: 14px; }

/* ---- kbd -------------------------------------------------------------- */
kbd {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    background: var(--bg-elev-1);
    border: 1px solid var(--border-hard);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-2);
    line-height: 1.5;
}

/* ---- Surface override for legacy Tailwind classes -------------------- */
/* TODO: вычистить после миграции всех шаблонов на новые классы */
.bg-surface { background: var(--bg-elev-0) !important; }
.bg-white   { background: var(--bg-elev-1) !important; }
.rounded-card { border-radius: var(--r-md) !important; }
.rounded-btn  { border-radius: var(--r-pill) !important; }
.text-text-heading { color: var(--ink-1) !important; }
.text-text-body    { color: var(--ink-2) !important; }
.text-text-muted   { color: var(--ink-3) !important; }
.text-primary      { color: var(--brand) !important; }
.bg-primary        { background: var(--brand) !important; }
.hover\:text-primary:hover { color: var(--brand) !important; }
.border-gray-100   { border-color: var(--border-soft) !important; }
.border-gray-200   { border-color: var(--border-soft) !important; }

/* ---- Animations ------------------------------------------------------- */
@keyframes fade-rise {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.enter { animation: fade-rise 360ms cubic-bezier(.2,.8,.2,1) both; }
.enter-1 { animation-delay: 40ms; }
.enter-2 { animation-delay: 80ms; }
.enter-3 { animation-delay: 120ms; }
.enter-4 { animation-delay: 160ms; }
.enter-5 { animation-delay: 200ms; }

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.shimmer {
    background: linear-gradient(
        90deg,
        var(--bg-inset) 0%,
        var(--brand-softer) 50%,
        var(--bg-inset) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.8s linear infinite;
}

/* ==========================================================================
   Daily Report — detailed analytics page (templates/daily_report.html)
   ========================================================================== */

/* Override the container to give the report more breathing room */
body:has(.rep-top) main {
    max-width: 1540px !important;
}

.rep-top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0 18px;
    flex-wrap: wrap;
}

.back-link {
    font-size: 11px;
    color: var(--ink-3);
    text-decoration: none;
    letter-spacing: 0.02em;
}
.back-link:hover { color: var(--brand); }

.rep-h1 {
    font-size: 22px;
    font-weight: 800;
    color: var(--ink-1);
    margin: 2px 0 4px;
    letter-spacing: -0.02em;
}
.rep-sub {
    font-size: 12px;
    color: var(--ink-3);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.rep-sub .sep { color: var(--ink-4); }
.rep-sub .period-tag {
    font-family: var(--font-mono);
    color: var(--ink-1);
    font-weight: 600;
    padding: 1px 7px;
    background: var(--brand-softer);
    border-radius: 6px;
}
.rep-sub .vs-prev { font-family: var(--font-mono); color: var(--ink-4); font-size: 11px; }

.rep-dates {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.rep-dates input[type="date"] {
    padding: 4px 8px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--bg-elev-1);
    font-size: 12px;
    color: var(--ink-1);
}
.preset-row {
    display: inline-flex;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    overflow: hidden;
    margin-right: 6px;
}
.preset-btn {
    padding: 4px 10px;
    background: var(--bg-elev-1);
    color: var(--ink-2);
    font-size: 11px;
    font-weight: 600;
    border: none;
    border-right: 1px solid var(--border-soft);
    cursor: pointer;
    transition: background 0.15s;
}
.preset-btn:last-child { border-right: none; }
.preset-btn:hover { background: var(--brand-softer); color: var(--brand); }
.preset-btn.is-active {
    background: var(--brand);
    color: #fff;
}

/* ---- Sticky top nav ----
   Стикнутая шапка отчёта: оставляем видимым назад-линк, заголовок, период
   и кнопки управления. На dark-fallback фон из bg-elev-0 + полупрозрачный. */
.rep-top-sticky {
    position: sticky;
    top: 0;
    z-index: 30;
    padding-top: 10px;
    padding-bottom: 10px;
    margin-bottom: 14px;
    background: color-mix(in srgb, var(--bg-elev-0) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(8px);
    -webkit-backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--border-soft);
    align-items: center;  /* переопределяем flex-end, чтобы в узкой шапке не «падало» вниз */
}
.rep-top-sticky .rep-h1 { font-size: 18px; margin: 0; }
.rep-top-sticky .rep-sub { font-size: 11px; }

/* ---- Net-switch (segmented: Всё / Поиск / Сети) ---- */
.net-switch {
    display: inline-flex;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    overflow: hidden;
    margin-right: 6px;
}
.net-btn {
    padding: 4px 12px;
    background: var(--bg-elev-1);
    color: var(--ink-2);
    font-size: 11px;
    font-weight: 600;
    border: none;
    border-right: 1px solid var(--border-soft);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    line-height: 20px;
}
.net-btn:last-child { border-right: none; }
.net-btn:hover { background: var(--brand-softer); color: var(--brand); }
.net-btn.is-active {
    background: var(--brand);
    color: #fff;
}
.net-btn.is-active:hover { background: var(--brand); color: #fff; }

/* ---- KPI strip (top) ---- */
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
    gap: 8px;
    margin-bottom: 18px;
}
.kpi-tile {
    background: var(--bg-elev-1);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 9px 12px;
    box-shadow: var(--shadow-card);
}
.kpi-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--ink-4);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 2px;
}
.kpi-value-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px;
}
.kpi-value {
    font-family: var(--font-mono);
    font-size: 17px;
    font-weight: 700;
    color: var(--ink-1);
    letter-spacing: -0.01em;
    white-space: nowrap;
}
.kpi-sub {
    font-size: 10px;
    color: var(--ink-3);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.delta {
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-mono);
    padding: 1px 4px;
    border-radius: 4px;
    white-space: nowrap;
}
.delta-up   { color: var(--ok-ink); background: var(--ok-soft); }
.delta-down { color: var(--err-ink); background: var(--err-soft); }

/* ---- widget wrapper ---- */
.widget {
    background: var(--bg-elev-1);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    padding: 12px 14px 14px;
    box-shadow: var(--shadow-card);
    margin-bottom: 14px;
}
.widget-full { grid-column: 1 / -1; }
.sect-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 8px;
}
.sect-title h2 {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-1);
    letter-spacing: -0.01em;
    margin: 0;
}
.sect-note {
    font-size: 10px;
    color: var(--ink-4);
    font-weight: 500;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 14px;
    margin-bottom: 0;
}
@media (max-width: 1000px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* ---- data tables ---- */
.tbl-scroll {
    max-height: 320px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
}
.tbl-scroll-tall { max-height: 520px; }

/* Кампании / объявления — внутренний scroll-зона почти на полный viewport,
   чтобы шапка «Кампания / Расход / 4 нед. / ц1…» залипала при прокрутке.
   Принцип «sticky-thead в длинных таблицах»: страница вокруг короткая,
   таблица крутится сама, рядом верхняя шапка KPI остаётся на месте. */
#campaigns-block .tbl-scroll,
#ads-block .tbl-scroll {
    max-height: calc(100vh - 280px);
    min-height: 480px;
}

.dtbl {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}
.dtbl thead th {
    position: sticky;
    top: 0;
    background: var(--bg-inset);
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 10px;
    padding: 3px 6px;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-bottom: 1px solid var(--border-hard);
    white-space: nowrap;
    z-index: 2;
}
.dtbl thead th.num { text-align: center; }
.dtbl td {
    padding: 3px 7px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--ink-1);
    white-space: nowrap;
}
.dtbl td.k { font-weight: 600; color: var(--ink-1); max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.dtbl td.tr { max-width: 360px; white-space: normal; }
.dtbl td.num { text-align: center; font-family: var(--font-mono); color: var(--ink-2); }
.dtbl tbody tr:nth-child(even) { background: var(--bg-elev-0); }
.dtbl tbody tr:hover { background: var(--brand-softer); }
.dtbl td.muted { text-align: center; color: var(--ink-4); padding: 14px; font-style: italic; }

/* Компактный режим .dtbl: 12px шрифт, 2px вертикальный padding, line-height 1.25.
   Используется на overview-таблицах дашборда, где должно умещаться 20+ строк
   без скролла. Перекрывает базовые .dtbl td правила. Применять class
   `dtbl-compact` ВСЕГДА на новых таблицах daily_report (день недели, час дня,
   интересы и т.д.) — см. скилл `agency-dashboard-table` (чек-лист новой таблицы).
   Образец полноразмерной — `.pl-tbl` (Площадки РСЯ). */
.dtbl.dtbl-compact { font-size: 12px; }
.dtbl.dtbl-compact tbody td { padding: 2px 7px; line-height: 1.25; }
.dtbl.dtbl-compact thead th { line-height: 1.25; }
.dtbl.dtbl-compact tr.dtbl-totals td { padding: 2px 7px; }

/* === .dtbl-overview — РЕЦЕПТ ОБЗОРНОЙ ТАБЛИЦЫ ДАШБОРДА ===
   Применять при создании любой новой sortable+sticky+compact таблицы
   (час дня, интересы, дни недели и т.п.). Включает:
   1. compact-стили (padding 2px / font 12px / line-height 1.25);
   2. sticky двухрядной шапки (row-1 top:0, row-2 top:var(--ovr-head-row1-h));
   3. sticky totals row (top:var(--ovr-thead-h)) — НЕ уезжает при скролле;
   4. явный фон шапки + totals (var(--bg-inset)) — иначе тело просвечивает.
   JS-замер CSS-переменных делает универсальный IIFE в daily_report.html
   (ищет все `.dtbl-overview` и считает высоты thead).
   Образец живой реализации: .pl-tbl (Площадки РСЯ) — взято оттуда.
   Селектор `.dtbl.dtbl-overview` повышает специфичность над глубже
   расположенными правилами `.dtbl thead th { position: sticky; top:0 }`. */
.dtbl.dtbl-overview { font-size: 12px; width: 100%; table-layout: fixed; }
.dtbl.dtbl-overview thead th,
.dtbl.dtbl-overview thead th.sortable,
.dtbl.dtbl-overview thead th.slot-col,
.dtbl.dtbl-overview thead th.slot-group-head {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg-inset);
    line-height: 1.25;
}
.dtbl.dtbl-overview .head-row-2 th,
.dtbl.dtbl-overview .head-row-2 th.sortable,
.dtbl.dtbl-overview .head-row-2 th.slot-col {
    top: var(--ovr-head-row1-h, 22px);
    z-index: 19;
}
.dtbl.dtbl-overview tbody td { padding: 2px 7px; line-height: 1.25; }
.dtbl.dtbl-overview tr.dtbl-totals td {
    position: sticky;
    top: var(--ovr-thead-h, 42px);
    z-index: 15;
    padding: 2px 7px;
    background: var(--bg-inset);
    color: var(--ink-1);
    font-weight: 700;
    border-bottom: 1px solid var(--border-hard);
}
/* Фиксированные ширины колонок — ровно как в .pl-tbl. Без них table-layout
   fixed раздаёт колонки auto-mode и числа не центруются под шапкой. */
.dtbl.dtbl-overview thead tr.head-row-1 > th.num         { width: 76px;  }
.dtbl.dtbl-overview thead tr.head-row-1 > th.slot-group-head { width: 180px; }
/* Hover/zebra строк тела — отдельно для overview, иначе наследуется
   tbody:nth-child(even) от базового .dtbl, мешает читабельности totals. */
.dtbl.dtbl-overview tbody tr:not(.dtbl-totals):nth-child(even) { background: var(--bg-elev-0); }
.dtbl.dtbl-overview tbody tr:not(.dtbl-totals):hover { background: var(--brand-softer); cursor: default; }

/* ---- bar cells (Excel-like data bar) ---- */
.bar-cell {
    position: relative;
    padding-right: 8px;
    isolation: isolate;
}
.bar-cell::before {
    content: "";
    position: absolute;
    inset: 2px auto 2px 2px;
    width: calc(var(--pct, 0) * 1%);
    background: linear-gradient(90deg, rgba(120,57,242,0.12), rgba(179,71,229,0.16));
    border-radius: 3px;
    z-index: -1;
}
.bar-cell span { position: relative; }

/* ---- campaigns / ads tables: одна таблица со встроенным sparkline-столбцом ---- */
.dtbl-camps-left { table-layout: fixed; width: 100%; }
.camps-body-row,
.camps-body-row td { height: 38px; }
.dtbl-camps-left td.camp-name {
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dtbl-camps-left th.num,
.dtbl-camps-left td.num {
    width: 62px;
    white-space: nowrap;
}
/* Для 2-row: fixed layout берёт ширины из head-row-1, у которой часть колонок — group-head colspan=3.
   Явно задаём ширины group-head и первого столбца (имя кампании). */
.dtbl-camps-left.dtbl-2row thead tr.head-row-1 > th:first-child { width: auto; }
.dtbl-camps-left.dtbl-2row thead tr.head-row-1 > th.num { width: 62px; }
.dtbl-camps-left.dtbl-2row thead tr.head-row-1 > th.slot-group-head { width: 186px; }

/* Toolbar над таблицей */
.camps-toolbar {
    display: flex;
    align-items: center;
    min-height: 34px;
    margin: 4px 0 10px;
    box-sizing: border-box;
    gap: 10px;
    flex-wrap: wrap;
}
.camps-filter-group {
    display: inline-flex;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-elev-0);
}
.camps-filter-btn {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 5px 10px;
    font-size: 12px;
    color: var(--ink-2);
    cursor: pointer;
    border-right: 1px solid var(--border-soft);
    transition: background .12s, color .12s;
}
.camps-filter-btn:last-child { border-right: 0; }
.camps-filter-btn:hover { background: var(--brand-softer); }
.camps-filter-btn.is-active {
    background: var(--brand, #7839F2);
    color: #fff;
    font-weight: 600;
}
.camps-search-input {
    padding: 5px 10px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    font-size: 12px;
    min-width: 220px;
    background: var(--bg-elev-0);
    color: var(--ink-1);
}
.camps-search-input:focus {
    outline: none;
    border-color: var(--brand, #7839F2);
}
.camps-counter { margin-left: auto; }

/* ---- inline sparkline column (встроенный график «расход + лиды» по 4 нед.) ---- */
.dtbl thead th.spark-col {
    width: 110px;
    text-align: center;
    vertical-align: middle;
}
.spark-cell {
    width: 110px;
    padding: 0 8px !important;
    line-height: 0;
    vertical-align: middle;
}
svg.inline-spark {
    display: block;
    width: 100%;
    height: 22px;
    cursor: default;
    overflow: visible;
}
.inline-spark .ils-cost { stroke: var(--brand, #7839F2); stroke-width: 1.4; }
.inline-spark .ils-g1   { stroke: #FF7A5C; stroke-width: 1.4; }
.inline-spark .ils-pt-cost { fill: var(--brand, #7839F2); }
.inline-spark .ils-pt-g1   { fill: #FF7A5C; }
.inline-spark-empty { color: var(--ink-4); font-size: 11px; line-height: 1; font-style: italic; }
.inline-spark-legend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
}
.inline-spark-legend .ils-lg {
    display: inline-block;
    width: 14px; height: 2px;
    border-radius: 1px;
    margin-right: 2px;
    vertical-align: middle;
}
.inline-spark-legend .ils-lg + .ils-lg { margin-left: 8px; }
.inline-spark-legend .ils-lg-cost { background: var(--brand, #7839F2); }
.inline-spark-legend .ils-lg-g1   { background: #FF7A5C; }

/* Sortable headers */
.dtbl .sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 18px;
}
.dtbl .sortable:hover { background: var(--brand-softer); }
.sort-ind {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 6px;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    opacity: 0.25;
    border-top: 5px solid currentColor;
}
.sort-ind.dir-desc {
    opacity: 1;
    border-top: 5px solid var(--brand, #7839F2);
}
.sort-ind.dir-asc {
    opacity: 1;
    border-top: 0;
    border-bottom: 5px solid var(--brand, #7839F2);
}

/* State chip — метка рядом с названием неактивной кампании */
.state-chip {
    display: inline-block;
    font-size: 9px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
    margin-left: 6px;
}
.state-chip.state-suspended { background: var(--warn-soft, #fff4cc); color: var(--warn-ink, #8a6100); }
.state-chip.state-archived  { background: var(--bg-inset); color: var(--ink-3); }
.state-chip.state-ended     { background: var(--bg-inset); color: var(--ink-3); }
.state-chip.state-off       { background: var(--bg-inset); color: var(--ink-3); }
.state-chip.state-mc        { background: var(--info-soft, #e6e0ff); color: var(--info-ink, #5b36c8); }
a.state-chip                { text-decoration: none; }
a.state-chip:hover          { filter: brightness(0.95); }

/* Region class badge — таблица «География». Цвета по семантике класса:
   capital — фиолетовый акцент (premium-аукцион); million — зелёный (хороший
   объём); regional_center — синий (рабочая аудитория); region/country —
   нейтральный серый (агрегат); other — мягкий warn (села/районы). */
.rclass-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.02em;
    line-height: 1.4;
    white-space: nowrap;
}
.rclass-badge.rclass-capital         { background: var(--info-soft, #e6e0ff); color: var(--info-ink, #5b36c8); }
.rclass-badge.rclass-million         { background: var(--ok-soft, #d6f5db);   color: var(--ok-ink, #1c6c30); }
.rclass-badge.rclass-regional_center { background: #d8e7ff;                  color: #2451a8; }
.rclass-badge.rclass-region          { background: var(--bg-inset);          color: var(--ink-2); }
.rclass-badge.rclass-country         { background: var(--bg-inset);          color: var(--ink-3); }
.rclass-badge.rclass-other           { background: var(--warn-soft, #fff4cc); color: var(--warn-ink, #8a6100); }

/* ---- Training widget (виджет «Обучение») ----
   Колонка после «Кампания» в таблице РК. См. план
   docs/superpowers/plans/2026-04-23-training-widget.md §5. */
.dtbl-camps-left.dtbl-2row thead tr.head-row-1 > th.training-col-head { width: 110px; }
.training-cell { cursor: help; padding-right: 6px !important; }
.training-cell .training-pill {
    display: inline-flex; align-items: center; gap: 4px;
    font-variant-numeric: tabular-nums;
    line-height: 1.1; white-space: nowrap;
}
.training-cell .training-bar {
    display: inline-block;
    width: 38px; height: 6px;
    background: rgba(120, 57, 242, 0.10);
    border-radius: 3px; overflow: hidden;
    flex-shrink: 0;
}
.training-cell .training-bar-fill {
    display: block; height: 100%;
    background: var(--ink-3);
    transition: width 200ms;
}
.training-cell .training-num { font-weight: 600; font-size: 11px; }
.training-cell .training-days { color: var(--ink-3); font-size: 10px; }
.training-cell .training-noviz { color: var(--ink-4); font-size: 10px; font-style: italic; }

.training-cell--learned       .training-bar-fill { background: var(--ok-ink, #0a7040); }
.training-cell--learned       .training-num      { color: var(--ok-ink, #0a7040); }
.training-cell--on-track      .training-bar-fill { background: var(--ok-ink, #0a7040); }
.training-cell--on-track      .training-num      { color: var(--ok-ink, #0a7040); }
.training-cell--at-risk       .training-bar-fill { background: var(--warn-ink, #8a6100); }
.training-cell--at-risk       .training-num      { color: var(--warn-ink, #8a6100); }
.training-cell--not-learning  .training-bar-fill { background: var(--err-ink, #b21515); }
.training-cell--not-learning  .training-num      { color: var(--err-ink, #b21515); }

.training-col-totals { color: var(--ink-3); font-size: 10px; font-weight: 500; }

/* Goal chain: 1→%→2→%→3, компактно */
.goal-chain {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.goal-chain .goal-n { font-weight: 600; color: var(--ink-1); }
.goal-chain .goal-n-2 { color: var(--info-ink, #5b36c8); }
.goal-chain .goal-n-3 { color: var(--ok-ink, #0a7040); }
.goal-chain .goal-arr {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    font-size: 9px;
    line-height: 1;
    color: var(--ink-3);
    padding: 0 1px;
}
.goal-chain .goal-arr small {
    font-size: 8px;
    margin-top: 0;
    opacity: 0.8;
    font-weight: 500;
}
.kpi-value .goal-chain { font-size: 17px; }

/* ---- Goal mini-tile: компактная плашка цели, живёт внутри .kpi-strip ----
   Занимает span 2 колонок, чтобы уместить имя + CPL + KPI pill + CR.
   Цвет левой рамки и пилла кодирует слот: 1 brand, 2 info, 3 ok. */
.goal-mini-tile {
    grid-column: span 2;
    border-left: 3px solid var(--ink-4);
    padding: 9px 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.goal-slot-1 { border-left-color: #7839F2; }
.goal-slot-2 { border-left-color: #5b36c8; }
.goal-slot-3 { border-left-color: #0a7040; }

.goal-mini-hdr {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    margin-bottom: 1px;
}
.goal-slot-pill {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--bg-canvas, #F4EEFB);
    color: var(--ink-3);
    white-space: nowrap;
    flex-shrink: 0;
}
.goal-slot-1 .goal-slot-pill { background: #EDE1FF; color: #7839F2; }
.goal-slot-2 .goal-slot-pill { background: #DDE7F8; color: #203F7E; }
.goal-slot-3 .goal-slot-pill { background: #DDF3E8; color: #0E5A3F; }

.goal-mini-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.goal-mini-sub {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
    font-size: 10px;
    color: var(--ink-3);
    margin-top: 1px;
}
.goal-mini-cpl {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 11px;
    color: var(--ink-1);
}
.goal-slot-kpi {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--bg-canvas, #F4EEFB);
    color: var(--ink-3);
    white-space: nowrap;
}
.goal-slot-kpi.is-good { background: var(--ok-soft); color: var(--ok-ink); }
.goal-slot-kpi.is-bad  { background: var(--err-soft); color: var(--err-ink); }
.goal-mini-cr {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 10px;
    color: var(--ink-2);
    white-space: nowrap;
}

@media (max-width: 720px) {
    .goal-mini-tile { grid-column: span 1; }
}

/* Колонки слотов в таблицах — цветные полоски сверху. Слот 1 — brand,
   слот 2 — info-ink, слот 3 — ok-ink. Ненавязчиво, но группу видно. */
.dtbl th.slot-col {
    position: relative;
    white-space: nowrap;
}
.dtbl th.slot-col .slot-head-pill { margin-right: 3px; }
/* Тонкий тон по группам — цель отличается оттенком, без жёстких линий.
   Оттенки — очень светлые версии пилюль (слот 1 — purple, 2 — blue, 3 — green).
   Применяем только к td — у thead sticky-фон должен оставаться непрозрачным (bg-inset),
   иначе строки tbody просвечиваются сквозь шапку при скролле. */
.dtbl td.slot-col-1 { background: rgba(120, 57, 242, 0.06); }
.dtbl td.slot-col-2 { background: rgba(32, 63, 126, 0.055); }
.dtbl td.slot-col-3 { background: rgba(14, 90, 63, 0.055); }
/* Убираем любые вертикальные разделители внутри таблицы — группы считываются тоном.
   Шапка оставлена без внутренних борзеров, чтобы не резала пилюли. */
.dtbl td + td,
.dtbl th + th,
.dtbl-2row thead tr.head-row-2 th + th { border-left: 0; }

/* Двухрядная шапка: group row (ц1/ц2/ц3 над sub-кол-во/CPL/CR%) */
.dtbl-2row thead th.slot-group-head {
    text-align: center;
    border-bottom: 2px solid;
    padding: 3px 4px;
}

/* Sticky-thead для двухрядной шапки .dtbl-2row (campaigns + ads).
   Row-1 (rowspan=2 базовые + slot-group-head) висит на top:0. Row-2 — ниже row-1
   (~22px). Без этого row-2 залипает поверх row-1 и закрывает «ц1/ц2/ц3»
   при прокрутке. height на th не выставляем — иначе сжимаются rowspan=2-ячейки.
   КРИТИЧНО: явный position: sticky на row-1, потому что .dtbl .sortable и
   .dtbl th.slot-col ниже в файле задают position: relative и побеждают
   базовый .dtbl thead th { position: sticky } по порядку правил при равной
   специфичности — row-1 уезжает наверх, а row-2 остаётся sticky → шапка
   разрывается. Тот же приём дублирован для .pl-tbl (см. ниже). */
.dtbl-2row thead tr.head-row-1 > th {
    position: sticky;
    top: 0;
    z-index: 21;
    background: var(--bg-inset);
}
.dtbl-2row thead tr.head-row-2 > th {
    position: sticky;
    /* top = реальная высота row-1.slot-group-head (≈23px). Без JS-замера падает
       в fallback 22px, на части viewport-ов даёт 1px зазор где tbody просвечивает
       (ИТОГО налеплено на КОЛ-ВО CPL CR%). Переменная ставится JS-блоком
       sync2RowHeads в daily_report.html, общая на все .dtbl-2row. */
    top: var(--dtbl-head-row1-h, 22px);
    z-index: 20;
    background: var(--bg-inset);
}
.dtbl-2row thead th.slot-group-head.slot-col-1 { border-bottom-color: #7839F2; }
.dtbl-2row thead th.slot-group-head.slot-col-2 { border-bottom-color: #5b36c8; }
.dtbl-2row thead th.slot-group-head.slot-col-3 { border-bottom-color: #0a7040; }
.dtbl-2row thead th.sub {
    font-size: 9px;
    font-weight: 500;
    color: var(--ink-3);
    text-transform: none;
    letter-spacing: 0;
    padding: 2px 5px;
    border-top: 1px solid var(--border-soft);
}

/* Totals row — первая строка tbody. Прокручивается вместе с содержимым
   (по фидбеку Лёши: «странный закреп»; оставляем sticky только на шапке).
   У .slot-col-* тон переопределяет фон — поэтому задаём bg-inset через !important,
   чтобы totals всегда читался как итоговая строка, а не как слот-колонка. */
.dtbl tr.dtbl-totals td {
    background: var(--bg-inset) !important;
    font-weight: 600;
    color: var(--ink-1);
    border-bottom: 2px solid var(--border-hard);
    padding: 4px 7px;
}
.dtbl tr.dtbl-totals td.k { font-weight: 700; text-transform: uppercase; font-size: 10px; letter-spacing: 0.03em; }
.dtbl tr.dtbl-totals:hover td { background: var(--bg-inset) !important; }

/* Площадки — используют базовую шапку .dtbl thead th (var(--bg-inset)),
   чтобы визуально сходиться с таблицей объявлений. Totals прокручивается
   вместе с телом таблицы (как в campaigns/ads — sticky-closures мешают
   двухрядной шапке и выглядят «плавающими»). */
/* Sticky-thead для двухрядной шапки .pl-tbl.
   Все th — sticky. Row-1 (включая rowspan=2 базовые и slot-group-head) висят на
   top:0. Row-2 (КОЛ-ВО/CPL/CR% × слоты) висит ниже row-1.slot-group-head, иначе
   накладывается и закрывает «ц1/ц2/ц3». Высота row-1 = CSS-переменная
   --pl-head-row1-h, выставляется JS на этапе init виджета (через measure
   .head-row-1 .slot-group-head). Fallback 22px — на случай если JS не успел.
   Дублируем position+top для конкретных подклассов th потому что в .dtbl
   каскаде уже сидят перебивки (.sortable / .slot-col → position:relative).
   Используем .pl-tbl.pl-tbl для повышенной специфичности. НЕ ТРОГАТЬ. */
.pl-tbl.pl-tbl thead th,
.pl-tbl.pl-tbl thead th.sortable,
.pl-tbl.pl-tbl thead th.slot-col,
.pl-tbl.pl-tbl thead th.slot-group-head {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg-inset);
}
.pl-tbl.pl-tbl .head-row-2 th,
.pl-tbl.pl-tbl .head-row-2 th.sortable,
.pl-tbl.pl-tbl .head-row-2 th.slot-col {
    top: var(--pl-head-row1-h, 22px);
    z-index: 19;
}
.pl-tbl tr.pl-totals td {
    position: sticky;
    top: var(--pl-thead-h, 42px);
    z-index: 15;
    background: var(--bg-inset);
    color: var(--ink-1);
    font-weight: 700;
    border-bottom: 1px solid var(--border-soft);
}

.slot-head-pill {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 0 4px;
    border-radius: 999px;
    margin-right: 2px;
    background: var(--bg-canvas, #F4EEFB);
    color: var(--ink-3);
    vertical-align: middle;
}
.slot-col-1 .slot-head-pill { background: #EDE1FF; color: #7839F2; }
.slot-col-2 .slot-head-pill { background: #DDE7F8; color: #203F7E; }
.slot-col-3 .slot-head-pill { background: #DDF3E8; color: #0E5A3F; }
th.goal-col { min-width: 110px; }

.camp-spark-head {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}
.camp-spark-legend {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 9px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--ink-3);
}
.camp-spark-legend .lg-sw {
    display: inline-block;
    margin-right: 3px;
    vertical-align: middle;
}
.camp-spark-legend .lg-bar {
    width: 8px;
    height: 8px;
    background: #7839F2;
    opacity: 0.4;
    border-radius: 1.5px;
}
.camp-spark-legend .lg-line {
    width: 12px;
    height: 2px;
    background: #FF7A5C;
    position: relative;
}
.camp-spark-legend .lg-line::after {
    content: "";
    position: absolute;
    top: -1.5px;
    left: 4px;
    width: 4px;
    height: 4px;
    background: #FF7A5C;
    border-radius: 50%;
}
.dtbl-camps-right td.camp-spark-cell {
    padding: 4px 8px;
    vertical-align: middle;
}
.camp-spark-slot {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
}
.camp-spark {
    line-height: 0;
    width: 100%;
}
.camp-spark-svg {
    width: 100%;
    height: 54px;
    display: block;
    overflow: hidden;
}
.camp-spark-empty {
    font-size: 10.5px;
    color: var(--ink-4);
    font-style: italic;
    white-space: nowrap;
}
.camp-spark-svg .spark-bar {
    fill: #7839F2;
    opacity: 0.28;
    transition: opacity .12s ease;
}
.camp-spark-svg .spark-hot:hover ~ .spark-hot,
.camp-spark-svg .spark-hot { cursor: pointer; }
.camp-spark-svg .spark-hot:hover rect { fill: rgba(120,57,242,0.08); }
.camp-spark-svg .spark-hot:hover circle { r: 3.4; }

#camp-tip {
    position: fixed;
    z-index: 10000;
    background: #1a1a24;
    color: #fff;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.5;
    box-shadow: 0 8px 24px rgba(10, 10, 20, 0.22);
    pointer-events: none;
    opacity: 0;
    transition: opacity .1s ease;
    max-width: 260px;
    white-space: nowrap;
}
#camp-tip[data-show="1"] { opacity: 1; }
#camp-tip:has(.ils-tip-grid) { max-width: none; }
#camp-tip:has(.tip-text) { max-width: 380px; white-space: normal; }
#camp-tip .tip-text {
    white-space: pre-line;
    line-height: 1.5;
    font-size: 11.5px;
    color: rgba(255,255,255,0.9);
}
#camp-tip .tip-head {
    font-weight: 600;
    color: #B89CEE;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    padding-bottom: 4px;
    margin-bottom: 4px;
}
#camp-tip .tip-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}
#camp-tip .tip-row span:first-child { color: rgba(255,255,255,0.65); }

/* ---- inline-spark tooltip: 4-column grid ---- */
#camp-tip .ils-tip-grid {
    display: grid;
    grid-template-columns: auto auto auto auto;
    column-gap: 16px;
    row-gap: 3px;
    align-items: baseline;
    margin-top: 2px;
}
#camp-tip .ils-tip-row { display: contents; }
#camp-tip .ils-tip-row > span {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
#camp-tip .ils-tip-row > span:not(:first-child) { text-align: right; }
#camp-tip .ils-tip-head-row > span {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: rgba(255,255,255,0.42);
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 2px;
}
#camp-tip .ils-tip-rng  { color: rgba(255,255,255,0.78); }
#camp-tip .ils-tip-cost { color: #C9B0FA; font-weight: 600; }
#camp-tip .ils-tip-g1   { color: #FFB199; font-weight: 600; }
#camp-tip .ils-tip-cpl  { color: rgba(255,255,255,0.88); }

/* --- Placement weekly tooltip: секции (ВСЕГО + per-РК) + CPL раскраска ---
   Тултип чёрный (см. #camp-tip background выше) → цвета для CPL берём
   light-варианты, иначе на тёмном не читается. */
#camp-tip .ils-tip-section {
    margin-top: 8px;
}
#camp-tip .ils-tip-section:first-of-type {
    margin-top: 4px;
}
#camp-tip .ils-tip-section-title {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.55);
    padding: 6px 0 4px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
#camp-tip .ils-tip-section:first-of-type .ils-tip-section-title {
    border-top: none;
    padding-top: 2px;
}
#camp-tip .ils-tip-section.ils-tip-archived .ils-tip-section-title {
    color: rgba(255,255,255,0.35);
}
#camp-tip .ils-tip-section.ils-tip-archived .ils-tip-row > span {
    opacity: 0.55;
}
#camp-tip .ils-tip-cpl-high {
    color: #FF8A7A;
    font-weight: 600;
}
#camp-tip .ils-tip-cpl-low {
    color: #A8E1B8;
}
#camp-tip .ils-tip-loading {
    padding: 8px 4px;
    color: rgba(255,255,255,0.55);
    font-size: 11px;
}
#camp-tip .ils-tip-more {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.65);
    font-size: 11px;
}
/* Если несколько секций (total + ≥1 РК) — даём фикс. ширину и vertical scroll.
   Сбрасываем глобальный white-space: nowrap у #camp-tip, иначе длинные имена
   РК («МК | Бани | Поволжье_Каркасные_Недорого_Под ключ_расчет_...») вылезают
   за пределы тултипа и съедают шапку. */
#camp-tip:has(.ils-tip-section + .ils-tip-section) {
    width: 360px;
    max-width: 360px;
    max-height: min(80vh, 600px);
    overflow-y: auto;
    white-space: normal;
}
#camp-tip .ils-tip-section-title {
    word-wrap: break-word;
    overflow-wrap: anywhere;
    line-height: 1.3;
}
/* Заголовок «{host} · 4 нед.» залипает наверху скроллируемого тултипа,
   чтобы при просмотре нижних РК было видно для какой площадки. */
#camp-tip:has(.ils-tip-section + .ils-tip-section) .tip-head {
    position: sticky;
    top: -8px;
    margin: -8px -10px 4px;
    padding: 8px 10px 6px;
    background: #1a1a24;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    z-index: 1;
}

/* ---- donut ---- */
.donut-wrap {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 6px 0;
}
.donut {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    box-shadow: var(--shadow-card);
}
.donut-hole {
    position: absolute;
    inset: 22%;
    background: var(--bg-elev-1);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.donut-center {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-1);
}
.donut-sub {
    font-size: 9px;
    color: var(--ink-4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}
.legend {
    flex: 1;
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    max-height: 140px;
    overflow-y: auto;
}
.legend li {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-2);
}
.sw {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}
.lg-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-val {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--ink-1);
    font-size: 10px;
}

/* ---- inline SVG charts ---- */
.chart-svg {
    width: 100%;
    height: auto;
    display: block;
}
.chart-svg .gridline { stroke: var(--border-soft); stroke-dasharray: 2 3; }
.chart-svg .bar     { fill: url(#grad-primary); fill: #7839F2; opacity: 0.78; }
.chart-svg .axis-lbl {
    font-size: 9px;
    fill: var(--ink-4);
    font-family: var(--font-mono);
}
.legend-inline {
    display: flex;
    gap: 12px;
    font-size: 10px;
    color: var(--ink-3);
    padding-top: 4px;
}
.li-item { display: inline-flex; align-items: center; gap: 4px; }
.legend-inline .sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend-inline .li-sw-event {
    background: transparent;
    border-left: 2px dashed #FF7A5C;
    width: 2px;
    height: 12px;
    border-radius: 0;
    position: relative;
}
.legend-inline .li-sw-event::before {
    content: '';
    position: absolute;
    top: -2px; left: -3px;
    width: 6px; height: 6px;
    background: #FF7A5C;
    border-radius: 50%;
}

/* ---- daily chart interactivity (day + event hovers) ---- */
.chart-svg-interactive .day-hot { cursor: crosshair; }
.chart-svg-interactive .day-hot:hover rect { fill: rgba(120, 57, 242, 0.06); }
.chart-svg-interactive .event-line {
    stroke: #FF7A5C;
    stroke-width: 1.5;
    stroke-dasharray: 3 3;
    opacity: 0.85;
    pointer-events: none;
}
.chart-svg-interactive .event-dot {
    fill: #FF7A5C;
    stroke: #fff;
    stroke-width: 1.2;
    pointer-events: none;
}
.chart-svg-interactive .event-hot { cursor: help; }
.chart-svg-interactive .event-hot:hover rect { fill: rgba(255, 122, 92, 0.12); }
.widget-chart-dyn { min-height: 220px; }

/* Day/week mode toggle inside chart widget */
.sect-title-dyn { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chart-mode-toggle {
    display: inline-flex;
    background: var(--bg-elev-0);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    padding: 2px;
    gap: 2px;
}
.chart-mode-toggle .cmt-btn {
    border: 0;
    background: transparent;
    color: var(--ink-3);
    padding: 4px 12px;
    font-size: 11px;
    line-height: 1.2;
    border-radius: 999px;
    cursor: pointer;
    transition: background .12s, color .12s;
}
.chart-mode-toggle .cmt-btn:hover { color: var(--ink-1); }
.chart-mode-toggle .cmt-btn.is-active {
    background: var(--brand);
    color: #fff;
}
.chart-mode-pane[hidden] { display: none; }

/* ---- heatmap ---- */
.heat-scroll {
    max-height: 280px;
    overflow: auto;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
}
table.heat {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}
table.heat thead th {
    position: sticky;
    top: 0;
    background: var(--bg-inset);
    padding: 5px 6px;
    color: var(--ink-2);
    font-weight: 700;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    z-index: 2;
}
table.heat th:first-child {
    left: 0;
    z-index: 3;
    min-width: 120px;
}
table.heat td.hk {
    position: sticky;
    left: 0;
    background: var(--bg-elev-1);
    padding: 4px 8px;
    font-weight: 600;
    color: var(--ink-1);
    font-size: 11px;
    border-right: 1px solid var(--border-soft);
    white-space: nowrap;
    z-index: 1;
}
table.heat td.hc {
    padding: 4px 6px;
    text-align: center;
    font-family: var(--font-mono);
    color: var(--ink-1);
    border-bottom: 1px solid var(--border-soft);
    background:
        linear-gradient(rgba(120,57,242, calc(var(--int) * 0.32)),
                        rgba(120,57,242, calc(var(--int) * 0.32))),
        var(--bg-elev-1);
    white-space: nowrap;
}
table.heat td.hc:empty { color: transparent; }

/* ---- footer ---- */
.rep-foot {
    font-size: 10px;
    color: var(--ink-4);
    text-align: center;
    padding: 16px 0 8px;
    border-top: 1px solid var(--border-soft);
    margin-top: 18px;
}

.py-4 { padding-top: 16px; padding-bottom: 16px; }
.py-6 { padding-top: 22px; padding-bottom: 22px; }
.muted { color: var(--ink-4); font-size: 11px; text-align: center; }

/* ============ Ads widget ============ */
/* ads-фильтры — та же визуалка, что у кампаний */
.ads-filter-btn {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 5px 10px;
    font-size: 12px;
    color: var(--ink-2);
    cursor: pointer;
    border-right: 1px solid var(--border-soft);
    transition: background .12s, color .12s;
}
.ads-filter-btn:last-child { border-right: 0; }
.ads-filter-btn:hover { background: var(--brand-softer); }
.ads-filter-btn.is-active {
    background: var(--brand, #7839F2);
    color: #fff;
    font-weight: 600;
}

/* Колонки и высоты */
.dtbl-ads-left { table-layout: fixed; width: 100%; }
.dtbl-ads-left th.num,
.dtbl-ads-left td.num {
    width: 58px;
    white-space: nowrap;
}
.dtbl-ads-left.dtbl-2row thead tr.head-row-1 > th.num { width: 58px; }
.dtbl-ads-left.dtbl-2row thead tr.head-row-1 > th.slot-group-head { width: 174px; }
.dtbl-ads-left th.ad-img-col,
.dtbl-ads-left td.ad-img-col {
    width: 52px;
    padding-left: 8px;
    padding-right: 4px;
}
.dtbl-ads-left th.ad-act-col,
.dtbl-ads-left td.ad-act-col {
    width: 40px;
    text-align: center;
}
/* Та же высота строк, что у кампаний — чтобы sparkline точно попадал в ряд */
#ads-block .camps-body-row,
#ads-block .camps-body-row td { height: 42px; }

/* Миниатюра */
.ad-thumb {
    display: inline-block;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-inset, #ececf1);
    vertical-align: middle;
}
.ad-thumb-empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: var(--bg-inset, #ececf1);
    color: var(--ink-3);
    font-weight: 600;
    font-size: 12px;
    font-family: inherit;
}

/* Заголовок + подзаголовок (РК · группа) */
.ad-title-cell {
    max-width: 0;
    overflow: hidden;
}
.ad-title-main {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-1);
    font-size: 13px;
}
.ad-title-sub {
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Toggle-кнопка остановить/запустить */
.ad-toggle-btn {
    appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border-soft);
    background: var(--bg-elev-0);
    color: var(--ink-2);
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}
.ad-toggle-btn:hover { border-color: var(--brand, #7839F2); color: var(--brand, #7839F2); }
.ad-toggle-btn.is-on {
    background: var(--warn-soft, #fff4cc);
    color: var(--warn-ink, #8a6100);
    border-color: var(--warn-soft, #fff4cc);
}
.ad-toggle-btn.is-on:hover {
    background: var(--err-soft, #fde2e2);
    color: var(--err-ink, #a03030);
    border-color: var(--err-soft, #fde2e2);
}
.ad-toggle-btn:disabled { opacity: 0.5; cursor: wait; }

/* Row under table: «Показать все (N)» */
.ads-showall-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 2px 2px;
    border-top: 1px solid var(--border-soft);
    margin-top: 6px;
}

/* ---- MK (Master Campaigns) footer bar under ads table ---- */
.mk-footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 8px;
    padding: 7px 12px;
    background: var(--warn-soft);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.35;
    color: var(--ink-2);
    cursor: help;
}
.mk-footer-label {
    font-weight: 600;
    color: var(--warn-ink);
    white-space: nowrap;
}
.mk-footer-metrics {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}
.mk-footer-metrics > span { white-space: nowrap; }
.mk-footer-metrics .slot-head-pill {
    font-size: 9px;
    padding: 1px 5px;
    margin-right: 4px;
    vertical-align: 1px;
}

/* ---- Ad metric segment tooltip ---- */
.metric-cell { cursor: help; }
.metric-cell:hover { background: rgba(120, 57, 242, 0.06); }
.pl-metric-cell { cursor: help; transition: background 120ms; }
.pl-metric-cell:hover { background: rgba(120, 57, 242, 0.06); }

:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) {
    position: fixed;
    z-index: 10001;
    background: #1a1a24;
    color: #fff;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.45;
    box-shadow: 0 10px 28px rgba(10, 10, 20, 0.32);
    pointer-events: none;
    max-width: 640px;
    min-width: 360px;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip)[hidden] { display: none; }
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-tip-head {
    font-weight: 600;
    color: #C7B0F0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding-bottom: 5px;
    margin-bottom: 8px;
    font-size: 11px;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-tip-foot {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.45);
    font-size: 10px;
    text-align: right;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-tip-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
}
/* У pl-seg-tip до 7 колонок: «Иерархия» (Кампания / Группа / Объявление) +
   «Аудитория и таргетинг» (Гео / Пол / Возраст / Тип таргетинга). Делим на
   две зоны с подзаголовком, ключи не обрезаем — длинные имена кампаний/гео
   видны полностью (wrap до 2 строк). Топ-5 строк на колонку, полные данные —
   через клик по площадке (drill-down). */
#pl-seg-tip { max-width: min(1280px, 96vw); min-width: 880px; padding: 12px 14px; }
#pl-seg-tip .seg-zones {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#pl-seg-tip .seg-zone {
    background: rgba(120, 57, 242, 0.06);
    border: 1px solid rgba(184, 156, 238, 0.18);
    border-radius: 8px;
    padding: 8px 10px 9px;
}
#pl-seg-tip .seg-zone-title {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #B89CEE;
    margin-bottom: 6px;
    opacity: 0.9;
}
#pl-seg-tip .seg-zone-3 .seg-tip-grid { grid-template-columns: repeat(3, minmax(220px, 1fr)); }
#pl-seg-tip .seg-zone-4 .seg-tip-grid { grid-template-columns: repeat(4, minmax(200px, 1fr)); }
#pl-seg-tip .seg-tip-grid { gap: 4px 18px; }
#pl-seg-tip .seg-row { padding: 1px 0; }
#pl-seg-tip .seg-col-title { margin-bottom: 4px; }
#pl-seg-tip .seg-key {
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
    word-break: break-word;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-col {
    min-width: 0;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-col-title {
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    display: flex;
    justify-content: space-between;
    opacity: 0.85;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-col-count {
    font-weight: 400;
    opacity: 0.5;
    font-size: 10px;
    text-transform: none;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-row {
    display: grid;
    grid-template-columns: 1fr 42px 56px;
    align-items: center;
    gap: 6px;
    padding: 1px 0;
    min-width: 0;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-row-meta {
    grid-template-columns: 1fr 32px 52px 58px;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-meta {
    color: rgba(255, 255, 255, 0.45);
    font-size: 10px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-key {
    color: rgba(255, 255, 255, 0.78);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-bar > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #7839F2, #B89CEE);
    border-radius: 2px;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-val {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #fff;
    font-weight: 500;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-val-min { color: #F87171; }
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-val-max { color: #4ADE80; }
/* Текущее объявление в срезе «Объявления группы» — маркер + жирный ключ */
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-row-self .seg-key {
    color: #fff;
    font-weight: 600;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-row-self .seg-key::before {
    content: '▸ ';
    color: #B89CEE;
}
/* Срез «Объявления группы» занимает всю ширину — длинные заголовки не влезают в колонку */
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-col.seg-col-wide {
    grid-column: 1 / -1;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-col.seg-col-wide .seg-row {
    grid-template-columns: 1fr 80px 64px;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-col.seg-col-wide .seg-row-meta {
    grid-template-columns: 1fr 80px 60px 60px;
}
:is(#ad-seg-tip, #pl-seg-tip, #pl-aud-tip, #camp-seg-tip) .seg-thumb {
    width: 18px;
    height: 18px;
    object-fit: cover;
    border-radius: 2px;
    margin-right: 6px;
    vertical-align: middle;
    background: rgba(255, 255, 255, 0.08);
}

/* ---- Campaign-row segments tooltip (большой, fixed center, backdrop) ---- */
.camp-name-text.camp-seg-tip-trigger {
    cursor: help;
    border-bottom: 1px dotted rgba(120, 57, 242, 0.45);
}
.camp-name-text.camp-seg-tip-trigger:hover {
    color: #7839F2;
    border-bottom-color: #7839F2;
}

/* ===========================================================
   Placements widget (daily_report «Площадки РСЯ»)
   =========================================================== */
.pl-summary {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 8px 0 12px; align-items: center;
}
.pl-pill {
  height: 34px; padding: 0 14px; border-radius: 999px;
  background: #EDE1FF; color: #1B1330; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; line-height: 1;
}
.pl-pill b { font-weight: 700; }
.pl-pill-minus { background: #FCEBD2; color: #6E420B; }
.pl-pill-crit { background: #FBDDD7; color: #7A2518; }
.pl-pill-cov-ok   { background: #D8EFD3; color: #21471B; }
.pl-pill-cov-warn { background: #FCEBD2; color: #6E420B; }
.pl-pill-cov-bad  { background: #FBDDD7; color: #7A2518; }
.pl-pill-recomp { background: transparent; padding: 0; height: auto; }
.pl-pill-am { background: transparent; padding: 0; height: auto; gap: 6px; }

.pl-toolbar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px 14px; padding: 8px 0 14px;
  border-bottom: 1px solid #ECE3F7;
  margin-bottom: 10px;
  font-size: 13px;
}
.pl-toolbar .pl-search {
  flex: 0 0 260px;
  padding: 6px 12px; font-size: 13px;
  border: 1px solid #DCCEF0; border-radius: 999px;
  background: #FFF; color: #1B1330;
}
.pl-toolbar .pl-search:focus { outline: 2px solid #B89CEE; border-color: #B89CEE; }
.pl-toolbar .pl-chk,
.pl-toolbar .pl-num {
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; color: #453866; cursor: pointer;
  font-size: 13px;
}
.pl-toolbar .pl-num { color: #7A6D95; font-size: 12px; cursor: default; }
.pl-toolbar input[type="checkbox"] { accent-color: #7839F2; margin: 0; }
.pl-toolbar .pl-num input[type="number"],
.pl-toolbar .pl-num select {
  width: 96px; padding: 4px 8px; font-size: 13px;
  border: 1px solid #DCCEF0; border-radius: 8px;
  background: #FFF; color: #1B1330;
}
.pl-toolbar .pl-num input[type="number"] { width: 84px; }
.pl-toolbar .pl-hint {
  font-size: 11px; color: #7A6D95;
  font-style: italic;
}

/* Строка с чипами-паттернами под тулбаром */
.pl-patterns {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 6px 8px;
  margin: 4px 0 6px 0;
  padding: 4px 0;
}
.pl-patterns-label {
  font-size: 11px; color: #7A6D95; font-weight: 600;
  margin-right: 4px;
}
.pl-pat {
  border: 1px solid #DCCEF0;
  background: #FFFFFF;
  color: #3B2F5A;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
}
.pl-pat:hover { background: #F6EFFE; border-color: #B89CE7; }
.pl-pat.is-active {
  background: #7839F2;
  border-color: #7839F2;
  color: #FFFFFF;
}
.pl-pat-adv-toggle {
  border: 1px dashed #B89CE7;
  background: transparent;
  color: #7839F2;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  margin-left: 8px;
}
.pl-pat-adv-toggle:hover { background: #F6EFFE; }

/* Панель тонкой настройки: 4 числовых поля + reset. По умолчанию скрыта. */
.pl-adv {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 10px 14px;
  padding: 8px 10px;
  margin: 0 0 8px 0;
  border: 1px solid #E3D7F5;
  border-radius: 8px;
  background: #FAF6FE;
}
.pl-adv[hidden] { display: none; }
.pl-adv .pl-num { font-size: 12px; color: #4B3A7A; }
.pl-adv input[type="number"] {
  width: 84px;
  padding: 3px 6px;
  border: 1px solid #DCCEF0;
  border-radius: 4px;
  font-size: 12px;
  background: #fff;
}
.pl-adv input[type="number"]:focus {
  outline: 2px solid #B89CEE;
  border-color: #B89CEE;
}
/* Компактный select оператора (≥/≤) рядом с input'ом фильтра */
.pl-adv .pl-adv-op {
  border: 1px solid #DCCEF0;
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
  padding: 2px 2px;
  margin: 0 2px;
  cursor: pointer;
  font-weight: 700;
  color: #4B3A7A;
  vertical-align: middle;
}
.pl-adv .pl-adv-op:focus {
  outline: 2px solid #B89CEE;
  border-color: #B89CEE;
}
.pl-adv .pl-num {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.pl-tbl th.sortable { cursor: pointer; user-select: none; }
.pl-tbl th.sortable:hover { background: #EDDCFC; }

.pl-tbl { font-size: 12px; width: 100%; table-layout: fixed; }
.pl-tbl th, .pl-tbl td { padding: 3px 7px; line-height: 1.25; }
.pl-tbl .pl-chk-col { width: 24px; text-align: center; padding: 3px 3px; }
.pl-tbl .pl-act-col { width: 72px; text-align: center; }
.pl-tbl thead tr.head-row-1 > th.num { width: 76px; }
.pl-tbl thead tr.head-row-1 > th.slot-group-head { width: 180px; }
.pl-tbl tr.pl-row td { padding-top: 2px; padding-bottom: 2px; }
/* Длинная таблица площадок: внутренний скролл с залипающей шапкой.
   max-height задаёт «окно» в которое вмещается thead+часть строк; thead
   sticky внутри этого окна. Страница вокруг скроллится отдельно — она
   короткая, потому что таблица не вырастает в высоту. */
/* ===== 📋 Сводка дня — расширенные cards: subjects + breakdown ===== */
.diag-baseline-row {
    margin-top: 6px;
    font-size: 11px;
    color: var(--ink-2, #555);
    display: flex; flex-wrap: wrap; gap: 12px;
}
.diag-baseline-row b { color: var(--ink-1); }
.diag-base { color: var(--ink-3, #999); }

.diag-subjects-label {
    margin-top: 8px; font-size: 11px; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
}
.diag-subjects {
    margin: 4px 0 0 0; padding-left: 16px;
    font-size: 12px; color: var(--ink-2);
}
.diag-subjects li { margin: 2px 0; }
.diag-subjects b { color: var(--ink-1); }

.diag-breakdown {
    margin-top: 8px; border-collapse: collapse; font-size: 11px;
    background: var(--elev-0, #fff); border-radius: 6px;
    width: 100%;
}
.diag-breakdown td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-soft, #ECE4F7);
}
.diag-breakdown tr.diag-tr-total td {
    background: var(--bg-inset, #FBF7FF); font-size: 12px;
}
.diag-bad { color: #c33; font-weight: 600; }
.diag-good { color: #3a7; font-weight: 600; }

/* ===== 📋 Сводка дня — pill на карточке клиента (dashboard.html) ===== */
.diag-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 999px;
    background: var(--bg-inset, #FBF7FF);
    border: 1px solid var(--border-soft, #ECE4F7);
    font-size: 11px; font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}
.diag-pill:hover {
    background: var(--brand-soft, #F2E8FB);
    border-color: var(--brand, #9b6dd8);
}
.diag-pill .diag-c { color: #d33; }
.diag-pill .diag-w { color: #b87830; }
.diag-pill .diag-i { color: #4a7a8e; }
/* Slot для cards раскрывается под header'ом карточки клиента — занимает
   всю ширину карточки, не ломает grid. */
.diag-cards-slot {
    display: grid; gap: 8px;
    padding: 12px 16px;
    background: var(--bg-inset, #FBF7FF);
    border-top: 1px solid var(--border-soft, #ECE4F7);
}
.diag-cards-slot[hidden] { display: none; }

/* ===== 📋 Сводка дня (daily_diagnose) ===== */
.diagnose-strip {
    margin: 0 0 16px 0;
    padding: 12px 16px;
    background: var(--bg-inset, #FBF7FF);
    border-radius: 10px;
    border: 1px solid var(--border-soft, #ECE4F7);
}
.diagnose-strip[hidden] { display: none; }
.diagnose-head {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 10px;
}
.diagnose-title { font-weight: 700; font-size: 14px; color: var(--ink-1); }
.diagnose-meta { font-size: 12px; color: var(--ink-3); }
.diagnose-cards { display: grid; gap: 8px; }
.diagnose-card {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    align-items: start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: white;
    border: 1px solid var(--border-soft, #ECE4F7);
}
.diagnose-card.sev-crit { border-left: 4px solid #d33; }
.diagnose-card.sev-warn { border-left: 4px solid #e8a13a; }
.diagnose-card.sev-info { border-left: 4px solid #5ab; }
.diagnose-card-sev {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em;
    padding: 3px 6px; border-radius: 4px;
    text-align: center;
}
.diagnose-card.sev-crit .diagnose-card-sev { background: #fde6e6; color: #c33; }
.diagnose-card.sev-warn .diagnose-card-sev { background: #fdf3e1; color: #b87830; }
.diagnose-card.sev-info .diagnose-card-sev { background: #e6f1f6; color: #4a7a8e; }
.diagnose-card-body { min-width: 0; }
.diagnose-card-title { font-weight: 600; font-size: 13px; line-height: 1.3; }
.diagnose-card-expl { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.diagnose-card-meta {
    font-size: 11px; color: var(--ink-3); margin-top: 4px;
    display: flex; gap: 12px;
}
.diagnose-card-actions {
    display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
    justify-content: flex-end;
}
.diagnose-card-actions .btn { white-space: nowrap; }

/* Каскадные дочерние карточки (children в дереве): меньше визуального
 * веса, отступ слева как маркер иерархии. */
.diagnose-children {
    margin-left: 24px;
    border-left: 2px dashed var(--border-soft, #ECE4F7);
    padding-left: 12px;
    display: grid; gap: 6px;
    margin-top: -2px;  /* поджимает к родителю */
}
.diagnose-card.diagnose-child {
    grid-template-columns: 60px 1fr auto;
    padding: 6px 10px;
    background: #FAF8FE;
}
.diagnose-card.diagnose-child .diagnose-card-title { font-size: 12px; }
.diagnose-card.diagnose-child .diagnose-card-expl { display: none; }

/* Sections — компактная полоска cross-link'ов под carda. */
.diag-sections {
    margin-top: 6px;
    display: flex; flex-wrap: wrap; gap: 4px;
    font-size: 11px;
}
.diag-sec {
    padding: 2px 8px; border-radius: 10px;
    background: #F4EEFC; color: var(--ink-2);
}
.diag-sec-found { background: #fff0e3; color: #b87830; }
.diag-sec-empty { opacity: 0.55; }
.diag-sec-kb {
    margin-left: 4px;
    color: #6b46c1;
    text-decoration: none;
    font-weight: 600;
}
.diag-sec-kb:hover { text-decoration: underline; }

.diag-empty {
    padding: 12px; text-align: center;
    color: var(--ink-3); font-style: italic;
    background: #FAF8FE; border-radius: 6px;
}

/* Период-ярлык — сразу под заголовком, чтобы спец видел с чем сравнение */
.narr-period {
    display: inline-block;
    margin: 4px 0 6px 0;
    padding: 2px 8px;
    border-radius: 4px;
    background: #F4EEFC; color: var(--ink-2);
    font-size: 11px; font-weight: 500;
    letter-spacing: 0.02em;
}
.narr-kb-icon {
    display: inline-block;
    width: 16px; height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 50%;
    background: #6b46c1; color: white;
    font-style: italic; font-weight: 700;
    font-size: 11px;
    margin-right: 2px;
}

/* === Narrative-блоки (новый формат: что произошло / что делать) === */
.narr-block {
    margin-top: 10px;
    font-size: 13px; line-height: 1.5;
}
.narr-label {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--ink-3); margin-bottom: 4px;
}
.narr-block p { margin: 0; }
.narr-block ul {
    margin: 0; padding-left: 18px;
    list-style-type: '— ';
}
.narr-block li { margin: 2px 0; }
.narr-why {
    background: #FAF6FE;
    padding: 8px 12px; border-radius: 6px;
    border-left: 3px solid #8b5fbf;
}
.narr-noaction {
    background: #fef4ed;
    padding: 8px 12px; border-radius: 6px;
    border-left: 3px solid #e8a13a;
    color: #6b4516;
    font-style: italic;
}
.narr-todos {
    list-style: none !important; padding-left: 0 !important;
}
.narr-todos li {
    display: flex; gap: 10px;
    padding: 8px 12px; margin: 4px 0;
    background: white;
    border: 1px solid var(--border-soft, #ECE4F7);
    border-radius: 6px;
}
.narr-todo-act_now {
    border-left: 3px solid #d33 !important;
    background: #fff5f5 !important;
}
.narr-todo-wait {
    border-left: 3px solid #5ab !important;
    background: #f0f7fa !important;
}
.narr-todo-check {
    border-left: 3px solid #8b5fbf !important;
}
.narr-todo-kind {
    flex: 0 0 auto;
    font-size: 18px;
    line-height: 1.2;
}
.narr-todo-body { flex: 1 1 auto; min-width: 0; }
.narr-todo-text { font-size: 13px; }
.narr-todo-text b { font-weight: 600; }
.narr-todo-why {
    font-size: 12px; color: var(--ink-2);
    margin-top: 2px;
}
.narr-todo-link {
    margin-left: 6px;
    font-size: 11px; color: #6b46c1;
    text-decoration: none;
}
.narr-todo-link:hover { text-decoration: underline; }

/* Маркеры streak и triggered_via — рядом с title как badge. */
.diag-streak {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 6px;
    border-radius: 4px;
    background: #fff0e3; color: #b87830;
    font-size: 10px; font-weight: 600;
}
.diag-streak-chronic {
    background: #fde6e6; color: #c33;
    border: 1px solid #d33;
    animation: pulse-chronic 2s ease-in-out infinite;
}
@keyframes pulse-chronic {
    0%, 100% { box-shadow: 0 0 0 0 rgba(211, 51, 51, 0.4); }
    50%      { box-shadow: 0 0 0 4px rgba(211, 51, 51, 0); }
}
.diag-trigger {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    background: #F4EEFC; color: var(--ink-3);
    font-size: 10px;
}

/* KB-модалка — overlay поверх всего. */
.kb-modal {
    position: fixed; inset: 0; z-index: 9999;
}
.kb-modal[hidden] { display: none; }
.kb-modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(20, 12, 30, 0.55);
}
.kb-modal-window {
    position: absolute;
    top: 4vh; right: 4vw; bottom: 4vh; width: min(720px, 92vw);
    background: white; border-radius: 12px;
    overflow: auto;
    padding: 24px 28px;
    box-shadow: 0 20px 60px rgba(20, 12, 40, 0.35);
}
.kb-modal-close {
    position: absolute; top: 12px; right: 14px;
    width: 28px; height: 28px;
    border: none; background: transparent;
    font-size: 22px; cursor: pointer; color: var(--ink-3);
}
.kb-modal-close:hover { color: var(--ink-1); }
.kb-modal-content h2 {
    font-size: 18px; margin: 0 0 4px 0;
    color: var(--ink-1);
}
.kb-modal-content h3 {
    font-size: 13px;
    margin: 16px 0 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-2);
}
.kb-modal-content .kb-meta {
    font-size: 11px; color: var(--ink-3); margin-bottom: 8px;
}
.kb-modal-content .kb-desc {
    font-size: 13px; color: var(--ink-2); line-height: 1.5;
    background: #FAF6FE; padding: 8px 12px; border-radius: 6px;
}
.kb-modal-content ul {
    margin: 0; padding-left: 20px;
    font-size: 13px; line-height: 1.5;
}
.kb-modal-content ul.kb-numbered { list-style: decimal; }
.kb-modal-content li { margin: 3px 0; }
.kb-modal-content code {
    background: #F4EEFC; padding: 1px 5px; border-radius: 3px;
    font-size: 11px;
}
.kb-related {
    display: flex; flex-direction: column; gap: 4px;
    font-size: 12px;
}
.kb-related-link {
    color: #6b46c1; text-decoration: none;
    padding: 4px 8px;
    background: #FAF6FE;
    border-radius: 6px;
}
.kb-related-link:hover { background: #F4EEFC; }

.pl-widget .tbl-scroll,
.geo-widget .tbl-scroll {
    max-height: calc(100vh - 280px);
    min-height: 480px;
}
/* Ширины служебных колонок гео — те же что у площадок (pl-tbl).
   pl-act-col увеличен до 88px чтобы вместить «⊟ минус». */
.geo-widget .pl-tbl .pl-act-col { width: 88px; }
.geo-widget .pl-tbl tbody tr:hover { background: #FAF6FE; cursor: default; }
/* Компактная кнопка «минус/снять» в ряду */
.pl-tbl .pl-act-col .btn-sm { padding: 2px 8px; font-size: 11px; }
.pl-tbl .pl-host { font-size: 12px; }
.pl-tbl .pl-score { font-size: 11px; }
.pl-row[hidden] { display: none !important; }
.pl-tbl tr.pl-row:hover { background: #FAF6FE; cursor: default; }

.pl-host-cell { white-space: nowrap; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.pl-host { font-family: "JetBrains Mono", monospace; font-size: 12.5px; }
.pl-flag {
  display: inline-block; padding: 0 6px; margin-left: 6px;
  font-size: 11px; border-radius: 6px;
  background: #F6EFFE; color: #453866;
  vertical-align: middle;
}
.pl-flag-dsp { background: #DDE7F8; color: #203F7E; font-weight: 600; }
.pl-flag-wl { background: #DDF3E8; color: #0E5A3F; font-weight: 600; }
/* Cross-account ц1: площадка приносит конверсии в других кабинетах. */
.pl-flag-xa { background: #FFF1D6; color: #6E420B; font-weight: 700; cursor: help; }

.pl-xa-sort {
  display: inline-flex; align-items: center; gap: 2px;
  margin-left: 6px; padding: 1px 6px; border-radius: 999px;
  background: #FFF1D6; color: #6E420B; font-weight: 700;
  cursor: pointer; user-select: none; font-size: 11px;
  vertical-align: middle; line-height: 1.4;
}
.pl-xa-sort:hover { background: #FFE4B5; }
.pl-xa-sort .sort-ind { color: currentColor; }

.pl-pill-mini {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; margin-left: 6px;
}
.pl-pill-mini.pl-minus { background: #FCEBD2; color: #6E420B; }
.pl-pill-mini.pl-minus-partial { background: #E9DFF7; color: #3E2C6B; }
.pl-pill-mini.pl-nok { background: #FBDDD7; color: #7A2518; }
.pl-pill-mini.pl-common { background: #DDE7F8; color: #203F7E; }

/* Знак вопроса на шапке колонок, где есть памятка.
   cursor: help только на самом "?", иначе стрелка сортировки триггерит тултип. */
.pl-hint-mark {
  display: inline-block;
  width: 14px; height: 14px; line-height: 14px;
  margin-left: 3px;
  font-size: 10px; font-weight: 700;
  text-align: center; border-radius: 50%;
  background: #DCCEF0; color: #4B3A7A;
  vertical-align: middle;
  cursor: help;
  /* Увеличенная hit-area без визуального разрастания.
     Padding + box-shadow trick держит визуал 14×14, но hover ловит 22×22. */
  position: relative;
  box-sizing: content-box;
}
.pl-hint-mark::after {
  content: '';
  position: absolute;
  inset: -5px;  /* +5px со всех сторон → ~24×24 hit-area */
}
.pl-hint-mark:hover { background: #B89CE7; color: #fff; }

/* Памятка на шапку колонки — НЕ переиспользуем #camp-tip (там nowrap и компактные row/kv).
   Отдельный поповер, который красиво сам переносит строки. */
#pl-hint-tip {
  position: fixed;
  z-index: 10001;
  background: #1A1430;
  color: #F1E7FA;
  padding: 12px 14px 10px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 10px 28px rgba(10, 10, 20, 0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity .1s ease;
  max-width: 380px;
  min-width: 260px;
  white-space: normal;
  word-wrap: break-word;
}
#pl-hint-tip[data-show="1"] { opacity: 1; }
#pl-hint-tip .hint-head {
  font-weight: 700;
  color: #C9A7FB;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  padding-bottom: 6px;
  margin-bottom: 8px;
  font-size: 13px;
}
#pl-hint-tip .hint-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px 12px;
  padding: 2px 0;
}
#pl-hint-tip .hint-row b {
  color: rgba(255,255,255,0.55);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
#pl-hint-tip .hint-row span { color: #F1E7FA; }
#pl-hint-tip .hint-plain { padding: 2px 0; }
#pl-hint-tip .hint-formula {
  font-family: var(--font-mono);
  background: rgba(255,255,255,0.06);
  padding: 4px 6px;
  border-radius: 4px;
  margin: 4px 0;
  font-size: 11px;
}

.pl-score-cell { width: 120px; }
.pl-score {
  display: inline-flex; align-items: center; gap: 8px;
  width: 100px; justify-content: flex-end;
}
.pl-score-bar {
  position: relative; flex: 1;
  height: 6px; border-radius: 3px;
  background: #ECE3F7; overflow: hidden;
}
.pl-score-bar i {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--w, 0%);
  background: currentColor; opacity: .85;
  border-radius: 3px; display: block;
}
.pl-score-num { font-weight: 700; min-width: 18px; text-align: right; }
.pl-score-ok { color: #1F9D6F; }
.pl-score-warn { color: #C77A18; }
.pl-score-crit { color: #D94A3A; }
.pl-burn-sub {
  display: block;
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
  line-height: 1.2;
  text-align: right;
}

.pl-batch-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-top: 10px;
  border-radius: 12px; background: #F6EFFE;
  position: sticky; bottom: 12px; z-index: 5;
  box-shadow: 0 4px 14px rgba(120,57,242,0.12);
}
.pl-batch-bar[hidden] { display: none; }
.pl-batch-count { color: #1B1330; }
.pl-batch-bar .btn-solid { margin-left: auto; }

/* Модалка минусации */
.pl-dlg[hidden] { display: none; }
.pl-dlg {
  position: fixed; inset: 0; z-index: 9998;
  display: flex; align-items: center; justify-content: center;
}
.pl-dlg-backdrop {
  position: absolute; inset: 0;
  background: rgba(10,10,20,0.45);
}
.pl-dlg-card {
  position: relative;
  width: min(640px, 92vw); max-height: 86vh;
  display: flex; flex-direction: column;
  background: #FFF; border-radius: 16px;
  box-shadow: 0 24px 64px -16px rgba(10,10,20,0.35);
  overflow: hidden;
}
.pl-dlg-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid #ECE3F7;
}
.pl-dlg-title { margin: 0; font-size: 16px; color: #1B1330; }
.pl-dlg-close {
  background: transparent; border: 0; font-size: 24px; cursor: pointer;
  color: #7A6D95; line-height: 1; padding: 0 4px;
}
.pl-dlg-body {
  padding: 14px 18px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.pl-dlg-hosts-title, .pl-dlg-scope-title { font-size: 12px; color: #7A6D95; margin-bottom: 4px; }
.pl-dlg-hosts-list {
  max-height: 180px; overflow-y: auto;
  background: #FAF6FE; border: 1px solid #ECE3F7; border-radius: 10px;
  padding: 8px 10px; font-family: "JetBrains Mono", monospace; font-size: 12px;
  color: #453866; white-space: pre-wrap;
}
.pl-dlg-scope label {
  display: block; padding: 4px 0; font-size: 13px; color: #1B1330; cursor: pointer;
}
.pl-dlg-scope label input { accent-color: #7839F2; margin-right: 8px; }
.pl-dlg-camps {
  margin: 6px 0 0 24px;
  max-height: 180px; overflow-y: auto;
  background: #FAF6FE; border: 1px solid #ECE3F7; border-radius: 10px;
  padding: 6px 10px;
}
.pl-dlg-camps label { padding: 2px 0; font-size: 12.5px; }
.pl-dlg-preview { font-size: 12px; color: #7A6D95; min-height: 16px; }
.pl-dlg-preview.is-warn { color: #C77A18; }
.pl-dlg-preview.is-ok { color: #1F9D6F; }

.pl-dlg-mc-notice[hidden] { display: none; }
.pl-dlg-mc-notice {
  margin: 6px 0 0 0;
  padding: 8px 12px;
  background: #FCEBD2; color: #6E420B;
  border-radius: 8px;
  font-size: 12px; line-height: 1.45;
}
.pl-dlg-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 18px; border-top: 1px solid #ECE3F7;
}

/* ---- Phase 2A: toggle ON/OFF на строке кампании + undo-banner ---- */
.btn-camp-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 18px;
  margin-left: 6px; padding: 0;
  border: 1px solid var(--ink-4, #d6cce8); border-radius: 6px;
  background: var(--bg-elev-1, #fff); color: var(--ink-2, #4a3a6b);
  font-size: 10px; line-height: 1; cursor: pointer;
  vertical-align: middle;
  transition: background 0.12s, border-color 0.12s;
}
.btn-camp-toggle:hover {
  background: var(--bg-inset, #f3eefb);
  border-color: var(--brand, #7839F2);
}
.btn-camp-toggle.btn-camp-suspend { color: var(--warn-ink, #8a6100); }
.btn-camp-toggle.btn-camp-suspend:hover { background: var(--warn-soft, #fff4cc); }
.btn-camp-toggle.btn-camp-resume { color: var(--ok-ink, #1F7A4D); }
.btn-camp-toggle.btn-camp-resume:hover { background: var(--ok-soft, #d8f4e6); }
.btn-camp-toggle.btn-camp-strat { color: var(--ink-2); font-size: 11px; }
.btn-camp-toggle.btn-camp-strat:hover { background: var(--bg-inset); border-color: var(--brand, #7839F2); }
.btn-camp-toggle:disabled {
  opacity: 0.55; cursor: progress;
}

/* === Strategy editor modal === */
.strat-dlg {
  width: 560px; max-width: 92vw; max-height: 86vh;
  padding: 0; border: 1px solid var(--border-soft, #d6cce8); border-radius: 12px;
  background: var(--bg-elev-0, #fff); color: var(--ink-1);
  box-shadow: 0 20px 50px rgba(40, 20, 80, 0.18);
  overflow: hidden;
}
.strat-dlg::backdrop { background: rgba(20, 10, 40, 0.35); }
.strat-dlg-head {
  position: relative;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border-soft, #ece4f5);
  background: var(--bg-elev-1, #faf6ff);
}
.strat-dlg-title { font-size: 14px; font-weight: 600; color: var(--ink-1); }
.strat-dlg-sub   { margin-top: 2px; font-size: 11px; color: var(--ink-3); }
.strat-dlg-close {
  position: absolute; top: 10px; right: 10px;
  width: 26px; height: 26px; padding: 0;
  border: none; background: transparent;
  color: var(--ink-3); font-size: 18px; line-height: 1; cursor: pointer;
}
.strat-dlg-close:hover { color: var(--ink-1); }
.strat-dlg-body {
  max-height: calc(86vh - 130px); overflow-y: auto;
  padding: 14px 18px;
}
.strat-dlg-loading { color: var(--ink-3); padding: 20px 0; text-align: center; font-size: 12px; }
.strat-dlg-row {
  display: grid; grid-template-columns: 24px 150px 1fr; gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border-soft, #ece4f5);
}
.strat-dlg-row:last-child { border-bottom: none; }
.strat-risk-dot {
  width: 10px; height: 10px; border-radius: 50%;
  justify-self: center;
}
.strat-risk-dot.low  { background: var(--ok, #34c47e); }
.strat-risk-dot.med  { background: var(--warn, #f0b13a); }
.strat-risk-dot.high { background: var(--err, #e25f4f); }
.strat-row-label { font-size: 12px; color: var(--ink-2); }
.strat-row-control { display: flex; align-items: center; gap: 8px; }
.strat-row-control input[type=number],
.strat-row-control input[type=text],
.strat-row-control select {
  flex: 1 1 auto; min-width: 0;
  padding: 5px 8px; border: 1px solid var(--border-soft, #d6cce8);
  border-radius: 6px;
  background: var(--bg-elev-0, #fff); color: var(--ink-1);
  font-size: 12px; font-family: var(--font-sans, inherit);
}
.strat-row-control input[type=number]:focus,
.strat-row-control select:focus {
  outline: none; border-color: var(--brand, #7839F2);
}
.strat-row-suffix { font-size: 11px; color: var(--ink-3); }
.strat-row-warn {
  margin-top: 4px; grid-column: 2 / -1;
  font-size: 11px; color: var(--err-ink, #7A2518);
}
.strat-row-warn.med { color: var(--warn-ink, #8a6100); }
.strat-row-warn.low { display: none; }
.strat-row-readonly {
  font-size: 12px; color: var(--ink-3);
  padding: 5px 8px;
}
.strat-row-readonly::before { content: "🔒 "; }
.strat-goal-row {
  display: grid; grid-template-columns: 1fr 100px auto; gap: 8px;
  align-items: center;
}
.strat-row-readonly-mini {
  grid-column: 2 / -1;
  font-size: 11px; color: var(--ink-3);
  white-space: nowrap;
}
.strat-goals-hint {
  font-size: 10.5px; color: var(--ink-3);
  padding-top: 2px;
}
.strat-goals-hint a {
  color: var(--brand, #7839F2); text-decoration: underline;
}
.strat-metrics-bar {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px;
  padding: 8px 10px; margin: -4px 0 10px;
  background: var(--bg-inset, #f3eefb);
  border: 1px solid var(--border-soft, #ece4f5);
  border-radius: 8px;
  font-size: 11px;
}
.strat-metrics-period {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--ink-3);
}
.strat-metric { display: inline-flex; align-items: baseline; gap: 6px; }
.strat-metric-label { color: var(--ink-3); white-space: nowrap; }
.strat-metric b { color: var(--ink-1); font-weight: 600; white-space: nowrap; }

/* === РНП-таблица (главный дашборд) — наследует .dtbl стиль === */
.rnp-wrap {
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--bg-elev-0);
    margin-top: 8px;
    overflow: hidden;
}
.rnp-wrap .rnp-loading {
    padding: 16px; color: var(--ink-3); font-size: 11.5px;
    text-align: center;
}
.rnp-summary {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 8px 12px;
    background: var(--bg-elev-1);
    border-bottom: 1px solid var(--border-soft);
}
.rnp-sum-pill {
    display: inline-flex; align-items: baseline; gap: 6px;
    padding: 3px 10px;
    background: var(--bg-elev-0);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 11px;
    white-space: nowrap;
}
.rnp-sum-lbl {
    text-transform: uppercase; letter-spacing: 0.02em;
    font-size: 9.5px; font-weight: 700;
    color: var(--ink-3);
}
.rnp-sum-val { color: var(--ink-1); font-weight: 700; }
.rnp-scroll { overflow-x: auto; }
.rnp-grid {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    font-family: var(--font-mono);
}
.rnp-grid thead th {
    position: sticky; top: 0;
    background: var(--bg-inset);
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 10px;
    padding: 4px 6px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-bottom: 1px solid var(--border-hard);
    white-space: nowrap;
    z-index: 2;
    min-width: 56px;
}
.rnp-grid thead th.rnp-th-label {
    position: sticky; left: 0; z-index: 3;
    text-align: left;
    min-width: 160px;
    background: var(--bg-inset);
    color: var(--ink-2);
    padding-left: 12px;
}
.rnp-grid tbody td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--ink-1);
    white-space: nowrap;
    text-align: right;
    min-width: 56px;
}
.rnp-grid tbody td.rnp-cell-label {
    position: sticky; left: 0; z-index: 1;
    text-align: left;
    color: var(--ink-2);
    background: var(--bg-elev-1);
    font-family: var(--font-sans, inherit);
    font-weight: 600;
    padding-left: 12px;
    font-size: 11px;
    border-right: 1px solid var(--border-soft);
    min-width: 160px;
}
.rnp-grid tbody tr:nth-child(even) td:not(.rnp-cell-label) { background: var(--bg-elev-0); }
.rnp-grid tbody tr:hover td:not(.rnp-cell-label) { background: var(--brand-softer); }
.rnp-grid td.rnp-empty { color: var(--ink-4); }

/* Свёрнутая недельная колонка */
.rnp-grid thead th.rnp-th-week-collapsed {
    background: var(--bg-elev-1);
    border-left: 1px solid var(--border-hard);
    border-right: 1px solid var(--border-hard);
    min-width: 96px;
    cursor: default;
}
.rnp-grid tbody td.rnp-cell-week {
    border-left: 1px solid var(--border-hard);
    border-right: 1px solid var(--border-hard);
    font-weight: 600;
    min-width: 96px;
}
/* Развёрнутая неделя — лёгкая окантовка её первого дня */
.rnp-grid thead th.rnp-th-week-first,
.rnp-grid tbody td.rnp-cell-week-first {
    border-left: 1px solid var(--border-hard);
}
.rnp-week-toggle {
    display: inline-block;
    width: 16px; height: 16px; line-height: 14px;
    margin-right: 4px;
    padding: 0;
    border: 1px solid var(--border-hard);
    border-radius: 4px;
    background: var(--bg-elev-0);
    color: var(--ink-1);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    vertical-align: middle;
}
.rnp-week-toggle:hover {
    background: var(--brand-softer);
    border-color: var(--brand);
    color: var(--brand);
}

/* === Кликабельные ячейки + панель диагноза === */
.rnp-grid td.rnp-cell-clickable { cursor: pointer; transition: outline 0.1s; }
.rnp-grid td.rnp-cell-clickable:hover { outline: 2px solid var(--brand); outline-offset: -2px; }

.rnp-diag-panel {
    margin: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--bg-elev-1);
}
.rnp-diag-panel-inner { padding: 14px; }
.rnp-diag-loading {
    padding: 14px;
    color: var(--ink-3);
    font-size: 12px;
    text-align: center;
}
.rnp-diag-header {
    font-weight: 700;
    font-size: 13px;
    color: var(--ink-1);
    margin-bottom: 10px;
}
.rnp-diag-verdict {
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 12px;
}
.rnp-diag-verdict-red    { background: var(--err-soft); color: var(--err-ink); }
.rnp-diag-verdict-yellow { background: var(--warn-soft); color: var(--warn-ink); }
.rnp-diag-verdict-green  { background: var(--ok-soft); color: var(--ok-ink); }
.rnp-diag-verdict-grey   { background: var(--bg-elev-0); color: var(--ink-2); }

.rnp-diag-decomp {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--bg-elev-0);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-2);
}
.rnp-diag-decomp b { color: var(--ink-1); }

.rnp-diag-lines { display: flex; flex-direction: column; gap: 8px; }
.rnp-diag-line {
    padding: 10px 12px;
    border-left: 3px solid var(--border-soft);
    background: var(--bg-elev-0);
    border-radius: 0 6px 6px 0;
}
.rnp-diag-fact {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-1);
    margin-bottom: 6px;
}
.rnp-diag-rec {
    font-weight: 700;
    font-size: 12.5px;
    margin-bottom: 4px;
}
.rnp-diag-action-red    { color: var(--err-ink); }
.rnp-diag-action-yellow { color: var(--warn-ink); }
.rnp-diag-action-green  { color: var(--ok-ink); }
.rnp-diag-action-grey   { color: var(--ink-3); }
.rnp-diag-conf {
    font-weight: 400;
    color: var(--ink-3);
    font-size: 11px;
    margin-left: 8px;
}
.rnp-diag-expl summary {
    cursor: pointer;
    color: var(--ink-3);
    font-size: 11px;
    padding: 2px 0;
}
.rnp-diag-expl summary:hover { color: var(--brand); }
.rnp-diag-expl div {
    margin-top: 4px;
    padding: 6px 0;
    font-size: 11.5px;
    color: var(--ink-2);
    line-height: 1.5;
}

/* === Структурированный отчёт v3 === */
.rnp-diag-header-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 6px;
}
.rnp-diag-date { font-weight: 700; font-size: 13px; color: var(--ink-1); }
.rnp-diag-sev-badge {
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.02em;
}
.rnp-diag-sev-urgent { background: var(--err-soft); color: var(--err-ink); }
.rnp-diag-sev-act    { background: var(--warn-soft); color: var(--warn-ink); }
.rnp-diag-sev-watch  { background: var(--info-soft, #DBEAFE); color: var(--info-ink, #1E40AF); }
.rnp-diag-sev-noise  { background: var(--bg-elev-0); color: var(--ink-3); }
/* Streak-бейдж: одиночное событие vs системный паттерн. Показывается рядом
   с severity-бейджем в шапке диагноза. */
.rnp-diag-streak-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.01em;
    margin-left: 6px;
}
/* Utility-классы для подсветки ячеек/строк по статусу (используется в
   tbl_hourly и где ещё нужна inline-подсветка без отдельного row-класса). */
.bg-err-soft  { background: var(--err-soft) !important;  }
.bg-warn-soft { background: var(--warn-soft) !important; }
.bg-ok-soft   { background: var(--ok-soft) !important;   }
.text-err-ink  { color: var(--err-ink) !important;  }
.text-warn-ink { color: var(--warn-ink) !important; }
.text-ok-ink   { color: var(--ok-ink) !important;   }

/* Row-уровневая подсветка строк таблиц для часов / других overview-таблиц.
   Фон мягкий — чтобы не перебивать читаемость, но взгляд цеплял. */
tr.rnp-row-crit > td { background: var(--err-soft);  }
tr.rnp-row-warn > td { background: var(--warn-soft); }
tr.rnp-row-good > td { background: var(--ok-soft);   }
tr.rnp-row-crit > td.k::before { content: "🔴 "; }
tr.rnp-row-warn > td.k::before { content: "🟡 "; }
tr.rnp-row-good > td.k::before { content: "🟢 "; }

.rnp-diag-streak-systemic {
    background: var(--err-soft); color: var(--err-ink);
}
.rnp-diag-streak-oneoff {
    background: var(--bg-elev-0); color: var(--ink-3);
}
/* Severity «scale» — положительная аномалия (МАСШТАБИРОВАТЬ). */
.rnp-diag-sev-scale  {
    background: var(--ok-soft); color: var(--ok-ink);
}

/* === Cabinet-changes modal (клик по 🔧 → таблица с фильтрами) === */
#cab-changes-modal {
    position: fixed;
    inset: 0;
    z-index: 10500;
    display: none;
    align-items: center;
    justify-content: center;
}
#cab-changes-modal .cab-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 20, 0.55);
    backdrop-filter: blur(2px);
}
#cab-changes-modal .cab-modal-card {
    position: relative;
    width: min(1100px, 96vw);
    max-height: 92vh;
    background: var(--bg-elev-1, #fff);
    border-radius: 14px;
    box-shadow: 0 30px 80px rgba(10, 10, 20, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#cab-changes-modal .cab-modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-soft);
}
#cab-changes-modal .cab-modal-title {
    font-weight: 700; font-size: 14px; color: var(--ink-1);
}
#cab-changes-modal .cab-modal-close {
    background: none; border: none; font-size: 18px; color: var(--ink-3);
    cursor: pointer; padding: 0 6px; line-height: 1;
}
#cab-changes-modal .cab-modal-close:hover { color: var(--ink-1); }
#cab-changes-modal .cab-modal-filters {
    display: flex; align-items: center; gap: 14px;
    padding: 8px 16px;
    background: var(--bg-elev-0);
    border-bottom: 1px solid var(--border-soft);
    font-size: 12px;
    color: var(--ink-2);
}
#cab-changes-modal .cab-modal-filters label {
    display: inline-flex; align-items: center; gap: 6px;
}
#cab-changes-modal .cab-modal-filters select {
    padding: 3px 8px;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--bg-elev-1);
    color: var(--ink-1);
    font-size: 12px;
}
#cab-changes-modal .cab-modal-counter {
    margin-left: auto;
    color: var(--ink-3);
    font-size: 11px;
}
#cab-changes-modal .cab-modal-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
#cab-changes-modal .cab-modal-tbl-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
#cab-changes-modal .cab-modal-loading,
#cab-changes-modal .cab-modal-empty {
    padding: 28px 20px;
    color: var(--ink-3);
    font-size: 12px;
    text-align: center;
}
#cab-changes-modal .cab-source-direct {
    color: var(--brand);
    font-weight: 600;
    font-size: 11px;
}
#cab-changes-modal .cab-source-spec {
    color: var(--ok-ink);
    font-weight: 600;
    font-size: 11px;
}
/* Ширины колонок модалки. table-layout: fixed уже от .dtbl-overview. */
#cab-changes-modal .cab-modal-tbl { table-layout: fixed; width: 100%; }
#cab-changes-modal .cab-col-when   { width: 140px; }
#cab-changes-modal .cab-col-src    { width: 160px; }
#cab-changes-modal .cab-col-action {
    width: auto;
    /* Главное — обрезать длинный action text с ellipsis. */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 0;  /* trick для table-layout fixed чтобы ellipsis работал */
}
#cab-changes-modal .cab-col-action .cab-action-text {
    color: var(--ink-1);
}
#cab-changes-modal .cab-col-action .cab-action-note {
    color: var(--ink-3);
    margin-left: 8px;
    font-size: 10.5px;
}
#cab-changes-modal .cab-col-when,
#cab-changes-modal .cab-col-src {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hover-preview-tooltip для 🔧 удалён — оставлена только модалка по клику. */

/* Декомпозиция ΔCPA: каждая компонента = отдельная строка с явным «почему». */
.rnp-diag-decomp-block {
    margin: 6px 0 12px 0;
    padding: 10px 12px;
    background: var(--bg-elev-0);
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.5;
}
.rnp-diag-decomp-head {
    color: var(--ink-1);
    margin-bottom: 6px;
}
.rnp-diag-decomp-good { color: var(--ok-ink);  font-weight: 600; }
.rnp-diag-decomp-bad  { color: var(--err-ink); font-weight: 600; }
.rnp-diag-decomp-hint { color: var(--ink-3); font-weight: 400; margin-left: 4px; }
.rnp-diag-decomp-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.rnp-diag-decomp-list li {
    padding: 3px 0;
    color: var(--ink-2);
}
.rnp-diag-decomp-list li > span:first-child {
    display: inline-block;
    min-width: 110px;
}
.rnp-diag-verdict-text {
    font-size: 12.5px;
    color: var(--ink-1);
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--bg-elev-0);
    border-radius: 6px;
    line-height: 1.5;
}
.rnp-diag-section {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--bg-elev-0);
    border-radius: 6px;
}
.rnp-diag-section-h {
    font-weight: 700; font-size: 12px;
    color: var(--ink-1);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.rnp-diag-empty {
    font-size: 12px; color: var(--ink-3);
}
.rnp-diag-list {
    list-style: disc inside;
    margin: 0; padding: 0;
    font-size: 12.5px;
    color: var(--ink-1);
    line-height: 1.6;
}
.rnp-diag-list li { padding: 1px 0; }
.rnp-diag-actions {
    list-style: none; padding: 0; margin: 0;
}
.rnp-diag-actions li {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-soft);
}
.rnp-diag-actions li:last-child { border-bottom: 0; }
.rnp-diag-act-text {
    font-size: 12.5px; color: var(--ink-1);
}
.rnp-diag-mono { font-family: var(--font-mono); font-size: 11.5px; }

.rnp-diag-shifts {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    color: var(--ink-1);
}
.rnp-diag-shifts th {
    text-align: left;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--ink-3);
    font-weight: 700;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-soft);
}
.rnp-diag-shifts td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
.rnp-diag-shifts tr:last-child td { border-bottom: 0; }
.rnp-shift-in    { color: var(--err-ink); font-weight: 700; }   /* доля выросла = подозрение */
.rnp-shift-out   { color: var(--ok-ink); font-weight: 700; }    /* доля упала = ушло */
.rnp-shift-new   { color: var(--info-ink); font-weight: 700; }
.rnp-shift-delta { color: var(--ink-3); font-family: var(--font-mono); font-size: 11px; }

.rnp-cls-reliable_good { color: var(--ok-ink); font-weight: 600; }
.rnp-cls-reliable_bad  { color: var(--err-ink); font-weight: 600; }
.rnp-cls-newcomer      { color: var(--info-ink); font-weight: 600; }
.rnp-cls-volatile      { color: var(--warn-ink); font-weight: 600; }
.rnp-cls-core_failing  { color: var(--err-ink); font-weight: 600; }
.rnp-cls-low_data      { color: var(--ink-3); }

/* === Narrative-блоки v3 (точка В) === */
.rnp-diag-streak {
    font-size: 12px;
    color: var(--ink-1);
    background: var(--warn-soft);
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    font-weight: 600;
}
.rnp-diag-source {
    font-size: 11px;
    color: var(--ink-3);
    margin-bottom: 8px;
    font-style: italic;
}
.rnp-diag-narratives {
    display: flex; flex-direction: column; gap: 8px;
}
.rnp-diag-narrative {
    padding: 8px 10px;
    border-left: 3px solid var(--ink-3);
    background: var(--bg-elev-1);
    border-radius: 0 6px 6px 0;
}
.rnp-diag-narrative-ok  { border-left-color: var(--ok-ink); }
.rnp-diag-narrative-mid { border-left-color: var(--warn-ink); }
.rnp-diag-narrative-low { border-left-color: var(--ink-4); opacity: 0.85; }
.rnp-diag-narrative-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--ink-1);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.rnp-diag-narrative-icon { font-size: 13px; }
.rnp-diag-narrative-conf {
    margin-left: auto;
    font-weight: 400;
    font-size: 10.5px;
    color: var(--ink-3);
    text-transform: none;
    letter-spacing: 0;
}
.rnp-diag-narrative-text {
    font-size: 12.5px;
    color: var(--ink-1);
    line-height: 1.55;
}
.rnp-diag-section-sub {
    font-size: 11px;
    color: var(--ink-3);
    margin-bottom: 6px;
    font-style: italic;
}
.rnp-diag-search-log {
    margin-top: 14px;
    padding: 8px 12px;
    font-size: 10.5px;
    color: var(--ink-3);
    border-top: 1px dashed var(--border-soft);
    font-style: italic;
}
/* 6 уровней подсветки — !important чтобы переопределить zebra-фон nth-child(even) */
.rnp-grid td.rnp-cell-green-strong { background: #b8e8c8 !important; color: #0e3a25; }
.rnp-grid td.rnp-cell-green        { background: #dff2e5 !important; color: #1f5a3a; }
.rnp-grid td.rnp-cell-yellow       { background: #fdebb1 !important; color: #6a4d10; }
.rnp-grid td.rnp-cell-red          { background: #fcd2cc !important; color: #6a2118; }
.rnp-grid td.rnp-cell-red-strong   { background: #f5a098 !important; color: #4d1410; }
.rnp-grid td.rnp-cell-info         { background: #dceaf7 !important; color: #1a3958; }
.strat-goal-row .strat-goal-id {
  font-size: 11.5px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.strat-dlg-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  border-top: 1px solid var(--border-soft, #ece4f5);
  background: var(--bg-elev-1, #faf6ff);
}
.strat-dlg-msg { flex: 1; font-size: 11px; color: var(--ink-3); }
.strat-dlg-msg.is-err { color: var(--err-ink, #7A2518); }
.strat-dlg-msg.is-ok  { color: var(--ok-ink, #1F7A4D); }

/* Confirm overlay */
.strat-confirm {
  width: 480px; max-width: 92vw;
  padding: 0; border: 1px solid var(--err, #e25f4f); border-radius: 12px;
  background: var(--bg-elev-0, #fff);
  box-shadow: 0 20px 50px rgba(80, 20, 20, 0.22);
  overflow: hidden;
}
.strat-confirm::backdrop { background: rgba(20, 10, 40, 0.45); }
.strat-confirm-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft, #ece4f5);
  background: var(--err-soft, #fde7e3); color: var(--err-ink, #7A2518);
  font-size: 13px; font-weight: 600;
}
.strat-confirm-body { padding: 14px 16px; font-size: 12.5px; line-height: 1.5; color: var(--ink-1); }
.strat-confirm-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 10px 16px;
  border-top: 1px solid var(--border-soft, #ece4f5);
  background: var(--bg-elev-1, #faf6ff);
}

/* Toast (after apply) */
.strat-toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 1100;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  background: var(--ink-1, #2a1f4a); color: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  font-size: 12.5px;
}
.strat-toast[hidden] { display: none; }
.strat-toast-msg { line-height: 1.4; }
.strat-toast-undo {
  background: transparent; border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff; padding: 4px 10px; border-radius: 6px;
  font-size: 11.5px; cursor: pointer;
}
.strat-toast-undo:hover { background: rgba(255, 255, 255, 0.12); }
.strat-toast-close {
  background: transparent; border: none; color: rgba(255, 255, 255, 0.6);
  font-size: 16px; cursor: pointer; padding: 0 4px;
}

.undo-banner {
  position: fixed; right: 24px; bottom: 24px; z-index: 1000;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: var(--ink-1, #2a1f4a); color: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  animation: undo-slide-in 0.18s ease-out;
}
.undo-banner .undo-text { max-width: 360px; line-height: 1.35; }
.undo-banner .undo-text b { color: #fff; font-weight: 600; }
.undo-banner .btn-undo {
  background: transparent; color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 6px;
  padding: 4px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.undo-banner .btn-undo:hover {
  background: rgba(255, 255, 255, 0.12); border-color: #fff;
}
.undo-banner .btn-undo:disabled { opacity: 0.5; cursor: progress; }
.undo-banner .undo-close {
  background: transparent; color: rgba(255, 255, 255, 0.7);
  border: none; font-size: 18px; cursor: pointer;
  line-height: 1; padding: 0 0 0 4px;
}
.undo-banner .undo-close:hover { color: #fff; }
@keyframes undo-slide-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Watchdog: красная плашка над дашбордом для админа.
   Появляется когда есть аккаунты с consecutive_failures>=3 или
   last_success_at < now-12h. Источник: templates/dashboard.html. */
.sync-alert-banner {
    margin: 0 0 12px;
    padding: 10px 16px;
    background: var(--err-soft);
    color: var(--err-ink);
    border: 1px solid var(--err-ink);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
}
