:root {
  --bg: #f3f6fc;
  --panel: #ffffff;
  --panel-2: #f7f9fe;
  --line: #e2e8f4;
  --line-strong: #cbd5e8;
  --text: #172033;
  --muted: #6b7894;
  --accent: #2f6fed;
  --accent-2: #2456c7;
  --gold: #b7791f;
  --radius: 16px;
  --shadow: 0 14px 36px rgba(28, 52, 96, .08);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(47, 111, 237, .10), transparent 60%),
    radial-gradient(800px 500px at 0% 0%, rgba(183, 121, 31, .06), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.hidden { display: none !important; }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #355bd8);
  color: white; font-weight: 800; font-size: 20px;
  box-shadow: 0 8px 20px rgba(47, 111, 237, .25);
}
.brand-title { font-weight: 700; letter-spacing: .2px; color: var(--text); }
.brand-sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.badge {
  padding: 6px 10px; border-radius: 999px;
  border: 1px solid rgba(47, 111, 237, .22);
  background: #eef4ff;
  color: var(--accent-2); font-size: 12px; white-space: nowrap;
}
.badge.warn { color: #a16207; border-color: rgba(183, 121, 31, .35); background: #fff8e8; }
.ghost-link { color: var(--muted); text-decoration: none; font-size: 13px; }
.ghost-link:hover { color: var(--accent-2); }

.layout {
  display: grid; grid-template-columns: 290px minmax(0, 1fr);
  gap: 26px; max-width: 1480px; margin: 0 auto; padding: 26px 28px 60px;
}
.sidebar {
  position: sticky; top: 86px; align-self: start;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.side-title { font-weight: 700; font-size: 16px; }
.link-btn { background: none; border: 0; color: var(--muted); padding: 0; font-size: 12px; }
.link-btn:hover { color: var(--accent-2); }
.filter-block { padding: 14px 0; border-top: 1px solid var(--line); }
.filter-block:first-of-type { border-top: 0; padding-top: 0; }
.filter-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.hint { color: var(--gold); letter-spacing: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line-strong); background: #fff;
  color: var(--text); border-radius: 999px; padding: 6px 11px; font-size: 12px;
}
.chip:hover { border-color: rgba(47, 111, 237, .55); background: #f6f9ff; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.check {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 8px 9px; margin: 2px -9px; border-radius: 10px;
  color: #2a3550; cursor: pointer; font-size: 13px;
}
.check:hover { background: #f4f7ff; }
.check input { accent-color: var(--accent); margin: 2px 0 0; }
.check b { color: var(--gold); font-weight: 600; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
input[type="number"], input[type="search"], #accessToken {
  width: 100%; background: #fff; color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 10px; outline: none;
}
input::placeholder { color: #95a2ba; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 111, 237, .12); }
.side-note { border-top: 1px solid var(--line); padding-top: 14px; color: var(--muted); font-size: 11.5px; line-height: 1.5; }

.content { min-width: 0; }
.content-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 4px 0 16px; }
.content-head h1 { font-size: 30px; margin: 0 0 4px; letter-spacing: -.02em; color: var(--text); }
.result-count { color: var(--muted); font-size: 13px; }
.content-actions select {
  background: #fff; color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 9px 12px; outline: none;
}
.active-filters { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 16px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid rgba(47, 111, 237, .22); background: #eef4ff;
  color: var(--accent-2); border-radius: 999px; padding: 5px 10px; font-size: 12px;
}
.pill button { border: 0; background: none; color: inherit; padding: 0; font-size: 14px; line-height: 1; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.card {
  position: relative; text-align: left; color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  padding: 0; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
  box-shadow: 0 4px 16px rgba(28, 52, 96, .04);
}
.card:hover { transform: translateY(-2px); border-color: rgba(47, 111, 237, .38); box-shadow: 0 16px 34px rgba(28, 52, 96, .12); }
.card-media {
  height: 132px; position: relative;
  background:
    radial-gradient(300px 140px at 80% 15%, rgba(47, 111, 237, .24), transparent 60%),
    linear-gradient(135deg, #e8f0ff, #d7e5ff 60%, #cfdffc);
  display: flex; align-items: flex-end; padding: 13px;
  border-bottom: 1px solid #dbe5f5;
}
.card-media::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(47, 111, 237, .07) 1px, transparent 1px), linear-gradient(90deg, rgba(47, 111, 237, .07) 1px, transparent 1px);
  background-size: 26px 26px; mask-image: linear-gradient(#000, transparent);
}
.room-badge {
  position: relative; z-index: 1; background: rgba(255, 255, 255, .82);
  border: 1px solid rgba(47, 111, 237, .18); border-radius: 8px; padding: 4px 8px; font-size: 12px; color: var(--accent-2);
}
.play-dot {
  position: absolute; z-index: 2; right: 14px; bottom: 13px;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .9); border: 1px solid rgba(47, 111, 237, .18);
  box-shadow: 0 6px 16px rgba(28, 52, 96, .14);
  backdrop-filter: blur(8px);
}
.play-dot::before { content: ""; margin-left: 3px; border-left: 10px solid var(--accent); border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.card-body { padding: 13px 14px 15px; }
.price { font-size: 19px; font-weight: 750; letter-spacing: -.02em; color: var(--text); }
.price span { font-size: 12px; color: var(--muted); font-weight: 500; }
.card-meta { color: var(--muted); font-size: 12px; margin: 5px 0 9px; }
.card-district { font-size: 12px; color: #52617d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.tag {
  font-size: 10.5px; color: #52617d; background: #f1f5fb;
  border: 1px solid #e1e8f4; border-radius: 5px; padding: 2px 6px;
}
.tag.accent { color: #8a5a0a; border-color: rgba(183, 121, 31, .22); background: #fff8e8; }
.empty { text-align: center; color: var(--muted); padding: 70px 10px; }
.load-more-wrap { display: flex; justify-content: center; padding: 26px 0 0; }
.primary, .secondary {
  border-radius: 10px; padding: 10px 16px; border: 1px solid transparent; font-weight: 600;
}
.primary { background: var(--accent); color: white; }
.primary:hover { background: #4c82f5; }
.secondary { background: #fff; border-color: var(--line-strong); color: var(--text); }
.secondary:hover { border-color: var(--accent); background: #f7faff; }

.login-screen { min-height: calc(100vh - 74px); display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(460px, 100%); background: var(--panel);
  border: 1px solid var(--line); border-radius: 20px; padding: 28px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 8px; font-size: 25px; color: var(--text); }
.login-card p { color: var(--muted); margin: 0 0 18px; }
.login-card form { display: grid; gap: 10px; }
.error { color: #c03434; font-size: 13px; margin-top: 12px; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(23, 32, 51, .48); backdrop-filter: blur(8px); }
.player-shell {
  position: relative; z-index: 1; width: min(1040px, 100%); max-height: calc(100vh - 48px);
  overflow: auto; background: #fff; color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 18px; box-shadow: 0 24px 60px rgba(20, 33, 61, .25); padding: 18px;
}
.modal-close {
  position: absolute; top: 10px; right: 12px; z-index: 3;
  border: 0; background: rgba(23, 32, 51, .65); color: white; width: 34px; height: 34px; border-radius: 50%; font-size: 22px;
}
.video-stage {
  position: relative; background: #000; border-radius: 12px; overflow: hidden;
  display: flex; justify-content: center; align-items: center; min-height: 240px;
}
.video-stage video { display: block; width: auto; height: auto; max-width: 100%; max-height: 68vh; background: #000; }
.player-info { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; padding: 16px 4px 4px; }
.player-info h2 { margin: 0 0 5px; font-size: 20px; color: var(--text); }
.player-meta { color: var(--muted); font-size: 12.5px; }
.player-info .ghost-link { white-space: nowrap; padding-top: 4px; }

@media (max-width: 1120px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout { grid-template-columns: 260px minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .topbar { padding: 12px 16px; }
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .sidebar { position: static; }
  .grid { grid-template-columns: 1fr; }
  .content-head { align-items: flex-start; flex-direction: column; }
  .content-head h1 { font-size: 24px; }
  .player-shell { padding: 12px; }
  .player-info { flex-direction: column; }
}

/* --- roles / notes / access gate --- */
.layout { grid-template-columns: 280px minmax(0, 1fr) 320px; align-items: start; }
.notes {
  position: sticky; top: 86px; align-self: start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-height: 260px;
}
.notes-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.note-status { color: var(--muted); font-size: 11px; text-align: right; }
.note-empty { color: var(--muted); font-size: 12.5px; padding: 18px 4px; }
.note-empty-icon { font-size: 26px; color: var(--accent); margin-bottom: 8px; }
#noteTitle { margin: 0 0 5px; font-size: 16px; line-height: 1.3; color: var(--text); }
.note-meta { color: var(--muted); font-size: 11.5px; margin-bottom: 12px; }
#noteText {
  width: 100%; min-height: 220px; resize: vertical;
  background: #fbfcff; color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 10px; outline: none; line-height: 1.5;
}
#noteText:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,111,237,.1); }
.card { cursor: pointer; }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47,111,237,.15), 0 16px 34px rgba(28,52,96,.12); }
.card .play-dot { padding: 0; cursor: pointer; }
.note-dot {
  position: absolute; z-index: 2; top: 12px; right: 13px;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px;
  color: #8a5a0a; background: #fff8e8; border: 1px solid rgba(183,121,31,.3);
}
.gate {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 34px 26px; text-align: center; margin-bottom: 18px;
}
.gate-icon { font-size: 30px; margin-bottom: 8px; color: var(--accent); }
.gate h2 { margin: 0 0 6px; font-size: 22px; }
.gate p { color: var(--muted); margin: 0 auto 18px; max-width: 520px; }
.locked .sidebar { opacity: .5; pointer-events: none; filter: grayscale(.2); }
.login-label { display: block; color: var(--muted); font-size: 12px; margin: 3px 0 -3px; }
.login-card form { gap: 9px; }
.login-card .primary { margin-top: 6px; }
@media (max-width: 1280px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr); }
  .notes { grid-column: 1 / -1; position: static; }
  #noteText { min-height: 130px; }
}
@media (max-width: 820px) {
  .notes { grid-column: auto; }
  .gate { padding: 24px 16px; }
}

/* mobile overrides must stay last */
@media (max-width: 820px) {
  body { overflow-x: hidden; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .brand { gap: 9px; min-width: 0; }
  .brand-sub { display: none; }
  .brand-title { font-size: 15px; }
  .logo { width: 36px; height: 36px; border-radius: 10px; font-size: 18px; }
  .top-actions { margin-left: auto; gap: 8px; }
  .badge { font-size: 11px; padding: 4px 8px; }
  .layout { grid-template-columns: 1fr !important; padding: 14px; gap: 14px; }
  .sidebar { position: static; width: 100%; }
  .notes { grid-column: auto; position: static; width: 100%; }
  .content-head { align-items: stretch; }
  .content-actions select { width: 100%; }
  .gate { padding: 22px 14px; }
  .note-empty { padding: 10px 2px; }
}

.mobile-only { display: none; }
@media (max-width: 820px) {
  .mobile-only { display: inline-block; }
  .sidebar { display: none; }
  .sidebar.mobile-open { display: block; }
  #filtersToggle { border: 1px solid var(--line-strong); border-radius: 8px; padding: 4px 8px; background: #fff; }
}

/* admin inside the same panel */
.login-switch { display:block; margin:14px auto 0; background:none; border:0; color:var(--accent); font-size:13px; }
.admin-panel { position:fixed; inset:0; z-index:70; background:#f4f6fb; overflow:auto; padding:0 0 60px; }
.admin-panel-bar { position:sticky; top:0; z-index:2; display:flex; align-items:center; justify-content:space-between; gap:18px; padding:14px 24px; background:rgba(255,255,255,.94); border-bottom:1px solid var(--line); backdrop-filter:blur(12px); }
.admin-panel-title { font-size:20px; font-weight:700; color:var(--text); }
.admin-panel .admin-wrap { max-width:1180px; margin:0 auto; padding:24px; }
.admin-panel .panel { background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:18px; box-shadow:var(--shadow); }
.admin-panel .panel h2 { margin:0 0 12px; font-size:17px; color:var(--text); }
.admin-panel .field { margin-bottom:12px; }
.admin-panel .field label { display:block; color:var(--muted); font-size:12px; margin-bottom:6px; }
.admin-panel .field input { width:100%; background:#fff; color:var(--text); border:1px solid var(--line-strong); border-radius:10px; padding:9px 10px; outline:none; }
.admin-panel .stats { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:14px; }
.admin-panel .stat { background:#f6f8fd; border:1px solid var(--line); border-radius:10px; padding:9px 12px; font-size:12px; color:var(--muted); }
.admin-panel .stat b { color:var(--text); }
.admin-panel .admin-columns { display:grid; grid-template-columns:360px minmax(0,1fr); gap:20px; align-items:start; margin-bottom:20px; }
.admin-panel table { width:100%; border-collapse:collapse; font-size:13px; }
.admin-panel th { text-align:left; color:var(--muted); font-weight:500; font-size:11px; text-transform:uppercase; letter-spacing:.06em; padding:8px 6px; border-bottom:1px solid var(--line); white-space:nowrap; }
.admin-panel td { padding:10px 6px; border-bottom:1px solid var(--line); vertical-align:top; }
.admin-panel .status { display:inline-block; border-radius:999px; padding:3px 8px; font-size:11px; border:1px solid var(--line-strong); white-space:nowrap; }
.admin-panel .status.active { color:#15803d; border-color:rgba(21,128,61,.22); background:#f0fbf4; }
.admin-panel .status.blocked { color:#b91c1c; border-color:rgba(185,28,28,.22); background:#fff2f2; }
.admin-panel .status.access { color:#a16207; border-color:rgba(183,121,31,.28); background:#fff8e8; }
.admin-panel .row-actions { display:flex; gap:6px; flex-wrap:wrap; }
.admin-panel .mini { border:1px solid var(--line-strong); background:#fff; color:var(--text); border-radius:7px; padding:4px 8px; font-size:11px; }
.admin-panel .mini:hover { border-color:var(--accent); background:#f7faff; }
.admin-panel .mini.danger:hover { border-color:#e18a8a; color:#b91c1c; background:#fff5f5; }
.admin-panel .notif { padding:10px 0; border-bottom:1px solid var(--line); font-size:12.5px; }
.admin-panel .notif:last-child { border-bottom:0; }
.admin-panel .notif-time { color:var(--muted); font-size:11px; margin-top:2px; }
.admin-modal { position:fixed; inset:0; z-index:90; display:grid; place-items:center; padding:24px; }
.admin-modal-backdrop { position:absolute; inset:0; background:rgba(23,32,51,.48); backdrop-filter:blur(8px); }
.admin-modal-card { position:relative; z-index:1; width:min(820px,100%); max-height:80vh; overflow:auto; background:#fff; border:1px solid var(--line-strong); border-radius:18px; padding:22px; box-shadow:0 24px 60px rgba(20,33,61,.25); }
.admin-modal-card h2 { margin:0 0 14px; }
@media (max-width: 900px) { .admin-panel .admin-columns { grid-template-columns:1fr; } .admin-panel-bar { padding:12px 14px; } .admin-panel .admin-wrap { padding:14px; } }

/* video table view */
.content-actions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.view-switch { display:flex; border:1px solid var(--line-strong); border-radius:9px; overflow:hidden; background:#fff; }
.view-btn { border:0; background:#fff; color:var(--muted); font-size:12px; padding:8px 10px; cursor:pointer; }
.view-btn + .view-btn { border-left:1px solid var(--line); }
.view-btn.active { background:#eef4ff; color:var(--accent); font-weight:600; }
.view-btn:hover { background:#f7faff; }
.table-view { background:#fff; border:1px solid var(--line); border-radius:13px; overflow:hidden; box-shadow:var(--shadow); }
.video-table { width:100%; border-collapse:collapse; font-size:13px; table-layout:fixed; }
.video-table th { text-align:left; color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.06em; padding:10px 14px; border-bottom:1px solid var(--line); background:#f8faff; }
.video-table th.name { text-align:left; }
.video-table td { padding:6px 14px; border-bottom:1px solid var(--line); line-height:1.35; }
.video-table td.num { width:64px; color:var(--muted); font-variant-numeric:tabular-nums; }
.video-table td.name { text-align:left; font-weight:500; color:var(--text); word-break:break-word; }
.video-table th.note { width:34%; text-align:left; }
.video-table td.note { width:34%; text-align:left; white-space:pre-wrap; word-break:break-word; font-size:12.5px; line-height:1.35; color:#374151; }
.video-table tbody tr { cursor:pointer; }
.video-table tbody tr:hover { background:#f7faff; }
.video-table tbody tr.selected { background:#eef4ff; }
.video-table tbody tr:last-child td { border-bottom:0; }
.table-pager { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 14px; border-top:1px solid var(--line); background:#fbfcff; }
.page-btn { border:1px solid var(--line-strong); background:#fff; color:var(--text); border-radius:7px; padding:6px 10px; font-size:12px; }
.page-btn:disabled { opacity:.4; cursor:default; }
.page-info { color:var(--muted); font-size:12px; }
@media print {
  @page { size: A4; margin: 10mm; }
  body { background:#fff !important; }
  .topbar, .sidebar, .notes, .content-head, .active-filters, .table-pager, .load-more-wrap, .gate, .empty, .modal, .admin-panel { display:none !important; }
  .layout { display:block !important; padding:0 !important; }
  .content { padding:0 !important; }
  .table-view { border:0; box-shadow:none; border-radius:0; }
  .video-table { font-size:10pt; }
  .video-table th, .video-table td { padding:2px 4px; }
  .video-table thead { display:table-header-group; }
  .video-table tr { page-break-inside:avoid; }
}

.print-only { display:none; }
@media print {
  .topbar, #loginScreen, #app, #adminPanel, .modal, .admin-modal { display:none !important; }
  #printView { display:block !important; }
  .print-sheet { break-after:page; page-break-after:always; }
  .print-sheet:last-child { break-after:auto; page-break-after:auto; }
  .print-head { font:600 11pt Arial, sans-serif; margin:0 0 5mm; }
  .print-table { width:100%; border-collapse:collapse; font:8pt Arial, sans-serif; }
  .print-table th, .print-table td { border-bottom:1px solid #ddd; padding:0.7mm 1.8mm; white-space:nowrap; }
  .print-table th { text-align:left; font-size:8pt; color:#555; }
  .print-table th.name, .print-table td.name { text-align:left; }
  .print-table th.note, .print-table td.note { width:34%; text-align:left; white-space:pre-wrap; }
  .print-table td.num { width:12mm; color:#777; }
  body { background:#fff !important; }
}

/* narrow # column + inline note editing */
.video-table th.num, .video-table td.num {
  width: 32px !important;
  min-width: 32px;
  max-width: 32px;
  padding-left: 4px;
  padding-right: 4px;
  text-align: center;
  font-size: 11px;
}
.video-table td.note { cursor: text; }
.video-table td.note:hover { background: #eef6ff; box-shadow: inset 0 0 0 1px #bcd7ff; }
.cell-note-input {
  width: 100%;
  min-height: 54px;
  resize: vertical;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 5px 6px;
  font: inherit;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--text);
  background: #fff;
  outline: none;
}
.table-hint { display: none; color: var(--muted); font-size: 11.5px; margin: -6px 0 8px; }
body.table-view .table-hint { display: block; }
body.table-view .layout { grid-template-columns: 280px minmax(0, 1fr); }
body.table-view #notesPanel { display: none; }
body.table-view .content { min-width: 0; }
.print-table th.num, .print-table td.num { width: 7mm; padding-left: 1mm; padding-right: 1mm; }
