/* ── Design tokens ─────────────────────────────────────────────────────────
   Light, slate-based admin theme for the CL Signage UI. */
:root {
    --bg: #f6f7f9;
    --card: #ffffff;
    --fg: #0f172a;
    --fg-muted: #64748b;
    --fg-faint: #94a3b8;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --primary: #449A5C;
    --primary-hover: #37814c;
    --primary-fg: #ffffff;
    --good: #16a34a;
    --good-bg: #dcfce7;
    --warn: #d97706;
    --warn-bg: #fef3c7;
    --bad: #dc2626;
    --bad-bg: #fee2e2;
    --pending: #64748b;
    --pending-bg: #f1f5f9;
    --radius: 4px;
    --radius-sm: 4px;
    --shadow: 0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.06);
    font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
/* The hidden attribute must win over component display rules (modals, toggled
   fields). Without this, `.modal-overlay{display:grid}` keeps modals on screen. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { background: var(--bg); color: var(--fg); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-wrap: break-word; }
* { -webkit-tap-highlight-color: rgba(68,154,92,.18); }
a { color: inherit; text-decoration: none; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85em; background: var(--pending-bg); padding: 1px 5px; border-radius: 4px; }

/* ── App shell ──────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px; flex-shrink: 0; background: var(--card);
    border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 16px 16px; border-bottom: 1px solid var(--border); }
.brand-logo { width: 160px; height: auto; max-width: 100%; display: block; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; }
.brand-name { font-weight: 650; }
.topbar-logo { height: 24px; width: auto; display: block; }
.nav { flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--radius-sm); color: var(--fg-muted); font-weight: 500; transition: background .12s, color .12s; }
.nav-item:hover { background: var(--bg); color: var(--fg); }
.nav-item.active { background: var(--primary); color: var(--primary-fg); box-shadow: var(--shadow); }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px; }
.who-ws { font-size: 12px; font-weight: 600; color: var(--primary); background: #e9f3eb; border: 1px solid #d0e7d7; border-radius: 6px; padding: 5px 9px; margin-bottom: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who { margin-bottom: 8px; }
.who-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-role { color: var(--fg-faint); font-size: 12px; text-transform: capitalize; }

.content { flex: 1; min-width: 0; padding: 28px 32px; }

/* ── Page header ────────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-title { font-size: 24px; font-weight: 700; margin: 0; }
.page-sub { color: var(--fg-muted); margin: 4px 0 0; }

/* ── Cards & grids ──────────────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card-title { font-size: 15px; font-weight: 650; margin: 0 0 4px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { font-size: 15px; font-weight: 650; margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
@media (max-width: 980px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat-label { color: var(--fg-muted); font-size: 13px; font-weight: 500; }
.stat-value { font-size: 30px; font-weight: 750; margin: 4px 0 6px; }
.stat-foot { color: var(--fg-faint); font-size: 12.5px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot-good { background: var(--good); } .dot-bad { background: var(--bad); }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.muted { color: var(--fg-muted); }
.link { color: var(--primary); font-weight: 500; }
.link:hover { text-decoration: underline; }
.empty { color: var(--fg-muted); padding: 20px; text-align: center; }

/* ── Status pills ───────────────────────────────────────────────────────── */
.pill { display: inline-block; padding: 2px 9px; border-radius: 4px; font-size: 12px; font-weight: 600; text-transform: capitalize; }
.pill-online, .pill-executed, .pill-active { color: var(--good); background: var(--good-bg); }
.pill-offline, .pill-failed { color: var(--bad); background: var(--bad-bg); }
.pill-warning, .pill-sent { color: var(--warn); background: var(--warn-bg); }
.pill-pending, .pill-draft, .pill-inactive { color: var(--pending); background: var(--pending-bg); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--card); color: var(--fg); font-weight: 550; font-size: 14px; cursor: pointer; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--fg-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--fg); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 550; color: var(--fg); }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--card); color: var(--fg); font: inherit; }
/* Color pickers render as a small swatch, not a full-width stretched bar. */
input[type="color"] { width: 46px; height: 34px; padding: 3px; cursor: pointer; flex: none; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }
input[type="checkbox"], input[type="radio"] { width: auto; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(68,154,92,.15); }

