

:root,
[data-theme="dark"] {
    
    --bg:           #0a0a09;
    --bg2:          #111110;
    --surface:      #1a1a18;
    --surface2:     #222220;
    --surface3:     #2a2a28;
    --surface4:     #353531;

    
    --border:       rgba(255,255,255,.07);
    --border2:      rgba(255,255,255,.11);
    --border3:      rgba(255,255,255,.16);

    
    --text:         #f5f5f4;
    --text2:        #d6d3d1;
    --muted:        #78716c;
    --muted2:       #a8a29e;

    /* Brand / Primary — use dark theme blues & oranges */
    --primary:      #016FB9;
    --primary-h:    #0180d4;
    --primary-light:rgba(1,111,185,.14);
    --accent:       #FF9505;
    --accent-h:     #e8870a;
    --accent-light: rgba(255,149,5,.12);
    --cta:          #EC4E20;
    --cta-h:        #d94118;
    --cta-light:    rgba(236,78,32,.12);

    /* Semantic */
    --success:      #22c55e;
    --success-light:rgba(34,197,94,.12);
    --danger:       #ef4444;
    --danger-light: rgba(239,68,68,.12);
    --warning:      #FF9505;
    --warning-light:rgba(255,149,5,.12);
    --live:         #ef4444;
    --live-pulse:   rgba(239,68,68,.3);

    /* Extended palette */
    --orange:       #f97316;
    --orange-light: rgba(249,115,22,.12);
    --amber:        #fbbf24;
    --amber-light:  rgba(251,191,36,.12);
    --purple:       #a78bfa;
    --purple-light: rgba(167,139,250,.12);

    /* Layout */
    --nav-h:              56px;
    --radius:             10px;
    --radius-lg:          14px;
    --radius-xl:          18px;

    /* Shadows */
    --shadow-sm:    0 1px 3px rgba(0,0,0,.4);
    --shadow:       0 4px 16px rgba(0,0,0,.5);
    --shadow-lg:    0 16px 48px rgba(0,0,0,.65);

    /* Scrollbar */
    --sb-track:     transparent;
    --sb-thumb:     rgba(255,255,255,.1);
}

/* ── LIGHT THEME ── */
[data-theme="light"] {
    /* Base */
    --bg:           #f0f4f5;
    --bg2:          #e8eef0;
    --surface:      #ffffff;
    --surface2:     #f4f7f8;
    --surface3:     #eaf0f2;
    --surface4:     #dde6e9;

    /* Borders */
    --border:       rgba(37,48,49,.1);
    --border2:      rgba(37,48,49,.16);
    --border3:      rgba(37,48,49,.22);

    /* Text */
    --text:         #253031;
    --text2:        #315659;
    --muted:        #6b8a8d;
    --muted2:       #4d6d70;

    /* Brand / Primary */
    --primary:      #2978A0;
    --primary-h:    #1f6691;
    --primary-light:rgba(41,120,160,.1);
    --accent:       #BCAB79;
    --accent-h:     #a8965e;
    --accent-light: rgba(188,171,121,.12);
    --cta:          #315659;
    --cta-h:        #253031;
    --cta-light:    rgba(49,86,89,.1);

    /* Semantic */
    --success:      #16a34a;
    --success-light:rgba(22,163,74,.1);
    --danger:       #dc2626;
    --danger-light: rgba(220,38,38,.1);
    --warning:      #d97706;
    --warning-light:rgba(217,119,6,.1);
    --live:         #dc2626;
    --live-pulse:   rgba(220,38,38,.25);

    /* Shadows */
    --shadow-sm:    0 1px 3px rgba(37,48,49,.08);
    --shadow:       0 4px 16px rgba(37,48,49,.1);
    --shadow-lg:    0 16px 48px rgba(37,48,49,.15);

    /* Scrollbar */
    --sb-thumb:     rgba(37,48,49,.15);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    color-scheme: dark;
}
[data-theme="light"] html,
[data-theme="light"] {
    color-scheme: light;
}

body {
    font-family: 'Manrope', 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; background: none; border: none; color: inherit; font-family: inherit; }

/* Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--sb-thumb) var(--sb-track);
}
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--sb-track); }
::-webkit-scrollbar-thumb { background: var(--sb-thumb); border-radius: 4px; }

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    border: 1px solid var(--border2);
    background: var(--surface2);
    color: var(--muted2);
    cursor: pointer;
    transition: border-color .2s, color .2s, background .2s;
    flex-shrink: 0;
}
.theme-toggle:hover {
    border-color: var(--primary);
    color: var(--text);
    background: var(--surface3);
}
.theme-toggle svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}
/* Show sun icon in dark, moon in light */
.theme-toggle .icon-sun  { display: block; }
.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun  { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

.ti {
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}
.ti--sm  { width: 14px; height: 14px; }
.ti--md  { width: 20px; height: 20px; }
.ti--lg  { width: 24px; height: 24px; }
.ti--xl  { width: 32px; height: 32px; }

.t-display {
    font-size: clamp(32px, 5vw, 56px);
    font-weight: 900;
    letter-spacing: -1.5px;
    line-height: .95;
}
.t-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -.5px;
}
.t-heading {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -.2px;
}
.t-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.t-mono {
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .04em;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid transparent;
    white-space: nowrap;
    line-height: 1.4;
}
.badge--primary { background: var(--primary-light); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }
.badge--accent  { background: var(--accent-light);  color: var(--accent);  border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.badge--cta     { background: var(--cta-light);     color: var(--cta);     border-color: color-mix(in srgb, var(--cta) 25%, transparent); }
.badge--success { background: var(--success-light); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.badge--danger  { background: var(--danger-light);  color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.badge--warning { background: var(--warning-light); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.badge--muted   { background: var(--surface3); color: var(--muted2); border-color: var(--border2); }
.badge--live    { background: var(--danger-light); color: var(--live); border-color: color-mix(in srgb, var(--live) 30%, transparent); }
.badge--pill    { border-radius: 20px; padding: 3px 10px; }
.badge--dot::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: badge-live-dot 1.4s infinite;
    flex-shrink: 0;
}
@keyframes badge-live-dot {
    0%,100% { opacity:1; transform:scale(1); }
    50%     { opacity:.4; transform:scale(.8); }
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.3;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 40%, transparent);
}
.btn--primary:hover { background: var(--primary-h); border-color: var(--primary-h); }
.btn--cta {
    background: var(--cta);
    color: #fff;
    border-color: var(--cta);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--cta) 35%, transparent);
}
.btn--cta:hover { background: var(--cta-h); border-color: var(--cta-h); }
.btn--accent {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn--accent:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn--ghost {
    background: transparent;
    color: var(--muted2);
    border-color: var(--border2);
}
.btn--ghost:hover { color: var(--text); border-color: var(--border3); background: var(--surface2); }
.btn--danger {
    background: var(--danger-light);
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn--lg { padding: 12px 24px; font-size: 14px; border-radius: 12px; }
.btn--icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }
.btn--icon.btn--sm { width: 28px; height: 28px; padding: 5px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color .2s;
}
.card:hover { border-color: var(--border2); }
.card--elevated {
    box-shadow: var(--shadow);
}
.card--interactive {
    cursor: pointer;
    transition: border-color .2s, transform .2s, box-shadow .2s;
}
.card--interactive:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface2) 50%, transparent);
}
.card-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted2);
    flex: 1;
}
.card-body { padding: 16px; }

.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: 9px 13px;
    background: var(--surface2);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    font-family: inherit;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    appearance: none;
}
.input:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.input::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--muted);
}

/* ── SELECT: рамка, стрелка, цветовая схема ── */
select {
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(255%2C255%2C255%2C.4)' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
    color-scheme: dark;
}
[data-theme="light"] select {
    color-scheme: light;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(0%2C0%2C0%2C.45)' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
/* Стрелка + padding для классов с background shorthand.
   select.class (0,1,1) > .class (0,1,0) — всегда побеждает. */
select.ctf-input, select.ctf-select,
select.ct2-input,
select.stp-input {
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(255%2C255%2C255%2C.4)' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
[data-theme="light"] select.ctf-input,
[data-theme="light"] select.ctf-select,
[data-theme="light"] select.ct2-input,
[data-theme="light"] select.stp-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(0%2C0%2C0%2C.45)' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--live);
    display: inline-block;
    animation: live-pulse 1.4s infinite;
    flex-shrink: 0;
}
@keyframes live-pulse {
    0%,100% { opacity:1; transform:scale(1); box-shadow:0 0 0 0 var(--live-pulse); }
    50%     { opacity:.6; transform:scale(.8); box-shadow:0 0 0 4px transparent; }
}

.glass {
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border2);
}
.glass--strong {
    background: color-mix(in srgb, var(--surface) 95%, transparent);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
}

.code-block {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 12px;
    color: var(--text2);
    overflow-x: auto;
}
.code-block .kw  { color: var(--primary); }
.code-block .str { color: var(--accent); }
.code-block .num { color: var(--cta); }
.code-block .cmt { color: var(--muted); font-style: italic; }

