/* ===========================================================================
   Payroll Orchestration
   Farben nach Corporate Design SVATG. Klee bleibt Marken- und Aktionsfarbe,
   die Statusfarben sind bewusst davon abgesetzt, damit ein grüner Button
   nicht wie ein Erledigt-Signal wirkt.
   =========================================================================== */

:root {
    --klee:       #2E8D4C;
    --klee-dark:  #25713D;
    --klee-text:  #1F6B3A;
    --nacht:      #1D1861;
    --himmel:     #64A9D4;
    --raps:       #FAD84D;
    --apfel:      #97BA74;
    --see:        #75AFA5;
    --mohn:       #D17875;
    --mohn-text:  #9A3B38;

    --ink:        #16211C;
    --ink-soft:   #566259;
    --ink-muted:  #8A968F;
    --line:       #E4EBE6;
    --line-soft:  #EFF4F0;
    --surface:    #FFFFFF;
    --canvas:     #E9F2EC;
    --tint:       #F4F9F5;

    --r-lg: 16px;
    --r-md: 11px;
    --r-sm: 8px;
    --shadow-card: 0 1px 2px rgba(20,40,28,.04), 0 4px 16px rgba(20,40,28,.05);
    --shadow-pop:  0 4px 12px rgba(20,40,28,.08), 0 12px 32px rgba(20,40,28,.12);

    --font: "Aptos", "Aptos Display", "Segoe UI Variable Text", "Segoe UI",
            system-ui, -apple-system, sans-serif;
    --sidebar-w: 236px;
}

* { box-sizing: border-box; }

/* Symbole wachsen nie über ihre Zeile hinaus. */
svg { flex: none; max-width: 100%; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--surface);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--klee-text); }
h1, h2, h3 { letter-spacing: -.015em; }

/* --- Grundgerüst: Seitenleiste und Inhalt -------------------------------- */

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

.sidebar {
    width: var(--sidebar-w); flex: none; padding: 20px 14px;
    display: flex; flex-direction: column; gap: 22px; position: sticky;
    top: 0; height: 100vh; background: var(--canvas);
    border-right: 1px solid #D8E6DC;
    box-shadow: inset -14px 0 18px -16px rgba(20,50,30,.22);
}

.sidebar__brand { display: flex; flex-direction: column; gap: 9px; padding: 2px 10px 0; }
.sidebar__brand img { height: 27px; width: auto; align-self: flex-start; }
.sidebar__mark {
    width: 30px; height: 30px; border-radius: var(--r-sm); background: var(--klee);
    color: #fff; font-weight: 700; font-size: 12px; font-style: italic;
    display: grid; place-items: center; letter-spacing: -.03em;
}
.sidebar__title { font-size: 13.5px; font-weight: 600; color: var(--ink-soft); letter-spacing: -.01em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
    color: var(--ink-muted); font-weight: 700; padding: 12px 10px 5px;
}
.nav a {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: var(--r-md); text-decoration: none; color: var(--ink-soft);
    font-size: 14px; font-weight: 500; transition: background .12s, color .12s;
}
.nav a:hover { background: rgba(255,255,255,.7); color: var(--ink); }
.nav a[aria-current="page"] {
    background: var(--surface); color: var(--klee-text); font-weight: 600;
    box-shadow: var(--shadow-card);
}
.nav svg { width: 17px; height: 17px; flex: none; stroke-width: 1.7; }

.sidebar__foot { margin-top: auto; }
.userchip {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px;
    border-radius: var(--r-md); background: rgba(255,255,255,.7);
}
.userchip:hover { background: var(--surface); }
.avatar {
    width: 30px; height: 30px; border-radius: 50%; flex: none;
    background: var(--klee); color: #fff; display: grid; place-items: center;
    font-size: 12px; font-weight: 600;
}
.userchip__name { font-size: 13px; font-weight: 600; line-height: 1.25; }
.userchip__role { font-size: 11.5px; color: var(--ink-muted); }

