:root {
  --navy: #0F1B33; --copper: #B87333; --paper: #F7F5F0; --sand: #DDD0C2;
  --ink: #18202e; --muted: #667085; --line: #e4ddd3; --card: #fff;
  --ok: #1f8a4c; --bad: #c2410c; --focus: #2f6fd6;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.pad { padding: 24px 16px; }

.bar { background: var(--navy); color: var(--paper); position: sticky; top: 0; z-index: 5; }
.bar-in { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: .02em; margin-right: auto; }
.logo svg { width: 26px; height: 26px; }
.bar select { background: #1b2a4a; border: 1px solid #33456b; color: var(--paper); border-radius: 8px; padding: 7px 10px; max-width: 220px; }
#tabs { display: flex; gap: 2px; background: #1b2a4a; border-radius: 9px; padding: 3px; }
#tabs button { background: none; border: 0; color: #c9d2e3; padding: 6px 12px; border-radius: 7px; cursor: pointer; }
#tabs button[aria-current] { background: var(--paper); color: var(--navy); font-weight: 600; }
.ghost { background: none; border: 1px solid #33456b; color: #c9d2e3; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
@media (max-width: 640px) { #tabs { order: 5; width: 100%; } #tabs button { flex: 1; } .bar select { flex: 1; max-width: none; } }

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 80px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0; }
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0 16px; }
.head .spacer { flex: 1; }

.btn { background: var(--navy); color: var(--paper); border: 0; border-radius: 9px; padding: 9px 14px; cursor: pointer; font-weight: 600; }
.btn.copper { background: var(--copper); }
.btn.light { background: #fff; color: var(--navy); border: 1px solid var(--line); font-weight: 500; }
.btn.small { padding: 5px 10px; font-size: 13px; font-weight: 500; }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid #f1c7b4; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--navy); text-decoration: underline; cursor: pointer; font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.shop-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.shop-title .muted { font-size: 13px; }

.screen { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.screen:first-of-type { border-top: 0; padding-top: 4px; }
.screen-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px #d8f0e1; }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px #fbe1d5; }
.status { font-size: 13px; }
.status.bad { color: var(--bad); }
.controls { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea { font-size: 14px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; min-width: 0; }
.field.grow { flex: 1; min-width: 180px; }
.actions { display: flex; gap: 8px; align-items: center; }

.empty { text-align: center; padding: 40px 16px; }
.empty p { margin: 6px 0 16px; }

.drop { border: 2px dashed var(--sand); border-radius: 14px; padding: 22px; text-align: center; background: #fbfaf7; cursor: pointer; }
.drop.over { border-color: var(--copper); background: #fbf3ec; }
.drop input { display: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 14px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.thumb { aspect-ratio: 16 / 9; background: #0b0f18; display: grid; place-items: center; overflow: hidden; position: relative; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: contain; }
.thumb iframe { position: absolute; top: 0; left: 0; width: 1920px; height: 1080px; border: 0; transform: scale(.0885); transform-origin: 0 0; pointer-events: none; }
.tile-body { padding: 8px 10px; display: grid; gap: 4px; font-size: 13px; }
.tile-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 11px; color: var(--muted); }

.pl-item { display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.pl-item .thumb { border-radius: 8px; }
.pl-item .field input { width: 80px; }
.pl-meta { display: grid; gap: 4px; min-width: 0; }
.pl-meta .tile-name { font-size: 14px; }
.icon-btn { background: #fff; border: 1px solid var(--line); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 6px 8px; }
td { border-top: 1px solid var(--line); padding: 10px 8px; vertical-align: top; }
.live { color: var(--ok); font-weight: 600; font-size: 12px; }
@media (max-width: 640px) { table, tbody, tr, td { display: block; } thead { display: none; } tr { border-top: 1px solid var(--line); padding: 8px 0; } td { border: 0; padding: 2px 0; } }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(15, 27, 51, .3); }
dialog::backdrop { background: rgba(15, 27, 51, .45); }
#dlg-form { padding: 20px; display: grid; gap: 12px; }
#dlg-form .actions { justify-content: flex-end; margin-top: 6px; }
.err { color: var(--bad); font-size: 13px; min-height: 1em; margin: 0; }
.checks { display: grid; gap: 6px; font-size: 14px; color: var(--ink); }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); background: var(--navy); color: var(--paper); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .25s; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--bad); }

.login { max-width: 360px; margin: 10vh auto; }
.login form { display: grid; gap: 12px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