.alert { padding: 10px 13px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 6px; }
.alert-error { color: var(--bad); background: var(--bad-bg); border: 1px solid #fecaca; }

/* ── Auth pages ─────────────────────────────────────────────────────────── */
.auth-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(180deg, #f8fafc, #eef2f7); }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 10px 30px rgba(15,23,42,.08); padding: 30px 28px; }
.auth-alt { text-align: center; color: var(--fg-muted); font-size: 13px; margin: 16px 0 0; }
.auth-head { text-align: center; margin-bottom: 20px; }
.auth-head h1 { font-size: 21px; margin: 8px 0 4px; }
.auth-head p { color: var(--fg-muted); margin: 0; font-size: 14px; }
.auth-mark { width: 46px; height: 46px; border-radius: 12px; background: var(--primary); color: #fff; display: grid; place-items: center; margin: 0 auto; }
.auth-logo { height: 46px; width: auto; max-width: 220px; display: block; margin: 0 auto 14px; }

/* ── Toolbar / layout helpers ───────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; }
.row-wrap { flex-wrap: wrap; }
.muted-sm { color: var(--fg-faint); font-size: 12.5px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.section-gap { margin-top: 22px; }
.inline-form { display: inline; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .field-row { grid-template-columns: 1fr; } }
.help { color: var(--fg-faint); font-size: 12px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 4px; background: var(--pending-bg); color: var(--fg-muted); font-size: 12px; margin: 2px 2px 0 0; }
.creator-line { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 12px; color: var(--fg-muted); }
.creator-line svg { opacity: .7; flex: none; }

/* ── Flash + toast ──────────────────────────────────────────────────────── */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; border: 1px solid transparent; animation: flash-in .25s ease; }
.flash.flash-out { animation: flash-out .45s ease forwards; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes flash-out { to { opacity: 0; transform: translateY(-8px); height: 0; padding-top: 0; padding-bottom: 0; margin: 0; border-width: 0; } }
.flash-success { color: var(--good); background: var(--good-bg); border-color: #bbf7d0; }
.flash-error { color: var(--bad); background: var(--bad-bg); border-color: #fecaca; }

.toast-host { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { padding: 11px 15px; border-radius: var(--radius-sm); color: #fff; background: #0f172a; box-shadow: 0 8px 24px rgba(15,23,42,.18); font-size: 13.5px; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--good); } .toast-error { background: var(--bad); } .toast-info { background: #0f172a; }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 1100; padding: 20px; }
.modal-card { background: var(--card); border-radius: 4px; box-shadow: 0 20px 50px rgba(15,23,42,.25); width: 100%; max-width: 560px; overflow: hidden; }
.modal-card.modal-sm { max-width: 420px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 650; }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Misc list items ────────────────────────────────────────────────────── */
.list-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.list-card h3 { margin: 0; font-size: 15px; }
.card-actions { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 10px; }
.card-actions .btn { height: 32px; }
/* Delete sits on the left; every other action is pushed to the right. */
.card-actions .card-del { order: -1; margin-right: auto; }
.thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: var(--radius-sm); background: #0f172a; }
/* Playlist card preview banner — full-bleed top, first image item. */
.list-card-thumb { display: block; margin: -16px -18px 6px; height: 132px;
    border-radius: var(--radius) var(--radius) 0 0; background-color: #0f172a;
    background-size: cover; background-position: center; background-repeat: no-repeat;
    border-bottom: 1px solid var(--border); }
.list-card-thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--fg-faint); }
details.adv > summary { cursor: pointer; color: var(--fg-muted); font-size: 13px; margin: 6px 0; }

.pl-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Playlist editor ────────────────────────────────────────────────────── */
.pl-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 16px; }
.pl-stats { display: flex; align-items: center; gap: 22px; }
.pl-stat { display: flex; flex-direction: column; }
.pl-stat-val { font-size: 26px; font-weight: 750; line-height: 1; font-variant-numeric: tabular-nums; }
.pl-stat-lbl { font-size: 12px; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }
.pl-stat-sep { width: 1px; height: 34px; background: var(--border); }
.pl-toolbar-opts { display: flex; align-items: flex-end; gap: 20px; }
.pl-switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; padding-bottom: 8px; position: relative; }
.pl-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.pl-switch-track { width: 38px; height: 22px; border-radius: 11px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.pl-switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.pl-switch input:checked + .pl-switch-track { background: var(--primary); }
.pl-switch input:checked + .pl-switch-track::after { transform: translateX(16px); }

.pl-list { display: flex; flex-direction: column; gap: 10px; }
.pl-card { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 12px 14px; transition: box-shadow .12s, border-color .12s; }
.pl-card:hover { box-shadow: 0 4px 14px rgba(15,23,42,.10); border-color: var(--border-strong); }
.pl-card.dragging { opacity: .55; border-color: var(--primary); box-shadow: 0 8px 22px rgba(15,23,42,.18); }
.pl-grip { color: var(--fg-faint); cursor: grab; display: flex; flex: none; }
.pl-grip:active { cursor: grabbing; }
.pl-card:hover .pl-grip { color: var(--fg-muted); }
.pl-idx { width: 22px; text-align: center; font-size: 13px; font-weight: 650; color: var(--fg-faint); font-variant-numeric: tabular-nums; flex: none; }
.pl-card-thumb { width: 112px; height: 63px; border-radius: 6px; overflow: hidden; background: #0f172a; color: #fff; display: grid; place-items: center; flex: none; font-size: 24px; }
.pl-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pl-card-body { flex: 1; min-width: 0; }
.pl-card-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.pl-type { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 2px 8px; border-radius: 20px; }
.pl-type-image { color: #2563eb; background: #e6efff; }
.pl-type-video { color: #db2777; background: #fce7f3; }
.pl-card-dur { display: flex; flex-direction: column; gap: 4px; width: 116px; flex: none; }
.pl-card-dur input { padding: 7px 9px; text-align: center; font-variant-numeric: tabular-nums; }
.pl-card-del { width: 30px; height: 30px; border: none; border-radius: 7px; background: transparent; color: var(--fg-faint); font-size: 18px; line-height: 1; cursor: pointer; flex: none; transition: background .12s, color .12s; }
.pl-card-del:hover { background: var(--bad-bg); color: var(--bad); }
.pl-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 50px 20px; color: var(--fg-muted); text-align: center; background: var(--card); border: 1px dashed var(--border-strong); border-radius: 10px; }
.pl-empty svg { color: var(--fg-faint); }

/* ── Media library ──────────────────────────────────────────────────────── */
.folder-bar { margin-bottom: 18px; }
.folder-chip { display: inline-block; padding: 5px 12px; border-radius: 4px; background: var(--card); border: 1px solid var(--border-strong); color: var(--fg-muted); font-size: 13px; font-weight: 500; }
.folder-chip:hover { background: var(--bg); color: var(--fg); }
.folder-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.folder-chip-wrap { display: inline-flex; align-items: center; gap: 2px; }
.folder-x { border: none; background: none; color: var(--fg-faint); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }
.folder-x:hover { color: var(--bad); }

.up-item { margin-top: 10px; }
.up-row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.up-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-bar { height: 6px; background: var(--pending-bg); border-radius: 4px; overflow: hidden; }
.up-fill { height: 100%; background: var(--primary); width: 0; transition: width .2s; }
.dl-icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex: 0 0 38px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); color: var(--primary); }

/* ── Layout editor ──────────────────────────────────────────────────────── */
.layout-editor { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
@media (max-width: 980px) { .layout-editor { grid-template-columns: 1fr; } }
.canvas-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; height: calc(100vh - 150px); display: flex; overflow: auto; }
.layout-editor { min-width: 0; }
/* margin:auto centres the canvas when it fits, and aligns to the start (fully
   scrollable) when zoomed beyond the viewport. */
.canvas { margin: auto; flex: 0 0 auto; position: relative; background: #0f172a repeating-linear-gradient(45deg, #141a26 0 10px, #0f172a 10px 20px); border-radius: 4px; overflow: hidden; user-select: none; touch-action: none; }
.cv-zoom { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 2px 4px; }
.cv-zoom #ly-zoom-label { font-size: 12.5px; color: var(--fg-muted); min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; }
.zone-box { position: absolute; border: 2px solid var(--primary); background: rgba(68,154,92,.18); box-sizing: border-box; cursor: move; display: flex; align-items: flex-start; }
.zone-box.selected { border-color: var(--accent, #f59e0b); box-shadow: 0 0 0 2px rgba(245,158,11,.4); z-index: 999 !important; }
.zone-label { font-size: 11px; color: #fff; background: rgba(0,0,0,.45); padding: 2px 6px; border-radius: 0 0 4px 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.zone-handle { position: absolute; right: -1px; bottom: -1px; width: 14px; height: 14px; background: var(--primary); border: 2px solid #fff; border-radius: 4px; cursor: se-resize; }
.zone-panel { margin-top: 18px; }
.ly-side { display: flex; flex-direction: column; }
.accordion { gap: 10px; }
.acc-item { background: var(--card); border: 1px solid var(--border); border-radius: 4px; box-shadow: var(--shadow); overflow: hidden; }
.acc-header { width: 100%; text-align: left; background: none; border: none; padding: 13px 16px; font-weight: 650; font-size: 15px; color: var(--fg); cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
.acc-header::after { content: '▾'; color: var(--fg-faint); transition: transform .2s; }
.acc-item.open .acc-header::after { transform: rotate(180deg); }
.acc-body { padding: 0 16px 16px; display: none; }
.acc-item.open .acc-body { display: block; }
.zone-content { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; pointer-events: none; background: transparent; }
img.zone-content { object-fit: cover; }
.snap-guide { position: absolute; pointer-events: none; z-index: 1000; }
.snap-guide-v { top: 0; bottom: 0; width: 1px; background: var(--warn); box-shadow: 0 0 0 0.5px var(--warn); }
.snap-guide-h { left: 0; right: 0; height: 1px; background: var(--warn); box-shadow: 0 0 0 0.5px var(--warn); }

/* ── Group / floor plan ─────────────────────────────────────────────────── */
.member-list { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; }
.floorplan { position: relative; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg); touch-action: none; user-select: none; display: none; }
.fp-img { display: block; width: 100%; height: auto; pointer-events: none; }
.fp-marker { position: absolute; transform: translate(-50%, -50%); background: var(--primary); color: #fff; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 4px; white-space: nowrap; cursor: move; box-shadow: 0 2px 6px rgba(0,0,0,.3); border: 2px solid #fff; }

/* ── Permissions matrix ─────────────────────────────────────────────────── */
.perm-table { width: 100%; border-collapse: collapse; }
.perm-table th, .perm-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.perm-table td.center, .perm-table th.center { text-align: center; }
.perm-section { font-weight: 650; margin: 18px 0 8px; }
.perm-search { position: relative; max-width: 360px; margin: 0 0 12px; }
.perm-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--fg-faint); pointer-events: none; }
.perm-search input { width: 100%; padding-left: 34px; }

/* Email template editor */
.et-vars { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; }
.et-var { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 5px; background: var(--bg-subtle, #f8fafc); color: var(--fg-muted); cursor: pointer; }
.et-var:hover { border-color: var(--primary); color: var(--primary); }
.et-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch; }
.et-body { width: 100%; min-height: 340px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.5; resize: vertical; white-space: pre; }
.et-preview { width: 100%; min-height: 340px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
@media (max-width: 860px) { .et-grid { grid-template-columns: 1fr; } }

/* ── Widget previews ────────────────────────────────────────────────────── */
.widget-card-preview { width: 100%; aspect-ratio: 16 / 9; border-radius: 4px; overflow: hidden; background: #0f172a; margin-bottom: 8px; }
.widget-card-preview iframe { width: 100%; height: 100%; border: 0; display: block; pointer-events: none; }
.modal-card.modal-wide { max-width: 860px; }
.wc-grid { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
@media (max-width: 760px) { .wc-grid { grid-template-columns: 1fr; } }
.wc-preview { position: sticky; top: 0; }
.wc-preview iframe { width: 100%; aspect-ratio: 16 / 9; border: 1px solid var(--border); border-radius: 4px; background: #000; display: block; }
.wc-control { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.wc-control .wc-row { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; margin: 2px 0; }
.wc-control .wc-row b { color: var(--fg-muted); min-width: 56px; flex: none; font-weight: 600; }
.wc-control .wc-row a, .wc-control .wc-row code { word-break: break-all; }
.wc-control code { font-size: 12px; }
.wc-control .wc-appbox { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border-strong); }
.wc-control .wc-row .wc-copy { margin-left: auto; align-self: center; padding: 3px 10px; font-size: 12px; flex: none; }
.wc-screens .wc-screen { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.wc-screens .wc-screen:first-child { border-top: 0; }
.wc-screens .wc-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--fg-muted); }
.wc-screens .wc-dot-online { background: var(--good); }
.wc-screens .wc-dot-offline { background: var(--bad); }
.wc-screens .wc-dot-warning { background: var(--warn); }
.wc-screens .wc-screen-main { min-width: 0; flex: 1; }
.wc-screens .wc-screen-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wc-screens .wc-screen-sub { font-size: 11.5px; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wc-screens .wc-ip { font-size: 12px; flex: none; }
.wc-screens .wc-screen .wc-copy { flex: none; padding: 3px 10px; font-size: 12px; }
.wc-upload-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }

/* ── Schedule: per-zone content assignment ──────────────────────────────── */
.zone-assign { display: flex; flex-direction: column; gap: 8px; }
.zone-assign-row { display: grid; grid-template-columns: 1fr auto 1.5fr; gap: 8px; align-items: center; }
.za-name { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-assign-row select { padding: 6px 8px; }

/* ── Layout editor: zone list ───────────────────────────────────────────── */
.zone-list-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 8px; font-size: 12px; font-weight: 600; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .04em; }
.zone-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.zone-row { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card); color: var(--fg); cursor: pointer; font: inherit; transition: background .12s, border-color .12s; }
.zone-row:hover { background: var(--bg); }
.zone-row.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.zone-row-dot { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--border-strong); flex: none; background-clip: padding-box; }
.zone-row-name { flex: 1; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-row-dim { color: var(--fg-faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.zone-props { border-top: 1px solid var(--border); padding-top: 12px; }
.zone-props-hint { color: var(--fg-faint); font-size: 12.5px; padding: 6px 0; }

/* ── Schedules: view toggle (icon tabs) ─────────────────────────────────── */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; border: none; background: var(--card); color: var(--fg-muted); padding: 7px 13px; font: inherit; font-weight: 550; cursor: pointer; }
.seg-btn svg { width: 15px; height: 15px; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--primary); color: var(--primary-fg); }

/* ── Schedules: calendar + timeline ─────────────────────────────────────── */
.cal-wrap { display: grid; grid-template-columns: 230px 1fr; gap: 16px; align-items: start; }
@media (max-width: 820px) { .cal-wrap { grid-template-columns: 1fr; } }

.cal-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 8px; }
.cal-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.cal-side-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--fg-faint); margin: 0 0 10px; }
.cal-player-list { display: flex; flex-direction: column; gap: 5px; }
.cal-player-item { text-align: left; padding: 9px 12px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--fg); font: inherit; font-weight: 550; cursor: pointer; transition: background .12s, border-color .12s; }
.cal-player-item:hover { background: var(--bg); }
.cal-player-item.active { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.cal-pal-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--fg-faint); margin: 10px 0 6px; }
.cal-pal-group:first-child { margin-top: 0; }
.cal-chip { display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: grab; font-size: 13px; font-weight: 550; }
.cal-chip:active { cursor: grabbing; }
.cal-chip-ic { display: inline-flex; flex: none; }
.cal-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cal-main { min-width: 0; padding: 0; overflow: hidden; }
.cal-weekbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.cal-weektitle { flex: 1; text-align: center; font-weight: 650; font-size: 15px; }
.cal-navbtn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--card); color: var(--fg); font-size: 17px; line-height: 1; cursor: pointer; }
.cal-navbtn:hover { background: var(--bg); }
.cal-zoom { display: flex; align-items: center; gap: 4px; }
.cal-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: none; border-radius: var(--radius-sm); background: transparent; color: var(--fg-muted); cursor: pointer; }
.cal-iconbtn:hover { background: var(--bg); color: var(--fg); }
.cal-zoom #cal-zoom-label { font-size: 12.5px; color: var(--fg-muted); min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }

.cal-grid-wrap { overflow: auto; max-height: 72vh; }
.cal-grid { min-width: 620px; }
.cal-head { display: grid; grid-template-columns: 56px repeat(7, 1fr); position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--border-strong); }
.cal-corner { border-right: 1px solid var(--border); }
.cal-dayhead { display: flex; flex-direction: column; align-items: center; gap: 1px; text-align: center; padding: 8px 4px; border-left: 1px solid var(--border); }
.cal-dh-day { font-size: 12px; font-weight: 500; color: var(--fg-muted); }
.cal-dh-date { font-size: 18px; font-weight: 650; color: var(--fg); line-height: 1.1; }
.cal-dayhead.today { background: #e9f3eb; }
.cal-dayhead.today .cal-dh-day, .cal-dayhead.today .cal-dh-date { color: var(--primary); }
.cal-col.today { background-color: #f5f7ff; }
.cal-body { display: grid; grid-template-columns: 56px repeat(7, 1fr); }
.cal-gutter { position: relative; border-right: 1px solid var(--border); }
.cal-hour { position: absolute; right: 6px; transform: translateY(-50%); font-size: 11px; color: var(--fg-faint); font-variant-numeric: tabular-nums; }
.cal-col { position: relative; border-left: 1px solid var(--border); background-image: repeating-linear-gradient(to bottom, var(--border) 0, var(--border) 1px, transparent 1px, transparent calc(var(--pph) * 1px)); }

.cal-block { position: absolute; left: 3px; right: 3px; border: 1px solid; border-radius: 6px; overflow: hidden; cursor: grab; user-select: none; touch-action: none; }
.cal-block.dragging { cursor: grabbing; z-index: 50; box-shadow: 0 6px 16px rgba(15,23,42,.18); opacity: .97; }
.cal-block.is-off { opacity: .5; }
.cal-block-top, .cal-block-bot { position: absolute; left: 0; right: 0; height: 7px; cursor: ns-resize; }
.cal-block-top { top: 0; } .cal-block-bot { bottom: 0; }
.cal-block-main { padding: 5px 8px; pointer-events: none; }
.cal-block-name { font-size: 12.5px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-block-time { font-size: 11px; opacity: .8; font-variant-numeric: tabular-nums; }
.cal-block-acts { position: absolute; top: 3px; right: 3px; display: none; gap: 2px; }
.cal-block:hover .cal-block-acts { display: flex; }
.cb-act { width: 19px; height: 19px; border: none; border-radius: 4px; background: rgba(15,23,42,.08); color: inherit; font-size: 11px; line-height: 1; cursor: pointer; padding: 0; }
.cb-act:hover { background: rgba(15,23,42,.18); }
.cal-drop-line { position: absolute; left: 0; right: 0; height: 0; border-top: 2px dashed var(--primary); pointer-events: none; z-index: 40; }
.cal-drop-line span { position: absolute; left: 2px; top: 1px; font-size: 10px; background: var(--primary); color: #fff; padding: 0 4px; border-radius: 3px; }

/* timeline */
.cal-timeline-wrap { overflow: auto; max-height: 72vh; }
.cal-timeline { min-width: 620px; }
.tl-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); }
.tl-row.tl-axis { position: sticky; top: 0; z-index: 4; background: var(--card); border-bottom: 1px solid var(--border-strong); }
.tl-daylabel { width: 88px; flex: none; padding: 9px 12px; font-size: 13px; color: var(--fg-muted); border-right: 1px solid var(--border); }
.tl-daylabel b { color: var(--fg); }
.tl-daylabel.today { background: #e9f3eb; color: var(--primary); }
.tl-daylabel.today b { color: var(--primary); }
.tl-track { position: relative; flex: 1; min-height: 44px; background-image: repeating-linear-gradient(to right, var(--border) 0, var(--border) 1px, transparent 1px, transparent calc(100% / 12)); }
.tl-axis .tl-track { min-height: 26px; }
.tl-hour { position: absolute; top: 7px; transform: translateX(-50%); font-size: 11px; color: var(--fg-faint); font-variant-numeric: tabular-nums; }
.tl-block { position: absolute; top: 6px; bottom: 6px; border: 1px solid; border-radius: 5px; padding: 0 7px; overflow: hidden; display: flex; align-items: center; font-size: 11.5px; font-weight: 600; cursor: pointer; }
.tl-block-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Player group: full-page editor ─────────────────────────────────────── */
.group-edit { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .group-edit { grid-template-columns: 1fr; } }
.group-edit-side { display: flex; flex-direction: column; gap: 12px; }
.group-edit-plan { display: flex; flex-direction: column; gap: 10px; }
.plan-head { display: flex; align-items: baseline; justify-content: space-between; font-weight: 600; }
.floorplan-lg { display: block; min-height: 60vh; }
.floorplan-lg.fp-has-img { min-height: 0; }
.fp-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--fg-faint); font-size: 13px; }
.fp-marker.dragging { box-shadow: 0 4px 12px rgba(0,0,0,.45); transform: translate(-50%, -50%) scale(1.06); z-index: 5; }

/* ── Media library: breadcrumb, folders, drag-drop, preview ──────────────── */
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; font-size: 14px; }
.crumb { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: var(--radius-sm); color: var(--fg-muted); font-weight: 550; border: 1px solid transparent; }
.crumb:hover { background: var(--bg); color: var(--fg); }
.crumb.current { color: var(--fg); }
.crumb.drop-hover { background: #e9f3eb; border-color: var(--primary); color: var(--primary); }
.crumb-sep { color: var(--fg-faint); }

.media-card, .folder-card { position: relative; }
.media-card { cursor: pointer; }
.folder-card { cursor: pointer; }
.folder-card.drop-hover, .media-card.drop-hover { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(68,154,92,.25); }
.folder-card[draggable="true"], .media-card[draggable="true"] { }
.folder-card.drop-hover { background: #e9f3eb; }
.folder-thumb { position: relative; width: 100%; aspect-ratio: 16/9; display: grid; place-items: center; border-radius: var(--radius-sm); background: #f1f5f9; color: #94a3b8; overflow: hidden; }
.folder-card:hover .folder-thumb { background: #e9eef4; color: #64748b; }
/* Folder content preview: 1 = single, 2 = split, 3+ = 2×2 quad. Absolutely
   filled so the grid divides the 16/9 box (no min-height:auto blowout). */
.folder-mosaic { position: absolute; inset: 0; display: grid; gap: 2px; background: var(--border); }
.folder-mosaic.n1 { grid-template-columns: 1fr; }
.folder-mosaic.n2 { grid-template-columns: 1fr 1fr; }
.folder-mosaic.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.folder-mosaic img { width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: cover; display: block; background: #0f172a; }
.folder-mosaic .m-empty { background: #e2e8f0; }

.iconbtn-del { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border: none; border-radius: 5px; background: rgba(15,23,42,.55); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; display: none; padding: 0; }
.media-card:hover .iconbtn-del, .folder-card:hover .iconbtn-del { display: block; }
.iconbtn-del:hover { background: var(--bad); }
.media-del, .folder-del { position: absolute; top: 0; right: 0; }

/* preview modal */
.mp-body { display: grid; grid-template-columns: 1fr 240px; gap: 18px; align-items: start; }
@media (max-width: 720px) { .mp-body { grid-template-columns: 1fr; } }
.mp-stage { display: flex; align-items: center; justify-content: center; background: #0f172a; border-radius: var(--radius-sm); min-height: 260px; overflow: hidden; }
.mp-stage img, .mp-stage video { max-width: 100%; max-height: 62vh; display: block; }
.mp-props { display: flex; flex-direction: column; gap: 0; }
.mp-prop { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.mp-prop span { color: var(--fg-muted); }
.mp-prop b { font-weight: 600; text-align: right; word-break: break-word; }

/* ── Upload drop zone ───────────────────────────────────────────────────── */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 34px 20px; border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--bg); color: var(--fg-muted); cursor: pointer; transition: border-color .15s, background .15s, color .15s; }
.dropzone > * { pointer-events: none; }
.dropzone:hover { border-color: var(--primary); color: var(--fg); }
.dropzone.dragover { border-color: var(--primary); background: #e9f3eb; color: var(--primary); transform: scale(1.01); }
.dz-icon { color: var(--fg-faint); transition: color .15s; }
.dropzone:hover .dz-icon, .dropzone.dragover .dz-icon { color: var(--primary); }
.dz-title { font-weight: 600; font-size: 15px; color: var(--fg); }
.dz-sub { font-size: 13px; }
.dz-browse { color: var(--primary); font-weight: 600; text-decoration: underline; }

/* ── Image cropper ──────────────────────────────────────────────────────── */
.cropper { position: relative; display: inline-block; max-width: 100%; line-height: 0; user-select: none; touch-action: none; }
.cropper img { display: block; max-width: 100%; max-height: 60vh; }
.crop-box { position: absolute; border: 1.5px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); cursor: move; box-sizing: border-box; }
.crop-handle { position: absolute; width: 14px; height: 14px; background: #fff; border: 1px solid var(--primary); border-radius: 2px; }
.crop-handle.nw { left: -8px; top: -8px; cursor: nwse-resize; }
.crop-handle.ne { right: -8px; top: -8px; cursor: nesw-resize; }
.crop-handle.sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.crop-handle.se { right: -8px; bottom: -8px; cursor: nwse-resize; }

/* ── Resource folder bar (groups/playlists/layouts/widgets/schedules) ──────── */
.folder-bar { margin-bottom: 18px; padding: 12px 14px 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.folder-bar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.folder-bar-head .crumbs { margin-bottom: 0; }
.folder-new { display: inline-flex; align-items: center; gap: 6px; }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 12px; }
.folder-tile { position: relative; display: flex; align-items: center; gap: 11px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: border-color .12s, box-shadow .12s, background .12s, transform .12s; }
.folder-tile:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.folder-tile-ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: #e9f3eb; color: var(--primary); flex-shrink: 0; }
.folder-tile-meta { min-width: 0; flex: 1; }
.folder-tile .fname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-tile .fmeta { color: var(--fg-faint); font-size: 12px; margin-top: 1px; }
.folder-tile .iconbtn-del { position: absolute; top: 5px; right: 5px; display: none; }
.folder-tile:hover .iconbtn-del { display: block; }
.folder-tile.drop-hover { border-color: var(--primary); background: #e9f3eb; box-shadow: 0 0 0 3px rgba(68,154,92,.14); }
.folder-tile.drag-dim, [data-folder-item].drag-dim { opacity: .45; }
.folder-hint { color: var(--fg-faint); font-size: 12px; margin: 12px 0 0; }
[data-folder-item][draggable="true"] { cursor: grab; }
[data-folder-item][draggable="true"]:active { cursor: grabbing; }

/* ── Responsive / mobile ───────────────────────────────────────────────────
   Desktop default: the mobile top bar + nav backdrop are hidden. */
.topbar { display: none; }
.nav-backdrop { display: none; }
.table-wrap { width: 100%; }

@media (max-width: 860px) {
    /* Sidebar becomes an off-canvas drawer toggled by the top-bar hamburger. */
    .sidebar {
        position: fixed; top: 0; left: 0; width: 248px; height: 100vh; z-index: 1200;
        transform: translateX(-100%); transition: transform .22s ease;
        box-shadow: 0 12px 40px rgba(15,23,42,.28);
    }
    .app.nav-open .sidebar { transform: translateX(0); }
    .nav-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1150; }
    .app.nav-open .nav-backdrop { display: block; }

    .content { padding: 14px; min-width: 0; }
    .topbar {
        display: flex; align-items: center; gap: 12px;
        position: sticky; top: 0; z-index: 1000;
        margin: -14px -14px 14px; padding: 9px 14px;
        background: var(--card); border-bottom: 1px solid var(--border);
    }
    .topbar .brand-name { font-weight: 650; }
    .nav-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 40px; height: 40px; flex-shrink: 0; padding: 0;
        border: 1px solid var(--border); border-radius: var(--radius-sm);
        background: var(--card); color: var(--fg); cursor: pointer;
    }

    .page-header { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 16px; }
    .page-header .row { flex-wrap: wrap; }
    .page-title { font-size: 20px; }

    .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .grid-cards { grid-template-columns: 1fr; }
    .folder-grid { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }

    /* Wide tables scroll horizontally inside their auto-inserted wrapper. */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table { min-width: 520px; }
    .perm-table { min-width: 460px; }

    .card { padding: 14px; }

    .modal-overlay { padding: 12px; }
    .modal-card, .modal-card.modal-sm, .modal-card.modal-wide { max-width: 100%; }
    .modal-body { max-height: 72vh; }

    /* 16px inputs stop iOS Safari from zooming the page on focus. */
    input, select, textarea, .btn { font-size: 16px; }

    /* Comfortable tap targets (≥44px) for touch. */
    .btn { padding: 10px 15px; min-height: 44px; }
    .btn-sm { min-height: 38px; padding: 7px 12px; font-size: 14px; }
    .nav-item { padding: 11px 12px; }
    .iconbtn { min-width: 40px; min-height: 40px; }

    /* Safe-area insets for the Dynamic Island / home indicator (viewport-fit=cover). */
    .content { padding-left: max(14px, env(safe-area-inset-left));
               padding-right: max(14px, env(safe-area-inset-right)); }
    .topbar { padding-top: calc(9px + env(safe-area-inset-top));
              margin-top: calc(-14px - env(safe-area-inset-top)); }
    .sidebar { padding-top: env(safe-area-inset-top); }
    .sidebar-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
    .auth-body { padding: 20px max(16px, env(safe-area-inset-left))
                 calc(20px + env(safe-area-inset-bottom)); }
}

/* iPhone 15 Pro (393pt) and other small phones. */
@media (max-width: 430px) {
    .stat-grid { grid-template-columns: 1fr; }
    .page-title { font-size: 19px; }
    .content { padding-top: 12px; padding-bottom: 12px; }
    .card { padding: 13px; border-radius: 8px; }
    .folder-grid { grid-template-columns: 1fr; }
    /* Stacked field rows go full-width instead of fixed max-widths. */
    .form .row > .field, .row.form-row > .field { max-width: none !important; flex: 1 1 100%; }
    .page-header .btn { width: 100%; }
    .modal-foot { flex-wrap: wrap; }
    .modal-foot .btn { flex: 1 1 auto; }
}
