/* Story of Prague CMS. Colours follow the app: teal #8BB1B9 on navy. */

:root {
    --font: "Raleway", system-ui, -apple-system, "Segoe UI", sans-serif;
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar: 248px;

    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface-2: #f7f9fb;
    --surface-3: #eef2f6;
    --border: #e1e6ed;
    --border-strong: #cbd3de;
    --text: #142033;
    --muted: #5b687c;
    --faint: #8a96a8;
    --accent: #3d7480;
    --accent-bg: #8bb1b9;
    --accent-soft: #e3eef0;
    --on-accent: #0b1a24;
    --danger: #c2414b;
    --danger-soft: #fbe9ea;
    --success: #2f8a5f;
    --success-soft: #e3f4ec;
    --warning: #a86d12;
    --warning-soft: #fbf0dc;
    --shadow: 0 1px 2px rgba(16, 28, 45, .06), 0 4px 16px rgba(16, 28, 45, .06);
    --shadow-lg: 0 20px 60px rgba(10, 18, 32, .25);

    --nav-bg: #0d1726;
    --nav-text: #b7c3d3;
    --nav-text-strong: #ffffff;
    --nav-hover: rgba(139, 177, 185, .12);
    --nav-active: rgba(139, 177, 185, .2);

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0a111c;
        --surface: #111b2a;
        --surface-2: #142033;
        --surface-3: #1a283d;
        --border: #223149;
        --border-strong: #2f4260;
        --text: #e5ecf4;
        --muted: #93a2b8;
        --faint: #6c7c94;
        --accent: #8bb1b9;
        --accent-bg: #8bb1b9;
        --accent-soft: rgba(139, 177, 185, .14);
        --on-accent: #0b1a24;
        --danger: #ef8a90;
        --danger-soft: rgba(239, 138, 144, .13);
        --success: #7ccaa4;
        --success-soft: rgba(124, 202, 164, .13);
        --warning: #e8bd72;
        --warning-soft: rgba(232, 189, 114, .13);
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
        --nav-bg: #070d16;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0a111c;
    --surface: #111b2a;
    --surface-2: #142033;
    --surface-3: #1a283d;
    --border: #223149;
    --border-strong: #2f4260;
    --text: #e5ecf4;
    --muted: #93a2b8;
    --faint: #6c7c94;
    --accent: #8bb1b9;
    --accent-bg: #8bb1b9;
    --accent-soft: rgba(139, 177, 185, .14);
    --on-accent: #0b1a24;
    --danger: #ef8a90;
    --danger-soft: rgba(239, 138, 144, .13);
    --success: #7ccaa4;
    --success-soft: rgba(124, 202, 164, .13);
    --warning: #e8bd72;
    --warning-soft: rgba(232, 189, 114, .13);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --nav-bg: #070d16;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    font-variant-numeric: lining-nums tabular-nums;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .86em; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

:focus-visible { outline: 2px solid var(--accent-bg); outline-offset: 2px; }

/* ---------- Layout ---------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar);
    display: flex;
    flex-direction: column;
    background: var(--nav-bg);
    color: var(--nav-text);
    z-index: 40;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px 18px;
    color: var(--nav-text-strong);
}
.brand:hover { text-decoration: none; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent-bg);
    color: #0b1a24;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: .5px;
}
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { display: block; font-size: 11px; font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase; color: var(--accent-bg); }

.nav { flex: 1; overflow-y: auto; padding: 6px 12px; }
.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    margin: 2px 0;
    border-radius: 8px;
    color: var(--nav-text);
    font-weight: 600;
    font-size: 14px;
}
.nav a i { width: 18px; text-align: center; opacity: .8; }
.nav a:hover { background: var(--nav-hover); color: var(--nav-text-strong); text-decoration: none; }
.nav a.active { background: var(--nav-active); color: var(--nav-text-strong); }
.nav a.active i { color: var(--accent-bg); opacity: 1; }

.sidebar-foot {
    padding: 14px 16px 18px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    display: grid;
    gap: 10px;
    font-size: 13px;
}
.user-row { display: flex; align-items: center; gap: 10px; }
.avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(139, 177, 185, .2);
    color: var(--accent-bg);
    font-weight: 700;
    text-transform: uppercase;
}
.user-row .name { flex: 1; color: var(--nav-text-strong); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .icon-btn { color: var(--nav-text); }
.sidebar-foot .icon-btn:hover { background: var(--nav-hover); color: #fff; }

.server-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .05);
    color: var(--nav-text);
    font-weight: 600;
}
.server-pill:hover { text-decoration: none; color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: #6fd09e; box-shadow: 0 0 0 3px rgba(111, 208, 158, .18); }
.dot.off { background: #ef7b82; box-shadow: 0 0 0 3px rgba(239, 123, 130, .18); }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar); }
.content { max-width: 1240px; margin: 0 auto; padding: 32px 36px 64px; }

.topbar { display: none; }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    body.nav-open .scrim { display: block; }
    .scrim { display: none; position: fixed; inset: 0; background: rgba(5, 10, 18, .5); z-index: 30; }
    .main { margin-left: 0; }
    .topbar {
        position: sticky;
        top: 0;
        z-index: 20;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 16px;
        background: var(--nav-bg);
        color: #fff;
        font-weight: 700;
    }
    .topbar .icon-btn { color: #fff; }
    .content { padding: 20px 16px 48px; }
}

/* ---------- Page header & toolbar ---------- */

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.2px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; font-weight: 600; font-size: 13px; color: var(--muted); }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}
.toolbar .search { flex: 1 1 260px; }
.toolbar select { flex: 0 1 220px; }

