/* Holzquadrat: Anthrazit, Sand, Weiss, Gold-Akzent – abgestimmt auf den Kapazitaetsplaner */
* { box-sizing: border-box; }
:root {
    --anthracite: #1f1d1b; --ink: #1f1d1b; --ink-2: #4a443e; --muted: #8a7e78;
    --bg: #f5f2ed; --surface: #ffffff; --sand: #efe8dd; --sand-2: #e6ddcf;
    --line: #e4ddd2; --line-2: #d4c9b9; --gold: #d2a850; --gold-ink: #94722b;
    --ok: #4c7a4f; --ok-bg: #e5eee1; --caution: #9a6a14; --caution-bg: #f6ebd3;
    --conflict: #a6402e; --conflict-bg: #f6e1da;
    --radius: 10px; --shadow: 0 1px 2px rgba(31,29,27,.06), 0 4px 14px rgba(31,29,27,.04);
}
body { margin: 0; font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
       background: var(--bg); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 16px; font-weight: 650; margin: 26px 0 10px; }

.topbar { background: var(--anthracite); color: #fff; padding: 0 28px; display: flex; align-items: stretch; gap: 36px;
          position: sticky; top: 0; z-index: 30; min-height: 68px; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.brand { display: flex; flex-direction: column; justify-content: center; line-height: 1.15; text-decoration: none; }
.brand strong { font-size: 17px; letter-spacing: .22em; font-weight: 700; }
.brand span { color: var(--gold); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.tabs { display: flex; gap: 6px; align-items: stretch; }
.tab { display: flex; align-items: center; padding: 0 24px; color: #cfc7bd; text-decoration: none; font-weight: 600;
       font-size: 16px; border-bottom: 3px solid transparent; border-top: 3px solid transparent; }
.tab:hover { color: #fff; background: rgba(255,255,255,.05); }
.tab.active { color: #fff; border-bottom-color: var(--gold); background: rgba(210,168,80,.10); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 14px; color: #cfc7bd; font-size: 13px; }
.userbox form { margin: 0; }
.link-light { color: #cfc7bd; }
.link-light:hover { color: #fff; }

main { padding: 20px 28px 40px; max-width: 1500px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px;
         box-shadow: var(--shadow); margin-bottom: 18px; }
.panel.narrow, form.narrow { max-width: 760px; }
.panel.login { max-width: 420px; margin: 8vh auto; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.facts { display: flex; gap: 18px; color: var(--ink-2); flex-wrap: wrap; }
.back { margin: 0 0 12px; } .back a { color: var(--muted); text-decoration: none; } .back a:hover { color: var(--ink); }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.muted { color: var(--muted); }
.code { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--gold-ink); background: #f7efdc;
        border-radius: 5px; padding: 2px 6px; }
code { font-size: 12px; background: var(--sand); padding: 1px 5px; border-radius: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent;
       border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--anthracite); color: #fff; } .btn.primary:hover { background: #3a3632; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); } .btn.secondary:hover { background: var(--sand); }
.btn.ghost { background: transparent; color: #cfc7bd; border-color: #4a443e; padding: 6px 12px; }
.btn.ghost:hover { color: #fff; border-color: var(--gold); }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn.big { padding: 12px 20px; font-size: 15px; }

.flash { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; border: 1px solid var(--line); border-left-width: 4px; }
.flash ul { margin: 6px 0 0; padding-left: 18px; }
.flash.ok { background: var(--ok-bg); border-color: #cddcc6; border-left-color: var(--ok); color: #2f5432; }
.flash.error { background: var(--conflict-bg); border-color: #e8c3b8; border-left-color: var(--conflict); color: var(--conflict); }
.flash.warn { background: var(--caution-bg); border-color: #ead7ad; border-left-color: var(--gold); color: var(--caution); }

.badge { display: inline-block; border: 1px solid var(--line); background: var(--bg); border-radius: 20px; padding: 2px 9px;
         font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--ink-2); vertical-align: middle; }
.badge.ok { background: var(--ok-bg); border-color: #cddcc6; color: var(--ok); }
.badge.off { background: var(--sand-2); color: var(--muted); }
.badge.warn { background: var(--conflict-bg); border-color: #e8c3b8; color: var(--conflict); }
.badge.plan { background: #f7efdc; border-color: #ead7ad; color: var(--gold-ink); }

.seg-group { display: inline-flex; background: var(--sand); border-radius: 8px; padding: 3px; gap: 2px; }
.seg-btn { padding: 6px 12px; border-radius: 6px; text-decoration: none; font: inherit; font-size: 13px; font-weight: 600;
           color: var(--muted); background: transparent; border: 0; cursor: pointer; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 4px 0 18px; overflow-x: auto; }
.subtab { padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.subtab:hover { color: var(--ink); }
.subtab.active { color: var(--ink); border-bottom-color: var(--gold); }

.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input[type=search] { min-width: 260px; }
input, select { font: inherit; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
input[readonly] { background: var(--bg); }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; }
label.check input { width: auto; margin-top: 3px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 18px; align-items: end; }
.hours-row, .share-inputs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; align-items: end; }
.share-inputs { grid-template-columns: repeat(4, minmax(0, 120px)) auto; }
.sum { font-size: 14px; color: var(--ink-2); padding-bottom: 8px; }
.sum strong.bad { color: var(--conflict); } .sum strong.good { color: var(--ok); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.cols h2:first-child { margin-top: 0; }
.perm-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.facts-list { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0 0 14px; }
.facts-list dt { color: var(--muted); } .facts-list dd { margin: 0; font-weight: 600; }

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
                font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tbody tr:hover { background: #fbf9f6; }
table.list td a { text-decoration: none; }
table.list .num { text-align: right; white-space: nowrap; }
table.list .center { text-align: center; }
table.list .actions { text-align: right; }
table.list .small { font-size: 12px; }
table.list.compact td { padding: 7px 10px; }
table.list tr.current td { background: #fbf6ea; }
table.list tr.inactive td { color: var(--muted); }
td.share.primary { font-weight: 700; color: var(--gold-ink); }
table.matrix input { width: 18px; height: 18px; }

@media (max-width: 900px) {
    main { padding: 14px 12px 28px; }
    .topbar { padding: 0 12px; gap: 12px; flex-wrap: wrap; }
    .brand span, .userbox .who { display: none; }
    .tab { padding: 0 12px; font-size: 15px; }
    .grid2, .grid3, .cols { grid-template-columns: 1fr; }
    .hours-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .share-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters input[type=search] { min-width: 0; flex: 1; }
}

/* --- V1-Finalisierung: ruhigere Tabellen --- */
table.list td, table.list th { line-height: 1.35; }
table.list td strong { font-weight: 650; }
.panel-head h1 { line-height: 1.2; }
.filters { align-items: center; }
.planer-ok { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
             border-radius: 50%; background: var(--ok-bg); color: var(--ok); font-weight: 700; font-size: 13px; cursor: help; }
.hint.footnote { margin-top: 14px; max-width: 900px; }
table.res-grid td:nth-child(3) { min-width: 180px; }
table.list tr.inactive td strong { color: var(--muted); }

@media (max-width: 700px) {
    .panel { padding: 16px 14px; }
    h1 { font-size: 19px; }
    table.list th, table.list td { padding: 8px 6px; }
    table.list .btn.small { padding: 5px 9px; }
    .filters .seg-group { width: 100%; }
    .filters .seg-btn { flex: 1; }
    .facts-list { grid-template-columns: 1fr; gap: 2px 0; }
    .facts-list dd { margin-bottom: 8px; }
}

/* --- Allgemein (Mitarbeiterseite, kleine Helfer) --- */
.spaced { margin-top: 12px; }
.hidden { display: none !important; }
.perm-group-title { font-size: 14px; margin: 14px 0 6px; }
/* Kopfleiste: Reiter duerfen schrumpfen und scrollen in sich, statt die Seite zu verbreitern */
.topbar .tabs { min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.topbar .userbox { flex: none; }

/* --- Rollen & Berechtigungen (v3): Holzquadrat-Stil --- */
main.page-centered { max-width: 1440px; margin: 0 auto; }
.rights-header { margin-bottom: 18px; }
.rights-header .hint { margin-top: 6px; font-size: 14px; }

/* Rollenauswahl als Reiterkarten */
.role-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.role-tab { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px;
            background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
            text-decoration: none; color: var(--ink-2); transition: border-color .15s, background .15s;
            flex-wrap: wrap; min-width: 0; }
.role-tab:hover { border-color: var(--line-2); background: #fbf9f6; color: var(--ink); }
.role-tab-name { font-size: 16px; font-weight: 650; }
.role-tab-count { font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.role-tab.active { background: var(--anthracite); border-color: var(--anthracite); color: #fff; box-shadow: inset 0 -3px 0 var(--gold); }
.role-tab.active .role-tab-count { color: var(--gold); }

/* Zusammenfassung / Aktionsleiste */
.rights-bar { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap;
              background: var(--sand); border: 1px solid var(--sand-2); border-radius: var(--radius);
              padding: 16px 22px; margin-bottom: 20px; position: sticky; top: 68px; z-index: 5; }
.rights-bar-role { font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.rights-bar-count { font-size: 15px; color: var(--ink-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
.rights-bar-note { font-size: 13px; color: var(--muted); margin-top: 4px; }
.rights-bar-actions { display: flex; align-items: center; gap: 14px; }
.unsaved { font-size: 14px; font-weight: 600; color: var(--caution); display: inline-flex; align-items: center; gap: 7px; }
.unsaved::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }

/* Gruppen als Sektionen */
.perm-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.perm-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.perm-section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
                     padding: 14px 20px; border-bottom: 1px solid var(--line); background: #fbf9f6; }
.perm-toggle { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0;
               font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.perm-toggle::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
                       transform: rotate(45deg); margin: -3px 2px 0 1px; transition: transform .15s; }
.perm-toggle[aria-expanded="false"]::before { transform: rotate(-45deg); margin-top: 0; }
.perm-section-title { font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.perm-section-tools { display: flex; align-items: center; gap: 14px; }
.tool-link { background: none; border: 0; padding: 2px 0; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted);
             cursor: pointer; }
.tool-link:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }
.perm-section-count { font-size: 15px; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums;
                      min-width: 54px; text-align: right; padding-left: 12px; border-left: 1px solid var(--line-2); }
.perm-section.collapsed .perm-section-body { display: none; }
.perm-section.collapsed .perm-section-head { border-bottom-color: transparent; }

/* Eine Zeile je Berechtigung: Text links, Checkbox in gemeinsamer rechter Spalte */
.perm-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 20px;
             padding: 13px 20px; border-top: 1px solid var(--line); cursor: pointer; font-weight: 400; color: var(--ink);
             transition: background .12s; }
.perm-line:first-child { border-top: 0; }
.perm-line:hover { background: #f8f4ec; }
.perm-line-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.perm-name { font-size: 16px; font-weight: 600; line-height: 1.3; }
.perm-desc { font-size: 14px; color: var(--muted); line-height: 1.4; }

/* Checkbox im HQ-Stil (statt Browser-Standard) */
.hq-check { appearance: none; -webkit-appearance: none; width: 22px; height: 22px; margin: 0; flex: none; cursor: pointer;
            border: 1.5px solid var(--line-2); border-radius: 5px; background: #fff; display: grid; place-content: center;
            transition: background .12s, border-color .12s; }
.hq-check::after { content: ""; width: 6px; height: 11px; border-right: 2.5px solid #fff; border-bottom: 2.5px solid #fff;
                   transform: rotate(45deg) scale(0); margin-top: -3px; transition: transform .12s; }
.hq-check:checked { background: var(--anthracite); border-color: var(--anthracite); }
.hq-check:checked::after { transform: rotate(45deg) scale(1); }
.hq-check:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.perm-line:hover .hq-check:not(:checked) { border-color: var(--ink-2); }

/* Weitere Module (ohne Rechte) kompakt */
.future-modules { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-top: 20px; padding: 14px 20px;
                  border: 1px dashed var(--line-2); border-radius: var(--radius); }
.future-title { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.future-list { font-size: 15px; color: var(--ink-2); }
.future-note { font-size: 13px; color: var(--muted); }
.rights-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 20px; }

@media (max-width: 1200px) {
    .perm-sections { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .rights-bar { position: static; }
}
@media (max-width: 700px) {
    .role-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .role-tab { flex-direction: column; align-items: flex-start; gap: 2px; padding: 11px 13px; }
    .role-tab-name { font-size: 15px; overflow-wrap: anywhere; }
    .rights-bar { padding: 14px 16px; }
    .rights-bar-actions { width: 100%; justify-content: space-between; }
    .perm-section-head { padding: 12px 14px; }
    .perm-section-tools { width: 100%; justify-content: space-between; }
    .perm-line { padding: 12px 14px; gap: 14px; }
    .perm-name { font-size: 15px; }
    .perm-desc { font-size: 13.5px; }
}
