/* ═══════════════════════════════════════════════════════════════════════
   Kontent Dominator 9000
   Тёмный плотный интерфейс продюсерского пульта: много данных на экран,
   ничего лишнего между цифрой и глазом.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --bg:          #0e0f13;
  --surface:     #16181f;
  --surface-2:   #1d202a;
  --surface-3:   #262a36;
  --border:      #2a2e3a;
  --border-soft: #21242e;

  --text:        #e8eaf0;
  --text-dim:    #a6adbf;
  --muted:       #79809a;

  --accent:      #ffb020;
  --accent-dim:  #a3720f;
  --blue:        #57a6ff;
  --good:        #3ddc97;
  --warn:        #ffb020;
  --bad:         #ff6161;
  --violet:      #b48cff;

  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 8px 28px rgba(0,0,0,.45);

  --sidebar-w:   232px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p  { margin: 0 0 10px; }

::selection { background: var(--accent); color: #14161c; }

/* ── Каркас ─────────────────────────────────────────────────────────── */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
  position: sticky; top: 0; height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 16px; }
.brand:hover { color: inherit; }
.brand-mark {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #ff7a45);
  color: #14161c; font-weight: 800; font-size: 14px;
  border-radius: 9px;
}
.brand-text { font-size: 11px; line-height: 1.25; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.brand-text b { color: var(--text); font-size: 12px; letter-spacing: .02em; }

.ws-name, .ws-switch { margin: 0 6px 14px; }
.ws-name {
  font-size: 12px; color: var(--accent);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ws-switch select { width: 100%; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 13.5px;
}
.nav a i { font-style: normal; width: 16px; text-align: center; opacity: .65; font-size: 13px; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--surface-3); color: var(--text); }
.nav a.on i { color: var(--accent); opacity: 1; }

.sidebar-foot {
  margin-top: auto; padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 6px;
}
.user-chip {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 13px;
}
.user-chip:hover, .user-chip.on { background: var(--surface-2); color: var(--text); }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 24px; height: 24px; flex: 0 0 24px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--surface-3); color: var(--accent);
  font-size: 11px; font-weight: 700;
}
.logout {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: var(--radius-sm); color: var(--muted); font-size: 15px;
}
.logout:hover { background: var(--surface-2); color: var(--bad); }

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; max-width: 1600px; }

/* ── Шапка страницы ─────────────────────────────────────────────────── */

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Карточки и сетки ───────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card + .card { margin-top: 14px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-head h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-dim); font-weight: 600; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.cols { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } }

/* ── Плитки метрик ──────────────────────────────────────────────────── */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.tile {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 13px 15px;
}
.tile .label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin-bottom: 5px;
}
.tile .value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.tile .value.small { font-size: 17px; }
.tile .note { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.tile.accent .value { color: var(--accent); }
.tile.blue   .value { color: var(--blue); }
.tile.good   .value { color: var(--good); }
.tile.violet .value { color: var(--violet); }

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

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-3); border-color: #39404f; color: var(--text); }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #14161c; font-weight: 620;
}
.btn-primary:hover { background: #ffc04d; border-color: #ffc04d; color: #14161c; }
.btn-ghost { background: transparent; }
.btn-danger:hover { border-color: var(--bad); color: var(--bad); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ── Формы ──────────────────────────────────────────────────────────── */

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=datetime-local], input[type=date], select, textarea {
  width: 100%;
  padding: 8px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit; font-size: 13.5px;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-dim);
  box-shadow: 0 0 0 2px rgba(255,176,32,.12);
}
input::placeholder, textarea::placeholder { color: #5c6379; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; }

/* ── Флеш-сообщения ─────────────────────────────────────────────────── */

.flash {
  padding: 10px 14px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-size: 13px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.flash-ok  { border-color: rgba(61,220,151,.35); background: rgba(61,220,151,.08); color: #9ff0c9; }
.flash-err { border-color: rgba(255,97,97,.35); background: rgba(255,97,97,.08); color: #ffb3b3; }

/* ── Фильтры каталога ───────────────────────────────────────────────── */

.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px;
}
.filters input[type=search] { flex: 1 1 240px; min-width: 180px; }
.filters select { width: auto; min-width: 130px; }
.filters .count { margin-left: auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* ── Сетка каталога ─────────────────────────────────────────────────── */

.clips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 13px;
}
.clip {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .13s, transform .13s;
}
.clip:hover { border-color: var(--border); transform: translateY(-2px); color: inherit; }
.clip-thumb {
  position: relative; aspect-ratio: 9 / 16; background: #0a0b0e;
  overflow: hidden;
}
.clip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.clip-thumb .no-thumb {
  width: 100%; height: 100%; display: grid; place-items: center;
  color: #343a4a; font-size: 30px;
}
.clip-thumb .dur {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(8,9,12,.82); color: #fff;
  padding: 2px 6px; border-radius: 4px;
  font-size: 11px; font-variant-numeric: tabular-nums;
}
.clip-thumb .badges { position: absolute; left: 6px; top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.clip-body { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.clip-desc {
  font-size: 12px; color: var(--text-dim); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 33px;
}
.clip-stats {
  display: flex; gap: 9px; font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums; margin-top: auto;
}
.clip-stats b { color: var(--text-dim); font-weight: 600; }
.clip-date { font-size: 11px; color: #5f677d; }

/* ── Бейджи ─────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 20px;
  font-size: 10.5px; font-weight: 600;
  background: var(--surface-3); color: var(--text-dim);
  border: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .04em;
}
.badge-accent { background: rgba(255,176,32,.14); color: var(--accent); border-color: rgba(255,176,32,.3); }
.badge-good   { background: rgba(61,220,151,.14); color: var(--good); border-color: rgba(61,220,151,.3); }
.badge-blue   { background: rgba(87,166,255,.14); color: var(--blue); border-color: rgba(87,166,255,.3); }
.badge-bad    { background: rgba(255,97,97,.14); color: var(--bad); border-color: rgba(255,97,97,.3); }
.badge-dark   { background: rgba(8,9,12,.75); border-color: transparent; color: #cdd3e0; }

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

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); font-weight: 600;
  padding: 0 10px 8px; border-bottom: 1px solid var(--border-soft);
}
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Пагинация ──────────────────────────────────────────────────────── */

.pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin: 22px 0 6px; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 34px; padding: 6px 10px; text-align: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border-soft);
  background: var(--surface); font-size: 12.5px; color: var(--text-dim);
}
.pager a:hover { border-color: var(--border); color: var(--text); }
.pager .on { background: var(--accent); border-color: var(--accent); color: #14161c; font-weight: 650; }
.pager .gap { border: none; background: none; color: var(--muted); min-width: 18px; padding: 6px 2px; }

/* ── Пустое состояние ───────────────────────────────────────────────── */

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .icon { font-size: 38px; opacity: .3; margin-bottom: 12px; }
.empty h3 { color: var(--text-dim); margin-bottom: 6px; }
.empty p { font-size: 13px; max-width: 460px; margin: 0 auto 14px; }

/* ── Вход и регистрация ─────────────────────────────────────────────── */

body.guest {
  display: grid; place-items: center; min-height: 100vh; padding: 24px;
  background: radial-gradient(circle at 50% 0%, #1a1c26 0%, var(--bg) 55%);
}
.auth-box { width: 100%; max-width: 380px; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .mark {
  width: 52px; height: 52px; margin: 0 auto 12px;
  display: grid; place-items: center; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #ff7a45);
  color: #14161c; font-weight: 800; font-size: 19px;
}
.auth-brand h1 { font-size: 19px; }
.auth-brand .sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 14px; padding: 24px; box-shadow: var(--shadow);
}
.auth-card .btn { width: 100%; justify-content: center; margin-top: 6px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 12.5px; color: var(--muted); }
.auth-foot a { color: var(--accent); }

/* ── График ─────────────────────────────────────────────────────────── */

.chart-wrap { position: relative; width: 100%; }
.chart-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--text-dim); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ── Мелочи ─────────────────────────────────────────────────────────── */

.muted { color: var(--muted); }
.dim   { color: var(--text-dim); }
.mono  { font-family: var(--mono); font-size: 12.5px; }
.nums  { font-variant-numeric: tabular-nums; }
.row   { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
.sep   { height: 1px; background: var(--border-soft); margin: 14px 0; }
.nowrap{ white-space: nowrap; }
.hidden{ display: none; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row; align-items: center; gap: 10px; overflow-x: auto; padding: 10px 12px; }
  .brand { padding: 0 8px 0 0; }
  .brand-text, .ws-name, .ws-switch, .user-name { display: none; }
  .nav { flex-direction: row; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: none; }
  .main { padding: 16px 14px 50px; }
}
