:root {
  --bg: #f5f6fa; --panel: #fff; --line: #e4e7ee; --text: #1a1d29; --muted: #6b7185; --accent: #6d5dfc; --accent2: #8b7dff;
  --side: #14161f; --side2: #1d2030; --sidetext: #c7cad8; --ok: #16a34a; --bad: #dc2626; --warn: #d97706; --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 18px; margin: 0 0 12px; } h3 { font-size: 15px; margin: 18px 0 8px; }
code { background: #eef0f6; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.muted { color: var(--muted); font-size: 13px; }
.warn { color: var(--warn); }
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=range] { padding: 0; accent-color: var(--accent); }
input[type=color] { padding: 2px; height: 36px; width: 60px; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 13px; font-weight: 600; color: #3a3f52; margin-bottom: 10px; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #c9cdda; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.span2 { grid-column: span 2; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eef0f6; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.badge.r2 { background: #fff1e6; color: #c2410c; } .badge.local { background: #e8f5ee; color: #15803d; }
.badge.err { background: #fde8e8; color: var(--bad); }
.alert { background: #fde8e8; color: #991b1b; padding: 10px 12px; border-radius: 8px; margin: 10px 0; }
.note { background: #f1efff; color: #3f3696; padding: 10px 12px; border-radius: 8px; margin: 10px 0; font-size: 13px; }

/* auth / installer */
.il-auth { display: flex; align-items: flex-start; justify-content: center; min-height: 100vh; padding: 60px 16px; background: radial-gradient(circle at 30% 0%, #2b2552, #12131c 60%); }
.auth-card { background: #fff; padding: 28px; border-radius: 14px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-card.wide { max-width: 640px; }
.brand { font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.brand small { font-size: 13px; color: var(--muted); font-weight: 500; }
.logo { color: var(--accent); }
.checks { list-style: none; padding: 0; margin: 0 0 10px; columns: 2; font-size: 13px; }
.checks .ok { color: var(--ok); } .checks .bad { color: var(--bad); font-weight: 600; }

/* layout */
#app { display: flex; min-height: 100vh; }
#side { width: 260px; flex: none; background: var(--side); color: var(--sidetext); padding: 16px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
#side .brand { color: #fff; padding: 0 8px; }
#main { flex: 1; min-width: 0; padding: 24px 28px 60px; }
.loading { color: var(--muted); padding: 40px; text-align: center; }
.nav-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6e7390; margin: 18px 8px 6px; display: flex; justify-content: space-between; align-items: center; }
.nav-sec button { background: none; border: 0; color: #9da2c0; cursor: pointer; font-size: 16px; line-height: 1; }
.nav a, .nav .item { display: flex; align-items: center; gap: 8px; color: var(--sidetext); text-decoration: none; padding: 7px 10px; border-radius: 7px; font-size: 13.5px; cursor: pointer; }
.nav a:hover { background: var(--side2); color: #fff; }
.nav a.on { background: var(--accent); color: #fff; }
.nav a .n { margin-left: auto; font-size: 11px; opacity: .6; }
.nav .sub a { padding-left: 30px; font-size: 13px; }
.nav .caret { width: 12px; display: inline-block; opacity: .6; }
.side-foot { margin-top: auto; padding-top: 16px; font-size: 12px; }
.jobs { background: var(--side2); border-radius: 8px; padding: 10px; margin: 10px 0; }
.jobs .job { margin-bottom: 8px; font-size: 12px; }
.jobs .bar { height: 5px; background: #333852; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.jobs .bar i { display: block; height: 100%; background: var(--accent2); }

/* header */
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); text-decoration: none; } .crumbs a:hover { color: var(--accent); }

/* video grid */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.vcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.vcard:hover { box-shadow: 0 8px 24px rgba(20,22,40,.1); transform: translateY(-2px); }
.vthumb { position: relative; aspect-ratio: 16/9; background: #1c1e2b center/cover no-repeat; }
.vthumb .dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.75); color: #fff; font-size: 11.5px; padding: 1px 6px; border-radius: 4px; }
.vthumb .st { position: absolute; left: 8px; top: 8px; }
.vthumb .prog { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.2); } .vthumb .prog i { display: block; height: 100%; background: var(--accent2); }
.vinfo { padding: 10px 12px; }
.vinfo .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vinfo .m { font-size: 12px; color: var(--muted); margin-top: 2px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); border: 2px dashed var(--line); border-radius: 14px; }
.dropping { outline: 3px dashed var(--accent); outline-offset: 6px; border-radius: 12px; }

/* video page */
.vpage { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 22px; align-items: start; }
.preview-box { position: sticky; top: 16px; }
.frame-wrap { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 10px; overflow: hidden; }
.frame-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 13px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.title-input { font-size: 20px; font-weight: 700; border: 1px solid transparent; padding: 4px 8px; margin-left: -8px; background: transparent; }
.title-input:hover, .title-input:focus { border-color: var(--line); background: #fff; }
.opt-group { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.opt-group:first-child { border: 0; padding-top: 0; margin-top: 0; }
.seg-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: #fff; cursor: pointer; font-size: 13px; }
.seg-row.sel { border-color: var(--accent); background: #f4f2ff; }
.seg-row .num { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex: none; }
canvas.timeline { width: 100%; height: 64px; display: block; border-radius: 8px; background: #20232f; cursor: pointer; }
.workvid { width: 100%; border-radius: 8px; background: #000; max-height: 340px; display: block; }
.thumbs-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.thumbs-pick img { width: 100%; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.thumbs-pick img:hover { border-color: var(--accent); }
.cur-thumb { width: 100%; max-width: 360px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: #1c1e2b; display: block; }
.cue-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cue-table td { padding: 3px 4px; vertical-align: top; }
.cue-table input { padding: 4px 6px; font-size: 12.5px; }
.cue-table .tc { width: 110px; }
.cue-list { max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
pre.code { background: #14161f; color: #d8dbf0; padding: 12px; border-radius: 8px; white-space: pre-wrap; word-break: break-all; font-size: 12.5px; margin: 6px 0 14px; }

/* stats */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi .v { font-size: 24px; font-weight: 800; } .kpi .l { font-size: 12px; color: var(--muted); }
.kpi.bot .v { color: var(--warn); }
canvas.chart { width: 100%; height: 200px; display: block; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.tbl td { padding: 6px 8px; border-bottom: 1px solid #f0f1f5; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15,16,26,.55); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 50px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 620px; padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head button { background: none; border: 0; font-size: 26px; cursor: pointer; color: var(--muted); line-height: 1; }
.up-item { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.up-item .bar { height: 6px; background: #eef0f6; border-radius: 3px; overflow: hidden; margin-top: 5px; } .up-item .bar i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.drive-list { max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.drive-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid #f0f1f5; font-size: 13px; }
.drive-item.folder { cursor: pointer; font-weight: 600; } .drive-item.folder:hover { background: #f7f7fb; }
.drive-item img { width: 64px; height: 36px; object-fit: cover; border-radius: 4px; background: #eee; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; }
#toast div { background: #1a1d29; color: #fff; padding: 10px 16px; border-radius: 9px; margin-top: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 13.5px; }
#toast div.err { background: var(--bad); }
.menu-btn { display: none; }

@media (max-width: 980px) {
  .vpage { grid-template-columns: 1fr; } .preview-box { position: static; }
  .cols2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  #side { position: fixed; left: -280px; z-index: 50; transition: left .2s; } #side.open { left: 0; }
  #main { padding: 16px; } .menu-btn { display: inline-flex; }
  .grid2, .grid3 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } .checks { columns: 1; }
}
