/* ============================================================
   MelnikTiket — оформление
   Светлая тема: небесная пастель. Тёмная: графит.
   ============================================================ */

/* Шрифт подключается отдельным файлом fonts.css (локально, без CDN). */

:root {
    --bg: #F4F9FD;
    --surface: #FFFFFF;
    --surface-2: #FAFCFE;
    --border: #DCE8F2;
    --border-strong: #C6D8E6;
    --text: #2C3A47;
    --muted: #6B7A89;

    --primary: #3D8DCA;
    --primary-ink: #1F5F8F;
    --primary-soft: #E3F1FB;

    --lav: #A9B4E6;
    --lav-soft: #ECEEFB;
    --lav-ink: #4A5480;

    --mint: #8FD5C0;
    --mint-soft: #E4F6F0;
    --mint-ink: #2E6B5A;

    --green-soft: #E6F5EE;
    --green-ink: #2F6B52;

    --grey-soft: #EEF2F5;
    --grey-ink: #5A6771;

    --coral: #F2A0A0;
    --coral-soft: #FDEBEB;
    --coral-ink: #A03B3B;

    --amber-soft: #FDF3E3;
    --amber-ink: #8A5B1E;
    --warm-soft: #FCEAE2;
    --warm-ink: #9A4A2E;

    --radius-card: 12px;
    --radius-field: 10px;
    --radius-btn: 10px;
    --radius-badge: 8px;

    --shadow-sm: 0 1px 2px rgba(44, 58, 71, 0.04), 0 2px 8px rgba(44, 58, 71, 0.04);
    --shadow-md: 0 4px 16px rgba(44, 58, 71, 0.07);

    --font: 'InterMT', 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    --container: 1200px;
}

[data-theme="dark"] {
    --bg: #1E2226;
    --surface: #262B30;
    --surface-2: #2B3137;
    --border: #333B42;
    --border-strong: #414B54;
    --text: #E6EAED;
    --muted: #9AA6B0;

    --primary: #6FB3E0;
    --primary-ink: #BFE0F5;
    --primary-soft: #26333D;

    --lav: #8E9AD0;
    --lav-soft: #2C3040;
    --lav-ink: #C3C9EA;

    --mint: #79C2AC;
    --mint-soft: #253530;
    --mint-ink: #A9DCCB;

    --green-soft: #24352C;
    --green-ink: #A5D6BC;

    --grey-soft: #2C3238;
    --grey-ink: #B4BEC7;

    --coral: #E88F8F;
    --coral-soft: #3A2929;
    --coral-ink: #F3BDBD;

    --amber-soft: #342C1F;
    --amber-ink: #E8C88C;
    --warm-soft: #3A2F28;
    --warm-ink: #F0BFA5;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 18px rgba(0, 0, 0, 0.28);
}

/* ---------------- Сброс ---------------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 22px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 28px; line-height: 36px; }
h2 { font-size: 22px; line-height: 30px; }
h3 { font-size: 18px; line-height: 26px; }

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

a { color: var(--primary-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

ul, ol { margin: 0; padding: 0; list-style: none; }

.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 18px; }
.nowrap { white-space: nowrap; }

:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    border-radius: 6px;
}

/* ---------------- Шапка ---------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 60px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    font-weight: 600;
    font-size: 17px;
}
.brand:hover { text-decoration: none; }

.brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background:
        radial-gradient(circle at 30% 30%, #FFFFFF 0 18%, transparent 19%),
        linear-gradient(135deg, var(--primary), var(--mint));
    box-shadow: var(--shadow-sm);
    flex: 0 0 auto;
}
.brand-mark-lg { width: 44px; height: 44px; border-radius: 12px; }

.nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1 1 auto;
    overflow-x: auto;
    scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav-link {
    padding: 8px 12px;
    border-radius: var(--radius-btn);
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}
.nav-link:hover { background: var(--primary-soft); color: var(--primary-ink); text-decoration: none; }
.nav-link.is-active { background: var(--primary-soft); color: var(--primary-ink); }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.theme-switch { display: flex; }

.icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    background: var(--surface);
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
}
.icon-btn:hover { background: var(--primary-soft); color: var(--primary-ink); text-decoration: none; }

.bell-count {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 500;
}
.user-link:hover { text-decoration: none; }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    text-transform: uppercase;
}

.user-link-text { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.link-btn {
    background: none;
    border: 0;
    padding: 0;
    color: var(--muted);
    font: inherit;
    cursor: pointer;
}
.link-btn:hover { color: var(--coral-ink); text-decoration: underline; }

/* ---------------- Страница ---------------- */

