@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700;12..96,800&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  --bg: #070a16;
  --panel: #121627;
  --panel-2: #1a2036;
  --line: #262d44;
  --line-2: #333c58;
  --text: #eef1fb;
  --muted: #8c93ad;
  --muted-2: #5d647e;
  --accent: #6A2CFF;
  --accent2: #148CFF;
  --accent-soft: rgba(106, 44, 255, .18);
  --grad: linear-gradient(90deg, #148CFF 0%, #6A2CFF 55%, #B12CFF 100%);
  --green: #4ade80;
  --red: #f87171;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
/* фирменная надпись IVN градиентом */
.wm { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 800; }
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background:
    radial-gradient(1100px 700px at 85% -10%, rgba(20,140,255,.16), transparent 60%),
    radial-gradient(900px 600px at 8% 18%, rgba(106,44,255,.20), transparent 55%),
    radial-gradient(900px 900px at 50% 120%, rgba(177,44,255,.15), transparent 55%),
    var(--bg);
}
/* звёздное небо — два слоя с параллаксом и мерцанием */
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .75;
  background-image:
    radial-gradient(1.6px 1.6px at 40px 60px, #fff, transparent),
    radial-gradient(1.6px 1.6px at 130px 20px, rgba(255,255,255,.7), transparent),
    radial-gradient(1px 1px at 80px 140px, #fff, transparent),
    radial-gradient(2px 2px at 200px 100px, rgba(255,255,255,.9), transparent),
    radial-gradient(1.2px 1.2px at 260px 50px, rgba(190,205,255,.85), transparent),
    radial-gradient(1px 1px at 300px 200px, rgba(255,220,200,.8), transparent);
  background-repeat: repeat; background-size: 340px 340px;
  animation: drift 220s linear infinite;
}
body::after {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 20px 30px, rgba(255,255,255,.9), transparent),
    radial-gradient(1px 1px at 90px 80px, rgba(255,255,255,.55), transparent),
    radial-gradient(1px 1px at 160px 40px, #fff, transparent),
    radial-gradient(1px 1px at 50px 160px, rgba(200,215,255,.7), transparent);
  background-repeat: repeat; background-size: 190px 190px;
  animation: twinkle 5.5s ease-in-out infinite alternate, drift2 150s linear infinite;
}
@keyframes drift  { from { background-position: 0 0; } to { background-position: 340px 680px; } }
@keyframes drift2 { from { background-position: 0 0; } to { background-position: -190px 380px; } }
@keyframes twinkle { 0% { opacity: .35; } 100% { opacity: .9; } }
h1,h2,h3 { font-family: 'Bricolage Grotesque', sans-serif; letter-spacing: -.02em; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }
a { color: var(--accent); }

/* ---------- LOGIN ---------- */
.login-wrap { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 40px 34px; box-shadow: var(--shadow); }
.login-card .mark { font-family: 'Bricolage Grotesque'; font-weight: 800; font-size: 26px; }
.login-card .mark b { color: var(--accent); }
.login-card p { color: var(--muted); font-size: 14px; margin: 6px 0 28px; }
.login-card label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.login-card input { width: 100%; margin: 8px 0 18px; padding: 13px 14px; background: var(--bg);
  border: 1px solid var(--line-2); border-radius: 10px; color: var(--text); font-size: 15px; }
.login-card input:focus { outline: none; border-color: var(--accent); }
.err { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 10px; }

/* ---------- LAYOUT ---------- */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 22px 16px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; }
.brand { font-family: 'Bricolage Grotesque'; font-weight: 800; font-size: 20px; padding: 6px 12px 22px; }
.brand b { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: 14.5px; border: 1px solid transparent; }
.nav:hover { color: var(--text); background: var(--panel); }
.nav.active { color: var(--text); background: var(--accent-soft); border-color: rgba(106,44,255,.25); }
.nav svg { width: 18px; height: 18px; flex: 0 0 18px; }
.nav .badge { margin-left: auto; background: var(--accent); color: #ffffff; font-size: 11px; font-weight: 800;
  border-radius: 20px; padding: 1px 8px; }
.side .spacer { flex: 1; }
.logout { color: var(--muted-2); background: none; border: none; text-align: left; padding: 11px 14px; font-size: 13px; }
.logout:hover { color: var(--red); }

.main { padding: 30px 38px 80px; max-width: 1200px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 26px; flex-wrap: wrap; gap: 14px; }
.page-head h1 { font-size: 30px; font-weight: 800; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ---------- BUTTONS ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font-weight: 600; font-size: 14px; transition: .15s; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.btn.sm { padding: 7px 11px; font-size: 13px; }
.btn.ghost { background: transparent; }

/* ---------- CARDS / GRID ---------- */
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted-2);
  margin: 8px 0 14px; font-weight: 700; }