.divider {
    height: 1px;
    background: var(--border);
    border: none;
    margin: 0;
}
.divider--label {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.divider--label::before,
.divider--label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    box-shadow: var(--shadow-lg);
    border: 1px solid transparent;
    pointer-events: auto;
    cursor: default;
    animation: toastIn .3s cubic-bezier(.34,1.56,.64,1) forwards;
    max-width: 360px;
    line-height: 1.4;
    backdrop-filter: blur(16px);
}
.toast.toast--out { animation: toastOut .25s ease forwards; }
.toast--success { background: color-mix(in srgb, var(--success) 10%, var(--surface)); border-color: color-mix(in srgb, var(--success) 30%, transparent); color: var(--success); }
.toast--error   { background: color-mix(in srgb, var(--danger) 10%,  var(--surface)); border-color: color-mix(in srgb, var(--danger) 30%,  transparent); color: var(--danger); }
.toast--info    { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); border-color: color-mix(in srgb, var(--primary) 30%, transparent); color: var(--primary); }
.toast--warning { background: color-mix(in srgb, var(--warning) 12%, var(--surface)); border-color: color-mix(in srgb, var(--warning) 30%, transparent); color: var(--warning); }
.toast-icon { flex-shrink: 0; }
.toast-close { margin-left: auto; flex-shrink: 0; opacity: .5; cursor: pointer; background: none; border: none; color: inherit; padding: 0; line-height: 1; font-size: 18px; transition: opacity .15s; }
.toast-close:hover { opacity: 1; }
@keyframes toastIn  { from { opacity:0; transform:translateY(12px) scale(.95); } to { opacity:1; transform:translateY(0) scale(1); } }
@keyframes toastOut { from { opacity:1; transform:translateY(0) scale(1); } to { opacity:0; transform:translateY(8px) scale(.95); } }

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(6px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: modalIn .2s cubic-bezier(.22,1,.36,1);
}
@keyframes modalIn { from { opacity:0; transform:scale(.95) translateY(12px); } to { opacity:1; transform:scale(1) translateY(0); } }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 800; }
.modal-body { padding: 20px 24px; }
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 80px 24px;
    text-align: center;
    color: var(--muted);
}
.empty-state svg { opacity: .3; width: 48px; height: 48px; }
.empty-state-title { font-size: 17px; font-weight: 900; color: var(--text2); }
.empty-state-text  { font-size: 13px; line-height: 1.7; max-width: 380px; }

.progress-bar {
    height: 6px;
    background: var(--surface3);
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 60%, var(--accent)));
    border-radius: 3px;
    transition: width .4s cubic-bezier(.4,0,.2,1);
}
.progress-bar--accent .progress-bar__fill { background: linear-gradient(90deg, var(--accent), var(--cta)); }
.progress-bar--success .progress-bar__fill { background: var(--success); }
.progress-bar--danger .progress-bar__fill { background: var(--danger); }

@keyframes skeleton-shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
    background-size: 800px 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius);
}

.transition-theme * {
    transition: background-color .25s ease, border-color .25s ease, color .2s ease !important;
}

.not-found-inline {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 16px;
    text-align: center;
    padding: 24px;
    color: var(--muted);
}
.not-found-inline svg { opacity: .4; }
.not-found-inline__title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    margin: 0;
}
.not-found-inline__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: background .15s;
}
.not-found-inline__link:hover { background: var(--primary-h); }

.color-success { color: var(--success); }
.color-danger  { color: var(--danger);  }
.color-primary { color: var(--primary); }
.color-accent  { color: var(--accent);  }
.color-warning { color: var(--warning); }
.color-muted   { color: var(--muted);   }
.color-muted2  { color: var(--muted2);  }
.color-text    { color: var(--text);    }
.color-text2   { color: var(--text2);   }
.color-orange  { color: var(--orange);  }
.color-amber   { color: var(--amber);   }
.color-purple  { color: var(--purple);  }
.color-white   { color: #fff;           }

.flex-1   { flex: 1; }
.pe-none  { pointer-events: none; }
.fw-700   { font-weight: 700; }
.fw-800   { font-weight: 800; }

/* ── STAFF BADGES ── */
.staff-badge {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: .3px;
    white-space: nowrap;
    cursor: default;
    vertical-align: middle;
    position: relative;
    background: var(--sb-bg-d);
    color: var(--sb-fg-d);
    margin-left:5px;
}
[data-theme="light"] .staff-badge {
    background: var(--sb-bg-l);
    color: var(--sb-fg-l);
}

/* Tooltip */
.staff-badge[data-sb-tip] { cursor: help; }
.staff-badge[data-sb-tip]::after {
    content: attr(data-sb-tip);
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface2);
    color: var(--text2);
    border: 1px solid var(--border2);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 200;
    pointer-events: none;
    box-shadow: var(--shadow);
    opacity: 0;
    transition: opacity .15s;
}
.staff-badge[data-sb-tip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--border2);
    z-index: 201;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
}
.staff-badge[data-sb-tip]:hover::after,
.staff-badge[data-sb-tip]:hover::before { opacity: 1; }