.page {
    max-width: var(--container);
    margin: 0 auto;
    padding: 24px 16px 64px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.page-title { font-size: 28px; line-height: 36px; }
.page-sub { margin: 4px 0 0; color: var(--muted); }

.grid-2 {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.stack { display: flex; flex-direction: column; gap: 20px; }

/* ---------------- Карточки ---------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.card-title { font-size: 18px; line-height: 26px; }
.card-link { font-size: 14px; font-weight: 500; }

/* ---------------- Счётчики ---------------- */

.stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stats-alerts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 420px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: transform .12s ease, box-shadow .12s ease;
}
.stat-card:hover {
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.stat-value { font-size: 26px; line-height: 32px; font-weight: 600; }
.stat-label { font-size: 13px; color: var(--muted); }

.stat-new { border-top: 3px solid var(--primary); }
.stat-accepted { border-top: 3px solid var(--lav); }
.stat-in_progress { border-top: 3px solid var(--mint); }
.stat-done { border-top: 3px solid #7FC8A9; }
.stat-cancelled { border-top: 3px solid #B6C2CC; }

.stat-overdue { border-top: 3px solid var(--coral); }
.stat-stale { border-top: 3px solid #E8BE86; }

.stat-overdue.has-value .stat-value { color: var(--coral-ink); }
.stat-stale.has-value .stat-value { color: var(--amber-ink); }

/* ---------------- Таблицы ---------------- */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table thead th {
    position: sticky;
    top: 0;
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: .02em;
    text-transform: uppercase;
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--primary-soft); }
.table tbody tr.is-clickable { cursor: pointer; }

.table a.row-link { color: var(--text); font-weight: 500; }
.table a.row-link:hover { color: var(--primary-ink); }

/* ---------------- Метки ---------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--radius-badge);
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

.badge-new { background: var(--primary-soft); color: var(--primary-ink); }
.badge-accepted { background: var(--lav-soft); color: var(--lav-ink); }
.badge-in_progress { background: var(--mint-soft); color: var(--mint-ink); }
.badge-done { background: var(--green-soft); color: var(--green-ink); }
.badge-cancelled { background: var(--grey-soft); color: var(--grey-ink); }
.badge-overdue { background: var(--coral-soft); color: var(--coral-ink); }
.badge-stale { background: var(--amber-soft); color: var(--amber-ink); }
.badge-muted { background: var(--grey-soft); color: var(--grey-ink); }

.badge-priority-low { background: transparent; color: var(--muted); border: 1px solid var(--border-strong); }
.badge-priority-normal { background: var(--grey-soft); color: var(--grey-ink); }
.badge-priority-high { background: var(--lav-soft); color: var(--lav-ink); }
.badge-priority-critical { background: var(--warm-soft); color: var(--warm-ink); }

/* ---------------- Кнопки ---------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-btn);
    border: 1px solid transparent;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: background .12s ease, border-color .12s ease, transform .12s ease;
    min-height: 42px;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, #000); color: #fff; }

.btn-secondary {
    background: var(--surface);
    color: var(--primary-ink);
    border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--primary-soft); }

.btn-danger { background: var(--coral-soft); color: var(--coral-ink); border-color: var(--coral); }
.btn-danger:hover { background: var(--coral); color: #fff; }

.btn-ghost { background: transparent; color: var(--primary-ink); }
.btn-ghost:hover { background: var(--primary-soft); }

.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 14px; }
.btn-block { width: 100%; }

/* ---------------- Формы ---------------- */

.form { display: flex; flex-direction: column; gap: 14px; }

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

.field label { font-size: 14px; font-weight: 500; }

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field input[type="datetime-local"],
.field input[type="file"],
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-field);
    transition: border-color .12s ease, box-shadow .12s ease;
    min-height: 42px;
}

.field textarea { min-height: 110px; resize: vertical; }

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.field input:disabled { background: var(--grey-soft); color: var(--muted); }

.field .hint { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 17px; }

.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: var(--coral); }

.field-error { font-size: 12.5px; color: var(--coral-ink); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 14px;
    cursor: pointer;
}
.checkbox input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--primary); }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}
.filters .field { min-width: 150px; flex: 1 1 150px; }
.filters .field label { font-size: 12.5px; color: var(--muted); }
.filters .field input,
.filters .field select { min-height: 38px; padding: 7px 10px; }
.filters-actions { display: flex; gap: 8px; }