.grid { display: grid; gap: 16px; }
.grid.screens { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.grid.media { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.grid.playlists { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card.pending { border-color: rgba(106,44,255,.4); background: linear-gradient(var(--panel), var(--panel)) padding-box; }

.screen-card .top { padding: 16px 16px 12px; display: flex; align-items: flex-start; gap: 10px; }
.screen-card .name { font-weight: 700; font-size: 16px; }
.screen-card .loc { color: var(--muted); font-size: 13px; margin-top: 2px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; margin-top: 5px; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: var(--muted-2); }
.screen-card .body { padding: 0 16px 14px; }
.screen-card .meta { font-size: 12px; color: var(--muted-2); margin-bottom: 12px; font-family: monospace; }
.screen-card select { width: 100%; padding: 9px 10px; background: var(--bg); border: 1px solid var(--line-2);
  border-radius: 9px; color: var(--text); font-size: 13.5px; margin-bottom: 12px; }
.screen-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pair-code { font-family: 'Bricolage Grotesque'; font-weight: 800; font-size: 30px; color: var(--accent);
  letter-spacing: .08em; padding: 8px 0 4px; }

.media-card .thumb { aspect-ratio: 16/10; background: #000; display: grid; place-items: center; position: relative; }
.media-card .thumb img, .media-card .thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-card .tag { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.65); backdrop-filter: blur(4px);
  font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 3px 7px; border-radius: 6px; letter-spacing: .05em; }
.media-card .info { padding: 11px 12px; display: flex; align-items: center; gap: 8px; }
.media-card .info .nm { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.media-card .info .sz { font-size: 11px; color: var(--muted-2); }
.icon-btn { background: none; border: none; color: var(--muted-2); padding: 4px; border-radius: 6px; }
.icon-btn:hover { color: var(--red); background: var(--panel-2); }

.pl-card { padding: 18px; }
.pl-card .nm { font-weight: 700; font-size: 17px; }
.pl-card .st { color: var(--muted); font-size: 13px; margin: 6px 0 14px; }
.pl-strip { display: flex; gap: 5px; margin-bottom: 14px; }
.pl-strip .px { width: 34px; height: 24px; border-radius: 5px; background: #000; overflow: hidden; flex: 0 0 auto; }
.pl-strip .px img { width: 100%; height: 100%; object-fit: cover; }
.pl-strip .more { color: var(--muted-2); font-size: 12px; align-self: center; }

/* ---------- EMPTY ---------- */
.empty { text-align: center; padding: 70px 20px; color: var(--muted-2); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty .big { font-size: 17px; color: var(--muted); margin-bottom: 6px; }

/* ---------- MODAL ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); z-index: 50;
  display: grid; place-items: center; padding: 24px; }
.modal { width: 100%; max-width: 560px; max-height: 86vh; overflow: auto; background: var(--panel);
  border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); }
.modal.wide { max-width: 820px; }
.modal .mhead { padding: 22px 24px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal .mhead h3 { font-size: 20px; }
.modal .mbody { padding: 22px 24px; }
.modal .mfoot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 7px; }
.field input, .field select { width: 100%; padding: 11px 12px; background: var(--bg); border: 1px solid var(--line-2);
  border-radius: 9px; color: var(--text); font-size: 14px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.close { background: none; border: none; color: var(--muted); font-size: 22px; line-height: 1; }

/* playlist editor */
.pe { display: grid; grid-template-columns: 1fr 240px; gap: 18px; }
.pe-list { display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.pe-item { display: flex; align-items: center; gap: 10px; padding: 8px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; }
.pe-item .th { width: 56px; height: 38px; border-radius: 6px; background: #000; overflow: hidden; flex: 0 0 56px; }
.pe-item .th img, .pe-item .th video { width: 100%; height: 100%; object-fit: cover; }
.pe-item .nm { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-item .dur { width: 64px; }
.pe-item .dur input { width: 100%; padding: 6px 8px; background: var(--bg); border: 1px solid var(--line-2);
  border-radius: 7px; color: var(--text); font-size: 13px; text-align: center; }
.pe-item .ord { display: flex; flex-direction: column; }
.pe-item .ord button { background: none; border: none; color: var(--muted-2); font-size: 11px; padding: 0 2px; }
.pe-item .ord button:hover { color: var(--text); }
.pe-pick { border-left: 1px solid var(--line); padding-left: 18px; }
.pe-pick h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 12px; }
.pe-pick .lib { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow: auto; }
.pe-pick .li { display: flex; align-items: center; gap: 9px; padding: 6px; border-radius: 8px; cursor: pointer; }
.pe-pick .li:hover { background: var(--panel-2); }
.pe-pick .li .th { width: 42px; height: 28px; border-radius: 5px; background: #000; overflow: hidden; flex: 0 0 42px; }
.pe-pick .li .th img, .pe-pick .li .th video { width: 100%; height: 100%; object-fit: cover; }
.pe-pick .li .nm { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text); padding: 12px 20px;
  border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transition: .25s; z-index: 100; font-size: 14px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.25); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.upbar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 10px; display: none; }
.upbar.show { display: block; }
.upbar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side .spacer { display: none; }
  .main { padding: 20px; }
  .pe { grid-template-columns: 1fr; } .pe-pick { border-left: none; padding-left: 0; border-top: 1px solid var(--line); padding-top: 16px; }
}

/* ---------- ФИЛИАЛЫ / массовые действия ---------- */
.hdr-select { padding: 9px 12px; background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 10px; color: var(--text); font-size: 14px; font-weight: 600; }
.hdr-select:focus { outline: none; border-color: var(--accent); }

.bulkbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid rgba(106,44,255,.35); border-left: 3px solid var(--accent);
  border-radius: 12px; padding: 12px 16px; margin: 4px 0 22px; }
.bulkbar .bb-info { font-size: 14px; color: var(--muted); }
.bulkbar .bb-info b { color: var(--text); font-size: 15px; }
.bulkbar .bb-sp { flex: 1; }

.branch-head { display: flex; align-items: center; gap: 12px; margin: 26px 0 12px;
  padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.branch-head .bh-title { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 18px;
  display: flex; align-items: baseline; gap: 12px; flex: 1; }
.branch-head .bh-count { font-family: 'Manrope', sans-serif; font-weight: 500; font-size: 12px; color: var(--muted-2); }

.sc-check { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--accent); cursor: pointer; flex: 0 0 18px; }
.screen-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

/* менеджер филиалов */
.br-list { margin-top: 6px; display: flex; flex-direction: column; gap: 8px; }
.br-row { display: flex; align-items: center; gap: 8px; }
.br-name { flex: 1; padding: 9px 11px; background: var(--bg); border: 1px solid var(--line-2);
  border-radius: 9px; color: var(--text); font-size: 14px; }
.br-name:focus { outline: none; border-color: var(--accent); }
.br-cnt { font-size: 12px; color: var(--muted-2); white-space: nowrap; min-width: 48px; text-align: right; }

/* ---------- АУДИО ---------- */
.audio-th { display:flex; align-items:center; justify-content:center;
  background:linear-gradient(135deg, rgba(20,140,255,.22), rgba(177,44,255,.22)); color:#9b6cff; }
.audio-th svg { width:42%; height:42%; }
.media-card .thumb.audio-th { background:linear-gradient(135deg, rgba(20,140,255,.22), rgba(177,44,255,.22)); }

.aud-grid { display:grid; grid-template-columns:1fr 280px; gap:18px; }
.aud-col { min-width:0; }
.aud-lib { border-left:1px solid var(--line); padding-left:18px; }
.aud-h { font-family:'Bricolage Grotesque',sans-serif; font-weight:700; font-size:15px; margin-bottom:12px; }
.aud-h span { font-family:'Manrope',sans-serif; font-weight:500; font-size:12.5px; color:var(--muted-2); }

.spot { display:flex; align-items:center; gap:10px; flex-wrap:wrap; background:var(--panel); border:1px solid var(--line);
  border-radius:11px; padding:10px 12px; margin-bottom:8px; }
.spot.off { opacity:.5; }
.sp-time { width:96px; padding:8px 9px; background:var(--bg); border:1px solid var(--line-2); border-radius:8px;
  color:var(--text); font-size:14px; font-variant-numeric:tabular-nums; }
.sp-time:focus, .sp-track:focus { outline:none; border-color:var(--accent); }
.sp-track { flex:1; min-width:140px; padding:8px 9px; background:var(--bg); border:1px solid var(--line-2);
  border-radius:8px; color:var(--text); font-size:13px; }
.sp-days { display:flex; gap:4px; }
.sp-days .day { width:30px; height:30px; border-radius:7px; border:1px solid var(--line-2); background:var(--panel-2);
  color:var(--muted); font-size:11px; font-weight:700; cursor:pointer; }
.sp-days .day.on { background:var(--accent); border-color:var(--accent); color:#ffffff; }
.sp-en { display:flex; align-items:center; gap:5px; font-size:12px; color:var(--muted); }
.sp-en input { accent-color:var(--accent); }

@media (max-width:760px){ .aud-grid{ grid-template-columns:1fr; } .aud-lib{ border-left:none; padding-left:0; border-top:1px solid var(--line); padding-top:16px; } }