.search { position: relative; }
.search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input[type=search] { padding-left: 36px; }

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 16px; font-weight: 700; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 28px 0 12px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.stat { padding: 18px 20px; display: grid; gap: 4px; color: var(--text); }
a.stat:hover { text-decoration: none; border-color: var(--accent-bg); }
.stat-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; font-size: 13px; }
.stat-label i { color: var(--accent); }
.stat-value { font-size: 28px; font-weight: 700; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: 700;
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    background: var(--surface-3);
    color: var(--text);
    transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { text-decoration: none; border-color: var(--border-strong); }
.btn:disabled, .btn.htmx-request { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent-bg); color: var(--on-accent); }
.btn-primary:hover { background: #9cc0c7; border-color: transparent; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 7px; gap: 6px; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.row-actions { display: flex; justify-content: flex-end; align-items: center; gap: 2px; }
.row-actions form { display: contents; }

/* ---------- Forms ---------- */

input[type=text], input[type=search], input[type=password], input[type=url], input[type=number], input[type=file], select, textarea {
    width: 100%;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
}
input[type=file] { padding: 6px 8px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-bg); box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly] { background: var(--surface-2); }
::placeholder { color: var(--faint); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.field { display: grid; gap: 6px; align-content: start; }
.field > label, .field-label { font-weight: 700; font-size: 13px; }
.field .hint { color: var(--muted); font-size: 12.5px; }
.field .error { color: var(--danger); font-size: 12.5px; font-weight: 600; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.input-group { display: flex; gap: 8px; }
.input-group > :first-child { flex: 1; }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14px; }
.switch input { appearance: none; width: 38px; height: 22px; margin: 0; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.switch input:checked { background: var(--accent-bg); }
.switch input:checked::after { transform: translateX(16px); }

.type-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.type-picker label { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 8px; cursor: pointer; }
.type-picker label:hover { border-color: var(--accent-bg); }
.type-picker input { position: absolute; opacity: 0; pointer-events: none; }
.type-picker strong { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.type-picker span { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.type-picker label:has(input:checked) { border-color: var(--accent-bg); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-bg); }
.type-picker label:has(input:focus-visible) { outline: 2px solid var(--accent-bg); outline-offset: 2px; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    padding: 11px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; }
.table .shrink { width: 1%; white-space: nowrap; }
.cell-main { font-weight: 700; color: var(--text); }
.cell-sub { display: block; color: var(--muted); font-size: 12.5px; }
.qr-id { max-width: 280px; word-break: break-all; }
.truncate { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb { display: block; width: 52px; height: 52px; object-fit: cover; border-radius: 8px; background: var(--surface-3); }
.thumb-wide { width: 92px; height: 52px; }

/* ---------- Badges, chips ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: var(--surface-3);
    color: var(--muted);
    white-space: nowrap;
}
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }

.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chip {
    display: inline-grid;
    place-items: center;
    min-width: 28px;
    height: 22px;
    padding: 0 6px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    background: var(--accent-soft);
    color: var(--accent);
}
.chip.missing { background: transparent; color: var(--faint); border: 1px dashed var(--border-strong); }

/* ---------- Pagination ---------- */

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.pager-links { display: flex; gap: 4px; flex-wrap: wrap; }
.pager-links a, .pager-links span {
    display: inline-grid;
    place-items: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 7px;
    font-weight: 700;
    color: var(--text);
}
.pager-links a:hover { background: var(--surface-3); text-decoration: none; }
.pager-links .current { background: var(--accent-bg); color: var(--on-accent); }
.pager-links .disabled { color: var(--faint); }
.pager select { width: auto; min-height: 30px; padding: 3px 30px 3px 10px; font-size: 13px; }

#list { transition: opacity .15s; }
#list.htmx-request, .htmx-request #list { opacity: .55; }

/* ---------- Empty state ---------- */

.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty i { font-size: 28px; color: var(--faint); margin-bottom: 10px; display: block; }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* ---------- Localization editor ---------- */

.loc-list { list-style: none; margin: 0; padding: 0; }
.loc-item { border-bottom: 1px solid var(--border); }
.loc-item:last-child { border-bottom: 0; }
.loc-item > summary {
    display: grid;
    grid-template-columns: minmax(180px, 260px) minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 12px 18px;
    cursor: pointer;
    list-style: none;
}
.loc-item > summary::-webkit-details-marker { display: none; }
.loc-item > summary:hover { background: var(--surface-2); }
.loc-item[open] > summary { background: var(--surface-2); border-bottom: 1px solid var(--border); }
.loc-key { min-width: 0; }
.loc-key .mono { font-weight: 700; color: var(--text); word-break: break-all; }
.loc-preview { min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.loc-meta { display: flex; align-items: center; gap: 10px; }
.loc-meta .caret { color: var(--faint); transition: transform .15s; }
.loc-item[open] .caret { transform: rotate(90deg); }
.loc-item.highlight > summary { box-shadow: inset 3px 0 0 var(--accent-bg); }
@media (max-width: 800px) {
    .loc-item > summary { grid-template-columns: 1fr auto; }
    .loc-preview { grid-column: 1 / -1; grid-row: 2; }
}

.loc-editor { padding: 16px 18px 20px; background: var(--surface-2); }
.loc-editor .loading { padding: 12px 0; color: var(--muted); }
.translations { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
@media (max-width: 700px) { .translations { grid-template-columns: 1fr; } }
.translation { display: grid; gap: 8px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.translation.is-missing { border-style: dashed; background: transparent; }
.translation.is-dirty { border-color: var(--warning); }
.translation.is-saved { border-color: var(--success); }
.translation-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.translation-head .lang-name { flex: 1; color: var(--muted); font-weight: 600; }
.translation textarea { min-height: 84px; }
.translation-foot { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.translation-foot .count { margin-right: auto; color: var(--faint); font-size: 12px; }
.save-state { font-size: 12px; font-weight: 700; color: var(--success); }

/* ---------- Image grid ---------- */

.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; padding: 16px; }
.image-card { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.image-card .ph { display: block; aspect-ratio: 4 / 3; background: var(--surface-3); }
.image-card img { display: block; width: 100%; height: 100%; object-fit: cover; }
.image-card .meta { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 12px; }
.image-card .meta .mono { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }

.dropzone {
    display: grid;
    place-items: center;
    gap: 6px;
    padding: 26px;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    text-align: center;
    color: var(--muted);
    cursor: pointer;
}
.dropzone.drag { border-color: var(--accent-bg); background: var(--accent-soft); }
.dropzone i { font-size: 24px; color: var(--accent); }
.dropzone img { max-height: 160px; border-radius: 8px; }
.dropzone input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }

/* ---------- Dialogs ---------- */

dialog {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}
dialog.wide { width: min(1100px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(5, 10, 18, .55); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: 17px; font-weight: 700; }
.dialog-body { padding: 20px; overflow: auto; }
.dialog-body .form-actions { margin: 20px -20px -20px; padding: 14px 20px; background: var(--surface-2); }

/* ---------- AR map ---------- */

.ar-map { position: relative; display: inline-block; max-width: 100%; line-height: 0; }
.ar-map img { display: block; max-width: 100%; border-radius: 8px; }
.ar-map.pick img { cursor: crosshair; }
.ar-pin { position: absolute; transform: translate(-50%, -100%); color: var(--accent-bg); font-size: 28px; line-height: 1; filter: drop-shadow(0 0 2px #fff) drop-shadow(0 2px 3px rgba(0, 0, 0, .5)); pointer-events: none; }
.ar-pins .ar-pin { pointer-events: auto; cursor: pointer; font-size: 24px; }
.ar-pins .ar-pin:hover { color: #fff; z-index: 2; }
.ar-hover { position: absolute; transform: translate(-50%, -140%); padding: 3px 7px; border-radius: 5px; background: rgba(0, 0, 0, .75); color: #fff; font-size: 12px; line-height: 1.3; pointer-events: none; white-space: nowrap; }

/* ---------- Toasts ---------- */

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 10px; width: min(380px, calc(100vw - 40px)); }
.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent-bg);
    border-radius: 9px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    font-weight: 600;
    font-size: 14px;
    animation: toast-in .2s ease;
}
.toast i { margin-top: 2px; color: var(--accent); }
.toast span { flex: 1; }
.toast.success { border-left-color: var(--success); }
.toast.success i { color: var(--success); }
.toast.error, .toast.danger { border-left-color: var(--danger); }
.toast.error i, .toast.danger i { color: var(--danger); }
.toast.hide { opacity: 0; transform: translateY(6px); transition: .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Auth ---------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 20% 0%, rgba(139, 177, 185, .18), transparent 60%), var(--nav-bg); }
.auth-card { width: min(400px, 100%); padding: 32px; }
.auth-card .brand { padding: 0 0 24px; color: var(--text); }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .field + .field { margin-top: 14px; }
.auth-card .btn { width: 100%; margin-top: 22px; height: 42px; }

/* ---------- Server page ---------- */

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 800px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-card { padding: 16px 18px; }
.chart-card h3 { display: flex; align-items: baseline; justify-content: space-between; font-size: 14px; margin-bottom: 10px; }
.chart-card h3 span { font-size: 22px; font-weight: 700; }
.chart-box { position: relative; height: 180px; }
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.device { padding: 16px 18px; display: grid; gap: 8px; }
.device h3 { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.device dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 13px; }
.device dt { color: var(--muted); }
.device dd { margin: 0; font-weight: 600; }

/* ---------- Gallery ---------- */

.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; padding: 16px; }
.gallery-item { display: grid; gap: 8px; padding: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--muted); cursor: zoom-in; text-align: center; }
.gallery-item:hover { border-color: var(--accent-bg); color: var(--text); }
.gallery-item img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.gallery-item span { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Full-screen image viewer: the page stays visible but dimmed behind it. */
dialog.lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; display: none; align-items: center; justify-content: center; gap: 16px; padding: 24px; }
dialog.lightbox[open] { display: flex; }
dialog.lightbox::backdrop { background: rgba(5, 10, 18, .82); backdrop-filter: blur(4px); }
.lightbox figure { margin: 0; display: grid; justify-items: center; gap: 12px; min-width: 0; }
.lightbox figure img { max-width: min(1200px, calc(100vw - 180px)); max-height: calc(100vh - 110px); border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.lightbox figcaption { display: flex; gap: 14px; color: #e6edf5; font-weight: 700; font-size: 14px; }
.lightbox figcaption .faint { color: #9fb0c3; font-weight: 600; }
.lightbox-nav { flex: none; width: 52px; height: 52px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .08); color: #fff; font-size: 18px; cursor: pointer; }
.lightbox-nav:hover { background: rgba(255, 255, 255, .18); }
.lightbox-close { position: fixed; top: 18px; right: 18px; color: #fff; background: rgba(255, 255, 255, .08); }
@media (max-width: 700px) {
    dialog.lightbox { padding: 12px; gap: 6px; }
    .lightbox figure img { max-width: calc(100vw - 110px); }
    .lightbox-nav { width: 40px; height: 40px; }
}

/* ---------- Tom Select theme ---------- */

.ts-wrapper.single .ts-control, .ts-wrapper .ts-control {
    min-height: 38px;
    padding: 7px 34px 7px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    box-shadow: none;
}
.ts-wrapper.single .ts-control { background-image: none; }
.ts-wrapper.focus .ts-control { border-color: var(--accent-bg); box-shadow: 0 0 0 3px var(--accent-soft); }
.ts-control input { color: var(--text) !important; font-size: 14px !important; }
.ts-control input::placeholder { color: var(--faint); }
.ts-wrapper.single .ts-control::after { border-color: var(--muted) transparent transparent; right: 14px; }
.ts-dropdown {
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    margin-top: 4px;
    overflow: hidden;
}
.ts-dropdown .option, .ts-dropdown .no-results, .ts-dropdown .loading-more { padding: 8px 12px; }
.ts-dropdown .active { background: var(--accent-soft); color: var(--text); }
.ts-dropdown .opt-key { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; font-weight: 700; }
.ts-dropdown .opt-sub { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-dropdown .spinner { border-color: var(--accent-bg) transparent; }
.ts-wrapper .clear-button { color: var(--muted); right: 30px !important; opacity: 1; }
.ts-wrapper.plugin-clear_button.single .ts-control { padding-right: 52px !important; }
.ts-item .opt-sub { display: none; }
