/* ── Tokens ── */
:root {
    --bg: #f4f5f8;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --border: #e3e6ec;
    --text: #1f2430;
    --text-muted: #6b7280;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-fg: #ffffff;
    --danger: #dc2626;
    --ok: #16a34a;
    --radius: 9px;
    --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
:root[data-theme="dark"] {
    --bg: #0f1116;
    --surface: #181b22;
    --surface-2: #1f232c;
    --border: #2a2f3a;
    --text: #e6e8ec;
    --text-muted: #9aa1ad;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
#app { height: 100%; }
a { color: inherit; text-decoration: none; }

/* ── Shell ── */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex: 0 0 232px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 14px; }
.brand { font-size: 18px; font-weight: 700; letter-spacing: -.3px; padding: 4px 8px 18px; }
.brand span { color: var(--primary); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 8px; color: var(--text-muted); font-weight: 500; transition: background .12s, color .12s; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary); color: var(--primary-fg); }
.nav-icon { display: inline-flex; width: 18px; height: 18px; }
.nav-icon svg { width: 18px; height: 18px; }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.user-chip { font-size: 13px; font-weight: 600; padding: 2px 6px 6px; display: flex; align-items: center; gap: 6px; }

.main { flex: 1; padding: 26px 30px; max-width: 1100px; }

/* ── Page header ── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.page-title { font-size: 20px; font-weight: 700; letter-spacing: -.3px; }
.page-title small { display: block; font-size: 13px; font-weight: 400; color: var(--text-muted); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; }

/* ── Card ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 18px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 12px; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-row { display: flex; gap: 14px; }
.form-row > .form-group { flex: 1; }
input[type=text], input[type=password], select {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font-family: inherit; font-size: 14px; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
input:disabled { background: var(--surface-2); color: var(--text-muted); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }

.check-list { display: flex; flex-direction: column; gap: 7px; }
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check-inline input { width: auto; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 15px; border: 1px solid transparent; border-radius: 8px; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

/* ── Upload ── */
.upload-area { position: relative; border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 26px; text-align: center; cursor: pointer; transition: border-color .12s, background .12s; }
.upload-area:hover, .upload-area.drag-active { border-color: var(--primary); background: var(--surface-2); }
.upload-area input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-area p { margin: 6px 0 0; color: var(--text-muted); font-size: 13px; }
.upload-progress { margin-top: 10px; }
.progress-item { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 4px 0; }

/* ── Table ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); padding: 12px 14px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.ta-right { text-align: right; white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-ok { background: var(--ok); }
.dot-off { background: var(--text-muted); }

/* ── Badge ── */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }
.badge-admin { background: rgba(79,70,229,.12); border-color: transparent; color: var(--primary); }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,17,22,.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 440px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal-header { padding: 16px 20px; font-size: 16px; font-weight: 700; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 20px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Alert ── */
.alert { padding: 11px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 500; margin-bottom: 14px; }
.alert-error { background: rgba(220,38,38,.1); color: var(--danger); }
.alert-success { background: rgba(22,163,74,.1); color: var(--ok); }
.alert-info { background: var(--surface-2); color: var(--text); }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 30px 28px; width: 100%; max-width: 360px; }
.brand-center { text-align: center; font-size: 22px; padding: 0 0 22px; }

.loading { color: var(--text-muted); padding: 20px; }

/* ── RND-PDFS Liste (kompakt) ── */
.btn-xs { padding: 2px 8px; font-size: 11px; }
.rnd-group { margin-bottom: 10px; }
.rnd-group-head { padding: 6px 12px; font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.rnd-group-head .rnd-count { font-weight: 400; color: var(--text-muted); }
.rnd-tbl td { padding: 5px 12px; vertical-align: middle; }
.rnd-tbl .rnd-name { font-weight: 600; font-size: 13px; }
.rnd-tbl .rnd-meta { font-size: 11px; color: var(--text-muted); }
.rnd-tbl tr.rnd-old { opacity: .5; }
.rnd-tbl tr.rnd-old .rnd-name { font-weight: 500; font-size: 12px; }
.rnd-tbl .rnd-actions { white-space: nowrap; }
.rnd-tbl .rnd-actions a { display: inline-block; }
.rnd-tbl .rnd-actions .rnd-orig { margin-top: 3px; }

/* ── Alias-Tokens für portierte Seitenplan-Styles ── */
:root {
    --accent: var(--primary);
    --accent-ring: rgba(79,70,229,.15);
    --info: #2563eb;
    --success: var(--ok);
    --warning: #d97706;
    --card: var(--surface);
    --input-bg: var(--surface);
    --btn-sec-hover: var(--surface-2);
}
:root[data-theme="dark"] { --accent-ring: rgba(99,102,241,.28); }

.btn-danger      { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: .88; }

.progress-bar-wrap { flex: 1; background: var(--surface-2); border-radius: 4px; height: 5px; overflow: hidden; }
.progress-bar      { height: 100%; background: var(--accent); border-radius: 4px; transition: width .1s; }
.progress-bar.indet { width: 40% !important; transition: none; animation: ff-indet 1.1s ease-in-out infinite; }
@keyframes ff-indet { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state h3 { font-size: 16px; color: var(--text); margin-bottom: 8px; }

/* ── Template/Card-Listen ── */
.tpl-admin-list { display: flex; flex-direction: column; gap: 10px; max-width: 880px; }
.tpl-admin-card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; }
.tpl-admin-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.tpl-admin-name { font-size: 15px; font-weight: 600; color: var(--text); }
.tpl-admin-slug { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.tpl-admin-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* ── Seitenplan-Tabelle ── */
.seitenplan-table { width: 100%; border-collapse: collapse; }
.seitenplan-table th {
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-muted); background: var(--surface-2); padding: 8px 10px; text-align: left;
}
.seitenplan-table td { padding: 5px 10px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
.seitenplan-table tbody tr:last-child td { border-bottom: none; }
.seitenplan-table .sp-row-vor td:first-child { color: var(--text-muted); }
.seitenplan-table td.sp-drag, .seitenplan-table .sp-row td:nth-child(2) { padding-top: 11px; }
.seitenplan-table input.sp-titel,
.seitenplan-table input.sp-kuerzel,
.seitenplan-table textarea.sp-anzeige {
    width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: 5px;
    font-size: 13px; font-family: inherit; background: var(--input-bg); color: var(--text);
}
.seitenplan-table input.sp-kuerzel { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; }
.seitenplan-table textarea.sp-anzeige { resize: vertical; min-height: 32px; line-height: 1.45; display: block; overflow: hidden; }
.seitenplan-table input.sp-titel:focus,
.seitenplan-table input.sp-kuerzel:focus,
.seitenplan-table textarea.sp-anzeige:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }

.sp-sw4c-badge {
    border: none; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 12px;
    padding: 5px 0; width: 52px; border-radius: 20px; text-align: center; color: #fff;
    transition: transform .08s, box-shadow .12s; margin-top: 1px;
}
.sp-sw4c-badge:active { transform: scale(.94); }
.sp-sw4c-badge.is-sw { background: #1f2430; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.sp-sw4c-badge.is-4c { background: linear-gradient(90deg, #06b6d4, #6366f1, #ec4899); }
.sp-vor-badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 700; background: var(--accent-ring); color: var(--accent); }
.seitenplan-table tbody .sp-row.sp-vor-start td { border-top: 4px solid var(--accent); }
.sp-table-wrap { overflow-x: auto; }

.seitenplan-table td.sp-drag { cursor: grab; text-align: center; color: var(--text-muted); font-size: 15px; user-select: none; line-height: 1; }
.seitenplan-table td.sp-drag:active { cursor: grabbing; }
.seitenplan-table .sp-row.sp-drop-target td { box-shadow: inset 0 2px 0 var(--accent); }
.seitenplan-table .sp-row.sp-conflict td { background: rgba(220,38,38,.10); }
.seitenplan-table .sp-row.sp-conflict input.sp-titel { border-color: var(--danger); color: var(--danger); font-weight: 600; }
.sp-tpl-hint { display: block; font-size: 11.5px; color: var(--warning); margin-top: 5px; }

/* ── Seitenpläne Übersicht: Filter + Counts ── */
.sp-filterbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.sp-filterbar label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.sp-filterbar select { width: auto; min-width: 170px; }
.sp-filterbar #sp-year { min-width: 100px; }
.sp-filter-count { font-size: 12px; color: var(--text-muted); }
.sp-count { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; margin-left: 4px; }
.sp-count.sp-4c { background: rgba(37,99,235,.12); color: var(--info); }
.sp-count.sp-sw { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.sp-summary { text-align: right; margin-top: 16px; font-size: 13px; color: var(--text-muted); }

/* ── ePaper Pipeline ── */
.epaper-badge-offen       { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.epaper-badge-freigegeben { background: rgba(22,163,74,.12); color: var(--success); }
.seitenplan-table .sp-row.epaper-assigned td { background: rgba(22,163,74,.10); }
.epaper-file { color: var(--success); font-size: 12.5px; font-weight: 600; }
.epaper-pick-sel { width: 100%; max-width: 360px; border: 1px solid var(--warning); font-size: 12.5px; }
.epaper-release { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding: 14px 18px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.epaper-release label { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; }
.epaper-release label.disabled { color: var(--text-muted); cursor: not-allowed; }
.epaper-release input { width: 17px; height: 17px; cursor: pointer; }
.epaper-release-hint { font-size: 12.5px; color: var(--warning); }

/* ── ET-Kalender (Sonntag gesperrt) ── */
.sp-datewrap { position: relative; }
#sp-et-display { cursor: pointer; }
.sp-cal { position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; width: 260px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 12px 40px rgba(0,0,0,.18); padding: 10px; }
.sp-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sp-cal-title { font-size: 13px; font-weight: 600; text-transform: capitalize; }
.sp-cal-nav { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; width: 26px; height: 26px; cursor: pointer; color: var(--text); font-size: 15px; line-height: 1; }
.sp-cal-nav:hover { background: var(--border); }
.sp-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.sp-cal-dow { font-size: 10.5px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); text-align: center; padding: 4px 0; }
.sp-cal-dow.so { color: var(--danger); opacity: .6; }
.sp-cal-cell { text-align: center; padding: 6px 0; font-size: 12.5px; border-radius: 5px; cursor: pointer; color: var(--text); }
.sp-cal-cell[data-iso]:hover { background: var(--accent-ring); }
.sp-cal-cell.selected { background: var(--accent); color: #fff; font-weight: 600; }
.sp-cal-cell.empty { cursor: default; }
.sp-cal-cell.disabled { color: var(--danger); opacity: .35; cursor: not-allowed; text-decoration: line-through; }

/* ── Seiten-Verwaltung: Wochentag-Sperren ── */
.seite-days { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; }
.seite-day-cb { display: flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; color: var(--text); }
.seite-day-cb input { width: auto; }
.seite-blocked-tags { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.seite-blocked-tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 700; background: rgba(220,38,38,.12); color: var(--danger); }