/* ---------------- Пустые состояния ---------------- */

.empty { padding: 32px 16px; text-align: center; }
.empty-title { font-weight: 600; margin-bottom: 4px; }
.empty-text { color: var(--muted); font-size: 14px; }

/* ---------------- Очередь и лента ---------------- */

.event-list { display: flex; flex-direction: column; }

.queue-item {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) auto;
    gap: 4px 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    align-items: center;
}
.event-list li:last-child .queue-item { border-bottom: 0; }
.queue-item:hover { text-decoration: none; }

.queue-number { font-weight: 600; color: var(--primary-ink); font-size: 13px; }
.queue-subject { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-place { grid-column: 2; color: var(--muted); font-size: 13px; }
.queue-date { color: var(--muted); font-size: 13px; white-space: nowrap; }

.timeline { display: flex; flex-direction: column; gap: 2px; }

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 9px 0;
}

.timeline-dot {
    width: 9px;
    height: 9px;
    margin-top: 7px;
    border-radius: 50%;
    background: var(--primary);
    flex: 0 0 auto;
}

.timeline-body { min-width: 0; }
.timeline-text { margin: 0; font-size: 14px; }
.timeline-meta { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------------- Уведомления ---------------- */

.notif-list { display: flex; flex-direction: column; }

.notif-item {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.notif-list li:last-child { border-bottom: 0; }

.notif-item.is-unread { background: var(--primary-soft); margin: 0 -20px; padding: 12px 20px; }

.notif-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.notif-type { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.notif-link { font-weight: 500; }
.notif-side { display: flex; align-items: center; gap: 12px; white-space: nowrap; }

/* ---------------- Список «ключ — значение» ---------------- */

.kv { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.kv-row { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 12px; }
.kv-row dt { color: var(--muted); font-size: 14px; }
.kv-row dd { margin: 0; font-size: 14px; }

/* ---------------- Тосты ---------------- */

.toasts {
    position: fixed;
    top: 72px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-card);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    font-size: 14px;
    animation: toast-in .18s ease-out;
}
.toast-success { border-left: 4px solid var(--mint); }
.toast-error { border-left: 4px solid var(--coral); }
.toast-info { border-left: 4px solid var(--primary); }

.toast-close {
    margin-left: auto;
    background: none;
    border: 0;
    font-size: 18px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0 2px;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: none; }
}

/* ---------------- Экран входа ---------------- */

.body-plain {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(1200px 600px at 10% -10%, var(--primary-soft), transparent 60%),
        radial-gradient(900px 500px at 100% 0%, var(--mint-soft), transparent 55%),
        var(--bg);
}

.plain-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-md);
    padding: 32px;
}

.login-brand { text-align: center; margin-bottom: 24px; }
.login-title { font-size: 24px; line-height: 32px; margin-top: 12px; }
.login-subtitle { color: var(--muted); font-size: 14px; margin: 2px 0 0; }
.login-hint { margin: 20px 0 0; font-size: 12.5px; color: var(--muted); text-align: center; line-height: 18px; }

/* ---------------- Ошибки ---------------- */

.error-page { text-align: center; max-width: 440px; }
.error-code { font-size: 64px; line-height: 1; font-weight: 600; color: var(--primary); opacity: .35; }
.error-title { margin-top: 8px; }
.error-text { color: var(--muted); margin: 8px 0 20px; }

.debug-box {
    text-align: left;
    background: var(--grey-soft);
    padding: 14px;
    border-radius: var(--radius-card);
    font-size: 12.5px;
    overflow: auto;
    margin-bottom: 16px;
}

/* ---------------- Утилиты ---------------- */

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mt-0 { margin-top: 0; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hidden { display: none !important; }

/* ---------------- Адаптив ---------------- */

@media (max-width: 1024px) {
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .topbar-inner { flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
    .nav { order: 3; width: 100%; flex: 0 0 100%; }
    .topbar-actions { margin-left: auto; }
    .user-link-text { display: none; }
    .page { padding: 18px 12px 56px; }
    .page-title { font-size: 22px; line-height: 30px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stats-alerts { max-width: none; }
    .card { padding: 16px; }
    .toasts { left: 12px; right: 12px; top: auto; bottom: 12px; max-width: none; }
    .form-row { grid-template-columns: 1fr; }
    .kv-row { grid-template-columns: 1fr; gap: 2px; }
    .queue-item { grid-template-columns: 80px minmax(0, 1fr); }
    .queue-date { grid-column: 2; }
}

@media (max-width: 520px) {
    .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .login-card { padding: 24px 18px; }
}

/* ---------------- Хлебные крошки и служебные блоки ---------------- */

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 10px;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary-ink); }

.section-title {
    font-size: 18px;
    line-height: 26px;
    margin: 4px 0 12px;
}

.inline-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.inline-form .field { flex: 1 1 260px; }

.col-actions { text-align: right; }
.table td.actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.table td.actions form { display: inline-flex; }

.more-wrap { text-align: center; margin-top: 16px; }

.alert {
    border-radius: var(--radius-card);
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
}
.alert-error { background: var(--coral-soft); border-color: var(--coral); color: var(--coral-ink); }
.alert-list { margin: 0; padding-left: 18px; list-style: disc; }

.notice {
    background: var(--primary-soft);
    color: var(--primary-ink);
    border-radius: var(--radius-card);
    padding: 12px 14px;
    font-size: 13.5px;
    line-height: 19px;
}

.secret-card { border-color: var(--mint); background: var(--mint-soft); }
.secret-note { font-size: 13px; color: var(--mint-ink); margin: 4px 0 12px; }
.secret-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin-bottom: 14px;
}
.secret-label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--mint-ink); }
.secret-value {
    display: inline-block;
    margin-top: 4px;
    font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--text);
    background: var(--surface);
    border-radius: 8px;
    padding: 6px 12px;
}

.divider { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.sub-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; }

.log-list { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.log-list li { display: flex; gap: 10px; flex-wrap: wrap; }

.text-ok { color: var(--green-ink); font-weight: 500; }
.text-bad { color: var(--coral-ink); font-weight: 500; }

/* ---------------- Оборудование: галерея и комментарии ---------------- */

.code-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--grey-soft);
    color: var(--grey-ink);
    font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
    font-size: 13px;
    letter-spacing: .02em;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.gallery-item {
    position: relative;
    margin: 0;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-card);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-item form { position: absolute; top: 6px; right: 6px; }

.gallery-remove {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 0;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gallery-remove:hover { background: var(--coral-ink); }

.link-list { display: flex; flex-direction: column; gap: 8px; }
.link-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.link-list li:last-child { border-bottom: 0; }

.comment-list { display: flex; flex-direction: column; gap: 14px; }

.comment {
    padding: 12px 14px;
    border-radius: var(--radius-card);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.comment-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    font-size: 14px;
}

.comment-body { font-size: 14px; line-height: 20px; }

/* ---------------- Заявки ---------------- */

.badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.ticket-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.text-block { font-size: 15px; line-height: 23px; }

.action-grid { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.action-grid form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.action-grid .field { min-width: 180px; }

.danger-zone { border-top: 1px dashed var(--border); padding-top: 12px; }
.danger-zone summary { cursor: pointer; color: var(--coral-ink); font-weight: 500; font-size: 14px; }

.file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.file-list li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }

.comment-actions { display: flex; gap: 10px; align-items: center; }
.comment-actions details summary { cursor: pointer; }

.comment-internal { border-left: 3px solid var(--amber-ink); background: var(--amber-soft); }
.comment-public { border-left: 3px solid var(--primary); }

.table-compact th, .table-compact td { padding: 8px 10px; font-size: 14px; }

.field-narrow { max-width: 110px; }

select.multi { min-height: 42px; padding: 6px; }
select.multi option { padding: 3px 6px; }

.cell-subject { display: block; font-weight: 500; }

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 8px; }