.main { flex: 1; min-width: 0; padding: 20px 34px 64px; background: var(--surface); }
.main__inner { max-width: 1240px; }

/* --- Kopfzeile einer Seite ----------------------------------------------- */

.head { display: flex; align-items: flex-end; justify-content: space-between;
        gap: 20px; flex-wrap: wrap; margin: 10px 0 20px; }
.head h1 { font-size: 27px; font-weight: 600; margin: 3px 0 0; }
.head p  { margin: 6px 0 0; color: var(--ink-soft); font-size: 14.5px; }
.crumb { font-size: 13px; color: var(--ink-muted); }
.crumb a { color: var(--ink-soft); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }

/* --- Karten -------------------------------------------------------------- */

.card {
    background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--line);
    box-shadow: 0 1px 2px rgba(20,40,28,.03); margin-bottom: 16px; overflow: hidden;
}
.card__head {
    padding: 17px 24px; display: flex; align-items: center; gap: 12px;
    justify-content: space-between; border-bottom: 1px solid var(--line-soft);
}
.card__head h2 { font-size: 16px; font-weight: 600; margin: 0; }
.card__body { padding: 22px 24px; }
.card__foot { padding: 16px 24px; border-top: 1px solid var(--line-soft); background: #FBFDFB; }
.muted { color: var(--ink-muted); font-size: 12.5px; }

/* --- Lauf-Kacheln -------------------------------------------------------- */

.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(305px, 1fr)); }

.tile {
    background: var(--surface); border-radius: var(--r-lg); padding: 18px 20px;
    box-shadow: 0 1px 2px rgba(20,40,28,.03); text-decoration: none; color: inherit;
    display: block; border: 1.5px solid var(--line);
    transition: box-shadow .14s, transform .14s, border-color .14s;
}
.tile:hover { box-shadow: var(--shadow-pop); transform: translateY(-2px); }
.tile--active { border-color: var(--klee); }
.tile__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tile__period { font-size: 17px; font-weight: 600; }
.tile__count { margin-top: 3px; font-size: 13px; color: var(--ink-muted); }
.tile__facts { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }

.fact { font-size: 13px; display: flex; align-items: center; gap: 8px; color: var(--ink-soft); }
.fact--alert { color: var(--mohn-text); font-weight: 600; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* --- Phasenband ---------------------------------------------------------- */

.rail { margin-top: 15px; }
.rail__track { display: flex; gap: 3px; }
.rail__seg { height: 6px; flex: 1; border-radius: 3px; background: var(--line); }
.rail__seg--done { background: var(--apfel); }
.rail__seg--current { background: var(--klee); }
.rail__seg--blocked { background: var(--mohn); }
.rail__labels { display: flex; justify-content: space-between; margin-top: 7px;
                font-size: 11.5px; color: var(--ink-muted); }

/* --- Phasen-Umschalter --------------------------------------------------- */

.phasenav {
    display: flex; align-items: center; gap: 14px; background: var(--tint);
    border: 1px solid var(--line); border-radius: var(--r-lg); padding: 13px 16px;
    margin-bottom: 16px;
}
.phasenav__mid { flex: 1; min-width: 0; text-align: center; }
.phasenav__name { font-size: 17px; font-weight: 600; }
.phasenav__meta { font-size: 13px; color: var(--ink-muted); margin-top: 2px; }
.phasenav__pips { display: flex; justify-content: center; gap: 5px; margin-top: 9px; }
.pip { width: 26px; height: 5px; border-radius: 3px; background: var(--line);
       border: 0; padding: 0; cursor: pointer; }
.pip--done { background: var(--apfel); }
.pip--current { background: var(--klee); }
.pip--blocked { background: var(--mohn); }

.iconbtn {
    width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
    background: var(--surface); display: grid; place-items: center; cursor: pointer;
    color: var(--ink-soft); flex: none; text-decoration: none;
}
.iconbtn:hover { background: var(--tint); color: var(--ink); }
.iconbtn[aria-disabled="true"] { opacity: .35; pointer-events: none; }
.iconbtn svg { width: 17px; height: 17px; }

/* --- Aufgabenzeilen ------------------------------------------------------ */

.row {
    display: grid; grid-template-columns: 3px 1fr auto; gap: 0 18px;
    padding: 17px 24px; border-bottom: 1px solid var(--line-soft); align-items: center;
}
.row:hover { background: #FBFDFB; }
.row:last-child { border-bottom: 0; }
.row__marker { align-self: stretch; border-radius: 3px; background: transparent; }
.row--crit .row__marker { background: var(--mohn); }
.row--warn .row__marker { background: var(--raps); }
.row--done { opacity: .58; }
.row--done .row__marker { background: var(--apfel); }
.row__title { font-size: 15.5px; font-weight: 600; line-height: 1.4; }
.row__title a { color: inherit; text-decoration: none; }
.row__title a:hover { color: var(--klee-text); }
.row__sub { margin-top: 5px; font-size: 13px; color: var(--ink-soft);
            display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.row__sub > span:not(:last-child)::after { content: "·"; margin-left: 10px; color: var(--line); }
.row__sub .label { color: var(--ink-muted); }
.row__right { display: flex; align-items: center; gap: 10px; }

/* --- Zeichen und Marken -------------------------------------------------- */

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px;
         font-weight: 600; padding: 4px 10px; border-radius: 999px;
         background: var(--line-soft); color: var(--ink-soft); white-space: nowrap; }
.badge--open     { background: #EDF1EE; color: var(--ink-soft); }
.badge--progress { background: #E3EFF8; color: #1C5C82; }
.badge--waiting  { background: #FDF3D0; color: #785904; }
.badge--done     { background: #E9F1E1; color: #47692F; }
.badge--cancel   { background: #EDF1EE; color: var(--ink-muted); text-decoration: line-through; }
.badge--closed   { background: var(--nacht); color: #fff; }

.chip { font-size: 11.5px; font-weight: 600; letter-spacing: .02em; color: var(--ink-muted);
        border: 1px solid var(--line); padding: 2px 7px; border-radius: 5px; white-space: nowrap; }
.chip--crit  { color: var(--mohn-text); border-color: #ECC7C5; background: #FCF3F2; }
.chip--carry { color: #785904; border-color: #F2E2A6; background: #FEFAEC; }

/* --- Merkpunkte ---------------------------------------------------------- */

.hints { list-style: none; margin: 8px 0 0; padding: 0; display: flex;
         flex-direction: column; gap: 5px; }
.hint { font-size: 13px; padding-left: 17px; position: relative; line-height: 1.45; }
.hint::before { content: ""; position: absolute; left: 0; top: 6px; width: 8px;
                height: 8px; border-radius: 2px; }
.hint--danger { color: var(--mohn-text); font-weight: 600; }
.hint--danger::before { background: var(--mohn); }
.hint--warn { color: #785904; }
.hint--warn::before { background: var(--raps); }
.hint--info { color: var(--ink-soft); }
.hint--info::before { background: var(--himmel); }

.guidance { background: var(--tint); border-left: 3px solid var(--apfel);
            padding: 12px 15px; font-size: 13px; color: var(--ink-soft);
            border-radius: 0 var(--r-sm) var(--r-sm) 0; margin: 0 0 16px; }

.facts-inline { margin-top: 6px; font-size: 13px; color: var(--ink-soft);
                display: flex; flex-wrap: wrap; gap: 3px 14px; }
.facts-inline__label { color: var(--ink-muted); }

/* --- Bedienelemente ------------------------------------------------------ */

.btn {
    font-family: inherit; font-size: 13.5px; font-weight: 500; padding: 8px 15px;
    border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer;
    text-decoration: none; display: inline-flex; align-items: center; gap: 7px;
    line-height: 1.4; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn--primary { background: var(--klee); color: #fff; }
.btn--primary:hover { background: var(--klee-dark); }
.btn--ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { background: var(--tint); }
.btn--quiet { background: transparent; color: var(--ink-soft); }
.btn--quiet:hover { background: var(--tint); color: var(--ink); }
.btn--danger { background: var(--surface); border-color: #ECC7C5; color: var(--mohn-text); }
.btn--danger:hover { background: #FCF3F2; }
.btn--sm { font-size: 12.5px; padding: 6px 11px; }

input[type="text"], input[type="number"], input[type="date"], input[type="search"],
select, textarea {
    font-family: inherit; font-size: 13.5px; padding: 8px 11px; width: 100%;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--klee); box-shadow: 0 0 0 3px rgba(46,141,76,.13);
}
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--klee); outline-offset: 2px; }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft);
               margin-bottom: 5px; }
.field__help { font-size: 11.5px; color: var(--ink-muted); margin-top: 4px; }
.inline { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }

/* --- Dropdown ------------------------------------------------------------ */

.dd { position: relative; display: inline-block; }
.dd__panel {
    position: absolute; right: 0; top: calc(100% + 6px); min-width: 232px;
    background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-pop);
    padding: 6px; z-index: 40; display: none; border: 1px solid var(--line-soft);
}
.dd__panel--left { right: auto; left: 0; }
.dd.is-open .dd__panel { display: block; }
.dd__item {
    display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
    padding: 8px 10px; border: 0; background: none; border-radius: var(--r-sm);
    font-family: inherit; font-size: 13.5px; color: var(--ink); cursor: pointer;
    text-decoration: none;
}
.dd__item:hover { background: var(--tint); }
.dd__item svg { width: 15px; height: 15px; color: var(--ink-muted); }
.dd__sep { height: 1px; background: var(--line-soft); margin: 5px 2px; }
.dd__label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
             color: var(--ink-muted); font-weight: 700; padding: 8px 10px 4px; }

/* --- Tabellen ------------------------------------------------------------ */

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase;
            letter-spacing: .07em; color: var(--ink-muted); font-weight: 700;
            padding: 13px 24px; border-bottom: 1px solid var(--line-soft); }
.table td { padding: 14px 24px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.table tr:last-child td { border-bottom: 0; }
.table a { text-decoration: none; font-weight: 500; }
.table tbody tr:hover { background: var(--tint); }

/* --- Meldungen ----------------------------------------------------------- */

.note { padding: 13px 17px; border-radius: var(--r-md); font-size: 13.5px;
        margin-bottom: 16px; border: 1px solid; }
.note--error { background: #FCF3F2; border-color: #ECC7C5; color: var(--mohn-text); }
.note--ok    { background: #EDF4E8; border-color: #CFE0C0; color: #3F5C2A; }
.note--warn  { background: #FEFAEC; border-color: #F2E2A6; color: #6E5205; }
.note ul { margin: 8px 0 0; padding-left: 18px; }

.empty { padding: 44px 20px; text-align: center; color: var(--ink-soft); }
.empty p { margin: 0 0 14px; }

/* --- Login --------------------------------------------------------------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login__card { background: var(--surface); border-radius: 18px; width: 100%;
               max-width: 360px; box-shadow: var(--shadow-pop); overflow: hidden; }
.login__bar { height: 5px; background: var(--klee); }
.login__body { padding: 36px 34px 34px; text-align: center; }
.login__logo { height: 34px; margin: 0 auto 26px; display: block; }
.login__mark { width: 46px; height: 46px; border-radius: 12px; background: var(--klee);
               color: #fff; font-weight: 700; font-style: italic; font-size: 17px;
               display: grid; place-items: center; margin: 0 auto 26px; }
.login .btn { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }

/* --- Schmale Fenster ----------------------------------------------------- */

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .sidebar { width: auto; height: auto; position: static; flex-direction: row;
               align-items: center; gap: 14px; padding: 12px 14px; overflow-x: auto;
               border-right: 0; border-bottom: 1px solid #D8E6DC; box-shadow: none; }
    .nav { flex-direction: row; }
    .nav__label, .sidebar__title, .userchip__name, .userchip__role { display: none; }
    .sidebar__foot { margin: 0; }
    .main { padding: 14px 16px 48px; }
    .row { grid-template-columns: 3px 1fr; }
    .row__right { grid-column: 2; margin-top: 8px; }
    .rail__labels { display: none; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }


/* --- Einstellungen ------------------------------------------------------- */

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

.idtag {
    font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
    font-size: 12px; font-weight: 600; color: var(--klee-text);
    background: var(--tint); border: 1px solid var(--line); border-radius: 5px;
    padding: 2px 7px; white-space: nowrap;
}

.editrow { padding: 16px 24px; border-bottom: 1px solid var(--line-soft); }
.editrow:last-child { border-bottom: 0; }
.editrow__grid {
    display: grid; gap: 12px; align-items: end;
    grid-template-columns: 2.2fr 1fr 1fr 1fr auto;
}
.editrow__grid--wide { grid-template-columns: 2fr 1fr 1.4fr auto; }
.editrow__grid--narrow { grid-template-columns: 2fr 1fr auto; }
.editrow .field label { font-size: 11px; }
.editrow input, .editrow select { font-size: 13px; padding: 7px 9px; }

.flagline { display: flex; gap: 14px; align-items: center; margin-top: 10px;
            font-size: 12.5px; color: var(--ink-soft); flex-wrap: wrap; }
.flagline label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.flagline input[type="checkbox"] { width: auto; accent-color: var(--klee); }

.hintbox { background: var(--tint); border: 1px solid var(--line); border-radius: var(--r-md);
           padding: 13px 16px; font-size: 13px; color: var(--ink-soft); margin-bottom: 18px; }

@media (max-width: 1000px) {
    .editrow__grid, .editrow__grid--wide, .editrow__grid--narrow { grid-template-columns: 1fr 1fr; }
}

/* --- Aufklappbare Einträge im Einstellungsbereich ------------------------ */

.item { border-bottom: 1px solid var(--line-soft); }
.item:last-of-type { border-bottom: 0; }
.item > summary {
    padding: 15px 24px; cursor: pointer; list-style: none;
    display: flex; align-items: center; gap: 12px;
}
.item > summary::-webkit-details-marker { display: none; }
.item > summary:hover { background: #FBFDFB; }
.item[open] > summary { background: var(--tint); }
.item__caret { width: 16px; height: 16px; color: var(--ink-muted);
               transition: transform .15s; flex: none; }
.item[open] .item__caret { transform: rotate(90deg); }
.item__num {
    width: 26px; height: 26px; border-radius: 7px; background: var(--tint);
    color: var(--ink-muted); font-size: 12px; font-weight: 700; flex: none;
    display: grid; place-items: center;
}
.item[open] .item__num { background: var(--surface); }
.item__title { font-size: 14.5px; font-weight: 600; flex: 1; min-width: 0; }
.item__meta { font-size: 12.5px; color: var(--ink-muted); display: flex;
              gap: 4px 10px; flex-wrap: wrap; align-items: center; margin-top: 3px; }
.item__body { padding: 4px 24px 20px; }

.formgroup { margin-bottom: 18px; }
.formgroup__title {
    font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
    color: var(--ink-muted); font-weight: 700; margin-bottom: 10px;
}
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }

.switchline { display: flex; flex-direction: column; gap: 9px; }
.switchline label { display: flex; gap: 9px; align-items: flex-start; cursor: pointer;
                    font-size: 13.5px; }
.switchline input[type="checkbox"] { width: auto; margin-top: 2px; accent-color: var(--klee); }
.switchline .sub { display: block; font-size: 12px; color: var(--ink-muted); }

.actionbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
             padding-top: 14px; border-top: 1px solid var(--line-soft); }
.actionbar__spacer { flex: 1; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.hint-sm { font-size: 12px; color: var(--ink-muted); }
