:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --ink: #0f1a17;
  --ink-2: #4a5a55;
  --ink-3: #8a9893;
  --line: #e3e9e6;
  --brand: #10b981;
  --brand-ink: #047857;
  --brand-soft: #e7f8f1;
  --side: #0c1714;
  --side-2: #14231f;
  --side-ink: #a9bbb5;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --warn: #f5a524;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 22, .04), 0 4px 16px rgba(16, 24, 22, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--ink);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-ink); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.muted { color: var(--ink-3); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 20px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 17px; padding: 4px 10px 22px; }
.logo .mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; }
.logo small { display: block; font-weight: 500; font-size: 11px; color: var(--side-ink); letter-spacing: .08em; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--side-ink); font-weight: 500; }
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.active { background: var(--brand); color: #04221a; font-weight: 700; }
.nav a.active svg { stroke: #04221a; }
.nav svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; }
.nav .sep { height: 1px; background: var(--side-2); margin: 10px 8px; }
.side .foot { margin-top: auto; padding: 12px; border-radius: 12px; background: var(--side-2); font-size: 12px; }
.side .foot b { color: #fff; display: block; font-size: 13px; }
.side .foot button { margin-top: 8px; background: none; border: 0; color: var(--brand); padding: 0; cursor: pointer; font-weight: 600; }

.main { min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 18px 32px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.org-chip { background: var(--brand-soft); color: var(--brand-ink); padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.page { padding: 28px 32px 60px; max-width: 1400px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 800; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* ---------- elements ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); padding: 9px 14px;
  border-radius: 10px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { border-color: #c9d4d0; background: #fafcfb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #032119; }
.btn.primary:hover { background: #0ea371; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: #f5c2c3; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 7px; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card h3 { font-size: 15px; font-weight: 700; }

.input, select.input, textarea.input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(16, 185, 129, .15); }
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--ink-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #eef2f1; color: var(--ink-2); }
.badge.green { background: var(--brand-soft); color: var(--brand-ink); }
.badge.red { background: var(--danger-soft); color: #b42318; }
.badge.amber { background: #fff4e0; color: #9a5b00; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); display: inline-block; }
.dot.on { background: var(--brand); box-shadow: 0 0 0 3px rgba(16, 185, 129, .2); }
.dot.off { background: var(--danger); }

.tabs { display: inline-flex; background: #e9eeec; padding: 3px; border-radius: 10px; }
.tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fafcfb; }
table.t td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr:hover td { background: #fbfdfc; }
.t-wrap { overflow-x: auto; }
.empty { padding: 48px 20px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat { padding: 18px 20px; }
.stat .k { color: var(--ink-2); font-weight: 600; font-size: 13px; }
.stat .v { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.stat .s { font-size: 12.5px; color: var(--ink-3); }
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.chart { width: 100%; height: 220px; display: block; }
.dev-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.dev-row:last-child { border-bottom: 0; }

/* ---------- content library ---------- */
.drop { border: 2px dashed #c8d6d1; border-radius: var(--radius); padding: 22px; text-align: center; background: #fbfdfc; color: var(--ink-2);
  margin-bottom: 18px; transition: background .15s, border-color .15s; cursor: pointer; }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop b { color: var(--ink); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.mcard { overflow: hidden; display: flex; flex-direction: column; }
.thumb { aspect-ratio: 16 / 9; background: #0c1714; position: relative; display: grid; place-items: center; overflow: hidden; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .tag { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 6px; text-transform: uppercase; letter-spacing: .04em; }
.thumb .web { color: #9fe7cd; font-weight: 700; font-size: 13px; padding: 10px; text-align: center; word-break: break-all; }
.mcard .meta { padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.mcard .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcard .acts { display: flex; gap: 6px; padding: 0 14px 12px; }
.progress { height: 6px; background: #e3ebe8; border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }

/* ---------- channels ---------- */
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.ch-card { cursor: pointer; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.ch-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16,24,22,.08); }
.ch-card .thumb { aspect-ratio: 16 / 8; }
.editor { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
.pl-item { display: grid; grid-template-columns: 22px 28px 64px 1fr 92px auto; gap: 12px; align-items: center; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: #fff; }
.pl-item.drag { opacity: .4; }
.pl-item.over { box-shadow: inset 0 3px 0 var(--brand); }
.pl-item .grip { cursor: grab; color: var(--ink-3); font-size: 18px; text-align: center; user-select: none; }
.pl-item .num { color: var(--ink-3); font-weight: 700; text-align: center; }
.pl-item .mini { width: 64px; height: 36px; border-radius: 6px; overflow: hidden; background: #0c1714; display: grid; place-items: center; color: #9fe7cd; font-size: 10px; font-weight: 700; }
.pl-item .mini img, .pl-item .mini video { width: 100%; height: 100%; object-fit: cover; }
.pl-item .nm { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.dur { display: flex; align-items: center; gap: 6px; }
.dur input { width: 64px; padding: 6px 8px; }
.lib { max-height: 70vh; overflow-y: auto; }
.lib-item { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.lib-item .mini { width: 64px; height: 36px; border-radius: 6px; overflow: hidden; background: #0c1714; display: grid; place-items: center; color: #9fe7cd; font-size: 10px; font-weight: 700; }
.lib-item .mini img, .lib-item .mini video { width: 100%; height: 100%; object-fit: cover; }
.lib-item .nm { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; font-weight: 600; }

/* ---------- days picker ---------- */
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { cursor: pointer; }
.days input { display: none; }
.days span { display: inline-block; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.days input:checked + span { background: var(--brand); border-color: var(--brand); color: #032119; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(8, 15, 13, .45); display: grid; place-items: center; z-index: 50; padding: 20px;
  animation: fade .15s ease; }
.modal { width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal.wide { max-width: 680px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px 22px 6px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; }
.x { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-3); }
.err { background: var(--danger-soft); color: #b42318; padding: 9px 12px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; display: none; }
@keyframes fade { from { opacity: 0; } }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--side); color: #fff;
  padding: 11px 18px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.callout { background: var(--brand-soft); border: 1px solid #c4eedc; border-radius: 12px; padding: 14px 16px; color: #065f46; }
.callout code { background: #fff; padding: 2px 6px; border-radius: 6px; font-weight: 700; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--side);
  background: radial-gradient(circle at 20% 10%, #12443a 0%, var(--side) 55%); padding: 20px; }
.login .card { width: 100%; max-width: 400px; padding: 32px; }
.login .logo { color: var(--ink); padding: 0 0 22px; }
.login .logo small { color: var(--ink-3); }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side .logo { padding: 4px 10px; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav .sep, .side .foot { display: none; }
  .dash-grid, .editor { grid-template-columns: 1fr; }
  .page, .top { padding-left: 16px; padding-right: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .pl-item { grid-template-columns: 22px 64px 1fr auto; }
  .pl-item .num, .pl-item .dur { display: none; }
}
