:root {
    --bg: #181818;
    --surface: #242424;
    --surface-2: #2a2a2a;
    --surface-3: #303030;
    --border: #3a3a3a;
    --border-soft: #323232;
    --text: #f2f2f2;
    --muted: #a5a5a5;
    --sidebar: #232323;
    --sidebar-border: #393939;
    --primary: #c4162a;
    --primary-dark: #9e1020;
    --primary-soft: rgba(196, 22, 42, .16);
    --green: #33b875;
    --amber: #e2a63b;
    --red: #ef6254;
    --blue: #53a8e2;
    --cyan: #59c4cb;
    --purple: #a984dc;
    --shadow: 0 8px 26px rgba(0, 0, 0, .22);
    --radius: 5px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Arial, Helvetica, sans-serif; color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
img { max-width: 100%; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    width: 292px;
    background: var(--sidebar);
    color: #e5e5e5;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    border-right: 1px solid var(--sidebar-border);
}
.brand { min-height: 82px; display: flex; align-items: center; gap: 13px; padding: 14px 22px; border-bottom: 1px solid #303030; }
.brand-logo { width: 48px; height: 48px; border-radius: 8px; object-fit: contain; background: #202020; }
.brand-copy strong { display: block; color: #fff; font-size: 22px; letter-spacing: .6px; line-height: 1; }
.brand-copy span { display: block; color: #9d9d9d; font-size: 12px; margin-top: 6px; }
.nav { padding: 14px 0 18px; flex: 1; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 14px; min-height: 50px; padding: 10px 22px; color: #e0e0e0; font-size: 16px; border-left: 3px solid transparent; }
.nav a:hover { background: #292929; color: #fff; }
.nav a.active { color: #fff; background: #2c2c2c; border-left-color: var(--primary); }
.nav-icon { width: 23px; flex: 0 0 23px; text-align: center; font-size: 19px; color: #f2f2f2; }
.nav-group-title { padding: 22px 22px 7px; color: #777; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.1px; }
.sidebar-footer { padding: 14px 22px; border-top: 1px solid #303030; color: #7e7e7e; font-size: 11px; }

.main-area { margin-left: 292px; width: calc(100% - 292px); min-width: 0; }
.topbar { height: 78px; background: #202020; border-bottom: 1px solid var(--border); display: flex; align-items: center; position: sticky; top: 0; z-index: 20; padding: 0 26px; }
.menu-button { display: none; border: 0; background: transparent; color: #fff; font-size: 22px; cursor: pointer; margin-right: 12px; }
.topbar-title { font-weight: 700; font-size: 15px; color: #d9d9d9; }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: #343434; border: 1px solid #474747; color: #fff; font-weight: 800; }
.user-meta strong, .user-meta span { display: block; line-height: 1.2; }
.user-meta span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.logout { margin-left: 12px; color: var(--muted); font-size: 12px; }
.logout:hover { color: #fff; }
.content { padding: 28px 26px 42px; max-width: 1780px; margin: 0 auto; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-header h1 { margin: 0; font-size: 28px; line-height: 1.2; letter-spacing: -.4px; }
.page-header p { margin: 6px 0 0; color: var(--muted); }
.page-actions { display: flex; align-items: end; gap: 9px; flex-wrap: wrap; }
.year-form { display: flex; align-items: end; gap: 8px; }
.year-form label { margin: 0; font-size: 11px; color: var(--muted); }
.year-form input { width: 96px; min-height: 38px; margin-top: 3px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: visible; }
.card-header { min-height: 58px; padding: 14px 17px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.card-header h2 { margin: 0; font-size: 17px; }
.card-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.card-body { padding: 17px; overflow-x: auto; }
.form-card { max-width: 940px; }

.btn { border: 1px solid transparent; border-radius: 4px; min-height: 38px; padding: 8px 13px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; font-weight: 700; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #303030; color: #eee; border-color: #484848; }
.btn-secondary:hover { background: #393939; }
.btn-danger { background: #4a2427; color: #ffb4b4; border-color: #754047; }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-sm { min-height: 31px; padding: 5px 9px; font-size: 12px; }
.btn-block { width: 100%; }

.alert { padding: 11px 13px; border-radius: 4px; border: 1px solid; margin-bottom: 14px; }
.alert-success { color: #a9ecc8; background: #153c2a; border-color: #286344; }
.alert-danger { color: #ffb8b1; background: #482421; border-color: #7a3e38; }
.alert-warning { color: #f6d98d; background: #483814; border-color: #796128; }
.alert-info { color: #b7ddf5; background: #193448; border-color: #315d78; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-grid.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 17px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: #777; }
.kpi-card.accent::before { background: var(--primary); }
.kpi-card.success::before { background: var(--green); }
.kpi-card.danger::before { background: var(--red); }
.kpi-card.blue::before { background: var(--blue); }
.kpi-card.amber::before { background: var(--amber); }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 7px; }
.kpi-value { font-size: clamp(21px, 2vw, 29px); font-weight: 800; letter-spacing: -.7px; white-space: nowrap; }
.kpi-value.small { font-size: 21px; }
.kpi-note { color: var(--muted); font-size: 11px; margin-top: 5px; }

.source-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin: -4px 0 14px; }
.source-chip, .status-pill, .code-badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 4px 8px; border: 1px solid; }
.source-chip.ok, .status-pill.ok { background: #183b2a; color: #9be4bd; border-color: #2f6047; }
.source-chip.stale, .status-pill.stale { background: #463716; color: #f0d17e; border-color: #6d5828; }
.source-chip.error, .status-pill.error { background: #492522; color: #ffb4ad; border-color: #75413d; }
.status-pill.neutral { background: #303030; color: #bdbdbd; border-color: #494949; }
.code-badge { margin-left: 7px; background: #303030; color: #c8c8c8; border-color: #464646; padding: 2px 7px; }
.data-state { margin: -4px 0 14px; padding: 10px 13px; border: 1px solid var(--border); border-radius: 4px; background: #222; color: #bbb; font-size: 12px; }
.data-state strong { color: #eee; }

.legend { display: flex; gap: 13px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--legend); }
.monthly-chart { height: 330px; display: grid; grid-template-columns: repeat(12, minmax(36px, 1fr)); gap: 7px; align-items: stretch; min-width: 780px; overflow: hidden; }
.month-column { display: grid; grid-template-rows: 38px 1fr 24px; min-width: 0; text-align: center; }
.month-value { font-size: 10px; color: #c5c5c5; align-self: end; padding-bottom: 4px; white-space: nowrap; }
.bar-track { background: repeating-linear-gradient(to top, transparent 0, transparent 24.5%, #343434 25%, transparent 25.5%); display: flex; align-items: end; justify-content: center; border-bottom: 1px solid #4a4a4a; }
.bar-stack { width: min(38px, 74%); min-height: 3px; display: flex; flex-direction: column-reverse; border-radius: 3px 3px 0 0; overflow: hidden; box-shadow: 0 0 0 1px rgba(255, 255, 255, .06); }
.bar-stack span { display: block; min-height: 0; }
.month-label { padding-top: 6px; color: #ddd; font-size: 11px; font-weight: 700; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--border-soft); padding: 10px 12px; text-align: left; vertical-align: middle; }
thead th { background: #2b2b2b; color: #bdbdbd; font-size: 11px; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; }
tbody tr:hover { background: #292929; }
tfoot th, tfoot td { background: #2d2d2d; font-weight: 800; border-top: 2px solid #444; }
table.numeric td:not(:first-child), table.numeric th:not(:first-child) { text-align: right; white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; }
td.actions { display: flex; justify-content: flex-end; align-items: center; gap: 5px; }
td.actions form { display: inline-flex; }
.empty { padding: 28px !important; text-align: center !important; color: var(--muted); }
.muted { color: var(--muted); }
.small-text { font-size: 11px; }
.error-text { color: #ff8e84 !important; }
.success-text { color: #7dddab !important; }

.detail-pop { position: relative; }
.detail-pop summary { color: #8cc9ef; cursor: pointer; font-weight: 700; }
.detail-panel { position: absolute; right: 0; top: 25px; width: min(680px, 80vw); z-index: 10; background: #252525; border: 1px solid #484848; border-radius: 4px; box-shadow: 0 14px 40px rgba(0, 0, 0, .45); padding: 5px; }
.detail-panel table { font-size: 12px; }

.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.demand-chart { padding-top: 8px; }
.demand-row { display: grid; grid-template-columns: 190px 1fr 86px; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.demand-row:last-child { border-bottom: 0; }
.demand-label strong, .demand-label span { display: block; }
.demand-label span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.hbar-group { display: grid; gap: 5px; }
.hbar { height: 22px; background: #333; border-radius: 3px; position: relative; overflow: hidden; }
.hbar span { display: block; height: 100%; min-width: 2px; }
.hbar span.required { background: var(--primary); }
.hbar span.available { background: var(--blue); }
.hbar em { position: absolute; inset: 0 7px 0 auto; display: flex; align-items: center; font-style: normal; font-size: 10px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000; }
.fte { text-align: right; font-weight: 800; color: var(--green); }
.fte.negative { color: var(--red); }
.employee-details > summary { cursor: pointer; list-style: none; }
.employee-details > summary::-webkit-details-marker { display: none; }

.dashboard-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.dashboard-tile { display: grid; grid-template-columns: 54px 1fr auto; gap: 15px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.dashboard-tile:hover { transform: translateY(-2px); border-color: #555; }
.dashboard-tile h2 { margin: 0 0 5px; font-size: 17px; }
.dashboard-tile p { margin: 0; color: var(--muted); }
.dashboard-tile > span { color: #e98995; font-weight: 800; }
.tile-icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 6px; background: var(--primary-soft); color: #ff9aa6; font-size: 22px; font-weight: 800; }

label { display: block; color: #ddd; font-weight: 700; margin-bottom: 14px; }
input, select { width: 100%; border: 1px solid #4c4c4c; background: #202020; color: var(--text); border-radius: 4px; min-height: 40px; padding: 8px 10px; margin-top: 5px; outline: none; }
input:focus, select:focus { border-color: #7b7b7b; box-shadow: 0 0 0 3px rgba(255, 255, 255, .06); }
input[type="file"] { padding: 7px; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.three { grid-template-columns: 1fr 1fr 1.2fr; }
.field-help { display: block; color: var(--muted); font-size: 11px; font-weight: 400; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; margin: 7px 0; font-weight: 600; }
.check input { width: 17px; min-height: 17px; margin: 0; }
.check-stack { padding-top: 23px; }
.form-actions { border-top: 1px solid var(--border); margin: 8px -17px -17px; padding: 14px 17px; display: flex; justify-content: flex-end; gap: 8px; background: #292929; }
.requirements { display: grid; gap: 9px; }
.requirements > div { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; border-bottom: 1px solid var(--border-soft); padding-bottom: 8px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #777; }
.status-dot.ok { background: var(--green); }
.status-dot.error { background: var(--red); }
code { background: #303030; border: 1px solid #464646; border-radius: 3px; padding: 2px 5px; color: #ddd; }
.logo-settings { display: grid; grid-template-columns: 150px 1fr; gap: 20px; align-items: start; }
.logo-preview { width: 128px; height: 128px; object-fit: contain; border: 1px solid #484848; border-radius: 8px; background: #1e1e1e; padding: 6px; }

/* Ranking */
.rank-chart { display: grid; gap: 10px; }
.rank-row { display: grid; grid-template-columns: 34px minmax(180px, 260px) 1fr 80px; gap: 12px; align-items: center; }
.rank-position { font-weight: 800; color: #cfcfcf; text-align: center; }
.rank-person strong, .rank-person span { display: block; }
.rank-person span { color: var(--muted); font-size: 11px; margin-top: 2px; }
.rank-track { height: 24px; background: #333; border-radius: 3px; overflow: hidden; }
.rank-fill { display: block; height: 100%; min-width: 2px; background: linear-gradient(90deg, var(--primary), #dc6674); }
.rank-score { text-align: right; font-weight: 800; }
.rank-medal { font-size: 17px; }

/* Sales */
.sales-timeline { height: 330px; display: grid; grid-template-columns: repeat(12, minmax(42px, 1fr)); gap: 8px; min-width: 820px; }
.sales-month { display: grid; grid-template-rows: 38px 1fr 24px; text-align: center; }
.sales-bars { display: flex; align-items: end; justify-content: center; gap: 4px; border-bottom: 1px solid #4a4a4a; background: repeating-linear-gradient(to top, transparent 0, transparent 24.5%, #343434 25%, transparent 25.5%); }
.sales-bar { width: 15px; min-height: 2px; border-radius: 3px 3px 0 0; }
.sales-bar.plan { background: var(--primary); }
.sales-bar.weighted { background: var(--blue); }
.sales-bar.contribution { background: var(--green); }
.sales-legend { margin: 0 0 12px; font-size: 12px; }
.sales-month-value { font-size: 10px; color: #c5c5c5; align-self: end; padding-bottom: 4px; }
.distribution-list { display: grid; gap: 12px; }
.distribution-row { display: grid; grid-template-columns: 140px 1fr 110px; gap: 12px; align-items: center; }
.distribution-label strong, .distribution-label span { display: block; }
.distribution-label span { color: var(--muted); font-size: 11px; }
.distribution-track { height: 22px; background: #333; border-radius: 3px; overflow: hidden; }
.distribution-fill { height: 100%; min-width: 2px; background: var(--primary); }
.distribution-value { text-align: right; font-weight: 800; }
.status-offen .distribution-fill { background: var(--amber); }
.status-gewonnen .distribution-fill { background: var(--green); }
.status-verloren .distribution-fill { background: var(--red); }

/* Organization chart */
.branch-org { margin-bottom: 22px; }
.branch-org:last-child { margin-bottom: 0; }
.org-tree, .org-tree ul { list-style: none; margin: 0; padding: 0; }
.org-tree > li { padding-left: 0; }
.org-tree ul { margin-left: 27px; padding-left: 22px; border-left: 1px solid #555; }
.org-tree li { position: relative; padding: 8px 0; }
.org-tree ul > li::before { content: ''; position: absolute; left: -22px; top: 31px; width: 20px; border-top: 1px solid #555; }
.org-node { display: inline-grid; grid-template-columns: 42px minmax(190px, 1fr); gap: 10px; align-items: center; min-width: 320px; max-width: 560px; padding: 10px 12px; background: #2b2b2b; border: 1px solid #484848; border-radius: 5px; }
.org-avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: #ffabb5; font-weight: 800; }
.org-node strong, .org-node span { display: block; }
.org-node span { color: var(--muted); font-size: 11px; margin-top: 2px; }
.org-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; color: #bbb; font-size: 10px; }
.stage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.stage-card { background: #292929; border: 1px solid #414141; border-radius: 4px; padding: 11px; }
.stage-card strong, .stage-card span { display: block; }
.stage-card span { color: var(--muted); font-size: 11px; margin-top: 3px; }

.auth-page, .setup-page { min-height: 100vh; background: radial-gradient(circle at 18% 14%, #3a3a3a 0, #222 38%, #121212 100%); padding: 32px 16px; }
.auth-page { display: grid; place-items: center; }
.auth-card { width: min(440px, 100%); background: #242424; border: 1px solid #404040; border-radius: 8px; box-shadow: 0 22px 70px rgba(0, 0, 0, .48); padding: 29px; }
.auth-card h1 { margin: 18px 0 2px; font-size: 24px; }
.auth-brand { padding: 0 0 18px; border-bottom: 1px solid var(--border); }
.auth-foot { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 18px; color: var(--muted); text-align: center; font-size: 11px; }
.setup-wrap { width: min(1120px, 100%); margin: 0 auto; }
.setup-header { color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-bottom: 24px; }
.setup-header .brand { padding-left: 0; min-width: 250px; border: 0; }
.setup-header h1 { margin: 0; }
.setup-header p { color: #c5c5c5; margin: 5px 0 0; }
.setup-grid { display: grid; grid-template-columns: .8fr 1.2fr; gap: 20px; align-items: start; }

/* Browser PDF report */
.report-page { background: #e8eaed; color: #161616; padding: 18px; min-height: 100vh; font-size: 10.5pt; }
.report-sheet { width: min(1500px, 100%); margin: 0 auto; background: #fff; box-shadow: 0 10px 35px rgba(0, 0, 0, .18); padding: 12mm; }
.print-toolbar { width: min(1500px, 100%); margin: 0 auto 12px; display: flex; gap: 8px; }
.report-header { display: grid; grid-template-columns: 68px 1fr auto; align-items: center; gap: 14px; border-bottom: 3px solid #c4162a; padding-bottom: 10px; margin-bottom: 14px; }
.report-logo { width: 62px; height: 62px; object-fit: contain; border-radius: 7px; }
.report-header strong, .report-header span { display: block; }
.report-header strong { font-size: 19pt; }
.report-header span { font-size: 12pt; margin-top: 3px; color: #555; }
.report-meta { text-align: right; color: #555; font-size: 9pt; }
.report-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 15px; }
.report-kpis.six { grid-template-columns: repeat(6, 1fr); }
.report-kpis > div { border: 1px solid #bbb; border-left: 4px solid #c4162a; padding: 8px; background: #fafafa; }
.report-kpis span, .report-kpis strong { display: block; }
.report-kpis span { font-size: 8.5pt; color: #555; }
.report-kpis strong { font-size: 13pt; margin-top: 4px; }
.report-section { margin-top: 15px; break-inside: avoid; }
.report-section h2 { font-size: 12pt; margin: 0 0 7px; padding-bottom: 4px; border-bottom: 1px solid #aaa; }
.report-table { font-size: 8.3pt; border: 1px solid #aaa; }
.report-table th, .report-table td { border: 1px solid #bbb; padding: 5px; color: #111; }
.report-table thead th { background: #e9ebee; color: #111; }
.report-table tfoot th, .report-table tfoot td { background: #e3e5e8; color: #111; }
.report-chart { height: 240px; display: grid; grid-template-columns: repeat(12, 1fr); gap: 5px; align-items: stretch; border: 1px solid #bbb; padding: 8px 7px 5px; }
.report-chart .month-column { grid-template-rows: 30px 1fr 20px; }
.report-chart .bar-track { background: repeating-linear-gradient(to top, transparent 0, transparent 24.5%, #e2e2e2 25%, transparent 25.5%); border-bottom-color: #888; }
.report-chart .month-value, .report-chart .month-label { color: #222; }
.report-rank-chart { display: grid; gap: 6px; border: 1px solid #bbb; padding: 8px; }
.report-rank-chart .rank-track { background: #e4e4e4; }
.report-rank-chart .rank-person span { color: #555; }
.report-rank-chart .rank-fill { background: #c4162a; }
.report-sales-chart { height: 240px; display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; border: 1px solid #bbb; padding: 8px 7px 5px; }
.report-sales-chart .sales-bars { background: repeating-linear-gradient(to top, transparent 0, transparent 24.5%, #e2e2e2 25%, transparent 25.5%); border-bottom-color: #888; }
.report-sales-chart .sales-month-value, .report-sales-chart .month-label { color: #222; }
.report-legend { color: #222; margin-bottom: 6px; }
.report-legend i { border: 1px solid rgba(0, 0, 0, .2); }
.report-org .org-node { background: #fafafa; color: #111; border-color: #999; }
.report-org .org-node span, .report-org .org-meta { color: #555; }
.report-org .org-tree ul { border-left-color: #999; }
.report-org .org-tree ul > li::before { border-top-color: #999; }
.report-footer { margin-top: 14px; border-top: 1px solid #aaa; padding-top: 5px; color: #666; font-size: 8pt; display: flex; justify-content: space-between; }

@media print {
    @page { size: A4 landscape; margin: 8mm; }
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    .print-toolbar { display: none !important; }
    .report-page { background: #fff; padding: 0; }
    .report-sheet { width: 100%; box-shadow: none; padding: 0; }
    .report-table { page-break-inside: auto; }
    .report-table tr { page-break-inside: avoid; page-break-after: auto; }
    .report-section { break-inside: avoid; }
}

@media (max-width: 1300px) {
    .kpi-grid.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1120px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-links { grid-template-columns: 1fr; }
    .grid-two, .grid-three { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; width: 100%; }
    .menu-button { display: block; }
    .topbar-title { display: none; }
    .content { padding: 18px 15px; }
    .page-header { align-items: flex-start; flex-direction: column; }
    .setup-grid { grid-template-columns: 1fr; }
    .setup-header { align-items: flex-start; flex-direction: column; }
    .demand-row { grid-template-columns: 125px 1fr 68px; }
    .rank-row { grid-template-columns: 30px minmax(140px, 200px) 1fr 65px; }
}
@media (max-width: 650px) {
    .kpi-grid, .kpi-grid.six { grid-template-columns: 1fr; }
    .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
    .page-actions, .year-form { width: 100%; }
    .year-form { align-items: end; }
    .dashboard-tile { grid-template-columns: 46px 1fr; }
    .dashboard-tile > span { grid-column: 2; }
    .user-meta { display: none; }
    .logout { margin-left: 0; }
    .demand-row, .rank-row, .distribution-row { grid-template-columns: 1fr; }
    .fte, .rank-score, .distribution-value { text-align: left; }
    .logo-settings { grid-template-columns: 1fr; }
}

/* Gesamt- und Niederlassungsstruktur */
.dashboard-scope { margin-bottom: 28px; }
.scope-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 4px 0 14px; padding: 10px 13px; background: #202020; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); }
.scope-heading h2 { margin: 0; font-size: 19px; }
.scope-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.branch-dashboard { margin: 0 0 28px; padding-top: 2px; }
.branch-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 13px; padding: 12px 15px; background: #282828; border: 1px solid #444; border-left: 4px solid #777; border-radius: var(--radius); }
.branch-header h3 { margin: 0; font-size: 18px; }
.branch-header p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.branch-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.branch-error { padding: 18px; border: 1px solid #75413d; background: #492522; color: #ffb4ad; border-radius: var(--radius); }
.branch-dashboard .kpi-grid { margin-bottom: 14px; }
.branch-dashboard .monthly-chart, .branch-dashboard .sales-timeline { height: 275px; }
.branch-dashboard .card { box-shadow: none; }
.branch-table-title { font-weight: 800; margin: 10px 0 8px; }

.report-scope-title { margin: 4px 0 10px; padding: 7px 9px; border-left: 4px solid #c4162a; background: #f0f1f3; font-size: 13pt; font-weight: 800; }
.report-branch { margin-top: 18px; padding-top: 2px; }
.report-branch-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 9px; margin-bottom: 9px; background: #eceef1; border: 1px solid #aaa; border-left: 4px solid #666; }
.report-branch-header strong { font-size: 12pt; }
.report-branch-header span { color: #555; font-size: 8.5pt; }
.report-error { border: 1px solid #ad544c; background: #f8dcd9; color: #7d241d; padding: 9px; }
.report-branch .report-kpis { margin-bottom: 10px; }
.report-branch .report-chart, .report-branch .report-sales-chart { height: 205px; }
.report-branch .demand-chart { border: 1px solid #bbb; padding: 8px; }

@media print {
    .report-branch { break-before: page; page-break-before: always; }
    .report-branch:first-of-type { break-before: auto; page-break-before: auto; }
    .report-branch-header { break-after: avoid; page-break-after: avoid; }
}

/* Security hardening 0.3.0 */
.auth-card-wide { width: min(620px, 100%); }
.security-code-input { text-align: center; letter-spacing: .22em; font-size: 24px; font-weight: 800; }
.security-steps { margin: 18px 0; padding-left: 22px; color: #ddd; }
.security-steps li { margin: 8px 0; }
.secret-box { display: grid; grid-template-columns: 110px 1fr; gap: 9px 12px; padding: 15px; margin: 16px 0; border: 1px solid #494949; border-radius: 5px; background: #1d1d1d; }
.secret-box > span { color: var(--muted); font-size: 12px; }
.secret-box code { overflow-wrap: anywhere; letter-spacing: .08em; }
.secret-box details { grid-column: 1 / -1; }
.secret-box summary { cursor: pointer; color: #9bcce8; }
.uri-code { display: block; margin-top: 9px; white-space: normal; overflow-wrap: anywhere; }
.recovery-code-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 18px 0; }
.recovery-code-grid code { display: block; padding: 9px 11px; text-align: center; font-size: 16px; letter-spacing: .08em; }
.recovery-confirm { margin: 18px 0; align-items: flex-start; }
.technical-error { margin-top: 14px; border: 1px solid #555; border-radius: 4px; background: #1d1d1d; }
.technical-error summary { cursor: pointer; padding: 10px 12px; color: #b7ddf5; font-weight: 700; }
.technical-error pre { margin: 0; padding: 12px; border-top: 1px solid #444; color: #ddd; white-space: pre-wrap; overflow-wrap: anywhere; }
.danger-zone { margin-top: 18px; border-color: #754047; }

@media (max-width: 650px) {
    .recovery-code-grid { grid-template-columns: 1fr; }
    .secret-box { grid-template-columns: 1fr; }
}
.logout-form { margin: 0 0 0 12px; }
.logout { appearance: none; border: 0; background: transparent; padding: 0; cursor: pointer; color: var(--muted); font-size: 12px; }
.logout:hover { color: #fff; }
