/*
 * Digital Signage admin.
 * Palette comes from the logo: navy wordmark, electric blue, orange signal.
 * Navy is the "control room" chrome; blue is for actions; orange only warns.
 */
@font-face {
    font-family: "Plus Jakarta Sans";
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url("../font/jakarta/plus-jakarta-sans-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Plus Jakarta Sans";
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url("../font/jakarta/plus-jakarta-sans-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    --navy: #0b1f5c;
    --navy-2: #13297a;
    --navy-ink: #c9d4f5;
    --blue: #1e6bff;
    --blue-deep: #1553d6;
    --blue-soft: #e6eeff;
    --cyan: #18c8ff;
    --orange: #ff7a00;
    --orange-soft: #fff1e3;
    --green: #12a150;
    --green-soft: #e3f6eb;
    --red: #d92d20;
    --red-soft: #fdecea;

    --canvas: #f1f4fb;
    --surface: #ffffff;
    --surface-2: #f7f9fd;
    --line: #dde3f0;
    --line-strong: #c3cce0;
    --ink: #0e1733;
    --ink-2: #44506e;
    --muted: #6b7592;

    --r-shell: 14px;
    --r-control: 9px;
    --sidebar: 252px;
    --focus: 0 0 0 3px rgba(30, 107, 255, .35);
    color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100dvh;
    background: var(--canvas);
    color: var(--ink);
    font: 15px/1.55 "Plus Jakarta Sans", system-ui, "Segoe UI", Roboto, sans-serif;
    font-feature-settings: "tnum" 0;
}
a { color: var(--blue-deep); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); letter-spacing: -.01em; }
h1, .h1 { font-size: 1.65rem; line-height: 1.2; font-weight: 800; letter-spacing: -.02em; }
h2, .h2 { font-size: 1.2rem; font-weight: 700; }
.h3 { font-size: 1.05rem; font-weight: 700; }
.h4 { font-size: .95rem; font-weight: 700; }
p { margin: 0; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: .88em; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
    position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    background: var(--navy);
    color: var(--navy-ink);
    display: flex; flex-direction: column; gap: 20px;
    padding: 20px 14px;
}
.sidebar-logo { display: block; padding: 4px 8px 8px; }
.sidebar-logo img { display: block; width: 100%; max-width: 196px; height: auto; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: .76rem; font-weight: 600; color: #8796c9; padding: 0 10px 6px; letter-spacing: .02em; }
.nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 10px; border-radius: var(--r-control);
    color: var(--navy-ink); font-weight: 500;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--blue); color: #fff; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15); }
.nav-link .count { margin-left: auto; background: var(--orange); color: #fff; font-size: .72rem; font-weight: 700; border-radius: 99px; padding: 1px 8px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.who { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), var(--cyan)); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .85rem; flex: none; }
.who-name { color: #fff; font-weight: 600; line-height: 1.2; }
.who-role { font-size: .78rem; color: #8796c9; }
.sidebar-foot form { margin: 0; }
.sidebar-foot .nav-link { width: 100%; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }

.main { min-width: 0; display: flex; flex-direction: column; }
.scrim { display: none; }
.mobilebar { display: none; }
.content { width: 100%; max-width: 1320px; margin: 0 auto; padding: 28px 32px 56px; display: flex; flex-direction: column; gap: 22px; }

/* ---------- Page structure ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { color: var(--ink-2); margin-top: 6px; max-width: 70ch; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-shell); padding: 22px; }
.panel-flush { padding: 0; overflow: hidden; }
/* Kept for templates that still say "card". */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-shell); padding: 22px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-lg { display: flex; flex-direction: column; gap: 22px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.narrow { max-width: 680px; }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.split-narrow { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.actions form, td.actions form { display: inline; margin: 0; }
.empty { text-align: center; color: var(--ink-2); padding: 36px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .icon { width: 36px; height: 36px; color: var(--line-strong); }
.steps { text-align: left; margin: 0; padding-left: 20px; color: var(--ink-2); }
.steps li { margin: 6px 0; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .88rem; color: var(--ink); }
label.check, .check { flex-direction: row; align-items: center; gap: 9px; font-weight: 500; cursor: pointer; }
.align-end { align-self: end; padding-bottom: 11px; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=email], input[type=date], input[type=time], input[type=search], select, textarea {
    width: 100%; font: inherit; font-weight: 400; color: var(--ink);
    padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--blue); margin: 0; }
input[type=color] { width: 100%; height: 42px; padding: 3px; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: #fff; cursor: pointer; }
textarea { resize: vertical; }
::placeholder { color: #a3abc4; opacity: 1; }
.code-input::placeholder { color: #d3d9e8; }
.input { display: flex; flex-direction: column; gap: 6px; }
.input label { font-weight: 600; }
.error-message { color: var(--red); font-size: .84rem; font-weight: 500; }
.form-error { border-color: var(--red) !important; }
.hint { font-size: .82rem; color: var(--muted); font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: var(--r-control); padding: 12px 16px; margin: 0; }
fieldset.days { display: flex; flex-wrap: wrap; gap: 10px 20px; }
legend { font-weight: 600; font-size: .88rem; padding: 0 6px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 0; padding: 8px 10px; }
.code-input { font-size: 1.7rem !important; letter-spacing: .32em; text-transform: uppercase; text-align: center; font-weight: 800 !important; }
.form-foot { display: flex; gap: 10px; align-items: center; padding-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.2; cursor: pointer; white-space: nowrap;
    padding: 9px 15px; border-radius: var(--r-control); border: 1px solid var(--line-strong);
    background: #fff; color: var(--ink); text-decoration: none;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.btn-danger { color: var(--red); border-color: #f3c3be; }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--blue-soft); border-color: transparent; color: var(--blue-deep); }
.btn-sm { padding: 6px 11px; font-size: .82rem; }
.btn-block { width: 100%; }
form .btn-block { width: 100%; }

/* ---------- Flash ---------- */
.message { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-control); border: 1px solid; border-left-width: 4px; cursor: pointer; font-weight: 500; }
.message.success { background: var(--green-soft); border-color: #a9dcbe; border-left-color: var(--green); color: #0b5d2f; }
.message.error { background: var(--red-soft); border-color: #f3c3be; border-left-color: var(--red); color: #8a1c13; }
.message.warning { background: var(--orange-soft); border-color: #ffd2a8; border-left-color: var(--orange); color: #8a4300; }
.message.info, .message:not(.success):not(.error):not(.warning) { background: var(--blue-soft); border-color: #bcd0ff; border-left-color: var(--blue); color: #12368f; }

/* ---------- Status ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.badge-ok { color: #0b6b35; background: var(--green-soft); border-color: #b5e2c7; }
.badge-off { color: #9a4a00; background: var(--orange-soft); border-color: #ffd2a8; }
.badge-warn { color: #9a4a00; background: var(--orange-soft); border-color: #ffd2a8; align-self: flex-start; }
.badge-blue { color: var(--blue-deep); background: var(--blue-soft); border-color: #c5d6ff; }
.badge-navy { color: #fff; background: var(--navy); border-color: var(--navy); }
.lamp { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.badge-ok .lamp { box-shadow: 0 0 0 3px rgba(18, 161, 80, .18); }

/* ---------- Tables ---------- */
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tbody tr:hover td { background: #fafbff; }
tr:last-child td { border-bottom: 0; }
td.actions { justify-content: flex-end; }
tr.is-disabled td { opacity: .5; }
.cell-title { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: .82rem; color: var(--muted); }
.bulk-bar { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; background: var(--surface-2); }
.bulk-bar select { width: auto; min-width: 220px; }
.paginator { display: flex; gap: 6px; list-style: none; flex-wrap: wrap; padding: 0; margin: 0; }
.paginator li { list-style: none; }
.paginator a { display: inline-block; padding: 7px 13px; border: 1px solid var(--line); border-radius: var(--r-control); background: #fff; font-weight: 600; color: var(--ink-2); }
.paginator li.active a { background: var(--navy); color: #fff; border-color: var(--navy); }
.paginator li.disabled a { opacity: .4; pointer-events: none; }
.plain-list { margin: 0; padding-left: 18px; }
.plain-list li { margin: 6px 0; }
.info-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; word-break: break-word; font-weight: 500; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search] { width: 260px; }
.toolbar select { width: auto; }
.tabs { display: inline-flex; gap: 2px; background: #e4e9f5; padding: 4px; border-radius: 11px; }
.tabs a { padding: 7px 15px; border-radius: 8px; color: var(--ink-2); font-weight: 600; font-size: .88rem; }
.tabs a.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(11, 31, 92, .12); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* ---------- Screen wall (signature element) ---------- */
.wall-summary { font-size: 1.25rem; font-weight: 700; line-height: 1.35; max-width: 60ch; }
.wall-summary strong { color: var(--blue-deep); }
.wall-summary .warn { color: #b45400; }
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px 18px; }
.tv { display: flex; flex-direction: column; gap: 9px; color: inherit; }
.tv:hover { text-decoration: none; }
.tv-frame {
    position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden;
    background: #050c24;
    border: 6px solid #10183a;
    box-shadow: 0 1px 0 #2a3566 inset, 0 10px 18px -12px rgba(11, 31, 92, .55);
}
.tv-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tv-frame .layout-thumb { height: 100%; width: auto; margin: 0 auto; border-radius: 0; }
.tv-frame.is-off img, .tv-frame.is-off .layout-thumb { filter: grayscale(1) brightness(.45); }
.tv-frame.is-off::after { content: "Offline"; position: absolute; inset: 0; display: grid; place-items: center; color: #ffd2a8; font-weight: 700; letter-spacing: .02em; }
.tv-stand { width: 34%; height: 5px; margin: -4px auto 0; background: #c3cce0; border-radius: 0 0 6px 6px; }
.tv-meta { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.tv-name { font-weight: 700; color: var(--ink); line-height: 1.3; }
.tv-sub { font-size: .8rem; color: var(--muted); }
.tv-noshot { position: absolute; inset: 0; display: grid; place-items: center; color: #6d7aa8; font-size: .8rem; text-align: center; padding: 10px; }
.now-playing { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: .82rem; }
.now-playing li { display: flex; gap: 6px; min-width: 0; }
.now-playing b { font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.now-playing span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Media ---------- */
.dropzone { border: 2px dashed var(--line-strong); text-align: center; background: var(--surface); transition: border-color .15s, background .15s; }
.dropzone.is-over { border-color: var(--blue); background: var(--blue-soft); }
.dropzone-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.dropzone-inner .icon { width: 34px; height: 34px; color: var(--blue); }
.dropzone-inner label.btn { display: inline-flex; flex-direction: row; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.media-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-shell); }
.media-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: #0b1335; }
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-type { position: absolute; top: 8px; left: 8px; background: rgba(11, 31, 92, .85); color: #fff; font-size: .72rem; padding: 3px 8px; border-radius: 6px; font-weight: 700; display: inline-flex; gap: 4px; align-items: center; }
.media-type .icon { width: 13px; height: 13px; }
.media-audio { position: absolute; inset: 0; display: grid; place-items: center; color: #8fb3ff; background: linear-gradient(135deg, #0b1f5c, #12307a); }
.media-audio .icon { width: 44px; height: 44px; }
.media-name { display: flex; gap: 6px; padding: 12px 12px 0; margin: 0; }
.media-name input { padding: 6px 9px; font-size: .88rem; }
.media-meta { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px 12px; gap: 8px; }
.media-meta form { margin: 0; }
.media-note { margin: 10px 12px 0; font-size: .78rem; line-height: 1.4; color: var(--muted); }
.media-note.is-warn { color: #8a4300; background: var(--orange-soft); border-radius: 8px; padding: 6px 9px; }
.media-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px 0; }
.media-actions form { margin: 0; }
.media-process { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 14px 16px; background: rgba(11, 19, 53, .78); color: #fff; font-size: .82rem; }
.media-process b { font-weight: 700; }
.media-process.is-failed { background: rgba(138, 28, 19, .82); }
.media-process .progress { background: rgba(255, 255, 255, .22); }
.media-process .progress span { background: #fff; }
.progress { display: block; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.progress span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--blue); transition: width .4s ease; }
.media-card[data-status="queued"] .progress span { width: 100% !important; opacity: .35; animation: progress-wait 1.4s ease-in-out infinite alternate; }
@keyframes progress-wait { from { opacity: .15; } to { opacity: .45; } }
.upload-progress { width: min(360px, 100%); display: flex; flex-direction: column; gap: 6px; align-items: stretch; text-align: center; }
@media (prefers-reduced-motion: reduce) {
    .progress span { transition: none; }
    .media-card[data-status="queued"] .progress span { animation: none; }
}

/* ---------- Playlist editor ---------- */
.item-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item-row { border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.item-row.is-disabled .item-main { opacity: .5; }
.item-row.is-dragging { border-color: var(--blue); background: var(--blue-soft); box-shadow: 0 12px 24px -14px rgba(11, 31, 92, .5); position: relative; z-index: 2; }
.item-row.drop-before { box-shadow: 0 -3px 0 var(--blue); }
.item-row.drop-after { box-shadow: 0 3px 0 var(--blue); }
.item-main { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.drag-handle { border: 0; background: none; padding: 8px 4px; margin: -4px 0; cursor: grab; color: var(--muted); user-select: none; touch-action: none; display: grid; place-items: center; border-radius: 6px; }
.drag-handle:hover { color: var(--ink); background: var(--surface-2); }
.is-sorting, .is-sorting * { cursor: grabbing !important; user-select: none; }
.item-icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue-deep); flex: none; }
.item-thumb { width: 64px; height: 36px; object-fit: cover; border-radius: 6px; flex: none; }
.item-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.item-text strong { font-weight: 700; }
.item-text .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; }
.item-form { border-top: 1px solid var(--line); padding: 16px; background: var(--surface-2); border-radius: 0 0 11px 11px; }
.type-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.type-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border: 1px solid var(--line); border-radius: 11px; background: #fff; cursor: pointer; font: inherit; font-size: .84rem; font-weight: 600; color: var(--ink-2); }
.type-btn .icon { width: 22px; height: 22px; color: var(--blue); }
.type-btn:hover { border-color: var(--blue); color: var(--ink); }
.type-btn.active { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-deep); box-shadow: inset 0 0 0 1px var(--blue); }

/* ---------- Layouts ---------- */
.layout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.layout-card { display: flex; flex-direction: column; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-shell); }
.layout-card:hover { border-color: var(--line-strong); }
.layout-card-body { display: flex; flex-direction: column; gap: 3px; }
.layout-card-body strong { font-weight: 700; }
.layout-card-body .muted { font-size: .84rem; }
.layout-stage { background: var(--surface-2); border-radius: 10px; padding: 12px; display: flex; align-items: center; justify-content: center; height: 170px; }
.layout-thumb { position: relative; height: 100%; max-width: 100%; background: #0b1335; border-radius: 4px; overflow: hidden; }
.layout-thumb-region { position: absolute; border: 1px solid #0b1335; background: var(--blue); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.layout-thumb-region:nth-child(5n+2) { background: #7b2ff7; }
.layout-thumb-region:nth-child(5n+3) { background: #18a7e0; }
.layout-thumb-region:nth-child(5n+4) { background: #ff7a00; }
.layout-thumb-region:nth-child(5n+5) { background: #3b4fd6; }
.layout-thumb-region span { color: #fff; font-size: .64rem; font-weight: 700; text-align: center; padding: 2px; line-height: 1.15; }

/* ---------- Layout editor ---------- */
.layout-editor { display: flex; flex-direction: column; gap: 16px; }
.editor-body { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.editor-canvas-wrap { display: flex; flex-direction: column; gap: 10px; background: #e4e9f5; }
.editor-canvas { position: relative; width: 100%; margin: 0 auto; background: #000; border-radius: 4px; overflow: hidden; touch-action: none; user-select: none; border: 6px solid #10183a; }
.editor-region { position: absolute; border: 2px solid rgba(255, 255, 255, .75); background: rgba(30, 107, 255, .55); color: #fff; cursor: move; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-size: .85rem; overflow: hidden; }
.editor-region small { opacity: .9; font-size: .74rem; padding: 0 4px; }
.editor-region.selected { border-color: var(--orange); box-shadow: inset 0 0 0 2px var(--orange); z-index: 999 !important; }
.editor-region .resize-handle { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; background: var(--orange); cursor: nwse-resize; }
.region-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.region-list li { padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; font-weight: 600; }
.region-list li.selected { border-color: var(--blue); background: var(--blue-soft); }
.region-list li .muted { font-size: .8rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Screen access picker ---------- */
.screen-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; max-height: 340px; overflow-y: auto; padding: 2px; }
.screen-option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 500; flex-direction: row; }
.screen-option:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.screen-option input { margin-top: 3px; }
.screen-option small { display: block; color: var(--muted); font-weight: 400; }

/* ---------- Settings tabs ---------- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 20px; }
.settings-nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: var(--r-control); color: var(--ink-2); font-weight: 600; }
.settings-nav a:hover { background: #e4e9f5; text-decoration: none; }
.settings-nav a.active { background: #fff; color: var(--ink); box-shadow: inset 3px 0 0 var(--blue); }
.redirect-box { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-control); padding: 10px 12px; }
.redirect-box code { border: 0; background: none; padding: 0; flex: 1; }
.order-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.order-list li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.order-list .pos { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .85rem; }

/* ---------- Auth pages ---------- */
.auth-body {
    min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
    background:
        radial-gradient(900px 500px at 85% -10%, rgba(30, 107, 255, .35), transparent 60%),
        radial-gradient(700px 420px at -10% 110%, rgba(255, 122, 0, .22), transparent 60%),
        var(--navy);
}
.auth-box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 18px; }
.auth-logo { display: block; width: 280px; height: auto; max-width: 80%; margin: 0 auto 6px; }
.auth-card { background: #fff; border-radius: 18px; padding: 28px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .6); }
.auth-card h1 { font-size: 1.35rem; }
.auth-links { display: flex; justify-content: space-between; font-size: .88rem; }
.auth-foot { text-align: center; color: #8796c9; font-size: .8rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .split, .split-narrow, .editor-body, .settings { grid-template-columns: minmax(0, 1fr); }
    .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 900px) {
    .app { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); z-index: 60; transform: translateX(-100%); transition: transform .2s ease; }
    .app.nav-open .sidebar { transform: none; box-shadow: 20px 0 40px rgba(0, 0, 0, .3); }
    .app.nav-open .scrim { display: block; }
    .scrim { display: none; position: fixed; inset: 0; background: rgba(5, 12, 36, .45); z-index: 50; }
    .mobilebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--navy); position: sticky; top: 0; z-index: 40; }
    .mobilebar img { height: 34px; width: auto; }
    .mobilebar button { background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; display: grid; place-items: center; }
    .mobilebar .icon { width: 24px; height: 24px; }
    .content { padding: 20px 16px 40px; }
    .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .toolbar input[type=search] { width: 100%; }
}
@media (max-width: 560px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
    .item-main { flex-wrap: wrap; }
    h1, .h1 { font-size: 1.4rem; }
    .wall { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Media field + gallery pop-up ---------- */
.field-label { font-weight: 600; font-size: .88rem; }
.media-field { display: flex; flex-direction: column; gap: 8px; }
.media-field-selected { display: flex; flex-wrap: wrap; gap: 8px; }
.media-field-selected:empty { display: none; }
.chip-thumb { display: inline-flex; align-items: center; gap: 8px; max-width: 220px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: .82rem; font-weight: 500; }
.chip-thumb img { width: 44px; height: 28px; object-fit: cover; border-radius: 5px; flex: none; }
.chip-thumb .icon { width: 28px; height: 28px; padding: 5px; background: var(--blue-soft); color: var(--blue-deep); border-radius: 5px; flex: none; }
.chip-thumb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.picker { border: 0; padding: 0; border-radius: 16px; width: min(1040px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); background: var(--surface); color: var(--ink); box-shadow: 0 40px 80px -30px rgba(5, 12, 36, .6); }
.picker::backdrop { background: rgba(5, 12, 36, .55); }
.picker-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 48px); margin: 0; }
.picker-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.picker-head input { width: 260px; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 18px 22px; overflow-y: auto; min-height: 200px; }
.pick { display: flex; flex-direction: column; gap: 6px; padding: 6px; border: 2px solid transparent; border-radius: 12px; background: var(--surface-2); cursor: pointer; font: inherit; text-align: left; color: var(--ink); }
.pick:hover { border-color: var(--line-strong); }
.pick.selected { border-color: var(--blue); background: var(--blue-soft); }
.pick-thumb { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #0b1335; }
.pick-thumb img, .pick-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick-order { position: absolute; top: 6px; right: 6px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 99px; background: var(--blue); color: #fff; font-weight: 800; font-size: .82rem; display: none; align-items: center; justify-content: center; box-shadow: 0 0 0 2px #fff; }
.pick.selected .pick-order { display: inline-flex; }
.pick-name { font-size: .8rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.picker-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }

/* ---------- Clock style picker ---------- */
.clock-styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.clock-style { position: relative; display: flex; flex-direction: column; gap: 6px; align-items: stretch; cursor: pointer; font-weight: 600; font-size: .82rem; }
.clock-style input { position: absolute; opacity: 0; pointer-events: none; }
.clock-sample { height: 66px; border-radius: 10px; background: #0f172a; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2px solid transparent; font-weight: 800; font-size: 1.15rem; line-height: 1.1; overflow: hidden; }
.clock-style input:checked + .clock-sample { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30, 107, 255, .25); }
.clock-style input:focus-visible + .clock-sample { box-shadow: var(--focus); }
.clock-sample small { font-size: .55rem; font-weight: 500; opacity: .8; margin-top: 3px; }
.clock-sample-analog svg { width: 46px; height: 46px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }
.clock-sample-analog svg path { stroke: #5b9bff; }
.clock-sample-card { background: #fff; color: #0f172a; border-color: #dde3f0; }
.clock-sample-card b { font-size: .5rem; background: #1e6bff; color: #fff; align-self: stretch; text-align: center; padding: 2px 0; }
.clock-sample-card i { font-style: normal; font-size: 1.2rem; }
.clock-sample-card small { margin: 0; }
.clock-sample-flip { flex-direction: row; gap: 4px; }
.clock-sample-flip b { background: #1e293b; padding: 6px 5px; border-radius: 5px; box-shadow: inset 0 -1px 0 #000, inset 0 1px 0 #334155; }
.clock-sample-neon { color: #9cc3ff; text-shadow: 0 0 6px #1e6bff, 0 0 14px #1e6bff; }
.clock-sample-line { font-size: .64rem; font-weight: 600; white-space: nowrap; }
.clock-style-name { text-align: center; color: var(--ink-2); }

/* ---------- Layout editor: backgrounds and px ---------- */
.unit-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.unit-pair input { padding-right: 6px; }
.unit-caption { font-size: .74rem; color: var(--muted); font-weight: 500; }
.bg-field .media-field-selected .chip-thumb { max-width: 100%; }
.editor-region.has-bg { background-color: transparent; background-repeat: no-repeat; }
.bg-choice { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; }
.bg-choice .hint { flex-basis: 100%; }
.bg-choice input[type=color] { width: 56px; height: 34px; margin-left: 4px; }

/* ---------- Layout editor: settings grid, unit inputs, canvas bar ---------- */
.editor-settings { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 16px; align-items: end; }
.editor-settings .span-2 { grid-column: span 2; }
.editor-settings .span-3 { grid-column: span 3; }
.editor-settings .span-6 { grid-column: 1 / -1; }
.editor-settings .music-field .row { flex-wrap: wrap; }
.editor-settings .music-field .media-field-selected { display: flex; flex-wrap: wrap; gap: 6px; }
.range-field { display: flex; align-items: center; gap: 12px; }
.range-field input { flex: 1; padding: 0; accent-color: var(--blue); }
.range-field output { min-width: 3.2em; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.editor-settings > label, .editor-settings > .media-field { min-width: 0; }
.editor-settings .media-field .row { flex-wrap: nowrap; min-width: 0; }
.editor-settings .media-field-selected { min-width: 0; flex: 0 1 auto; }
.editor-settings .media-field-selected .chip-thumb { max-width: 220px; }
.input-unit { position: relative; display: block; }
.input-unit input { padding-right: 34px; }
.input-unit > span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-size: .8rem; font-weight: 600; color: var(--muted); pointer-events: none; }
input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.canvas-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; }
.canvas-bar .hint { flex: 1 1 260px; }
.canvas-bar .row { flex-wrap: nowrap; }
.inline-label { flex-direction: row; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.inline-label select { width: auto; padding: 6px 30px 6px 10px; }
.editor-canvas-wrap { gap: 14px; }
.editor-panel { position: sticky; top: 16px; max-height: calc(100dvh - 32px); overflow-y: auto; }
.editor-panel .unit-caption { display: block; margin-bottom: 4px; }

/* Sidebar colour runs the full page height even when the page is long. */
.app { background: linear-gradient(to right, var(--navy) 0, var(--navy) var(--sidebar), var(--canvas) var(--sidebar)); }

/* Flash messages: text and link flow as one paragraph. */
.message { display: block; line-height: 1.5; }
.message a { font-weight: 600; white-space: nowrap; }

@media (max-width: 1100px) {
    .editor-settings { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .editor-panel { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 900px) {
    .app { background: var(--canvas); }
}
@media (max-width: 560px) {
    .editor-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .editor-settings .span-2, .editor-settings .span-3 { grid-column: 1 / -1; }
    .canvas-bar .row { width: 100%; justify-content: space-between; }
}
.order-list li.is-dragging { border-color: var(--blue); background: var(--blue-soft); box-shadow: 0 12px 24px -14px rgba(11, 31, 92, .5); }

/* ---------- Small screens: tables become stacked cards ---------- */
@media (max-width: 720px) {
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tr { position: relative; padding: 14px 16px; border-bottom: 1px solid var(--line); }
    .table-cards tr:last-child { border-bottom: 0; }
    .table-cards td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; align-items: baseline; gap: 14px; text-align: right; }
    .table-cards td[data-label]::before { content: attr(data-label); flex: none; font-size: .78rem; font-weight: 600; color: var(--muted); text-align: left; }
    .table-cards td.cell-main { display: block; text-align: left; padding-bottom: 6px; }
    .table-cards td.cell-check { position: absolute; top: 14px; right: 16px; width: auto; padding: 0; }
    .table-cards tr:has(.cell-check) td.cell-main { padding-right: 36px; }
    .table-cards td.actions { justify-content: flex-start; padding-top: 10px; }
    .table-cards td.cell-sub br { display: none; }
    .table-cards tbody tr:hover td { background: none; }
    .table-wrap { overflow-x: visible; }
    .bulk-bar { flex-direction: column; align-items: stretch; }
    .bulk-bar select { min-width: 0; width: 100%; }
    .bulk-bar .muted { margin-left: 0 !important; }
    .page-head > .row, .page-head > .actions { width: 100%; }
    .section-head { align-items: flex-start; }
}

/* Playlist rows on narrow screens: content on top, buttons on their own line. */
@media (max-width: 560px) {
    .item-main { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 8px 10px; }
    .item-main .item-thumb { display: none; }
    .item-main .actions { grid-column: 1 / -1; }
    .item-main .actions .btn { flex: 1 1 auto; }
    .toolbar > * { flex: 1 1 auto; }
    .toolbar select { width: 100%; }
    .tabs { width: 100%; }
    .tabs a { flex: 1; text-align: center; }
    .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .layout-grid { grid-template-columns: minmax(0, 1fr); }
    .type-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .clock-styles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 14px; }
    .picker-head, .picker-foot { padding: 14px; }
    .picker-head input { width: 100%; }
    .picker-foot .row { width: 100%; justify-content: flex-end; }
    .settings-nav a { flex: 1 1 45%; }
    .auth-card { padding: 22px; }
}
