:root {
  --brand: #FF0707;
  --brand-dark: #d10000;
  --brand-soft: #fff0f0;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e6e6ea;
  --bg: #f6f6f8;
  --card: #ffffff;
  --ok: #16a34a;
  --off: #9ca3af;
  --radius: 12px;
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; }
[hidden] { display: none !important; }
a { color: var(--brand-dark); }
h2 { font-size: 22px; margin: 0; }
h3 { font-size: 15px; margin: 26px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--brand); display: inline-block; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--card); padding: 32px; border-radius: 16px; width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.08); display: grid; gap: 14px; }
.error { color: var(--brand-dark); min-height: 1em; margin: 0; }

/* header */
.top { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 18px; padding: 10px 20px; flex-wrap: wrap; }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.top nav a { padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--ink); text-decoration: none; white-space: nowrap; font-weight: 500; }
.top nav a:hover { background: var(--bg); }
.top nav a.active { background: var(--brand-soft); color: var(--brand-dark); }
@media (max-width: 820px) {
  .top { padding: 10px 16px; gap: 10px; }
  .top nav { order: 3; flex-basis: 100%; }
}

main { max-width: 1100px; margin: 0 auto; padding: 22px 20px 80px; }
@media (max-width: 640px) { main { padding: 18px 16px 80px; } }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.toolbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* buttons + inputs */
.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 9px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn:hover { border-color: #cfcfd6; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--brand-dark); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
label { display: grid; gap: 5px; font-weight: 600; font-size: 13px; color: #3a3a3f; }
input, select, textarea { font: inherit; font-weight: 400; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; align-content: start; }
.card-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.card-title { font-weight: 700; font-size: 16px; }
.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill.on { background: #e8f7ee; color: var(--ok); }
.pill.off { background: #f1f1f3; color: var(--muted); }
.kv { font-size: 13px; color: var(--muted); }
.kv b { color: var(--ink); font-weight: 600; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }
.sched { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13px; }
.sched li { background: var(--bg); border-radius: 7px; padding: 6px 9px; }

.empty { background: var(--card); border: 1px dashed #d4d4da; border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); margin-top: 16px; }
.empty ol { text-align: left; display: inline-block; margin: 10px 0 0; line-height: 1.8; }

/* media */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 14px; }
.thumb { aspect-ratio: 16 / 9; background: #111; border-radius: 8px; overflow: hidden; position: relative; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb .badge { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.thumb.widget { display: grid; place-items: center; text-align: center; padding: 4px; background: var(--brand); color: #fff; font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.mcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: grid; gap: 6px; }
.mcard .name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcard.pick { cursor: pointer; }
.mcard.pick.sel { outline: 3px solid var(--brand); }
.drop { border: 2px dashed #d0d0d8; background: var(--card); border-radius: var(--radius); padding: 26px; text-align: center; cursor: pointer; margin-top: 14px; }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.progress { height: 8px; background: var(--line); border-radius: 9px; overflow: hidden; margin-top: 10px; }
.progress div { height: 100%; background: var(--brand); width: 0; transition: width .2s; }

/* playlist editor */
.items { display: grid; gap: 8px; margin-top: 14px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: grid; grid-template-columns: 30px 110px 1fr auto auto; gap: 12px; align-items: center; }
.item .n { color: var(--muted); font-weight: 700; text-align: center; }
.item .thumb { width: 110px; }
.item .meta { min-width: 0; }
.item .meta .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .dur { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.item .dur input { width: 74px; }
@media (max-width: 640px) {
  .item { grid-template-columns: 80px 1fr; }
  .item .n { display: none; }
  .item .thumb { width: 80px; }
  .item .dur, .item .btns { grid-column: 1 / -1; }
}
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 14px; }
.dirty { color: var(--brand-dark); font-weight: 600; font-size: 13px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(20,20,25,.45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-card { background: var(--card); border-radius: 16px; width: 100%; max-width: 620px; max-height: 90vh; overflow: auto; padding: 22px; display: grid; gap: 14px; }
.modal-card.wide { max-width: 900px; }
.modal-card .foot { display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: -22px; background: var(--card); padding: 12px 0 2px; }
.rule { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 10px; }
.days { display: flex; gap: 5px; flex-wrap: wrap; }
.days button { width: 40px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.days button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.code-input { font-size: 28px; letter-spacing: .3em; text-transform: uppercase; text-align: center; font-weight: 700; }
.note { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--muted); line-height: 1.5; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 60; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
#logout { margin-left: auto; }
