/* ==========================================================================
   Administrace CZ×TW – moderní rozhraní (světlý i tmavý režim podle systému).
   S webem sdílí jen akcentovou červenou; jinak vlastní, klidný „dashboard“ styl.
   ========================================================================== */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --surface-3: #f1f3f5;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #111827;
    --text-2: #374151;
    --muted: #6b7280;
    --accent: #e5484d;
    --accent-hover: #cf3a40;
    --accent-soft: #fdeceb;
    --accent-text: #c1343a;
    --ok: #15803d;
    --ok-soft: #e7f6ec;
    --warn: #b45309;
    --warn-soft: #fef3e2;
    --danger: #dc2626;
    --danger-soft: #fdecec;
    --info-soft: #eef2ff;
    --focus: 0 0 0 3px rgba(229, 72, 77, .22);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 16px 40px rgba(16, 24, 40, .14), 0 3px 8px rgba(16, 24, 40, .06);
    --sidebar-w: 272px;
    --checker: repeating-conic-gradient(#eef0f3 0 25%, #fff 0 50%) 0 0 / 16px 16px;
    color-scheme: light;
}

/* Tmavý režim: ručně (přepínač u názvu → data-theme="dark"), jinak podle systému, pokud uživatel nezvolil světlý. */
:root[data-theme="dark"] {
    --bg: #0e1116;
    --surface: #161b22;
    --surface-2: #1b2129;
    --surface-3: #222a33;
    --border: #2a313c;
    --border-strong: #3a4250;
    --text: #e8edf3;
    --text-2: #c3cad4;
    --muted: #8d96a3;
    --accent: #ff5f65;
    --accent-hover: #ff767b;
    --accent-soft: rgba(255, 95, 101, .13);
    --accent-text: #ff8a8e;
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, .12);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, .12);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .12);
    --info-soft: rgba(129, 140, 248, .12);
    --focus: 0 0 0 3px rgba(255, 95, 101, .3);
    --shadow-sm: none;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55);
    --checker: repeating-conic-gradient(#20262e 0 25%, #1a1f26 0 50%) 0 0 / 16px 16px;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0e1116;
        --surface: #161b22;
        --surface-2: #1b2129;
        --surface-3: #222a33;
        --border: #2a313c;
        --border-strong: #3a4250;
        --text: #e8edf3;
        --text-2: #c3cad4;
        --muted: #8d96a3;
        --accent: #ff5f65;
        --accent-hover: #ff767b;
        --accent-soft: rgba(255, 95, 101, .13);
        --accent-text: #ff8a8e;
        --ok: #4ade80;
        --ok-soft: rgba(74, 222, 128, .12);
        --warn: #fbbf24;
        --warn-soft: rgba(251, 191, 36, .12);
        --danger: #f87171;
        --danger-soft: rgba(248, 113, 113, .12);
        --info-soft: rgba(129, 140, 248, .12);
        --focus: 0 0 0 3px rgba(255, 95, 101, .3);
        --shadow-sm: none;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55);
        --checker: repeating-conic-gradient(#20262e 0 25%, #1a1f26 0 50%) 0 0 / 16px 16px;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.55 'Inter', 'Noto Sans TC', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-feature-settings: 'cv11', 'ss01';
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.015em; color: var(--text); }
p { margin: 0 0 .75em; }
code { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-3); color: var(--text-2); padding: 2px 6px; border-radius: 5px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 22px; height: 22px; }