@media (max-width: 1024px) {
    .ticket-layout { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------- Админка и отчёты ---------------- */

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
}

.admin-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px;
    border-radius: var(--radius-card);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    color: var(--text);
    transition: transform .12s ease, box-shadow .12s ease;
}
.admin-card:hover {
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.admin-card-title { font-weight: 600; font-size: 16px; }
.admin-card-value { font-size: 26px; line-height: 32px; font-weight: 600; color: var(--primary-ink); }
.admin-card-text { font-size: 13px; color: var(--muted); line-height: 18px; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tab {
    padding: 8px 14px;
    border-radius: var(--radius-btn);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 14px;
}
.tab:hover { text-decoration: none; color: var(--primary-ink); border-color: var(--border-strong); }
.tab.is-active { background: var(--primary-soft); color: var(--primary-ink); border-color: var(--primary); }

.stats-report { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); max-width: none; }

@media (max-width: 760px) {
    .admin-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .admin-card { padding: 14px; }
    .admin-card-value { font-size: 22px; }
}

/* ---------------- Установщик ---------------- */
.check-list { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.check-list li { display: flex; gap: 8px; align-items: baseline; }

/* ---------------- Таблицы на телефоне: карточки ---------------- */

@media (max-width: 760px) {
    .table-cards thead { display: none; }

    .table-cards tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: var(--radius-card);
        background: var(--surface);
        padding: 12px 14px;
        margin-bottom: 10px;
    }
    .table-cards tbody tr:last-child { margin-bottom: 0; }

    .table-cards tbody td {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 12px;
        border: 0;
        padding: 5px 0;
        text-align: right;
    }

    .table-cards tbody td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        color: var(--muted);
        font-size: 12.5px;
        text-align: left;
    }

    .table-cards tbody td[data-label=""] { display: block; text-align: left; }
    .table-cards tbody td.actions {
        justify-content: flex-start;
        padding-top: 10px;
        margin-top: 6px;
        border-top: 1px solid var(--border);
    }
    .table-cards tbody td.actions::before { content: ""; }
}

/* ---------------- Работа с БД: служебные блоки ---------------- */

.mt-24 { margin-top: 24px; }

