:root {
  --bg: #14161a;
  --surface: #1c1f26;
  --surface-2: #232732;
  --border: #2d323d;
  --text: #e4e6eb;
  --muted: #8b919e;
  --accent: #4a90d9;
  --accent-soft: #1f3349;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  flex-shrink: 0;
}

.brand {
  font-size: 16px;
  font-weight: 600;
  padding: 4px 10px 20px;
  letter-spacing: -0.3px;
}
.brand span { color: var(--accent); }

nav { display: flex; flex-direction: column; gap: 2px; }
nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 6px;
  transition: background .12s, color .12s;
}
nav a:hover { background: var(--surface-2); color: var(--text); }
nav a.on { background: var(--accent-soft); color: var(--text); }

.content { flex: 1; display: flex; flex-direction: column; }

.topbar {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; font-weight: 600; }

.page { padding: 24px 28px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card.accent { border-color: var(--accent); }
.card-value { font-size: 28px; font-weight: 600; letter-spacing: -0.5px; }
.card-label { color: var(--muted); margin-top: 4px; font-size: 13px; }

.hint { color: var(--muted); font-size: 13px; }

.toolbar { display: flex; gap: 8px; margin-bottom: 18px; }
.chip {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}
.chip:hover { color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.grid th {
  text-align: left;
  padding: 11px 14px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.grid td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
.grid tr:last-child td { border-bottom: none; }
.grid tr:hover td { background: var(--surface-2); }
.muted { color: var(--muted); }

.badge {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 11px;
  font-size: 12px;
  font-weight: 600;
}

.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

/* --- топбар: блок пользователя --- */
.topbar { display: flex; align-items: center; justify-content: space-between; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.uname { font-weight: 600; }
.urole {
  padding: 2px 8px; border-radius: 10px; font-size: 11px;
  background: var(--accent-soft); color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.logout {
  color: var(--muted); text-decoration: none; padding: 5px 12px;
  border: 1px solid var(--border); border-radius: 6px;
}
.logout:hover { color: var(--text); border-color: var(--muted); }

/* --- страница входа --- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 36px 32px; width: 340px; text-align: center;
}
.login-brand { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
.login-brand span { color: var(--accent); }
.login-sub { color: var(--muted); margin: 4px 0 24px; font-size: 13px; }
.login-card form { display: flex; flex-direction: column; text-align: left; }
.login-card label {
  font-size: 12px; color: var(--muted); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.login-card input {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 10px 12px; margin-bottom: 16px; font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 11px; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 4px;
}
.login-card button:hover { background: #3a7bc4; }
.login-error {
  background: #3a1f24; border: 1px solid #6b2b35; color: #e8a0a8;
  padding: 10px; border-radius: 6px; font-size: 13px; margin-bottom: 18px;
}
.back-link { color: var(--accent); text-decoration: none; font-size: 14px; }

/* --- формы разделов --- */
.panel-form {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 22px;
}
.panel-form h3 { font-size: 14px; margin-bottom: 14px; font-weight: 600; }
.row-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row-form .field { display: flex; flex-direction: column; min-width: 130px; }
.row-form .field.grow { flex: 1; min-width: 200px; }
.row-form .field.small { min-width: 100px; max-width: 120px; }
.row-form label {
  font-size: 11px; color: var(--muted); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.row-form input, .row-form select, .filter-bar input, .filter-bar select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 8px 10px; font-size: 13px;
}
.row-form input:focus, .row-form select:focus { outline: none; border-color: var(--accent); }
.row-form button, .filter-bar button {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 9px 18px; font-size: 13px; font-weight: 600; cursor: pointer;
  height: 35px;
}
.row-form button:hover, .filter-bar button:hover { background: #3a7bc4; }

/* --- фильтр-бар --- */
.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; align-items: center; }
.filter-bar input { flex: 1; max-width: 320px; }

/* --- действия в таблице --- */
.actions { display: flex; gap: 6px; }
.inline { display: inline; margin: 0; }
.btn-mini {
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 5px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.btn-mini:hover { color: var(--text); border-color: var(--muted); }
.btn-mini.danger:hover { color: #e8a0a8; border-color: #6b2b35; }

/* --- бейджи статусов --- */
.badge.ok { background: #1c3a2a; color: #6bcf9a; }
.badge.off { background: #3a2a1c; color: #cf9a6b; }
.badge.err { background: #3a1f24; color: #e8a0a8; }
.badge.warn { background: #3a341c; color: #cfc16b; }

/* --- утилиты таблицы --- */
.ellipsis { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellipsis-wide { max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* --- версия под брендом --- */
.version {
  font-size: 11px; color: var(--muted); padding: 0 10px 16px;
  letter-spacing: 0.5px; margin-top: -12px;
}

/* --- сеточная форма (источники с автологином) --- */
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-form .field { display: flex; flex-direction: column; }
.grid-form .field.span2 { grid-column: 1 / -1; }
.grid-form label {
  font-size: 11px; color: var(--muted); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.grid-form input {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 9px 11px; font-size: 13px;
}
.grid-form input:focus { outline: none; border-color: var(--accent); }
.grid-form .divider-label {
  font-size: 12px; color: var(--accent); padding-top: 6px;
  border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px;
}
.grid-form .submit-row { align-items: flex-start; }
.grid-form button {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 10px 22px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.grid-form button:hover { background: #3a7bc4; }
.form-hint {
  margin-top: 14px; font-size: 12px; color: var(--muted);
  line-height: 1.5; border-top: 1px solid var(--border); padding-top: 12px;
}

/* --- кликабельные строки каталога --- */
.clickable { cursor: pointer; }
.clickable:hover td { background: var(--surface-2); }
.title-link { font-weight: 500; color: var(--accent); }
.poster-cell { width: 46px; padding: 6px 8px !important; }
.mini-poster { width: 34px; height: 50px; object-fit: cover; border-radius: 4px; display: block; }
.no-poster { display: block; width: 34px; height: 50px; background: var(--surface-2); border-radius: 4px; }

/* --- детальная страница тайтла --- */
.back-arrow { color: var(--muted); text-decoration: none; margin-right: 6px; }
.back-arrow:hover { color: var(--text); }
.title-head { display: flex; gap: 22px; margin-bottom: 26px; }
.title-poster {
  width: 160px; border-radius: 10px; flex-shrink: 0;
  border: 1px solid var(--border);
}
.title-meta { flex: 1; }
.title-row { margin-bottom: 8px; font-size: 14px; }
.meta-label { color: var(--muted); display: inline-block; min-width: 50px; }
.imdb-link {
  color: #f5c518; text-decoration: none; font-weight: 600;
  background: rgba(245,197,24,0.1); padding: 2px 10px; border-radius: 5px;
}
.imdb-link:hover { background: rgba(245,197,24,0.2); }
.title-desc {
  margin-top: 14px; color: var(--text); line-height: 1.6; font-size: 14px;
  padding-top: 14px; border-top: 1px solid var(--border);
}
.section-title { font-size: 15px; font-weight: 600; margin: 8px 0 14px; }

/* --- пагинация --- */
.pager { display: flex; align-items: center; gap: 4px; margin-top: 18px; flex-wrap: wrap; }
.pager-btn {
  min-width: 32px; height: 32px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); text-decoration: none; font-size: 13px;
}
.pager-btn:hover { color: var(--text); border-color: var(--muted); }
.pager-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager-btn.disabled { opacity: 0.3; pointer-events: none; }
.pager-dots { color: var(--muted); padding: 0 2px; }
.pager-info { margin-left: 12px; color: var(--muted); font-size: 12px; }

/* --- компактная таблица (детальная страница) --- */
.grid.compact th, .grid.compact td { padding: 8px 10px; font-size: 13px; }
.ellipsis-mid {
  max-width: 320px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
/* детальная страница не должна растягиваться шире контейнера */
.page { max-width: 100%; overflow-x: hidden; }
.grid { table-layout: auto; }

/* --- рабочий список «нужно проверить» --- */
.hint-line { color: var(--muted); font-size: 13px; margin-bottom: 16px; line-height: 1.5; }
.btn-mini.ok-btn { color: #6bcf9a; border-color: #1c3a2a; }
.btn-mini.ok-btn:hover { background: #1c3a2a; color: #8be0b3; }

/* --- IMDB-бейдж в таблицах (жёлтый, как на детальной странице) --- */
.imdb-badge {
  color: #f5c518; background: rgba(245,197,24,0.1);
  padding: 2px 8px; border-radius: 5px; font-size: 12px; font-weight: 600;
}

/* --- массовая проверка --- */
.check-toolbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 16px;
}
.check-toolbar .hint-line { margin-bottom: 0; flex: 1; }
.btn-verify {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 10px 18px; font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.btn-verify:hover { background: #3a7bc4; }

/* --- прогресс-бар фоновых задач --- */
.task-progress {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px; margin-bottom: 18px;
}
.tp-label { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.tp-bar {
  height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden;
}
.tp-fill {
  height: 100%; background: var(--accent); border-radius: 4px;
  transition: width 0.4s ease;
}
.tp-fill.tp-error { background: #cf6b6b; }
.tp-info { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* --- вторичные кнопки и тулбар --- */
.toolbar-spacer { flex: 1; }
.btn-secondary {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.btn-secondary:hover { border-color: var(--muted); }

/* --- строка редактирования в таблице --- */
.edit-row td { background: var(--surface-2); padding: 16px !important; }
.edit-row .grid-form { max-width: 700px; }

/* ===== Дашборд: графики ===== */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 20px;
}
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  min-height: 240px;
}
.panel-head {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 18px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.head-note { font-size: 12px; font-weight: 400; color: var(--muted); }

/* кольцо покрытия */
.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.donut { width: 180px; height: 180px; flex-shrink: 0; }
.donut-num { font-size: 34px; font-weight: 700; fill: var(--text); }
.donut-sub { font-size: 12px; fill: var(--muted); }
.legend { display: flex; flex-direction: column; gap: 10px; }
.leg { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.leg b { color: var(--text); margin-left: auto; padding-left: 12px; }
.dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }

/* столбцы активности */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 180px;
  padding-top: 20px;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}
.bar {
  width: 100%;
  max-width: 28px;
  background: linear-gradient(180deg, var(--accent), var(--accent-soft));
  border-radius: 4px 4px 0 0;
  transition: opacity .12s;
  min-height: 2px;
}
.bar-col:hover .bar { opacity: .8; }
.bar-val { font-size: 11px; color: var(--muted); height: 14px; }
.bar-day { font-size: 10px; color: var(--muted); white-space: nowrap; }

/* горизонтальные полосы по трекерам */
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar-row { display: flex; align-items: center; gap: 12px; }
.hbar-name {
  width: 140px;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.hbar-track {
  flex: 1;
  height: 22px;
  background: var(--surface-2);
  border-radius: 5px;
  overflow: hidden;
}
.hbar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent));
  border-radius: 5px;
  min-width: 2px;
  transition: width .3s;
}
.hbar-num { font-size: 12px; color: var(--muted); width: 56px; text-align: right; flex-shrink: 0; }

/* топ тайтлов */
.top-list { display: flex; flex-direction: column; gap: 2px; }
.top-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 6px;
  text-decoration: none;
  transition: background .12s;
}
.top-row:hover { background: var(--surface-2); }
.top-rank {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.top-name {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-year { color: var(--muted); font-size: 12px; }
.top-badge {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 3px 9px;
  border-radius: 20px;
  flex-shrink: 0;
}
.empty-mini { color: var(--muted); font-size: 13px; padding: 30px 0; text-align: center; }

/* ===== Большой интерактивный график ===== */
.chart-panel { margin-top: 20px; }
.chart-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.chart-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.chart-sub span { color: var(--accent); font-weight: 600; }
.chart-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chart-select {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; padding: 7px 12px; font-size: 13px;
  cursor: pointer;
}
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 2px; }
.seg button {
  background: transparent; border: none; color: var(--muted);
  padding: 6px 14px; font-size: 13px; border-radius: 5px; cursor: pointer;
  transition: background .12s, color .12s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent); color: #fff; }
.chart-area { position: relative; width: 100%; }
.chart-area svg { width: 100%; height: 260px; display: block; }
.chart-area .ax { fill: var(--muted); font-size: 11px; }
.chart-area .hit { cursor: pointer; }
.chart-tip {
  position: absolute; transform: translate(-50%, -100%);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 7px; padding: 7px 11px; font-size: 12px; color: var(--text);
  pointer-events: none; opacity: 0; transition: opacity .12s; white-space: nowrap;
  z-index: 5; box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.chart-tip.show { opacity: 1; }
.chart-tip b { color: var(--accent); font-size: 14px; }
.chart-tip span { color: var(--muted); }

/* покрытие — горизонтальная составная полоса */
.cov-bar {
  display: flex; height: 28px; border-radius: 7px; overflow: hidden;
  background: var(--surface-2); margin-bottom: 16px;
}
.cov-seg { height: 100%; transition: width .3s; }
.cov-legend { flex-direction: column; gap: 9px; }
.panel-wide { grid-column: 1 / -1; }