/* ---------- Kostra ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 4px;
    background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px;
}
.sidebar-head { display: flex; align-items: flex-start; gap: 4px; }
.sidebar-head .brand { flex: 1; min-width: 0; }
.theme-toggle { margin-top: 5px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 4px 16px 6px; text-decoration: none; white-space: nowrap; }
.brand-mark {
    display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 10px;
    background: linear-gradient(145deg, #f0555a, #c9303a); color: #fff;
    font: 700 19px 'Noto Sans TC', sans-serif; box-shadow: 0 4px 12px rgba(229, 72, 77, .35);
}
.brand b { display: block; font-size: 14px; font-weight: 650; letter-spacing: -.01em; }
.brand small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.sidebar nav { display: flex; flex-direction: column; gap: 1px; }
.nav-group { margin: 16px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sidebar nav a {
    display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px;
    color: var(--text-2); text-decoration: none; font-weight: 500;
    transition: background .15s, color .15s;
}
.sidebar nav a .icon { color: var(--muted); transition: color .15s; }
.sidebar nav a:hover { background: var(--surface-3); color: var(--text); }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.sidebar nav a.active .icon { color: var(--accent); }
.nav-count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; }
.sidebar-foot { margin-top: auto; padding-top: 14px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font-weight: 650; font-size: 13px; }
.user-card .who { min-width: 0; flex: 1; }
.user-card .who b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .who small { display: block; color: var(--muted); font-size: 12px; }
.icon-button {
    display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
    border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-button:hover { background: var(--surface-3); color: var(--text); }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px clamp(16px, 3vw, 36px);
    background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 500; min-width: 0; }
.crumbs b { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; }
.content { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px clamp(16px, 3vw, 36px) 96px; }

/* ---------- Hlavička stránky ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .eyebrow { font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.page-head .eyebrow a { text-decoration: none; }
.page-head .eyebrow a:hover { color: var(--text); }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.025em; }
.page-head h1 .period { display: none; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 720px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Tlačítka ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 38px; padding: 8px 14px; border: 1px solid var(--accent); border-radius: 8px;
    background: var(--accent); color: #fff; font: 600 13.5px/1.2 inherit; font-family: inherit;
    text-decoration: none; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:focus-visible { box-shadow: var(--focus); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); border-color: var(--muted); }
.btn.ghost { background: transparent; color: var(--text-2); border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.small { min-height: 30px; padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.icon-only { padding: 0; width: 30px; }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.link-button { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }
.link-button:hover { color: var(--text); }
.inline { display: inline; }

/* ---------- Karty ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 20px; }
.card > h2, .card-head h2 { font-size: 15.5px; font-weight: 650; }
.card > h2 { margin-bottom: 16px; }
.card > h2 .muted { font-weight: 500; font-size: 13px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-sub { margin: -10px 0 16px; color: var(--muted); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); }
.empty .icon { width: 28px; height: 28px; margin: 0 auto 8px; display: block; color: var(--border-strong); }

/* KPI */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
    display: flex; align-items: center; gap: 14px; padding: 16px 18px; text-decoration: none;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
    transition: border-color .15s, transform .15s, box-shadow .15s;
}
.stat:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.stat-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 10px; background: var(--surface-3); color: var(--text-2); }
.stat b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.stat > span:last-child > span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat.alert .stat-icon { background: var(--accent-soft); color: var(--accent); }
.stat.alert b { color: var(--accent-text); }
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; flex: 1; min-width: 50px; }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.progress.partial i { background: var(--warn); }
.progress-cell { display: flex; align-items: center; gap: 10px; }
.progress-cell span { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; min-width: 52px; }

