/* Urlaubsplanung – schlichtes, responsives Layout ohne externe Abhängigkeiten. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1d2327;
  --muted: #5b6770;
  --border: #d6dce1;
  --primary: #1f5f8b;
  --primary-hover: #174a6c;
  --danger: #b3261e;
  --danger-hover: #8c1d17;
  --focus: #ffbf47;
  --header: #263238;
  --header-text: #ffffff;
  --success-bg: #e8f5e9;
  --success-border: #2e7d32;
  --error-bg: #fdecea;
  --error-border: #b3261e;
  --warning-bg: #fff8e1;
  --warning-border: #f9a825;
  --info-bg: #e8f1f8;
  --info-border: #1f5f8b;
  /* Status colours from SPEC 2.1 */
  --st-approved: #2e7d32;
  --st-pending: #f9a825;
  --st-cancel-requested: #ef6c00;
  --st-rejected: #9e9e9e;
  --st-cancelled: #e0e0e0;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 1px 4px rgba(0, 0, 0, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

h1 { font-size: 1.6rem; margin: 1.25rem 0 .75rem; line-height: 1.25; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1.05rem; margin: 0 0 .5rem; }

code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; word-break: break-all; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 1rem; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 10; }
.skip-link:focus { left: 1rem; top: .5rem; }

/* ------------------------------------------------------------------ header */

.site-header { background: var(--header); color: var(--header-text); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding-top: .6rem; padding-bottom: .6rem; }
.brand { color: var(--header-text); text-decoration: none; display: flex; flex-direction: column; line-height: 1.2; margin-right: auto; }
.brand:hover { color: var(--header-text); }
.brand-title { font-weight: 700; font-size: 1.15rem; }
.brand-sub { font-size: .8rem; opacity: .85; }

.main-nav ul, .sub-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.main-nav a, .sub-nav a {
  display: inline-block; padding: .4rem .7rem; border-radius: 6px; text-decoration: none;
}
.main-nav a { color: var(--header-text); }
.main-nav a:hover { background: rgba(255, 255, 255, .12); color: var(--header-text); }
.main-nav a[aria-current="page"] { background: rgba(255, 255, 255, .2); font-weight: 600; }

