:root {
  --primary: #1a4fb0;
  --primary-dark: #123a86;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1d2733;
  --muted: #667085;
  --line: #dde3ea;
  --pos: #11823b;
  --neg: #c0262d;
  --weekend: #f1f2f4;
  --holiday: #fdeee4;
  --today: #e5f5e9;
  --current: #fff6d6;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main.wrap { flex: 1 0 auto; width: 100%; }
a { color: var(--primary); }
h1 { font-size: 1.55rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.mt { margin-top: 1.6rem; }

/* Kopfzeile */
.topbar { background: linear-gradient(90deg, #06122b 0%, #0d2652 55%, #163a6e 100%); color: #fff; border-bottom: 3px solid #1fa3ec; }
.topbar-inner { display: flex; align-items: center; gap: 1.2rem; min-height: 64px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.05rem; display: flex; align-items: center; gap: .75rem; }
.brand-logo { height: 48px; width: auto; display: block; }
.brand-name { padding-left: .75rem; border-left: 1px solid rgba(255,255,255,.3); white-space: nowrap; }
.mainnav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.mainnav a { color: #dbe7f3; text-decoration: none; padding: .45rem .75rem; border-radius: 6px; }
.mainnav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.mainnav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.logout { display: flex; align-items: center; gap: .6rem; margin: 0; }
.who { color: #dbe7f3; font-size: .9rem; display: inline-flex; align-items: center; gap: .35rem; min-width: 0; }
.who-icon { width: 14px; height: 14px; fill: currentColor; opacity: .8; flex: 0 0 auto; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main.wrap { padding-top: 1.4rem; padding-bottom: 2rem; }
.footer { background: #06122b; color: #c9d6e8; font-size: .82rem; padding: 1rem 0; margin-top: 1rem; }
.footer-inner { display: flex; justify-content: space-between; gap: .4rem 1.5rem; flex-wrap: wrap; }
.footer .muted { color: #8ea3bf; }
.auth-logo { text-align: center; margin: 1.5rem 0 -0.5rem; }
.auth-logo img { max-width: 100%; height: auto; width: 380px; }

/* Karten & Layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1.2rem; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.pager { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.pager strong { font-size: 1.1rem; min-width: 3.5rem; text-align: center; }
.monthpick { margin: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.2rem; align-items: start; }
.cols .card { margin-bottom: 0; }

/* Formulare */
label { display: block; margin-bottom: .9rem; font-weight: 600; font-size: .9rem; }
label small { display: block; font-weight: 400; color: var(--muted); }
label.radio { font-weight: 400; display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
input, select, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=number], input[type=time], input[type=date], select {
  display: block; width: 100%; margin-top: .3rem; padding: .5rem .6rem;
  border: 1px solid #c5ced8; border-radius: 6px; background: #fff; min-height: 38px;
}
input:focus, select:focus { outline: 2px solid #8cb4dc; outline-offset: 0; border-color: var(--primary); }
input[placeholder]:invalid:not(:placeholder-shown):not(:focus) { border-color: var(--neg); }
form.inline label { display: inline-block; }
.in-hm { max-width: 9rem; }

.btn {
  display: inline-block; padding: .55rem 1rem; border-radius: 6px; border: 1px solid #c5ced8;
  background: #fff; color: var(--text); text-decoration: none; cursor: pointer; line-height: 1.2;
}
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-small { padding: .35rem .7rem; font-size: .9rem; }
.btn-ghost { background: transparent; color: inherit; border-color: rgba(127,127,127,.45); }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.45); }
.btn-block { width: 100%; }

.auth { max-width: 420px; margin: 2rem auto; }
.auth h1 { margin-bottom: 1rem; }

fieldset { border: 0; padding: 0; margin: .6rem 0 0; min-width: 0; }
fieldset.is-disabled { opacity: .55; }
.inline-label { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
.inline-label select { width: auto; margin-top: 0; }
.yearpick { margin: 0; }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; background: #e9eef4; color: #3b4a5a; font-size: .8rem; font-weight: 600; }
.badge-own { background: #dcecf9; color: var(--primary); }
.btn-link { background: none; border: 0; color: var(--neg); cursor: pointer; padding: .1rem .4rem; font-size: 1rem; }
.btn-link:hover { background: #fdecec; border-radius: 4px; }
.holidays { margin: 1rem 0; }
.holidays form { margin: 0; }
.rowform { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.rowform label { flex: 1; margin-bottom: 0; min-width: 12rem; }
.holidays { table-layout: fixed; }
.grid.holidays td { white-space: normal; overflow-wrap: anywhere; }
.grid.holidays td:nth-child(1) { width: 4.2rem; white-space: nowrap; font-weight: 600; }
.grid.holidays td:nth-child(2) { width: 2.6rem; white-space: nowrap; color: var(--muted); }
.holidays td:nth-child(4) { width: 2.6rem; }
.addhol { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: .8rem; }
.addhol label { margin-bottom: 0; flex: 1 1 9rem; min-width: 0; }
.addhol .btn { flex: 0 0 auto; }

/* Meldungen */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash-success { background: #e8f6ec; border-color: #b6e0c2; color: #145a2a; }
.flash-error   { background: #fdecec; border-color: #f2c0c2; color: #8d1c21; }
.flash-info    { background: #eaf2fb; border-color: #c2d8f0; color: #1f4e78; }

/* Kennzahlen */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .2rem; }
.stat .label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.stat .value { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--muted); font-size: .8rem; }
.stat-main { border: 2px solid var(--primary); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.2rem; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: .35rem .85rem; font-size: .9rem; }
.chip-link { text-decoration: none; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* Tabellen */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.grid th, .grid td { padding: .45rem .55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
.grid thead th { background: var(--primary); color: #fff; font-weight: 600; font-size: .85rem; vertical-align: bottom; }
.grid thead th small { font-weight: 400; opacity: .85; }
.grid tfoot th { background: #e9eff6; }
.grid .num { text-align: right; }
.grid.compact th, .grid.compact td { padding: .35rem .5rem; }
.grid.compact input { margin-top: 0; }
.weeks tr.empty td { color: var(--muted); }
.weeks tr.current td { background: var(--current); font-weight: 700; }

.entry td { padding: .25rem .35rem; }
.entry input, .entry select { margin-top: 0; min-height: 34px; padding: .3rem .4rem; }
.entry .in-time { width: 4.8rem; text-align: center; }
.entry .in-pause { width: 4.6rem; }
.entry select { width: 7.6rem; }
.entry .in-note { min-width: 12rem; }
.entry .date { font-weight: 600; }
.entry .wd { display: inline-block; width: 1.6rem; font-weight: 400; color: var(--muted); }
.entry .sticky { position: sticky; left: 0; z-index: 1; background: var(--card); }
.entry thead .sticky { background: var(--primary); z-index: 2; }
.entry tr.weekend .sticky { background: var(--weekend); }
.entry tr.holiday .sticky { background: var(--holiday); }
.entry tr.today .sticky { background: var(--today); }
.entry td.invalid input, .entry input.invalid { border-color: var(--neg); background: #fff5f5; }
.entry tr.weekend td { background: var(--weekend); }
.entry tr.holiday td { background: var(--holiday); }
.entry tr.today td { background: var(--today); }
.entry tr.today .date { color: var(--pos); }

.entry tr.dirty td:first-child { box-shadow: inset 3px 0 0 #e0a100; }
.entry tr.weeksum td { background: #eef3f8; font-size: .85rem; font-weight: 600; color: #3b4a5a; border-bottom: 2px solid #c9d6e3; }
.formbar { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; margin-top: 1rem;
  position: sticky; bottom: 0; z-index: 5; background: var(--card); padding: .6rem 0; border-top: 1px solid var(--line); }

.help ul { margin: .6rem 0 0; padding-left: 1.2rem; }
.help summary { cursor: pointer; font-weight: 600; }

/* Kopfzeile auf schmalen Bildschirmen: Zeile 1 = Logo + Abmelden, Zeile 2 = Menü über volle Breite */
@media (max-width: 900px) {
  .topbar-inner { gap: .35rem .75rem; padding-top: .5rem; padding-bottom: .4rem; }
  .brand { order: 1; }
  .logout { order: 2; margin-left: auto; }
  .mainnav {
    order: 3; flex: 0 0 100%; width: 100%;
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    gap: .2rem;
  }
  .mainnav::-webkit-scrollbar { display: none; }
  .mainnav a { flex: 1 1 auto; text-align: center; white-space: nowrap; padding: .5rem .55rem; }
}
@media (max-width: 640px) {
  .logout { gap: .45rem; min-width: 0; flex: 0 1 auto; }
  .who { font-size: .78rem; max-width: 36vw; }
  .logout .btn-small { padding: .3rem .6rem; font-size: .85rem; }
  .mainnav a { font-size: .9rem; padding: .5rem .35rem; }
  .brand-logo { height: 38px; }
  .brand-name { display: none; }
  h1 { font-size: 1.3rem; }
  .stat .value { font-size: 1.5rem; }
}
@media print {
  .topbar, .pager, .formbar, .help, .footer, .chips { display: none !important; }
  body { background: #fff; }
  .card { border: none; padding: 0; }
}

/* Verwaltung (1.3.0) */
.badge-off { background: #fdecec; color: var(--neg); }
.btn-danger { background: var(--neg); border-color: var(--neg); color: #fff; font-weight: 600; }
.btn-danger:hover { background: #9d1d23; border-color: #9d1d23; }
.card.danger { border-color: #f2c0c2; }
.card.danger h2 { color: var(--neg); }
.card.narrow { max-width: 640px; }
.grid.users tr.inactive td { color: var(--muted); background: #fafafa; }
.grid.users td { vertical-align: middle; }
.grid.users .badge { margin-right: .2rem; }

/* Saldo-Filter in der Verwaltung (1.4.0) */
.tablehead { display: flex; justify-content: space-between; align-items: center; gap: .6rem 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tablehead h2 { margin: 0; }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid #c5ced8; border-radius: 8px; overflow: hidden; background: #fff; }
.segmented .seg { padding: .4rem .8rem; text-decoration: none; color: var(--text); font-size: .9rem; border-left: 1px solid #c5ced8; white-space: nowrap; }
.segmented .seg:first-child { border-left: 0; }
.segmented .seg:hover { background: #eef3f8; }
.segmented .seg .count { display: inline-block; min-width: 1.4rem; padding: 0 .35rem; margin-left: .25rem; border-radius: 999px; background: #e9eef4; font-size: .78rem; font-weight: 600; text-align: center; }
.segmented .seg.active { background: var(--primary); color: #fff; font-weight: 600; }
.segmented .seg.active .count { background: rgba(255,255,255,.25); color: #fff; }
.segmented .seg-pos:not(.active) .count { background: #e8f6ec; color: var(--pos); }
.segmented .seg-neg:not(.active) .count { background: #fdecec; color: var(--neg); }
.grid.users th, .grid.users td { padding: .45rem .38rem; font-size: .92rem; }
.grid.users .btn-small { padding: .3rem .55rem; font-size: .85rem; }
@media (max-width: 640px) {
  .tablehead .segmented { display: flex; width: 100%; flex-wrap: nowrap; }
  .segmented .seg { flex: 1 1 0; text-align: center; padding: .45rem .3rem; font-size: .8rem; white-space: normal; }
  .segmented .seg .count { margin-left: .15rem; }
}
.userlink { font-weight: 700; color: var(--text); text-decoration: none; }
.userlink:hover { color: var(--primary); text-decoration: underline; }
.entry input.auto-break { background: #fff8e1; border-color: #e0a100; }
@media (max-width: 400px) {
  .mainnav { gap: .1rem; }
  .mainnav a { font-size: .85rem; padding: .5rem .25rem; }
}
@media (max-width: 350px) {
  .mainnav a { font-size: .78rem; padding: .5rem .2rem; }
  .brand-logo { height: 32px; }
}

/* Hinweis auf seitlich scrollbare Tabellen (1.7.0): halbtransparenter Pfeil im Seitenrand */
.scroll-hint {
  position: fixed; z-index: 20; width: 26px; height: 26px; margin-top: -13px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; padding: 0; cursor: pointer;
  background: rgba(26, 79, 176, .55); color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.scroll-hint.show { opacity: 1; pointer-events: auto; }
.scroll-hint:hover, .scroll-hint:focus-visible { background: rgba(26, 79, 176, .85); outline: none; }
.scroll-hint svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
@media print { .scroll-hint { display: none !important; } }

/* Erste Spalte beim seitlichen Scrollen fixieren (1.7.1) */
.entry tfoot .sticky { background: #e9eff6; z-index: 1; }
.entry tr.weeksum .sticky { background: #eef3f8; }
.entry .sticky { box-shadow: 1px 0 0 var(--line); }
.grid.sticky-first th:first-child,
.grid.sticky-first td:first-child { position: sticky; left: 0; z-index: 1; background: var(--card); box-shadow: 1px 0 0 var(--line); }
.grid.sticky-first thead th:first-child { background: var(--primary); z-index: 2; }
.grid.sticky-first tfoot th:first-child { background: #e9eff6; }
.grid.weeks.sticky-first tr.current td:first-child { background: var(--current); }
.grid.users.sticky-first tr.inactive td:first-child { background: #fafafa; }
.grid.users td:first-child { white-space: normal; min-width: 7.5rem; }
@media (max-width: 640px) {
  .grid.users td:first-child, .grid.users th:first-child { max-width: 9rem; overflow-wrap: anywhere; }
}

/* Verwaltung: Augen-Button und Jahresansicht (1.8.0) */
.grid.users td.actions { white-space: nowrap; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; padding: .3rem .45rem; }
.btn-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.btn-icon:hover { color: var(--primary); }
.view-sub { margin: .25rem 0 0; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.view-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: -.4rem 0 1rem; }
.view-nav { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .8rem 1rem; }
.monthjump { display: flex; flex-wrap: wrap; gap: .15rem .6rem; font-size: .9rem; }
.monthjump a { text-decoration: none; font-weight: 600; }
.monthjump a.muted { font-weight: 400; color: var(--muted); }
.chip-warn { background: #fff4e0; border-color: #f0c674; }
.entry.readonly td { padding: .4rem .55rem; }
.entry.readonly td.note { white-space: normal; min-width: 10rem; }
.entry.readonly tr.warn td:not(.sticky) { background: #fff8e8; }
.warnmark { color: #b26a00; cursor: help; }
.card[id^="m"] { scroll-margin-top: 1rem; }
.badge-sys { background: #1a4fb0; color: #fff; }
.cols.single { grid-template-columns: minmax(0, 680px); }
.footer a { color: #fff; text-decoration: none; }
.footer a:hover { text-decoration: underline; }