/* ---------- Tabulky ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--surface-2); }
td.actions { white-space: nowrap; text-align: right; }
td.actions > * { vertical-align: middle; }
td.actions form { display: inline; }
.title-cell a { font-weight: 600; text-decoration: none; }
.title-cell a:hover { color: var(--accent-text); }
.title-cell small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.num { font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.sprite { width: 52px; height: 40px; object-fit: contain; }
.thumb { width: 52px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--checker); }
.drag { cursor: grab; color: var(--border-strong); width: 28px; padding-right: 0; }
.drag:hover { color: var(--muted); }
tr.dragging td { background: var(--accent-soft) !important; }

/* ---------- Štítky ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 1.5; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--accent-soft); color: var(--accent-text); }
.badge.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Formuláře ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field .label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.field .hint { font-size: 12.5px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number],
input[type=datetime-local], input[type=search], select, textarea {
    width: 100%; font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
    border: 1px solid var(--border-strong); border-radius: 8px; padding: 9px 12px; min-height: 40px;
    transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
textarea { min-height: 90px; resize: vertical; line-height: 1.55; }
textarea.code { font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.check { display: inline-flex; gap: 10px; align-items: center; font-weight: 500; cursor: pointer; color: var(--text-2); }
.check input { appearance: none; width: 36px; height: 20px; flex: none; margin: 0; border-radius: 99px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; }
.check input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.check input:checked { background: var(--accent); }
.check input:checked::after { transform: translateX(16px); }
.check input:focus-visible { outline: none; box-shadow: var(--focus); }
.field-validation-error, .text-danger { color: var(--danger); font-size: 12.5px; font-weight: 500; }
.validation-summary-errors { background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; color: var(--danger); }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.validation-summary-valid { display: none; }
.input-validation-error { border-color: var(--danger) !important; }
.form-actions {
    position: sticky; bottom: 16px; z-index: 15; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    margin-top: 8px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); box-shadow: var(--shadow-lg);
}
.form-actions .dirty-note { margin-left: auto; color: var(--warn); font-size: 12.5px; font-weight: 600; }
.note { display: flex; gap: 10px; background: var(--info-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 14px; margin-bottom: 18px; color: var(--text-2); font-size: 13px; }

/* Opakovatelné řádky */
.repeater { display: grid; gap: 10px; }
.repeat-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: start; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.repeat-row .row-num { font-weight: 600; color: var(--muted); font-size: 12.5px; padding-top: 11px; font-variant-numeric: tabular-nums; }
.repeat-row .row-fields { display: grid; gap: 8px; min-width: 0; }
.repeat-row .row-fields.two { grid-template-columns: 1fr 1.4fr; }
.repeat-row .row-tools { display: flex; gap: 2px; }

/* Výběr ilustrace */
.sprites { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.sprites > label { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 104px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 10px 8px; cursor: pointer; font-size: 12.5px; font-weight: 500; color: var(--text-2); transition: border-color .15s, box-shadow .15s; }
.sprites > label:hover { border-color: var(--border-strong); }
.sprites input { position: absolute; opacity: 0; pointer-events: none; }
.sprites img { width: 76px; height: 54px; object-fit: contain; }
.sprites > label:has(input:checked) { border-color: var(--accent); box-shadow: var(--focus); color: var(--accent-text); font-weight: 600; }
.sprites > label:has(input:focus-visible) { box-shadow: var(--focus); }
.sprites .custom-tile { text-align: center; }
.sprites .custom-tile .icon { width: 26px; height: 26px; color: var(--muted); }
.sprite-custom { margin-top: 14px; }
.sprite-group { grid-column: 1 / -1; margin-top: 8px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sprite-group:first-child { margin-top: 0; }
.sprites .none-tile { text-align: center; }
.none-mark, .jm-none { display: grid; place-items: center; width: 76px; height: 54px; font-size: 30px; color: var(--muted); }

/* ---------- Výběr obrázku ---------- */
.image-picker { display: grid; gap: 10px; }
.ip-drop {
    position: relative; display: grid; place-items: center; min-height: 150px; overflow: hidden;
    border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--checker); cursor: pointer;
    transition: border-color .15s, background-color .15s;
}
.image-picker.compact .ip-drop { min-height: 110px; max-width: 280px; }
.ip-drop:hover, .ip-drop.over { border-color: var(--accent); }
.ip-drop.over::after { content: ''; position: absolute; inset: 0; background: var(--accent-soft); }
.ip-drop img { display: block; max-width: 100%; max-height: 260px; object-fit: contain; }
.ip-empty { display: grid; justify-items: center; gap: 2px; padding: 18px; text-align: center; background: var(--surface-2); position: absolute; inset: 0; align-content: center; color: var(--muted); font-size: 12.5px; }
.ip-empty b { color: var(--text-2); font-size: 13px; font-weight: 600; }
.ip-empty .icon { width: 26px; height: 26px; margin-bottom: 6px; }
.ip-busy { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 80%, transparent); font-weight: 600; z-index: 2; }
.ip-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ip-path { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ip-error { color: var(--danger); font-size: 12.5px; font-weight: 500; }

/* Dialog knihovny médií */
.media-dialog { width: min(980px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 48px)); padding: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.media-dialog::backdrop { background: rgba(15, 18, 25, .45); backdrop-filter: blur(3px); }
.media-dialog[open] { display: flex; flex-direction: column; }
.md-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.md-head h2 { font-size: 16px; margin-right: auto; }
.md-head input[type=search] { max-width: 240px; min-height: 34px; padding: 6px 10px; }
.md-body { overflow-y: auto; padding: 18px; }
.md-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.md-item { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); cursor: pointer; text-align: left; padding: 0; font: inherit; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
.md-item:hover, .md-item:focus-visible { border-color: var(--accent); box-shadow: var(--focus); transform: translateY(-1px); outline: none; }
.md-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--checker); display: block; }
.md-item span { padding: 7px 9px; font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-drop { margin-bottom: 14px; padding: 16px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); text-align: center; color: var(--muted); font-size: 13px; }
.md-drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }

/* ---------- Knihovna médií (stránka) ---------- */
.dropzone {
    display: grid; justify-items: center; gap: 6px; padding: 34px 20px; margin-bottom: 20px; text-align: center;
    border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface);
    color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .icon { width: 30px; height: 30px; color: var(--accent); }
.dropzone b { color: var(--text); font-size: 15px; }
.upload-list { display: grid; gap: 6px; margin: -8px 0 20px; }
.upload-list div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; }
.media-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.media-toolbar input[type=search] { max-width: 320px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.media-item { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.media-thumb { aspect-ratio: 4 / 3; background: var(--checker); display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-body { padding: 11px 12px; display: grid; gap: 4px; font-size: 12.5px; }
.media-body b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-body .row { display: flex; gap: 4px; margin-top: 6px; }
.upload { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Záložky, přepínač jazyka ---------- */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.tabs button, .tabs a { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 10px 12px; font: 500 13.5px inherit; font-family: inherit; color: var(--muted); cursor: pointer; text-decoration: none; border-radius: 6px 6px 0 0; }
.tabs button:hover, .tabs a:hover { color: var(--text); background: var(--surface-3); }
.tabs button[aria-selected=true], .tabs a.current { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.tabs.pills { border: 0; background: var(--surface-3); padding: 3px; border-radius: 10px; display: inline-flex; }
.tabs.pills a, .tabs.pills button { border: 0; margin: 0; border-radius: 8px; padding: 6px 12px; }
.tabs.pills a.current, .tabs.pills button[aria-selected=true] { background: var(--surface); box-shadow: var(--shadow); }
.lang-picker { display: inline-flex; gap: 3px; flex-wrap: wrap; margin-bottom: 18px; background: var(--surface-3); padding: 3px; border-radius: 10px; }
.lang-picker a { display: flex; gap: 8px; align-items: center; padding: 7px 12px; border-radius: 8px; text-decoration: none; font-weight: 500; color: var(--text-2); }
.lang-picker a:hover { color: var(--text); }
.lang-picker a.current { background: var(--surface); box-shadow: var(--shadow); color: var(--text); font-weight: 600; }
.lang-picker a.current .muted { color: var(--muted); }
.lang-tabs { margin-top: 6px; }

/* Texty webu */
.text-field { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.text-field:first-child { padding-top: 4px; }
.text-field:last-child { border-bottom: 0; padding-bottom: 4px; }
.text-field .meta b { display: block; font-size: 13.5px; font-weight: 600; }
.text-field .meta code { display: inline-block; margin-top: 4px; font-size: 11px; }
.text-field .meta .hint { display: block; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.text-field .changed { display: inline-flex; margin-top: 8px; }
.meta-line { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* ---------- Oznámení ---------- */
.toasts { position: fixed; top: 72px; right: 20px; z-index: 100; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.flash {
    display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
    font-weight: 500; animation: toast-in .25s ease-out;
}
.flash .icon { color: var(--ok); margin-top: 1px; }
.flash.error .icon { color: var(--danger); }
.flash span { flex: 1; }
.flash.hide { animation: toast-out .25s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- Editor (Quill) ---------- */
.rich-wrap { border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); overflow: hidden; }
.rich-wrap:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.rich-wrap .ql-toolbar.ql-snow { border: 0; border-bottom: 1px solid var(--border); background: var(--surface-2); padding: 6px 8px; }
.rich-wrap .ql-container.ql-snow { border: 0; font: 15px/1.65 'Inter', system-ui, sans-serif; }
.rich-wrap .ql-editor { min-height: 220px; max-height: 620px; overflow-y: auto; color: var(--text); }
.rich-wrap .ql-editor.ql-blank::before { color: var(--muted); font-style: normal; }
.rich-wrap .ql-editor img { max-width: 100%; height: auto; border-radius: 6px; }
.rich-wrap .ql-snow .ql-stroke { stroke: var(--text-2); }
.rich-wrap .ql-snow .ql-fill { fill: var(--text-2); }
.rich-wrap .ql-snow .ql-picker { color: var(--text-2); }
.rich-wrap .ql-snow .ql-picker-options { background: var(--surface); border-color: var(--border); }
.rich-wrap .ql-snow.ql-toolbar button:hover .ql-stroke, .rich-wrap .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--accent); }
.rich-wrap .ql-snow.ql-toolbar button:hover .ql-fill, .rich-wrap .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--accent); }
.rich-wrap .ql-snow .ql-tooltip { z-index: 5; border-radius: 8px; box-shadow: var(--shadow-lg); background: var(--surface); color: var(--text); border-color: var(--border); }
.rich-source { margin-top: 6px; }
.rich-source summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }

/* ---------- Přihlášení ---------- */
body.plain { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-art {
    position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 44px;
    background: radial-gradient(ellipse at 20% 20%, #2d3563 0, transparent 55%), radial-gradient(ellipse at 90% 90%, rgba(229, 72, 77, .55) 0, transparent 50%), #121731;
    color: #fff;
}
.auth-art::after { content: '管理'; position: absolute; right: -.08em; bottom: -.25em; font: 700 min(28vw, 360px) 'Noto Sans TC', sans-serif; color: rgba(255, 255, 255, .05); pointer-events: none; }
.auth-art .brand b, .auth-art .brand small { color: #fff; }
.auth-art .brand small { opacity: .7; }
.auth-art h2 { color: #fff; font-size: clamp(26px, 3vw, 38px); font-weight: 700; letter-spacing: -.03em; max-width: 460px; }
.auth-art p { color: rgba(255, 255, 255, .72); max-width: 420px; margin-top: 12px; }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; }
.login { width: min(380px, 100%); }
.login h1 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.login form { display: grid; gap: 16px; margin-top: 24px; }
.login .btn { width: 100%; min-height: 42px; }
.login .note { margin-top: 16px; }

@media (max-width: 1100px) {
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .text-field { grid-template-columns: 1fr; gap: 10px; }
}
@media (max-width: 900px) {
    body.plain { grid-template-columns: 1fr; }
    .auth-art { display: none; }
}
@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 50; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: none; }
    .scrim { position: fixed; inset: 0; z-index: 40; background: rgba(15, 18, 25, .4); }
    .menu-toggle { display: inline-grid; }
    .form-grid { grid-template-columns: 1fr; }
    .repeat-row .row-fields.two { grid-template-columns: 1fr; }
    .topbar .hide-mobile { display: none; }
    .content { padding-top: 20px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Soubory ke stažení, soubory v knihovně */
.attachments.over { border-color: var(--accent); box-shadow: var(--focus); }
.attachments .card-head h2 { display: flex; gap: 8px; align-items: center; }
.file-row .row-fields { gap: 4px; }
.file-row [data-file-meta] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-file { display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--surface-3); color: var(--accent-text); font-size: 18px; letter-spacing: .06em; }
.media-thumb .doc { display: grid; place-items: center; width: 100%; height: 100%; font-size: 22px; color: var(--accent-text); background: var(--surface-3); }

/* Editor publikace: hlavní sloupec + boční panel */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.editor-side { position: sticky; top: 76px; display: grid; gap: 0; }
.editor-side .card { padding: 18px 18px 20px; }
.side-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.side-actions .btn { flex: 1; }
.title-input { font-size: 24px !important; font-weight: 700; letter-spacing: -.02em; border: 0 !important; padding: 4px 0 !important; min-height: 0 !important; box-shadow: none !important; background: transparent !important; }
.perex-input { border: 0 !important; padding: 4px 0 12px !important; min-height: 0 !important; box-shadow: none !important; font-size: 15px; color: var(--text-2); border-bottom: 1px solid var(--border) !important; border-radius: 0 !important; margin-bottom: 14px; background: transparent !important; resize: none; }
.tox-tinymce { border-radius: 10px !important; border-color: var(--border-strong) !important; }
@media (max-width: 1100px) { .editor-layout { grid-template-columns: 1fr; } .editor-side { position: static; } }

/* Publikace – přehled */
.filter-bar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.filter-bar .lang-picker { margin: 0; }
.pub-admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.pub-admin-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s; }
.pub-admin-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.pub-admin-cover { position: relative; aspect-ratio: 16 / 9; display: grid; place-items: center; background: linear-gradient(135deg, #1b2340, #3b2f5e 60%, rgba(229, 72, 77, .5)); color: rgba(255, 255, 255, .7); }
.pub-admin-cover img { width: 100%; height: 100%; object-fit: cover; }
.pub-admin-flag { position: absolute; top: 10px; left: 10px; }
.pub-admin-body { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 16px; flex: 1; }
.pub-admin-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.pub-admin-title { font-weight: 650; font-size: 15.5px; line-height: 1.35; text-decoration: none; }
.pub-admin-title:hover { color: var(--accent-text); }
.pub-admin-body .muted .icon { vertical-align: -3px; }
.pub-admin-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; align-items: center; }

/* Přehled: mapa investiční cesty */
.journey-card .card-head h2 { display: flex; gap: 8px; align-items: center; }
.journey-map { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 14px; counter-reset: step; }
.jm-step { position: relative; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); transition: border-color .15s, box-shadow .15s, transform .15s; }
.jm-step:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.jm-step.is-hidden { opacity: .65; }
.jm-link { display: flex; flex-direction: column; gap: 4px; padding: 12px 12px 10px; text-decoration: none; flex: 1; }
.jm-top { display: flex; justify-content: space-between; align-items: center; }
.jm-num { font-weight: 700; font-size: 12px; color: var(--accent-text); background: var(--accent-soft); padding: 2px 8px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.jm-art { width: 100%; height: 64px; object-fit: contain; margin: 6px 0 4px; }
.jm-label { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.jm-title { font-size: 14px; line-height: 1.3; font-weight: 650; }
.jm-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.jm-stats > span { display: inline-flex; align-items: center; gap: 3px; }
.jm-stats .icon.sm { width: 13px; height: 13px; }
.jm-ok { color: var(--ok); }
.jm-miss { color: var(--warn); }
.jm-add { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 7px; border-top: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--text-2); text-decoration: none; border-radius: 0 0 var(--radius) var(--radius); }
.jm-add:hover { background: var(--accent-soft); color: var(--accent-text); }
.jm-new { border-style: dashed; background: transparent; }
.jm-new .jm-link { align-items: center; justify-content: center; gap: 8px; color: var(--muted); min-height: 190px; }
.jm-new:hover .jm-link { color: var(--accent-text); }
.recent-pubs { display: grid; gap: 4px; }
.recent-pub { display: flex; gap: 12px; align-items: center; padding: 8px; border-radius: 8px; text-decoration: none; }
.recent-pub:hover { background: var(--surface-2); }
.recent-pub img, .recent-pub .rp-ph { width: 64px; height: 44px; border-radius: 6px; object-fit: cover; flex: none; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); }
.recent-pub b { display: block; font-size: 14px; font-weight: 600; }
.recent-pub small { color: var(--muted); font-size: 12px; }
@media (max-width: 860px) { .journey-map { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .jm-art { height: 48px; } }

/* překladatel: zamčené sekce + výběr jazyků u uživatele */
.is-locked { opacity: .6; filter: grayscale(.4); }
.translator-note { border-color: var(--accent, #e5484d); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }
