:root {
    --bg: #0f1115;
    --surface: #1a1d24;
    --surface2: #232730;
    --border: #2e333d;
    --text: #e6e8ec;
    --muted: #8b93a1;
    --primary: #5b8cff;
    --primary-d: #4571e0;
    --ok: #2ecc71;
    --warn: #f1c40f;
    --danger: #e74c3c;
    --radius: 14px;
}
* { box-sizing: border-box; }
/* всегда резервируем место под вертикальный скроллбар — чтобы контент не «прыгал»
   вбок при переходе между короткими и длинными страницами */
html { overflow-y: scroll; scrollbar-gutter: stable; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px;
}
a { color: var(--primary); text-decoration: none; }

/* topbar */
.topbar {
    background: var(--surface); border-bottom: 1px solid var(--border); height: 56px;
}
.topbar-inner {
    max-width: 1000px; margin: 0 auto; height: 100%; padding: 0 24px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar .links { display: flex; gap: 6px; flex-shrink: 0; }
.topbar .user { flex-shrink: 0; }
/* фраза-пожелание занимает середину и обрезается, не толкая меню и выход */
.topbar .greet { flex: 1 1 auto; min-width: 0; position: relative; text-align: right; }
.topbar .greet-text {
    display: block; color: var(--muted); font-size: 13px; font-weight: 400; opacity: .6;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* подсказка фразы — через глобальную систему [data-tip], позиция снизу-справа */
.topbar .greet[data-tip]:hover::after {
    top: calc(100% + 8px); bottom: auto; left: auto; right: 0; transform: none;
}
.topbar .links a {
    padding: 8px 14px; border-radius: 10px; color: var(--muted); font-weight: 500;
}
.topbar .links a:hover { background: var(--surface2); color: var(--text); }
.topbar .links a.active { background: var(--primary); color: #fff; }
.topbar .user { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.topbar .user .logout { color: var(--danger); display: inline-flex; align-items: center;
    padding: 4px; border-radius: 8px; transition: transform .15s, color .15s; }
.topbar .user .logout:hover { color: #ff8a7a; transform: translateX(2px) scale(1.08); }

.container { max-width: 1000px; margin: 0 auto; padding: 28px 24px; }
h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 28px 0 12px; }
.muted { color: var(--muted); }

/* flash */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.flash.error { background: rgba(231,76,60,.15); color: #ff8a7a; border: 1px solid rgba(231,76,60,.3); }
.flash.ok { background: rgba(46,204,113,.15); color: #5fe39b; border: 1px solid rgba(46,204,113,.3); }

/* buttons */
button, .btn-secondary {
    cursor: pointer; border: none; border-radius: 10px; font-size: 15px; font-weight: 600;
    padding: 10px 18px; background: var(--primary); color: #fff; transition: .15s;
}
button:hover { background: var(--primary-d); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { display: inline-block; background: var(--surface2); color: var(--text); margin-top: 18px; }

/* login */
.login-box {
    max-width: 340px; margin: 12vh auto; background: var(--surface);
    padding: 32px; border-radius: var(--radius); border: 1px solid var(--border); text-align: center;
}
.login-box h1 { margin-bottom: 4px; }
.login-box form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
input, select, textarea {
    background: var(--surface2); border: 1px solid var(--border); color: var(--text);
    border-radius: 10px; padding: 10px 12px; font-size: 15px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
/* единый цвет всех плейсхолдеров */
::placeholder { color: var(--muted); opacity: 1; }

/* кастомная стрелка для select (чтобы не липла к краю) */
select {
    appearance: none; -webkit-appearance: none; padding-right: 34px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%238b93a1' d='M6 8 0 0h12z'/></svg>");
    background-repeat: no-repeat; background-position: right 12px center;
}
/* белая иконка календаря на тёмном фоне */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8); cursor: pointer; opacity: .8;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* generate */
.center-title { text-align: center; }
.gen-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 22px; }
.gen-btn {
    width: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 30px 0; border-radius: var(--radius);
    background: linear-gradient(160deg, var(--surface2), var(--surface));
    border: 1px solid var(--border); transition: transform .15s, border-color .15s, box-shadow .15s;
}
.gen-btn:hover:not(:disabled) {
    border-color: var(--primary); transform: translateY(-3px);
    box-shadow: 0 10px 26px rgba(91,140,255,.18);
    /* не давать глобальному button:hover красить карточку синим */
    background: linear-gradient(160deg, var(--surface2), var(--surface));
}
.gen-btn:disabled { opacity: .45; cursor: not-allowed; }
.gen-btn.loading { opacity: 1; position: relative; }
.gen-btn.loading > * { visibility: hidden; }
.gen-btn.loading::after {
    content: ""; position: absolute; top: 50%; left: 50%;
    width: 26px; height: 26px; margin: -13px 0 0 -13px;
    border: 3px solid rgba(255,255,255,.25); border-top-color: var(--primary);
    border-radius: 50%; animation: spin .7s linear infinite; visibility: visible;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gen-btn .flag { font-size: 40px; line-height: 1; }
.gen-btn .name { font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.gen-btn .stock {
    font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 4px;
    background: rgba(255,255,255,.04); padding: 2px 10px; border-radius: 999px;
}

/* card / result */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.card label { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase;
    letter-spacing: .6px; margin: 18px 0 7px; }
.card label:first-of-type { margin-top: 0; }
.copy-row { display: flex; gap: 10px; align-items: flex-start; }
.copy-row code, .copy-row textarea {
    flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--border);
    border-radius: 10px; padding: 11px 14px; font-family: ui-monospace, monospace; font-size: 13px;
    word-break: break-all; white-space: pre-wrap; color: var(--text); resize: vertical; line-height: 1.5;
}
.copy-row code { display: flex; align-items: center; }
.copy-row .copy-btn {
    flex: 0 0 132px; width: 132px; height: 44px; text-align: center; font-weight: 600;
    font-size: 14px; background: var(--surface2); border: 1px solid var(--border);
    white-space: nowrap; overflow: hidden; transition: background .15s, border-color .15s;
}
.copy-row .copy-btn:hover { background: var(--primary); border-color: var(--primary); }
.result-card { margin-top: 24px; border-color: rgba(91,140,255,.35); }
.result-card h2 { margin-top: 0; display: flex; align-items: center; gap: 8px; }

/* архив записок */
.archive-head { display: flex; align-items: center; justify-content: space-between;
    gap: 16px; margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--border); }
.archive-title { margin: 0; }
.search-wrap { position: relative; width: 260px; }
.search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--muted); pointer-events: none; }
.archive-search { width: 100%; padding-left: 36px; }
.archive-table { margin-top: 12px; }
.archive-table .nowrap { white-space: nowrap; color: var(--muted); font-size: 13px; }
.archive-table .mono { font-size: 12px; }
.arch-link { font-size: 16px; position: relative; }
/* подсказка ссылки — справа, с переносом длинного URL (не уезжает за край) */
.arch-link[data-tip]:hover::after {
    left: auto; right: 0; transform: none;
    white-space: normal; word-break: break-all; width: 320px; max-width: 80vw;
}
.more-wrap { text-align: center; margin-top: 16px; }
#archive-more { background: var(--surface2); border: 1px solid var(--border); padding: 9px 22px; }
#archive-more:hover { border-color: var(--primary); }
#archive-more[hidden] { display: none; }

/* tables */
table.data { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: var(--surface2); color: var(--muted); font-size: 13px; font-weight: 600; }
table.data tr:last-child td { border-bottom: none; }
.mono { font-family: ui-monospace, monospace; font-size: 13px; }

/* keys table */
.keys-table { table-layout: fixed; }
.keys-table th:nth-child(1), .keys-table td:nth-child(1) { width: 42%; }
.keys-table th:nth-child(2), .keys-table td:nth-child(2) { width: 18%; }
.keys-table th:nth-child(3), .keys-table td:nth-child(3) { width: 16%; }
.keys-table th:nth-child(4), .keys-table td:nth-child(4) { width: 10%; }
.keys-table th:nth-child(5), .keys-table td:nth-child(5) { width: 14%; }
.keys-table td { vertical-align: middle; }
.keys-table .edit { width: 100%; }
.keys-table input, .keys-table select { width: 100%; }
.keys-table .mono { white-space: nowrap; }
.info-icon { cursor: help; margin-left: 6px; opacity: .8; position: relative; }
.info-icon:hover { opacity: 1; }

/* подсказка-вопрос у заголовка */
.with-help { display: flex; align-items: center; gap: 10px; }
.help-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%; background: var(--surface2);
    border: 1px solid var(--border); color: var(--muted); font-size: 13px;
    font-weight: 700; cursor: help; position: relative;
}
.help-icon:hover { color: var(--text); border-color: var(--primary); }

/* поповер-подсказка со списком */
.help-wrap { position: relative; display: inline-flex; }
.help-pop {
    position: absolute; left: 0; top: calc(100% + 10px); width: 360px; z-index: 40;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 14px 16px; box-shadow: 0 18px 44px rgba(0,0,0,.5);
    opacity: 0; visibility: hidden; transform: translateY(-4px);
    transition: opacity .14s, transform .14s; pointer-events: none;
}
.help-wrap:hover .help-pop { opacity: 1; visibility: visible; transform: none; }
.help-pop-title {
    font-size: 13px; font-weight: 700; color: var(--text);
    text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px;
}
.help-pop ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.help-pop li {
    font-size: 13px; font-weight: 400; color: var(--muted); line-height: 1.5;
}
.help-pop li b { color: var(--text); font-weight: 600; }
.hp-dot {
    display: inline-block; width: 9px; height: 9px; border-radius: 50%;
    margin-right: 6px; vertical-align: middle;
}

.edit-key { display: flex; flex-direction: column; gap: 6px; }

/* переключение просмотр / редактирование */
.keys-table tr:not(.editing) .edit { display: none; }
.keys-table tr.editing .view { display: none; }
.keys-table tr.editing td { background: rgba(91,140,255,.07); }

/* бейдж модуля */
.badge {
    display: inline-block; padding: 4px 12px; border-radius: 999px;
    font-size: 13px; font-weight: 600; color: #1a1d24; white-space: nowrap;
}
.date-main { font-weight: 600; }

/* иконки-кнопки действий */
.icon-btn { width: 34px; height: 34px; padding: 0; font-size: 14px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center; }
.edit-sm, .cancel-sm { background: var(--surface2); border: 1px solid var(--border); }
.edit-sm:hover { background: var(--primary); }
.row-soon td { background: rgba(241,196,15,.12); }
.row-overdue td { background: rgba(231,76,60,.16); }
table.data tr.row-soon td { border-bottom: 1px solid rgba(0,0,0,.35); }
table.data tr.row-overdue td { border-bottom: 1px solid rgba(0,0,0,.4); }
.row-done td { opacity: .45; }
.center { text-align: center; }
.days-left { font-size: 11px; color: var(--muted); margin-top: 3px; }
.row-overdue .days-left { color: #ff8a7a; }
.row-soon .days-left { color: var(--warn); }
.actions { white-space: nowrap; text-align: right; }
.actions .icon-btn { display: inline-flex; margin-left: 4px; vertical-align: middle; }
.actions .icon-btn[hidden] { display: none; }
.save-sm { padding: 6px 10px; background: var(--surface2); border: 1px solid var(--border); }
.danger-sm { padding: 6px 10px; background: rgba(231,76,60,.2); color: #ff8a7a; }
.danger-sm:hover { background: var(--danger); color: #fff; }

/* вопрос при входе */
.today-ask {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    background: linear-gradient(135deg, rgba(91,140,255,.18), rgba(91,140,255,.06));
    border: 1px solid rgba(91,140,255,.4); border-radius: var(--radius);
    padding: 16px 20px; margin-bottom: 22px;
}
.today-ask-text { font-size: 16px; }
.today-ask-btns { display: flex; gap: 10px; }
.ts-work { background: #c0392b; }
.ts-work:hover { background: #a93226; }
.ts-off { background: var(--surface2); border: 1px solid var(--border); }

/* смены: шапка */
.shifts-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.edit-toggle { background: var(--surface2); border: 1px solid var(--border); }
.edit-toggle.active { background: var(--ok); border-color: var(--ok); }

/* легенда */
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 10px 0 18px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--border); display: inline-block; flex-shrink: 0; }

/* блок месяца */
.month-block { margin-bottom: 26px; }
.month-title-row { font-size: 18px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt-left { display: flex; align-items: center; gap: 10px; }
.edit-toggle-sm { font-size: 13px; padding: 6px 12px; font-weight: 600; }
.mt-left { cursor: pointer; user-select: none; }
.mt-left:hover { color: #fff; }
.chevron {
    width: 0; height: 0; flex-shrink: 0;
    border-top: 6px solid transparent; border-bottom: 6px solid transparent;
    border-left: 9px solid var(--muted);
    transition: transform .15s; transform-origin: 30% 50%;
}
.mt-left:hover .chevron { border-left-color: #fff; }
.month-block:not(.collapsed) .chevron { transform: rotate(90deg); }
.month-block.collapsed .cal-wrap { display: none; }
.month-block.collapsed .edit-toggle { display: none; }   /* у свёрнутого месяца кнопки нет */
.cur-badge {
    font-size: 12px; font-weight: 600; color: #fff; background: var(--primary);
    padding: 2px 10px; border-radius: 999px;
}
.cur-badge.next-badge {
    color: var(--muted); background: var(--surface2); border: 1px solid var(--border);
}

/* календарь */
.cal-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--border); }
.cal { border-collapse: collapse; width: 100%; table-layout: fixed; }
.cal th, .cal td { border: 1px solid var(--border); text-align: center; }
.cal th { background: var(--surface2); color: var(--muted); font-size: 11px; font-weight: 600;
    padding: 4px 0; }
.cal .emp-col { width: 88px; }
.cal td.cell, .cal thead th:not(.emp-col) { width: auto; }
.cal th.wd { background: #2f3550; color: #c8cfe0; font-weight: 500; }
.cal th.we { color: #ff8a7a; }
.cal th:last-child, .cal td:last-child { border-right: none; }
.cal tr:last-child td { border-bottom: none; }
.cal .emp-col {
    position: sticky; left: 0; z-index: 2; background: var(--surface);
    text-align: left; padding: 8px 14px; font-weight: 600; white-space: nowrap; min-width: 90px;
    border-left: none;
}
.cal thead .emp-col { background: var(--surface2); }
.cal td.cell { height: 34px; padding: 0; }
/* кликабельность только в режиме редактирования */
.cal.edit-on td.cell.editable { cursor: pointer; }
.cal.edit-on td.cell.editable:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal td.today { box-shadow: inset 0 0 0 2px var(--primary); }
.salary { max-width: 480px; }

/* popup выбора статуса */
.status-menu {
    position: absolute; z-index: 50; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 6px; box-shadow: 0 8px 28px rgba(0,0,0,.5);
    display: flex; flex-direction: column; gap: 2px; min-width: 210px;
}
.status-menu[hidden] { display: none; }
.sm-opt {
    display: flex; align-items: center; gap: 9px; text-align: left; width: 100%;
    background: transparent; border: none; color: var(--text); padding: 9px 12px;
    border-radius: 7px; font-size: 14px; font-weight: 500;
}
.sm-opt:hover { background: var(--surface2); }
.sm-clear { color: var(--muted); }

/* forms */
.checkin { display: flex; align-items: center; gap: 14px; margin: 16px 0; }
.key-add-row {
    display: grid; grid-template-columns: 1fr 1.5fr 1fr 160px 130px;
    gap: 10px; margin: 16px 0 22px;
}
.key-add-row input, .key-add-row select, .key-add-row button { width: 100%; }
.key-form { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.key-form textarea { width: 100%; }
.inline { display: flex; gap: 6px; align-items: center; }

/* руководства */
.manuals-search { width: 100%; margin: 8px 0 18px; }
.manuals-search-wrap { width: 100%; margin: 20px 0 18px; }
.manuals-list { display: flex; flex-direction: column; gap: 6px; }
.manual-row {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 14px;
}
.manual-row:hover { border-color: var(--primary); }
.manual-title { font-weight: 500; }
.manual-langs { display: flex; gap: 6px; flex-shrink: 0; }
.lang-copy {
    background: var(--surface2); border: 1px solid var(--border); color: var(--text);
    padding: 6px 12px; font-size: 13px; font-weight: 600; min-width: 64px;
}
.lang-copy:hover { background: var(--primary); border-color: var(--primary); }
.lang-copy.copied { background: var(--ok); border-color: var(--ok); }

/* ── Архив отключённых ключей ── */
.archive-block { margin-top: 22px; }
.archive-toggle {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
    background: transparent; border: none; color: var(--muted);
    font-size: 14px; font-weight: 600; padding: 6px 0;
}
.archive-toggle:hover { background: transparent; color: var(--text); }
.archive-toggle .arch-caret { font-size: 11px; }
.arch-count {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 10px; padding: 1px 8px; font-size: 12px; color: var(--muted);
}
.keys-archive { margin-top: 10px; opacity: .85; }
.keys-archive[hidden] { display: none; }

/* ── Маска ввода даты (ДД.ММ.ГГ подсказка остаётся видна) ── */
.date-mask { position: relative; display: block; width: 100%; }
.date-mask input { position: relative; z-index: 1; color: transparent; caret-color: var(--text); }
.date-ghost {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 2;
    display: flex; align-items: center;
    padding: 10px 12px; font-size: 15px; font-family: inherit;
    pointer-events: none; white-space: pre; letter-spacing: 0;
}
.date-ghost .dg-typed { color: var(--text); }
.date-ghost .dg-rest  { color: var(--muted); opacity: 1; }

/* кнопка быстрой отметки «отключено» */
.done-btn { color: var(--muted); font-weight: 700; }
.done-btn:hover { color: var(--ok); border-color: var(--ok); }

/* ── Модальное подтверждение ── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(8,10,14,.62); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center; padding: 20px;
    animation: mo-fade .14s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes mo-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
    width: 100%; max-width: 380px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 16px; padding: 26px 24px 22px;
    text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.5);
    animation: mo-pop .16s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes mo-pop { from { transform: translateY(10px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-icon { font-size: 36px; line-height: 1; margin-bottom: 10px; }
.modal-title { margin: 0 0 8px; font-size: 18px; }
.modal-text { margin: 0 0 22px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; }
.modal-btn { flex: 1; padding: 11px 0; border-radius: 10px; font-weight: 600; font-size: 14px; }
.modal-btn.cancel { background: var(--surface2); border: 1px solid var(--border); color: var(--text); }
.modal-btn.cancel:hover { background: var(--border); }
.modal-btn.ok { background: var(--ok); color: #06210f; }
.modal-btn.ok:hover { filter: brightness(1.08); }
.modal-btn.ok.danger { background: var(--danger); color: #fff; }

/* ── Кнопка-чекбокс «отключить» ── */
.check-btn {
    display: inline-flex; align-items: center; gap: 7px;
    background: transparent; border: none; padding: 4px 6px;
    color: var(--muted); font-size: 13px; font-weight: 500;
}
.check-btn .cb-box {
    width: 18px; height: 18px; border-radius: 5px; flex-shrink: 0;
    border: 2px solid var(--border); background: var(--surface2);
    position: relative; transition: .15s;
}
.check-btn .cb-box::after {
    content: "✓"; position: absolute; inset: 0; display: flex;
    align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; color: #fff; opacity: 0; transition: .15s;
}
.check-btn:hover { background: transparent; color: var(--ok); }
.check-btn:hover .cb-box { border-color: var(--ok); background: var(--ok); }
.check-btn:hover .cb-box::after { opacity: 1; }

/* зелёная галочка Done в архиве */
.done-mark { color: var(--ok); font-weight: 800; font-size: 15px; }

/* колонка «Отключено» в архиве — заголовок и галочка по центру */
.keys-archive th:nth-child(4), .keys-archive td:nth-child(4) { text-align: center; }

/* кнопка удаления — как «редактировать», но краснеет при наведении */
.del-sm { background: var(--surface2); border: 1px solid var(--border); color: var(--danger); font-weight: 800; }
.del-sm:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* кастомный дропдаун выбора модуля (в стиле сайта) */
.msel { position: relative; width: 100%; }
.msel-btn {
    width: 100%; text-align: left; background: var(--surface2);
    border: 1px solid var(--border); color: var(--text); font-weight: 400;
    border-radius: 10px; padding: 10px 34px 10px 12px; font-size: 15px;
    position: relative;
}
.msel-btn:hover { background: var(--surface2); }
.msel-btn::after {
    content: ""; position: absolute; right: 13px; top: 50%;
    width: 0; height: 0; margin-top: -2px;
    border-left: 5px solid transparent; border-right: 5px solid transparent;
    border-top: 6px solid var(--muted); transition: transform .15s;
}
.msel-btn.placeholder { color: var(--muted); }
.msel.open .msel-btn { border-color: var(--primary); }
.msel.open .msel-btn::after { transform: rotate(180deg); }
.msel-list {
    list-style: none; margin: 6px 0 0; padding: 6px;
    position: absolute; left: 0; right: 0; top: 100%; z-index: 50;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.45);
    max-height: 340px; overflow-y: auto;
}
.msel-list[hidden] { display: none; }
.msel-list li {
    padding: 9px 12px; border-radius: 8px; cursor: pointer;
    font-size: 14px; color: var(--text); transition: background .12s;
}
.msel-list li:hover { background: var(--surface2); }
/* первый пункт-сброс «—» */
.msel-list li[data-val=""] { color: var(--muted); }
/* тонкий скроллбар в теме сайта */
.msel-list::-webkit-scrollbar { width: 8px; }
.msel-list::-webkit-scrollbar-track { background: transparent; }
.msel-list::-webkit-scrollbar-thumb {
    background: var(--border); border-radius: 8px; border: 2px solid var(--surface);
}
.msel-list::-webkit-scrollbar-thumb:hover { background: #3c4250; }
.msel-list { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ── Блок «Видео» на странице руководств ── */
.video-block {
    margin: 4px 0 22px; padding: 16px 18px;
    background: linear-gradient(135deg, rgba(255,0,0,.07), rgba(255,0,0,.02));
    border: 1px solid rgba(255,0,0,.25); border-radius: 14px;
}
.video-head {
    display: flex; align-items: center; gap: 9px;
    font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 12px;
}
.video-list { display: flex; flex-direction: column; gap: 8px; }
.video-row {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 14px;
}
.video-row:hover { border-color: rgba(255,0,0,.4); }
.video-title { font-weight: 500; }
.video-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.video-open {
    display: inline-flex; align-items: center; padding: 6px 14px; border-radius: 10px;
    font-size: 13px; font-weight: 600; color: #fff; background: #e60000;
    border: 1px solid #e60000;
}
.video-open:hover { background: #ff1a1a; }
/* кнопка-иконка «копировать» */
.icon-copy {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; padding: 0; border-radius: 10px;
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--muted); cursor: pointer; transition: background .14s, border-color .14s, color .14s;
}
.icon-copy:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.icon-copy.copied { background: var(--ok); border-color: var(--ok); color: #fff; }
.icon-copy svg { display: block; }

/* ── Сигналы о новой записке ── */
/* вспышка карточки результата */
@keyframes flashNew {
    0%   { border-color: var(--ok); box-shadow: 0 0 0 4px rgba(46,204,113,.30); }
    60%  { border-color: var(--ok); box-shadow: 0 0 0 4px rgba(46,204,113,.18); }
    100% { border-color: rgba(91,140,255,.35); box-shadow: 0 0 0 0 rgba(46,204,113,0); }
}
.result-card.flash-new { animation: flashNew 1.1s ease; }
/* плашка «Новая» в заголовке результата */
.new-badge {
    display: inline-block; margin-left: 8px; padding: 2px 9px; border-radius: 999px;
    font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
    background: var(--ok); color: #06210f;
}
/* подсветка свежей строки в архиве */
@keyframes rowNew { 0% { background: rgba(46,204,113,.22); } 100% { background: transparent; } }
.archive-table tr.row-new td { animation: rowNew 1.8s ease; }

/* тост-уведомление */
.toast-wrap {
    position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
    z-index: 2000; display: flex; flex-direction: column; gap: 10px; align-items: center;
    pointer-events: none;
}
.toast {
    display: inline-flex; align-items: center; gap: 9px;
    background: var(--surface); border: 1px solid var(--ok); color: var(--text);
    padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
    box-shadow: 0 12px 34px rgba(0,0,0,.5);
    animation: toastIn .25s ease, toastOut .3s ease forwards 2.4s;
}
.toast .toast-ico {
    width: 22px; height: 22px; border-radius: 50%; background: var(--ok); color: #06210f;
    display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px;
}
@keyframes toastIn  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(12px); } }

/* будущие дни — примерные, приглушаем цвет наложением (не opacity,
   чтобы подсказка-tooltip оставалась яркой) */
.cal .cell.future::before {
    content: ""; position: absolute; inset: 0;
    background: rgba(16,18,24,.6); pointer-events: none;
}
.cal.edit-on .cell.future.editable:hover::before { background: rgba(16,18,24,.22); }

/* разделитель между годами в графике смен */
.year-sep {
    display: flex; align-items: center; gap: 14px;
    margin: 26px 0 18px; color: var(--muted); font-size: 13px; font-weight: 600;
}
.year-sep::before, .year-sep::after {
    content: ""; flex: 1; height: 1px; background: var(--border);
}

/* ── Промокоды ── */
.promo-list { display: flex; flex-direction: column; gap: 8px; }
.promo-row {
    display: flex; align-items: center; gap: 14px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 14px;
}
.promo-row:hover { border-color: var(--primary); }
.promo-code {
    background: var(--bg); border: 1px dashed var(--border); border-radius: 8px;
    padding: 8px 14px; cursor: pointer; flex-shrink: 0;
}
.promo-code:hover { border-color: var(--primary); background: var(--bg); }
.promo-code .mono { font-size: 15px; font-weight: 700; letter-spacing: .5px; color: var(--text); }
.promo-discount {
    color: var(--ok); font-weight: 700; font-size: 15px; flex: 1;
}
.promo-copy { min-width: 132px; flex-shrink: 0; }

/* обёртка для прокрутки широких таблиц на узких экранах */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ═══════════ Мобильная адаптация (≤640px) ═══════════ */
@media (max-width: 640px) {
    .container { padding: 18px 14px; }
    h1 { font-size: 20px; }
    h2 { font-size: 16px; }

    /* шапка: меню скроллится вбок, фразу прячем, выход остаётся */
    .topbar { height: auto; }
    .topbar-inner { padding: 8px 12px; gap: 8px; flex-wrap: nowrap; }
    .topbar .greet { display: none; }
    .topbar .links {
        flex: 1 1 auto; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .topbar .links::-webkit-scrollbar { display: none; }
    .topbar .links a { padding: 8px 10px; white-space: nowrap; }

    /* карточки записок: один столбец, компактнее */
    .gen-grid { grid-template-columns: 1fr; gap: 10px; }
    .gen-btn { padding: 18px 0; }
    .gen-btn .name { font-size: 17px; }

    /* форма добавления ключа: вертикально */
    .key-add-row { grid-template-columns: 1fr; gap: 8px; }

    /* копирование: кнопка под полем */
    .copy-row { flex-direction: column; }
    .copy-row .copy-btn { flex: none; width: 100%; }

    /* архив записок: поиск под заголовком на всю ширину */
    .archive-head { flex-direction: column; align-items: stretch; gap: 12px;
        margin-top: 26px; padding-top: 22px; }
    .search-wrap { width: 100%; }

    /* широкие таблицы внутри скролла не сжимаются — листаются вбок */
    .table-scroll table.data { min-width: 560px; }

    /* ── Ключи: таблица превращается в карточки ── */
    .table-scroll:has(.keys-table) { overflow-x: visible; }
    .table-scroll table.keys-table { min-width: 0; }
    .keys-table, .keys-table tbody { display: block; width: 100%; }
    .keys-table thead { display: none; }
    .keys-table tr {
        display: block; background: var(--surface);
        border: 1px solid var(--border); border-radius: 12px;
        padding: 10px 14px; margin-bottom: 12px;
    }
    .keys-table tr.row-soon { background: rgba(241,196,15,.10); border-color: rgba(241,196,15,.45); }
    .keys-table tr.row-overdue { background: rgba(231,76,60,.12); border-color: rgba(231,76,60,.5); }
    /* убрать табличные линии-бордюры в карточном виде */
    table.data.keys-table tr.row-soon td,
    table.data.keys-table tr.row-overdue td,
    .keys-table td { border: none; }

    .keys-table td {
        display: flex; align-items: center; justify-content: space-between;
        gap: 12px; padding: 7px 0; text-align: right; background: transparent;
    }
    .keys-table td:not(:last-child) { border-bottom: 1px solid rgba(255,255,255,.06) !important; }
    .keys-table td::before {
        content: attr(data-label); color: var(--muted);
        font-size: 12px; font-weight: 600; text-align: left; flex: 0 0 auto;
    }
    .keys-table td[data-label=""]::before,
    .keys-table td.actions::before { content: none; }

    /* ячейка с ключом — на всю ширину, моноширинный перенос */
    .keys-table td.cell-key { display: block; text-align: left; padding-top: 2px; }
    .keys-table td.cell-key::before { display: block; margin-bottom: 5px; }
    .keys-table td.cell-key .mono { white-space: normal; word-break: break-all; font-size: 13px; line-height: 1.4; }

    /* дата + остаток дней выравниваем вправо в столбик */
    .keys-table td[data-label="Когда отключить"] .view { text-align: right; }
    .keys-table .date-main { font-size: 14px; }

    /* статус-кнопка Done крупнее для тача */
    .keys-table td.center { justify-content: space-between; }
    .check-btn { font-size: 14px; padding: 6px 4px; }
    .check-btn .cb-box { width: 20px; height: 20px; }

    /* действия — ряд одинаковых крупных кнопок */
    .keys-table td.actions {
        justify-content: flex-end; gap: 10px; padding-top: 10px;
        border-top: 1px solid rgba(255,255,255,.08) !important; margin-top: 4px;
    }
    .keys-table td.actions .icon-btn {
        width: 42px; height: 42px; font-size: 17px; margin-left: 0; border-radius: 10px;
    }

    /* режим редактирования: поля во всю ширину под подписью */
    .keys-table tr.editing td { display: block; text-align: left; }
    .keys-table tr.editing td::before { display: block; margin-bottom: 5px; }
    .keys-table tr.editing td .edit { width: 100%; }
    /* при редактировании статус-ячейку прячем, кнопки оставляем в ряд */
    .keys-table tr.editing td.center { display: none; }
    .keys-table tr.editing td.actions { display: flex; }

    /* руководства/промокоды/видео: строки переносятся */
    .manual-row, .promo-row, .video-row { flex-wrap: wrap; }
    .manuals-search-wrap, .manuals-search { width: 100%; }
    .promo-copy, .video-copy { min-width: 0; }

    /* подсказки-поповеры не вылезают за экран */
    .help-pop { width: min(320px, 86vw); }
    .topbar .greet::after { max-width: 86vw; white-space: normal; }

    /* модалка по ширине экрана */
    .modal-card { max-width: 92vw; }
}

/* ── Единая всплывающая подсказка (вместо нативных title) ── */
[data-tip] { position: relative; }
[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
    padding: 6px 10px; border-radius: 8px;
    font-size: 12px; font-weight: 400; line-height: 1.3; white-space: nowrap;
    max-width: 320px; box-shadow: 0 8px 22px rgba(0,0,0,.45);
    z-index: 100; pointer-events: none;
}
[data-tip=""]:hover::after { display: none; }   /* пустые не показываем */
/* крайние ячейки календаря — подсказку прижимаем к краю, чтобы не вылезала
   за контейнер и не появлялся горизонтальный скролл */
.cal td.cell:nth-last-child(-n+4)[data-tip]:hover::after { left: auto; right: 0; transform: none; }
.cal tbody td.cell:nth-child(2)[data-tip]:hover::after { left: 0; right: auto; transform: none; }
/* выход в шапке — подсказку вниз, чтобы не обрезалась сверху */
.logout[data-tip]:hover::after { top: calc(100% + 8px); bottom: auto; left: auto; right: 0; transform: none; }

/* ── Тонкие скроллбары в стиле сайта (везде) ── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3c4250; }

/* тост ошибки (красный) */
.toast.toast-err { border-color: var(--danger); }
.toast.toast-err .toast-ico { background: var(--danger); color: #fff; }