.user-box { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.user-box form { margin: 0; }
.user-name { opacity: .9; }

.sub-nav { background: #eceff1; border-bottom: 1px solid var(--border); }
.sub-nav ul { padding: .35rem 0; align-items: center; }
.sub-nav a { color: var(--text); }
.sub-nav a:hover { background: #dfe4e8; }
.sub-nav a[aria-current="page"] { background: var(--surface); font-weight: 600; box-shadow: var(--shadow); }
.mode-pill { margin-left: auto; padding: .15rem .6rem; border-radius: 999px; background: var(--st-pending); color: #1d1d1d; font-size: .8rem; font-weight: 600; }

main { padding-bottom: 2rem; }
main:focus { outline: none; }

.site-footer { color: var(--muted); font-size: .85rem; padding: 1rem 0 2rem; }

/* ------------------------------------------------------------------ cards and grids */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  margin: 0 0 1rem;
}
.card.narrow { max-width: 440px; margin: 2rem auto; }

.grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid > .card { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hint { display: block; color: var(--muted); font-size: .85rem; }
.nowrap { white-space: nowrap; }
.is-negative { color: var(--danger); font-weight: 600; }
.breadcrumb { margin: 1rem 0 0; font-size: .9rem; color: var(--muted); }

.tag {
  display: inline-block; padding: 0 .45rem; border-radius: 4px; background: #eceff1;
  color: var(--text); font-size: .78rem; font-weight: 600; vertical-align: middle;
}

/* ------------------------------------------------------------------ balance cards */

.balance-list { margin: 0; }
.balance-row { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 1px solid #eef1f3; }
.balance-row:last-child { border-bottom: 0; }
.balance-row dt { color: var(--muted); }
.balance-row dd { margin: 0; text-align: right; }
.balance-row.is-strong dt, .balance-row.is-strong dd { color: var(--text); font-weight: 700; font-size: 1.1rem; }
.balance-card.is-negative { border-color: var(--danger); }
.num { font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; }

/* ------------------------------------------------------------------ status badges (SPEC 2.1 colours) */

.badge {
  display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem;
  font-weight: 600; line-height: 1.5; white-space: nowrap; border: 1px solid transparent;
}
.badge-approved { background: var(--st-approved); color: #ffffff; }
.badge-pending { background: var(--st-pending); color: #1d1d1d; }
.badge-cancel_requested { background: var(--st-cancel-requested); color: #1d1d1d; }
.badge-rejected { background: var(--st-rejected); color: #1d1d1d; }
.badge-cancelled { background: var(--st-cancelled); color: #3a3a3a; border-color: #c4c4c4; text-decoration: line-through; }
/* mail outbox status */
.badge-mail-sent { background: var(--st-approved); color: #ffffff; }
.badge-mail-queued { background: var(--st-pending); color: #1d1d1d; }
.badge-mail-failed { background: var(--danger); color: #ffffff; }
.badge-mail-preview { background: #eceff1; color: #3a3a3a; border-color: #c4c4c4; }

/* ------------------------------------------------------------------ notice + flashes */

.notice-box {
  background: var(--warning-bg); border: 1px solid var(--warning-border); border-left-width: 6px;
  border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem;
}
.notice-box h2 { margin-bottom: .4rem; }
.notice-box p { margin: 0 0 .6rem; }
.notice-box form { margin: 0; }
.notice-box-urgent { border-color: var(--error-border); border-left-width: 8px; }

.flashes { margin: 1rem 0; display: grid; gap: .5rem; }
.flash { padding: .65rem 1rem; border-radius: 6px; border-left: 5px solid; background: var(--info-bg); border-color: var(--info-border); }
.flash-success { background: var(--success-bg); border-color: var(--success-border); }
.flash-error { background: var(--error-bg); border-color: var(--error-border); }
.flash-warning { background: var(--warning-bg); border-color: var(--warning-border); }
.card .flash { margin: .75rem 0; }

.secret-box { border-color: var(--warning-border); background: var(--warning-bg); }
.secret code { font-size: 1.25rem; background: var(--surface); padding: .25rem .6rem; border-radius: 6px; border: 1px solid var(--border); user-select: all; }

.error-card { max-width: 640px; margin: 2rem auto; }
.error-code { color: var(--muted); margin: 0; font-weight: 600; }

/* ------------------------------------------------------------------ forms */

.form-stack { display: grid; gap: .85rem; }
.form-grid { display: grid; gap: .85rem 1rem; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); align-items: start; }
.field-wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label, .label-like { font-weight: 600; font-size: .92rem; }
.field-checks { gap: .2rem; }
.field-checks .check { font-weight: 400; display: flex; align-items: center; gap: .45rem; }
.field-button { justify-content: flex-end; }
.filter-bar { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; margin-bottom: 1rem; }
.filter-bar .field { min-width: 160px; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], select, textarea {
  font: inherit; color: var(--text); background: #ffffff; width: 100%;
  padding: .5rem .6rem; border: 1px solid #9aa5ad; border-radius: 6px; min-height: 2.5rem;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--primary); }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
  padding: .55rem 1rem; min-height: 2.5rem; border-radius: 6px;
  border: 1px solid #9aa5ad; background: #ffffff; color: var(--text);
}
.btn:hover { background: #eef2f5; color: var(--text); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #ffffff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #ffffff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #ffffff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #ffffff; }
.btn-small { padding: .3rem .65rem; min-height: 2rem; font-size: .875rem; }
.btn:disabled, .btn:disabled:hover { opacity: .55; cursor: not-allowed; background: #ffffff; color: var(--text); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--header-text); border-color: rgba(255, 255, 255, .5); }
.btn-ghost:hover { background: rgba(255, 255, 255, .12); color: var(--header-text); }
.button-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0; }
.button-row form { margin: 0; }
.inline-form { display: inline; margin-left: .5rem; }

.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); margin: 1rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

.preview { padding: .6rem .8rem; border-radius: 6px; background: var(--info-bg); border-left: 5px solid var(--info-border); }
.preview.has-errors { background: var(--error-bg); border-color: var(--error-border); }
.preview p { margin: 0; }
.preview ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* ------------------------------------------------------------------ tables */

/* position: relative makes the scroll container the containing block of the absolutely positioned
   .sr-only header texts; otherwise they escape it and widen the whole page on phones. */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 .75rem; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid #e3e8ec; vertical-align: top; }
thead th { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); border-bottom: 2px solid var(--border); }
tbody tr:hover { background: #f8fafb; }
td.actions { white-space: nowrap; }
td.actions form { display: inline; margin: 0; }
td.actions a + a { margin-left: .75rem; }
tr.is-inactive td { color: var(--muted); }
tr.is-current td { background: #f1f8f1; }
.kv-list { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.past summary { cursor: pointer; font-weight: 600; margin: .5rem 0; }
tfoot th, tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; }
tbody th { font-weight: 600; }
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { text-decoration: underline; }
thead th[aria-sort] { color: var(--text); }
tr.is-negative-row th, tr.is-negative-row td { background: #fdf3f2; }
.tag-danger { background: var(--danger); color: #ffffff; }
.error-text { color: var(--danger); overflow-wrap: anywhere; }

/* overview: the name column stays visible while the table scrolls sideways on phones */
table.overview th:first-child, table.overview td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
table.overview tbody tr:hover th:first-child { background: #f8fafb; }
table.overview tr.is-negative-row th:first-child { background: #fdf3f2; }
table.overview td, table.overview th { white-space: nowrap; }
/* A nowrap sticky column takes the width of the longest name and would then cover every number column
   on a phone: cap it and let long (double) names wrap at word boundaries – never in mid-word. */
@media (max-width: 640px) {
  table.overview th:first-child, table.overview td:first-child {
    min-width: 7rem; max-width: 10rem; white-space: normal; overflow-wrap: break-word;
  }
}
table.outbox td:first-child { min-width: 13rem; overflow-wrap: anywhere; }

/* Startsaldo + import: input table and preview (the name column stays visible while scrolling sideways) */
table.entry-table th, table.entry-table td { vertical-align: middle; }
table.entry-table tbody th:first-child, table.entry-table thead th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
table.entry-table tr.is-negative-row th:first-child { background: #fdf3f2; }
table.import-table tbody th:first-child, table.import-table thead th:first-child { position: static; }
input.input-days { min-width: 5.5rem; max-width: 7.5rem; }
input.input-note { min-width: 11rem; }
input[type="file"] { font: inherit; max-width: 100%; }
.status-list { margin: 0; padding-left: 1.1rem; }
.status-list li + li { margin-top: .15rem; }
.summary-counts { list-style: none; margin: .5rem 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1rem; }
.badge-imp-new { background: var(--st-approved); color: #ffffff; }
.badge-imp-changed { background: var(--st-pending); color: #1d1d1d; }
.badge-imp-unchanged { background: #eceff1; color: #3a3a3a; border-color: #c4c4c4; }
.badge-imp-error { background: var(--danger); color: #ffffff; }
/* Import preview: the first column is the line number (narrow), the name/e-mail cell is the second one.
   Long e-mail addresses wrap anywhere instead of widening the name column. */
table.import-table .hint { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  table.entry-table tbody th:first-child, table.entry-table thead th:first-child { min-width: 7rem; max-width: 9rem; overflow-wrap: break-word; }
  /* the 7rem name-column minimum above must not hit the "Zeile" column of the import preview … */
  table.import-table thead th:first-child { min-width: 0; max-width: none; width: 1%; }
  /* … whose name column (2nd) stays visible while scrolling to Status/Änderungen, capped in width */
  table.import-table thead th:nth-child(2), table.import-table tbody th[scope="row"] {
    position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 6rem; max-width: 9rem; overflow-wrap: break-word;
  }
  table.import-table tr.is-negative-row th[scope="row"] { background: #fdf3f2; }
}
table.outbox td:nth-child(2) { min-width: 9rem; overflow-wrap: anywhere; }
table.outbox td:nth-child(3) { min-width: 8rem; }

/* ------------------------------------------------------------------ settings + mail text */

.pref-group { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem 1rem .75rem; margin: 0; min-width: 0; }
.pref-group legend { font-weight: 700; padding: 0 .35rem; }
.pref { padding: .55rem 0; border-bottom: 1px solid #eef1f3; }
.pref:last-child { border-bottom: 0; }
.pref .check { display: flex; align-items: flex-start; gap: .55rem; font-weight: 600; cursor: pointer; }
.pref .check input { margin-top: .2rem; flex: none; }
.pref-info { margin-left: 1.65rem; }
.pref-notice { display: block; margin-top: .25rem; padding: .3rem .6rem; border-left: 4px solid var(--warning-border); background: var(--warning-bg); font-size: .85rem; }
.mail-subject { overflow-wrap: anywhere; }
.mail-body {
  margin: 0; padding: .85rem 1rem; background: #f8fafb; border: 1px solid var(--border); border-radius: 6px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .88rem; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: auto;
}
.mail-body.is-table { white-space: pre; overflow-wrap: normal; }   /* fixed-width table: scroll, never wrap */

/* ------------------------------------------------------------------ admin request cards */

.request-list { display: grid; gap: 1rem; }
.request-card { margin: 0; }
.request-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.request-head h2 { margin: 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .5rem 1rem; margin: 0 0 .75rem; }
.facts > div { min-width: 0; }
.facts .wide { grid-column: 1 / -1; }
.facts dt { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.decision-form { border-top: 1px solid var(--border); padding-top: .75rem; display: grid; gap: .5rem; }
.notes, .checklist { margin: .5rem 0 0; padding-left: 1.3rem; }
.checklist li { margin-bottom: .3rem; }

/* ------------------------------------------------------------------ small screens */

@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .card { padding: .85rem; }
  .header-inner { gap: .4rem 1rem; }
  .user-box { width: 100%; justify-content: space-between; }
  .request-head { flex-direction: column; align-items: flex-start; }
  .mode-pill { margin-left: 0; }
  .pref-group { padding: .35rem .65rem .5rem; }
  .pref-info { margin-left: 0; }
}

@media print {
  .site-header, .site-footer, form, .btn { display: none !important; }
  .card { box-shadow: none; border-color: #999; }
}

/* ------------------------------------------------------------------ absences (SPEC 11) */

.badge-abs-sick { background: #c62828; color: #ffffff; }
.badge-abs-other { background: #6a1b9a; color: #ffffff; }
.badge-abs-team { background: #78909c; color: #ffffff; }
.badge-leave { background: var(--st-approved); color: #ffffff; }
.badge-free { background: #1565c0; color: #ffffff; }
.badge-bday { background: #ad1457; color: #ffffff; }
.half-day { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1rem; }
.half-time { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.half-time input[type="time"] { width: auto; }
.preview.has-warnings { background: var(--warning-bg); border-color: var(--warning-border); }
.preview dl { margin: .3rem 0 0; }
.preview dt { font-weight: 600; }
.preview dd { margin: 0 0 .3rem; }
.warning-list { margin: 0; padding-left: 1.2rem; }
.warning-list li + li { margin-top: .25rem; }
.privacy-note { border-left: 4px solid var(--info-border); background: var(--info-bg); padding: .5rem .75rem; border-radius: 6px; }

/* ------------------------------------------------------------------ companies (SPEC 12) */

.badge-company { background: #e3eaf0; color: #1f3b52; border: 1px solid #b8c7d3; font-variant-numeric: tabular-nums; }
.subtotal td, .subtotal th { background: #f1f4f6; font-weight: 600; }
.group-head th { background: #eceff1; text-align: left; }
.plain-list { list-style: none; padding: 0; margin: 0 0 .75rem; }
.plain-list li + li { margin-top: .2rem; }

/* ------------------------------------------------------------------ monthly report and DATEV (SPEC 11.5, 11.7) */

.pref-group > .check, .form-stack > .check { display: flex; align-items: center; gap: .45rem; font-weight: 400; padding: .15rem 0; }
.pref-group > .check input, .form-stack > .check input { flex: none; }
.pref-group .form-grid { margin-top: .5rem; }
.preview + .preview { margin-top: .5rem; }
#datev h3 { margin-top: 1.25rem; }