.card-warn {
    border-left: 3px solid #E8A33D;
    background: var(--warn-bg, #FDF6E7);
}

.simple-list {
    margin: 8px 0 0;
    padding-left: 20px;
}
.simple-list li { margin-bottom: 4px; font-size: 14px; }

.field-grow { flex: 1 1 260px; }

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 16px 0 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 2px;
}
.tab {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 10px 10px 0 0;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    margin-bottom: -3px;
}
.tab:hover { color: var(--text); background: var(--surface-2, rgba(0,0,0,.03)); }
.tab.is-active {
    color: var(--accent, #3D8DCA);
    border-bottom-color: var(--accent, #3D8DCA);
    font-weight: 600;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.inline-form select {
    min-width: 180px;
    max-width: 100%;
    padding: 6px 8px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

.actions form { display: inline-block; margin-right: 6px; }

/* ---------------- Логи ---------------- */

.log-box {
    background: var(--surface-2, #F1F5F9);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 12px 14px;
    max-height: 65vh;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.55;
}
.log-line {
    white-space: pre-wrap;
    word-break: break-word;
    padding: 2px 0;
    color: var(--text);
}
.log-bad { color: #C0392B; }
.log-note { color: #2C7A7B; }

/* ---------------- Рассылки: предпросмотр по каналам ---------------- */

.channel-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.channel-row:last-child { border-bottom: 0; }

.channel-name { min-width: 110px; font-weight: 600; }
.channel-yes { color: #2F855A; }
.channel-no { color: #C0392B; }

.channel-details {
    flex-basis: 100%;
    margin-top: 4px;
}
.channel-details summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--muted);
}
.channel-details ul { max-height: 220px; overflow: auto; }

/* ---------------- Долги ---------------- */

.pay-bar {
    position: sticky;
    bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-md, 0 6px 20px rgba(0,0,0,.08));
}

/* ---------------- Меню с выпадающими группами ---------------- */

.nav-group { position: relative; }

.nav-parent {
    cursor: default;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}
.nav-group:hover .nav-parent,
.nav-group:focus-within .nav-parent {
    color: var(--text);
}

.caret { font-size: 10px; opacity: .7; }

.nav-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 60;
    min-width: 230px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(15, 35, 55, .14);
}

.nav-group:hover .nav-dropdown,
.nav-group:focus-within .nav-dropdown {
    display: block;
}

.nav-dropdown a {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}
.nav-dropdown a:hover {
    background: var(--surface-2, rgba(0, 0, 0, .04));
    color: var(--accent, #3D8DCA);
}

@media (max-width: 860px) {
    /* На телефоне никаких выпадашек: все ссылки идут подряд в прокрутке */
    .nav-group { display: contents; }
    .nav-parent { display: none; }
    .nav-dropdown {
        display: contents;
        position: static;
        background: none;
        border: 0;
        box-shadow: none;
        padding: 0;
        min-width: 0;
    }
    .nav-dropdown a {
        display: inline-block;
        padding: 8px 12px;
        white-space: nowrap;
    }
}

/* На компьютере меню не должно прокручиваться: overflow обрезал выпадашки */
@media (min-width: 861px) {
    .nav { overflow: visible; }
    .nav-link { white-space: nowrap; }
}

/* Слегка «придерживаем» закрытие, чтобы мышка успевала доехать до списка */
.nav-dropdown::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
}

.nav-group.is-open .nav-dropdown { display: block; }
.nav-group.is-open .nav-parent { color: var(--text); }

/* ---------------- Меню: без горизонтальной прокрутки страницы ---------------- */
/* Раньше у .nav был overflow-x: auto — он и обрезал выпадашки, и растягивал
   страницу на планшетах. Теперь меню переносится на новую строку. */
.nav {
    overflow: visible;
    flex-wrap: wrap;
    row-gap: 4px;
}

.topbar-inner {
    flex-wrap: wrap;
    row-gap: 6px;
}

@media (max-width: 860px) {
    .nav { justify-content: flex-start; }
    .nav-dropdown a { padding: 8px 10px; }
}

/* ---------------- Мобильное меню: кнопка и панель ---------------- */

.nav-toggle { display: none; }

@media (max-width: 860px) {
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        margin-left: auto;
        padding: 8px 12px;
        border: 1px solid var(--border);
        border-radius: var(--radius-btn);
        background: var(--surface);
        color: var(--text);
        font: inherit;
        font-size: 14px;
        cursor: pointer;
    }
    .nav-toggle-text { font-size: 13px; }

    .nav {
        display: none;
        order: 20;
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 8px 0 4px;
        border-top: 1px solid var(--border);
    }
    .nav.is-open { display: flex; }

    .nav-group { display: block; }
    .nav-parent {
        display: block;
        padding: 12px 4px 4px;
        font-size: 11px;
        letter-spacing: .04em;
        text-transform: uppercase;
        color: var(--muted);
        cursor: default;
    }
    .nav-parent .caret { display: none; }

    .nav-dropdown {
        display: block;
        position: static;
        min-width: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
        background: none;
    }
    .nav-dropdown::before { display: none; }
    .nav-dropdown a {
        display: block;
        padding: 11px 6px;
        border-bottom: 1px solid var(--border);
        font-size: 15px;
        white-space: normal;
    }
    .nav-link {
        display: block;
        padding: 11px 6px;
        border-bottom: 1px solid var(--border);
        font-size: 15px;
    }
}

/* Кнопка меню — справа, только значок, чтобы не теснила остальные кнопки */
@media (max-width: 860px) {
    .topbar-inner > .brand { order: 1; }
    .topbar-inner > .topbar-actions { order: 2; margin-left: auto; }
    .nav-toggle { order: 3; margin-left: 6px; margin-right: 0; padding: 9px 11px; }
    .nav-toggle-text { display: none; }
    .nav { order: 4; }
}

.review-text {
    margin-top: 12px;
    padding: 12px 14px;
    background: var(--surface-2, #F1F5F9);
    border-radius: 10px;
    line-height: 1.55;
    white-space: normal;
}
