
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #1a1a2e; padding: 20px; }
.container { max-width: 1400px; margin: 0 auto; }
h1 { text-align: center; margin-bottom: 24px; font-size: 24px; color: #1a1a2e; }
.summary { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.card { background: #fff; border-radius: 12px; padding: 20px 24px; flex: 1; min-width: 180px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); border-left: 4px solid #4a6fa5; }
.card.green { border-left-color: #2ecc71; }
.card.red { border-left-color: #e74c3c; }
.card.yellow { border-left-color: #f39c12; }
.card.blue { border-left-color: #4a6fa5; }
.card .num { font-size: 32px; font-weight: 700; margin-bottom: 4px; }
.card .label { font-size: 13px; color: #666; }
.controls { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.controls input[type="text"] { padding: 10px 16px; border: 2px solid #ddd; border-radius: 8px; font-size: 14px; width: 300px; outline: none; transition: border-color .2s; }
.controls input[type="text"]:focus { border-color: #4a6fa5; }
.btn { padding: 10px 20px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all .2s; }
.btn-check-all { background: #4a6fa5; color: #fff; }
.btn-check-all:hover { background: #3a5a8a; }
.btn-check-all:disabled { background: #999; cursor: not-allowed; }
.btn-individual { background: #e8f0fe; color: #4a6fa5; padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-individual:hover { background: #d0e0fd; }
.btn-individual:disabled { background: #eee; color: #999; cursor: not-allowed; }
.progress { font-size: 13px; color: #666; margin-left: 8px; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
thead th { background: #1a1a2e; color: #fff; padding: 14px 12px; text-align: left; font-size: 13px; font-weight: 600; position: sticky; top: 0; }
tbody tr { border-bottom: 1px solid #eee; transition: background .15s; }
tbody tr:hover { background: #f8f9ff; }
tbody td { padding: 12px 12px; font-size: 13px; }
.plate { font-weight: 700; font-size: 14px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-active { background: #d4edda; color: #155724; }
.badge-expired { background: #f8d7da; color: #721c24; }
.badge-warn { background: #fff3cd; color: #856404; }
.badge-checking { background: #e8f0fe; color: #4a6fa5; }
.badge-error { background: #f0f0f0; color: #999; }
.pass-info { font-size: 12px; color: #555; margin-top: 4px; }
.loading { display: inline-block; width: 14px; height: 14px; border: 2px solid #ccc; border-top-color: #4a6fa5; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 768px) { .summary { flex-direction: column; } table { font-size: 12px; } thead th, tbody td { padding: 8px 6px; } }

.table-wrap{overflow:auto}dialog{margin:auto;padding:24px;border:0;border-radius:12px;width:min(500px,95vw)}dialog::backdrop{background:#0008}label{display:block;margin:10px 0}label input{display:block;width:100%;padding:9px;border:1px solid #ccc;border-radius:6px}#notifications .notice{background:#fff3cd;padding:14px;margin-bottom:10px;border-radius:8px}#formError{color:#b00}td .btn{margin:3px} .muted{color:#777;font-size:12px}

/* Компактные сведения о пропуске и проверке */
.check-date { white-space: nowrap; font-weight: 600; }
.relative-date { color: #777; font-size: 12px; margin-top: 5px; }
.pass-expiry { font-size: 12px; margin-top: 6px; color: #555; }
.pass-details { margin-top: 7px; font-size: 12px; color: #666; }
.pass-details summary { cursor: pointer; color: #4a6fa5; }
.pass-details div { margin-top: 4px; }
.check-error { margin-top: 7px; font-size: 12px; color: #b34040; }
.check-error summary { cursor: pointer; }
.check-error div { margin-top: 4px; }

/* Комментарий и иконки действий */
.comment-cell { max-width: 260px; min-width: 180px; cursor: pointer; white-space: pre-wrap; word-break: break-word; }
.comment-cell:hover { background: #f2f6ff; }
.comment-cell.editing { cursor: default; background: #fff; }
.comment-editor textarea { width: 100%; padding: 8px; border: 1px solid #4a6fa5; border-radius: 6px; font: inherit; resize: vertical; }
.comment-actions { display: flex; gap: 6px; margin-top: 6px; justify-content: flex-end; }
.icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #d7dceb; background: #fff; color: #4a6fa5; border-radius: 8px; cursor: pointer; margin: 2px; transition: all .15s; }
.icon-btn:hover:not(:disabled) { background: #e8f0fe; border-color: #4a6fa5; }
.icon-btn:disabled { color: #aab; background: #f4f4f4; cursor: not-allowed; }
.icon-btn.icon-on { color: #2ecc71; border-color: #bfe9cf; }
.icon-btn.icon-on:hover { background: #e9fbf0; border-color: #2ecc71; }
.icon-btn.icon-save { color: #2ecc71; border-color: #bfe9cf; }

/* TRANSPORT TOOLBAR START */
.controls {
  gap: 10px;
  align-items: center;
}
.controls #search {
  flex: 1 1 280px;
  width: auto;
  min-width: 220px;
  height: 42px;
  background: #fff;
}
.controls .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.controls .btn:hover {
  text-decoration: none;
}
.controls .toolbar-primary {
  background: #4a6fa5;
  border-color: #4a6fa5;
  color: #fff;
}
.controls .toolbar-primary:hover:not(:disabled) {
  background: #3a5a8a;
  border-color: #3a5a8a;
}
.controls .toolbar-secondary {
  background: #fff;
  border-color: #cbd7e8;
  color: #365b8c;
}
.controls .toolbar-secondary:hover:not(:disabled) {
  background: #eaf0f9;
  border-color: #4a6fa5;
}
.controls .toolbar-logout {
  display: flex;
  margin: 0 0 0 auto;
}
.controls .toolbar-danger {
  background: #fff;
  border-color: #e5bcbc;
  color: #a83232;
}
.controls .toolbar-danger:hover:not(:disabled) {
  background: #fff0f0;
  border-color: #bd4545;
  color: #8f2424;
}
.controls .btn:focus-visible,
.controls #search:focus-visible {
  outline: 3px solid #4a6fa5;
  outline-offset: 3px;
}
.controls .btn:disabled {
  background: #eef0f3;
  border-color: #d9dee7;
  color: #6b7280;
  cursor: not-allowed;
}
.controls .progress {
  flex: 1 1 100%;
  margin: 0;
}
.controls .progress:empty {
  display: none;
}
@media (max-width: 768px) {
  .controls #search {
    flex-basis: 100%;
    min-width: 0;
    width: 100%;
  }
  .controls > .btn {
    flex: 1 1 200px;
    white-space: normal;
    text-align: center;
  }
  .controls .toolbar-logout {
    flex: 1 1 100%;
    justify-content: flex-end;
    margin-left: 0;
  }
}
/* TRANSPORT TOOLBAR END */

/* Фильтр по статусам пропусков */
.controls #statusFilter {
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid #cbd7e8;
  border-radius: 8px;
  background: #fff;
  color: #365b8c;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.filter-info { color: #777; font-size: 12px; white-space: nowrap; }
.card.orange { border-left-color: #e67e22; }
.badge-cancelled { background: #fdebd9; color: #9a4e00; }

/* Индикатор последнего пропуска */
.dot-cell { text-align: center; white-space: nowrap; }
.pass-dot {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: help;
  vertical-align: middle;
}
.dot-active { background: #2ecc71; box-shadow: 0 0 0 3px rgba(46,204,113,.22); }
.dot-warn { background: #f39c12; box-shadow: 0 0 0 3px rgba(243,156,18,.22); }
.dot-expired { background: #e74c3c; box-shadow: 0 0 0 3px rgba(231,76,60,.22); }
.dot-unchecked { background: #b9bec9; box-shadow: 0 0 0 3px rgba(185,190,201,.22); }
.dot-cancelled {
  background: #e67e22;
  animation: dot-pulse 1.6s ease-out infinite;
}
@keyframes dot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(230,126,34,.55); }
  70% { box-shadow: 0 0 0 10px rgba(230,126,34,0); }
  100% { box-shadow: 0 0 0 0 rgba(230,126,34,0); }
}
.pass-dot .tt {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 240px;
  max-width: 320px;
  background: #1a1a2e;
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.55;
  text-align: left;
  white-space: normal;
  z-index: 60;
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s, visibility .15s;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.pass-dot .tt::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #1a1a2e;
}
.pass-dot:hover .tt, .pass-dot:focus .tt { opacity: 1; visibility: visible; }
.tt-title { font-weight: 700; margin-bottom: 6px; }
.tt-note { color: #a7adc0; margin-top: 6px; font-size: 11px; }
.tt-alert {
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(230,126,34,.28);
  border: 1px solid #e67e22;
  border-radius: 6px;
  color: #ffc890;
  font-weight: 600;
}

/* Тёмная тема */
html.dark body { background: #12141c; color: #e6e8f0; }
html.dark h1 { color: #e6e8f0; }
html.dark .card { background: #1d2030; box-shadow: 0 2px 8px rgba(0,0,0,.45); }
html.dark .card .label { color: #9aa3b8; }
html.dark .controls input[type="text"],
html.dark .controls #statusFilter { background: #14161f; border-color: #333a4d; color: #e6e8f0; }
html.dark .controls #statusFilter option { background: #1d2030; color: #e6e8f0; }
html.dark table { background: #1d2030; box-shadow: 0 2px 8px rgba(0,0,0,.45); }
html.dark thead th { background: #262b3d; }
html.dark tbody tr { border-bottom-color: #2a2f42; }
html.dark tbody tr:hover { background: #242940; }
html.dark .muted { color: #8b93a8; }
html.dark .pass-expiry, html.dark .pass-details { color: #9aa3b8; }
html.dark .pass-details summary { color: #8fb0e0; }
html.dark .relative-date { color: #8b93a8; }
html.dark .check-error { color: #e08a8a; }
html.dark .comment-cell:hover { background: #242940; }
html.dark .comment-cell.editing { background: #1d2030; }
html.dark .icon-btn { background: #1d2030; border-color: #333a4d; color: #8fb0e0; }
html.dark .icon-btn:hover:not(:disabled) { background: #242940; border-color: #4a6fa5; }
html.dark .icon-btn:disabled { background: #1d2030; color: #5a6178; }
html.dark .controls .toolbar-secondary { background: #1d2030; border-color: #333a4d; color: #a8c0e8; }
html.dark .controls .toolbar-secondary:hover:not(:disabled) { background: #242940; border-color: #4a6fa5; }
html.dark .controls .toolbar-danger { background: #1d2030; border-color: #5a3a3a; color: #e08a8a; }
html.dark .controls .toolbar-danger:hover:not(:disabled) { background: #2a1d1d; border-color: #bd4545; color: #f0a0a0; }
html.dark .controls .btn:disabled { background: #1d2030; border-color: #2a2f42; color: #5a6178; }
html.dark dialog { background: #1d2030; color: #e6e8f0; }
html.dark label input { background: #14161f; border-color: #333a4d; color: #e6e8f0; }
html.dark #notifications .notice { background: #4a3d1e; color: #f0d9a0; }
html.dark .btn-individual { background: #26304a; color: #9fc0ff; }
html.dark .btn-individual:hover { background: #2e3a58; }
html.dark .filter-info { color: #8b93a8; }
html.dark .badge-cancelled { background: #4a3524; color: #ffb26b; }
html.dark .badge-active { background: #1d4030; color: #7fd6a4; }
html.dark .badge-expired { background: #462530; color: #f0a3ab; }
html.dark .badge-warn { background: #453a1c; color: #f0cd7e; }
html.dark .comment-editor textarea { background: #14161f; color: #e6e8f0; }

/* ==== Общие переменные и внутренние страницы ==== */
:root {
  --card: #fff;
  --line: #eee;
  --muted: #666;
  --input-border: #ddd;
  --hover-bg: #f8f9ff;
}
html.dark {
  --card: #1d2030;
  --line: #2a2f42;
  --muted: #9aa3b8;
  --input-border: #333a4d;
  --hover-bg: #242940;
}

/* Шапка внутренних страниц */
.subpage-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 22px; }
.subpage-head h1 { flex: 1; min-width: 240px; margin: 0; text-align: left; font-size: 22px; }
.subpage-head .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 14px; border: 1px solid #cbd7e8; border-radius: 8px; background: #fff; color: #365b8c; font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer; transition: background-color .15s, border-color .15s; }
.subpage-head .btn:hover { background: #eaf0f9; border-color: #4a6fa5; text-decoration: none; }
html.dark .subpage-head .btn { background: #1d2030; border-color: #333a4d; color: #a8c0e8; }
html.dark .subpage-head .btn:hover { background: #242940; border-color: #4a6fa5; }

/* Карточка-контейнер внутренних страниц */
.page-card { background: var(--card); border-radius: 12px; padding: 22px; box-shadow: 0 2px 8px rgba(0,0,0,.08); border-left: 4px solid #4a6fa5; }
html.dark .page-card { box-shadow: 0 2px 8px rgba(0,0,0,.45); }
.page-card p { margin: 8px 0; }
.page-card ul { margin: 10px 0 16px; }

/* Загрузка файла (импорт, документы) */
.file-drop { display: inline-flex; align-items: center; gap: 10px; padding: 12px 16px; border: 2px dashed var(--input-border); border-radius: 10px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; transition: border-color .15s, color .15s; min-height: 42px; max-width: 100%; }
.file-drop:hover { border-color: #4a6fa5; color: #4a6fa5; }
html.dark .file-drop:hover { color: #8fb0e0; }
.file-drop.has-file { border-style: solid; border-color: #2ecc71; color: #155724; }
html.dark .file-drop.has-file { color: #7fd6a4; }
.file-drop span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-drop input[type="file"] { display: none; }
.inline-form input[type="file"] { max-width: 280px; font-size: 12px; }

/* Панели результата / ошибок внутренних страниц */
.imp-result { white-space: pre-wrap; background: #e7f4e7; color: #155724; padding: 16px; border-radius: 10px; margin-top: 14px; border: 1px solid #bfe3bf; font-size: 13px; line-height: 1.6; }
html.dark .imp-result { background: #1d4030; color: #a9e5c3; border-color: #2a5240; }
.form-error { color: #a20; white-space: pre-wrap; margin-top: 10px; font-size: 13px; }
html.dark .form-error { color: #f0a3ab; }

/* Счётчик дней рядом со статусом пропуска */
.pass-days { font-size: 12px; font-weight: 700; margin-top: 3px; }
.pass-days-ok { color: #1e8449; }
.pass-days-warn { color: #b9770e; }
.pass-days-bad { color: #b03a2e; }
.pass-days-cancelled { color: #ca6f1e; }
html.dark .pass-days-ok { color: #7fd6a4; }
html.dark .pass-days-warn { color: #f0cd7e; }
html.dark .pass-days-bad { color: #f0a3ab; }
html.dark .pass-days-cancelled { color: #ffb26b; }

/* Ячейка выбора клиента на главной */
.client-cell {
  width: 100%;
  min-width: 150px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  transition: border-color .15s, background .15s;
}
.client-cell:hover { border-color: var(--input-border); }
.client-cell:focus { border-color: #4a6fa5; outline: none; background: var(--card); }
.client-cell.client-saved { border-color: #2ecc71; }
html.dark .client-cell:focus { border-color: #8fb0e0; }

/* ==== Страница входа ==== */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #d7e2f4 0%, #f0f2f5 65%); padding: 20px; }
html.dark .login-body { background: linear-gradient(135deg, #0e1017 0%, #1a1e2e 100%); }
.login-wrap { width: min(420px, 100%); }
.login-card { position: relative; background: var(--card); border-radius: 20px; padding: 36px 32px; box-shadow: 0 18px 50px rgba(26,42,74,.18); text-align: center; }
html.dark .login-card { box-shadow: 0 18px 50px rgba(0,0,0,.55); }
.login-logo { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 20px; background: linear-gradient(135deg, #4a6fa5, #2ecc71); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 32px; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; line-height: 1.55; }
.login-hint { display: flex; gap: 10px; align-items: flex-start; text-align: left; background: #e8f4fd; border: 1px solid #b9d7f2; color: #1b4f7c; border-radius: 12px; padding: 12px 14px; font-size: 13px; margin-bottom: 16px; }
html.dark .login-hint { background: #152a40; border-color: #274b6b; color: #a8d0f0; }
.login-hint > div { display: flex; gap: 10px; flex: 1; }
.login-hint .fa-circle-info { margin-top: 2px; font-size: 16px; }
.login-hint-text { line-height: 1.5; }
.login-hint-close { border: none; background: transparent; cursor: pointer; color: inherit; opacity: .6; padding: 2px; }
.login-hint-close:hover { opacity: 1; }
.login-error { display: flex; gap: 8px; align-items: center; justify-content: center; background: #fdecea; color: #a20; border-radius: 10px; padding: 10px; font-size: 13px; margin-bottom: 14px; }
html.dark .login-error { background: #462530; color: #f0a3ab; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-field { display: flex; align-items: center; gap: 10px; background: var(--card); border: 2px solid var(--input-border); border-radius: 12px; padding: 0 14px; transition: border-color .2s; }
.login-field:focus-within { border-color: #4a6fa5; }
.login-field > i { color: var(--muted); width: 16px; text-align: center; }
.login-field input { flex: 1; border: none; background: transparent; padding: 13px 0; font: inherit; font-size: 14px; color: inherit; outline: none; }
.login-eye { border: none; background: transparent; color: var(--muted); cursor: pointer; padding: 4px; }
.login-eye:hover { color: #4a6fa5; }
.login-submit { justify-content: center; min-height: 46px; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; }
.login-theme { position: absolute; top: 14px; right: 14px; border: 1px solid var(--input-border); background: var(--card); color: var(--muted); width: 36px; height: 36px; border-radius: 10px; cursor: pointer; }
.login-theme:hover { color: #4a6fa5; border-color: #4a6fa5; }

/* Чип текущего пользователя */
.user-chip { position: fixed; top: 14px; right: 16px; z-index: 100; display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--input-border); border-radius: 999px; padding: 7px 8px 7px 14px; font-size: 13px; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
html.dark .user-chip { box-shadow: 0 4px 14px rgba(0,0,0,.45); }
.user-chip .fa-circle-user { color: #4a6fa5; font-size: 16px; }
html.dark .user-chip .fa-circle-user { color: #8fb0e0; }
.user-logout { border: none; background: transparent; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 999px; font-size: 13px; }
.user-logout:hover { color: #c0392b; background: var(--hover-bg); }

/* Панель «пользователи онлайн» */
.online-bar { position: fixed; bottom: 12px; left: 16px; z-index: 90; background: var(--card); border: 1px solid var(--input-border); border-radius: 999px; padding: 6px 14px; font-size: 12px; color: var(--muted); box-shadow: 0 4px 12px rgba(0,0,0,.1); display: flex; align-items: center; gap: 8px; }
html.dark .online-bar { box-shadow: 0 4px 12px rgba(0,0,0,.45); }
.online-bar b { color: inherit; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #2ecc71; display: inline-block; animation: dot-pulse 1.8s infinite; }
.container { padding-bottom: 44px; }

/* Кастомный выпадающий список клиента */
.client-picker { position: relative; display: flex; align-items: center; min-width: 150px; }
.client-picker .client-cell { width: auto; flex: 1; min-width: 0; }
.client-arrow { border: none; background: transparent; color: var(--muted); cursor: pointer; padding: 5px 7px; border-radius: 6px; font-size: 11px; }
.client-arrow:hover { color: #4a6fa5; background: var(--hover-bg); }
.client-menu { position: absolute; top: calc(100% + 4px); left: 0; right: 0; max-height: 260px; overflow-y: auto; background: var(--card); border: 1px solid var(--input-border); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.2); z-index: 80; padding: 6px; }
.client-item { padding: 8px 10px; border-radius: 7px; font-size: 13px; cursor: pointer; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-item:hover { background: var(--hover-bg); }
.client-item.active { background: #e8f0fe; color: #365b8c; font-weight: 600; }
html.dark .client-item.active { background: #26304a; color: #9fc0ff; }
.client-empty { padding: 8px 10px; font-size: 12px; color: var(--muted); }

/* Мини-чат пользователей */
.chat-panel { position: fixed; bottom: 12px; right: 16px; z-index: 95; width: 300px; max-width: calc(100vw - 32px); background: var(--card); border: 1px solid var(--input-border); border-radius: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.18); overflow: hidden; display: flex; flex-direction: column; }
html.dark .chat-panel { box-shadow: 0 8px 28px rgba(0,0,0,.5); }
.chat-header { display: flex; align-items: center; gap: 8px; width: 100%; border: none; background: transparent; color: inherit; padding: 10px 14px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.chat-header:hover { background: var(--hover-bg); }
.chat-online { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 600; }
.chat-chevron { color: var(--muted); font-size: 11px; }
.chat-body { display: flex; flex-direction: column; height: 320px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 85%; background: var(--hover-bg); border-radius: 12px; padding: 7px 10px; font-size: 13px; align-self: flex-start; line-height: 1.4; word-break: break-word; }
.chat-msg.mine { align-self: flex-end; background: #e8f0fe; }
html.dark .chat-msg.mine { background: #26304a; }
.chat-msg-head { font-size: 10px; color: var(--muted); margin-bottom: 2px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; padding: 9px 12px; border: 2px solid var(--input-border); border-radius: 10px; background: transparent; color: inherit; font: inherit; font-size: 13px; outline: none; }
.chat-form input:focus { border-color: #4a6fa5; }
.chat-send { border: none; background: #4a6fa5; color: #fff; width: 38px; border-radius: 10px; cursor: pointer; flex-shrink: 0; }
.chat-send:hover { background: #3a5a8a; }
@media (max-width: 640px) { .chat-panel { width: calc(100vw - 24px); right: 12px; } }

/* Фикс: author-CSS display перебивал атрибут hidden */
.chat-body[hidden] { display: none; }

/* Правый нижний стек: чат + панель онлайн (не пересекаются) */
.online-bar {
  left: auto;
  right: 16px;
  bottom: 64px;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: bottom .2s ease;
}
.chat-panel:not(.collapsed) ~ .online-bar {
  bottom: 396px;
}
@media (max-width: 640px) {
  .online-bar { max-width: calc(100vw - 24px); right: 12px; }
}

/* Фикс: тёмная тема для поиска (ID-перебиваемое правило) */
html.dark .controls #search {
  background: #14161f;
  border-color: #333a4d;
  color: #e6e8f0;
}
html.dark .controls #search::placeholder { color: #5a6178; }

/* Бейдж непрочитанных сообщений чата */
.chat-badge { background: #e74c3c; color: #fff; border-radius: 999px; font-size: 10px; font-weight: 700; padding: 2px 7px; margin-left: 4px; }

/* Системная пометка в чате (локальная) */
.chat-system { align-self: center; background: transparent; color: var(--muted); font-size: 11px; padding: 2px 8px; }

/* Ссылка восстановления на странице входа */
.login-forgot { display: inline-block; margin-top: 14px; font-size: 13px; color: #4a6fa5; text-decoration: none; }
.login-forgot:hover { text-decoration: underline; }
html.dark .login-forgot { color: #8fb0e0; }
.user-chip a.user-logout { text-decoration: none; display: inline-flex; align-items: center; }

/* Автозаполнение браузера не должно красить поля входа в белый */
.login-field input { border-radius: 10px; }
.login-field input:-webkit-autofill,
.login-field input:-webkit-autofill:hover,
.login-field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #ffffff inset;
  -webkit-text-fill-color: #1a1a2e;
  caret-color: #1a1a2e;
  transition: background-color 9999s ease-in-out 0s;
}
html.dark .login-field input:-webkit-autofill,
html.dark .login-field input:-webkit-autofill:hover,
html.dark .login-field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #1d2030 inset;
  -webkit-text-fill-color: #e6e8f0;
  caret-color: #e6e8f0;
}

/* Уведомления с поддержкой тёмной темы */
.notice-ok { background: #e7f4e7; color: #155724; padding: 14px; border-radius: 8px; margin-bottom: 14px; }
html.dark .notice-ok { background: #1d4030; color: #a9e5c3; }
.notice-err { background: #fdecea; color: #a20; padding: 14px; border-radius: 8px; margin-bottom: 14px; }
html.dark .notice-err { background: #462530; color: #f0a3ab; }
