/* ===== Helpdesk · светлая тема ===== */
:root {
  --bg: #f4f7fb;
  --bg-card: #ffffff;
  --border: #e3e9f2;
  --text: #1e2a3a;
  --text-muted: #7a8aa0;
  --primary: #2f6fed;
  --primary-dark: #2458c4;
  --primary-soft: #eaf1fe;
  --success: #2e9e5b;
  --success-soft: #e7f6ec;
  --warn: #d98a1f;
  --warn-soft: #fdf3e3;
  --danger: #d64545;
  --danger-soft: #fdecec;
  --info-soft: #e8f4fd;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(30,42,58,.06), 0 4px 16px rgba(30,42,58,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; width: 100%; }
.main { flex: 1; padding-top: 24px; padding-bottom: 48px; }

/* ===== Шапка ===== */
.topbar { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.logo { font-size: 19px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo-icon { font-size: 22px; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--text-muted); font-weight: 500; }
.nav a:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav-new { margin-left: 8px; color: #fff !important; }
.nav-new:hover { background: var(--primary-dark) !important; color: #fff !important; }
.nav-user { display: flex; align-items: center; gap: 8px; margin-left: 12px; padding-left: 16px; border-left: 1px solid var(--border); white-space: nowrap; }
.nav-logout { margin-left: 12px; font-size: 13px; }

/* ===== Кнопки ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px; border-radius: 9px; border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s; text-decoration: none; line-height: 1.2; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); border-color: #cdd8e6; }
.btn-danger { background: #fff; color: var(--danger); border-color: #f2c4c4; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 7px; }
.btn-lg { padding: 12px 26px; font-size: 15px; }
.btn-block { width: 100%; }

/* ===== Карточки ===== */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-title { margin: 0 0 14px; font-size: 16px; font-weight: 700; }
.page-title { font-size: 24px; font-weight: 700; margin: 0 0 20px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.topic-add-row { display: flex; gap: 12px; align-items: flex-end; }
.topic-add-field { flex: 1; margin-bottom: 0; }
@media (max-width: 600px) { .topic-add-row { flex-direction: column; align-items: stretch; } .topic-add-field { margin-bottom: 12px; } }
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; cursor: pointer; }
.sort-link:hover { color: var(--accent, #2563eb); }
.sort-link.active { color: var(--accent, #2563eb); font-weight: 700; }
.sort-ind { font-size: 11px; opacity: .7; }
.empty { color: var(--text-muted); padding: 12px 0; }
.muted { color: var(--text-muted); }
.subhead { font-size: 14px; font-weight: 700; margin: 18px 0 10px; color: var(--text); }

/* ===== Flash ===== */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.flash-success { background: var(--success-soft); color: #1c6b3c; border: 1px solid #bfe5cd; }
.flash-error { background: var(--danger-soft); color: #a03030; border: 1px solid #f0c4c4; }

/* ===== Статистика ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat-card a, a.stat-card { color: inherit; text-decoration: none; display: block; }
a.stat-card:hover { border-color: var(--primary); }
.stat-num { font-size: 28px; font-weight: 800; }
.stat-label { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.stat-new .stat-num { color: var(--primary); }
.stat-mine .stat-num { color: var(--warn); }
.stat-resolved .stat-num { color: var(--success); }

/* ===== Таблицы ===== */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: 8px 10px; border-bottom: 2px solid var(--border); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafd; }
.t-num { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.t-num-big { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 15px; font-weight: 700; color: var(--text-muted); }
.t-subj { font-weight: 600; color: var(--text); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== Бейджи ===== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-new { background: var(--primary-soft); color: var(--primary); }
.st-assigned { background: var(--info-soft); color: #1b6fa8; }
.st-in_progress { background: var(--warn-soft); color: var(--warn); }
.st-waiting { background: #efe9fb; color: #7448b8; }
.st-resolved { background: var(--success-soft); color: var(--success); }
.st-closed { background: #eceff3; color: var(--text-muted); }
.prio-low { background: #eceff3; color: #5a6b80; }
.prio-normal { background: var(--primary-soft); color: var(--primary); }
.prio-high { background: var(--warn-soft); color: var(--warn); }
.prio-urgent { background: var(--danger-soft); color: var(--danger); }
.badge.internal { background: #f1ede2; color: #8a6d1a; }
.role-badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.role-applicant { background: #eceff3; color: #5a6b80; }
.role-agent { background: var(--info-soft); color: #1b6fa8; }
.role-admin { background: #f3e8fb; color: #7448b8; }

/* ===== Формы ===== */
.form .field { margin-bottom: 16px; }
.form label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.form .req { color: var(--danger); }
.form input[type=text], .form input[type=email], .form input[type=password], .form input[type=date], .form select, .form textarea,
.filter-form input, .filter-form select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 14.5px;
  font-family: inherit; background: #fff; color: var(--text); transition: border .15s, box-shadow .15s;
}
.form input:focus, .form select:focus, .form textarea:focus, .filter-form input:focus, .filter-form select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,111,237,.13);
}
.form textarea { resize: vertical; min-height: 90px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: span 1; } }
.form-section { grid-column: span 2; font-size: 15px; margin: 10px 0 4px; padding-top: 14px; border-top: 1px solid var(--border); }
.form-actions { display: flex; gap: 10px; align-items: center; }
.hint { color: var(--text-muted); font-size: 12px; display: block; margin-top: 4px; }

/* ===== Dropzone ===== */
.dropzone { border: 2px dashed #c6d4e8; border-radius: 10px; padding: 26px; text-align: center; color: var(--text-muted); cursor: pointer; background: #fafcff; transition: all .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.dropzone input { display: none; }
.dropzone .link { color: var(--primary); font-weight: 600; }
.file-list { list-style: none; padding: 0; margin: 10px 0 0; }
.file-list li { font-size: 13px; color: var(--text); background: #f6f9fd; border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px; margin-bottom: 5px; }

/* ===== Заявка ===== */
.ticket-head-main .ticket-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.ticket-subject { font-size: 22px; margin: 0 0 10px; font-weight: 700; }
.ticket-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--text-muted); font-size: 13.5px; }
.ticket-meta .due { color: var(--warn); font-weight: 600; }
.ticket-meta .resolved { color: var(--success); font-weight: 600; }
.actions-card { background: #fbfcfe; }
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.action-field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.action-row { display: flex; gap: 8px; }
.action-row select, .action-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px; min-width: 0; }

.ticket-main { min-width: 0; }
.ticket-desc { white-space: pre-wrap; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb { width: 110px; height: 110px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: #f0f4fa; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover { border-color: var(--primary); }
.files { list-style: none; padding: 0; margin: 0; }
.files li { padding: 7px 0; border-bottom: 1px dashed var(--border); }
.files li:last-child { border-bottom: none; }

/* ===== Переписка ===== */
.msg { border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; border: 1px solid var(--border); }
.msg-agent { background: #f2f7ff; border-color: #d5e3fa; }
.msg-applicant { background: #fff; }
.msg-internal { background: #fdf9ee !important; border: 1px dashed #e0c87a !important; }
.msg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.msg-date { font-size: 12px; margin-left: auto; }
.msg-body { white-space: pre-wrap; font-size: 14px; }
.reply-form { margin-top: 16px; }
.reply-form textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; font-family: inherit; font-size: 14px; resize: vertical; }
.reply-form textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,111,237,.13); }
.reply-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 10px; flex-wrap: wrap; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-muted); cursor: pointer; }

.events { list-style: none; padding: 0; margin: 0; }
.events li { padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.events li:last-child { border-bottom: none; }

/* ===== Фильтры ===== */
.filters { padding: 14px 16px; }
.filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-form input[type=text] { flex: 1; min-width: 200px; }
.filter-form select { width: auto; }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.list-head .page-title { margin: 0; }

/* ===== Бары статистики ===== */
.bar-row { display: grid; grid-template-columns: 150px 1fr 40px; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13.5px; }
.bar-label { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 10px; background: #edf1f7; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; transition: width .4s; }
.fill-new { background: var(--primary); }
.fill-assigned { background: #6ba3e0; }
.fill-in_progress { background: var(--warn); }
.fill-waiting { background: #a07fd6; }
.fill-resolved { background: var(--success); }
.fill-closed { background: #b8c2d0; }
.fill-assign { background: linear-gradient(90deg, #6ba3e0, var(--primary)); }
.fill-topic { background: linear-gradient(90deg, #7fd6a5, var(--success)); }
.prio-low-fill { background: #b8c2d0; }
.prio-normal-fill { background: var(--primary); }
.prio-high-fill { background: var(--warn); }
.prio-urgent-fill { background: var(--danger); }
.bar-val { font-weight: 700; text-align: right; }

/* ===== Авторизация ===== */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 140px); }
.auth-card { width: 100%; max-width: 400px; padding: 32px; text-align: center; }
.auth-logo { font-size: 44px; margin-bottom: 6px; }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-sub { color: var(--text-muted); margin: 0 0 20px; font-size: 14px; }
.auth-card .form { text-align: left; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.auth-tabs a { padding: 8px 12px; font-size: 13.5px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.auth-tabs a:hover { color: var(--primary); text-decoration: none; }
.auth-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.auth-ldap-note { font-size: 12px; color: var(--text-muted); margin: 14px 0 0; }
.ldap-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.ldap-help { padding-left: 18px; margin: 0; }
.ldap-help li { margin-bottom: 8px; }
.ldap-help code { background: #f0f4fa; padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }

/* ===== Ошибка ===== */
.error-wrap { text-align: center; padding: 60px 0; }
.error-code { font-size: 72px; font-weight: 800; color: var(--primary); }

/* ===== Подвал ===== */
.footer { background: #fff; border-top: 1px solid var(--border); padding: 14px 0; color: var(--text-muted); font-size: 13px; text-align: center; }

/* ===== Пользователи: таблица влезает в экран, сортировка кликом ===== */
.table-wrap { overflow: hidden; }
.users-table { width: 100%; table-layout: fixed; }
/* пропорции колонок (сумма = 100%): логин | фио | роль | отдел | почта | телефон | действия */
.users-table .cw-login  { width: 12%; }
.users-table .cw-name   { width: 24%; }
.users-table .cw-role   { width: 10%; }
.users-table .cw-dept   { width: 13%; }
.users-table .cw-email  { width: 16%; }
.users-table .cw-phone  { width: 7%; }
.users-table .cw-actions{ width: 18%; }
.users-table th, .users-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.users-table th { padding: 8px 8px; }
.users-table td { padding: 9px 8px; }
.users-table .th-actions, .users-table .col-actions { text-align: right; }
.users-table .row-actions { justify-content: flex-end; gap: 5px; flex-wrap: nowrap; }
.users-table .row-actions .btn { padding: 5px 9px; font-size: 12.5px; }
/* сортировка */
.sort-link { color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--primary); }
.sort-link.on { color: var(--primary); font-weight: 700; }

/* ===== Форма пользователя: ровная сетка ===== */
.user-form .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.user-form .form-grid .field input, .user-form .form-grid .field select { height: 42px; }
.user-form .form-grid .field input.readonly { background: #f4f7fb; color: var(--text-muted); }
.user-form-note { margin-top: 4px; }
.user-form-actions { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ===== Уведомления ===== */
.notify-page .card { margin-bottom: 18px; }
.notify-page .field label.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-weight: 500; cursor: pointer; }
.notify-page .field input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.notify-page .btn-row { display: flex; gap: 10px; margin-top: 16px; }
.notify-page .table.kv th { width: 180px; vertical-align: top; text-transform: none; font-size: 13px; padding: 8px 10px; }
.notify-page .table.kv td { padding: 8px 10px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.notify-page code { background: #f0f3f8; padding: 1px 6px; border-radius: 4px; font-size: 12.5px; }

/* ===== Массовые операции: галочки + панель действий ===== */
.col-chk { width: 32px; text-align: center; }
.col-chk input { cursor: pointer; }
.bulk-bar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 14px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
}
.bulk-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bulk-assign { display: flex; gap: 6px; align-items: center; }
.bulk-assign select { min-width: 180px; }

