/* ------------------------------------------------------------ Farben & Grundwerte */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e2e5ea;
  --line-strong: #cfd4dc;
  --text: #1c2230;
  --muted: #667085;
  --accent: #2f5bd3;
  --accent-soft: #e8eefc;
  --focus: #2f5bd3;

  --ok: #1f8a4c;
  --ok-soft: #e4f4ea;
  --warn: #b7791f;
  --warn-soft: #fcf1dc;
  --bad: #c62f2f;
  --bad-soft: #fbe5e5;

  --grp-billable: #2f5bd3;
  --grp-new_business: #7a4cc2;
  --grp-internal: #0f8a8a;
  --grp-on_hold: #8a94a6;
  --grp-done: #8a94a6;

  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #12151b;
    --surface: #1a1e26;
    --surface-2: #20252f;
    --line: #2c323d;
    --line-strong: #3a4250;
    --text: #e6e9ef;
    --muted: #97a0b0;
    --accent: #7c9cf5;
    --accent-soft: #243258;
    --focus: #7c9cf5;
    --ok: #4cc07f;
    --ok-soft: #173826;
    --warn: #e0a84a;
    --warn-soft: #3a2e17;
    --bad: #f07070;
    --bad-soft: #3d1e1e;
    --grp-billable: #7c9cf5;
    --grp-new_business: #b18cf0;
    --grp-internal: #4cc4c4;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs)/1.45 var(--font);
}
a { color: var(--accent); }
h1, h2 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ------------------------------------------------------------ Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--accent);
  background-image: linear-gradient(#fff, #fff), linear-gradient(#fff, #fff), linear-gradient(#fff, #fff);
  background-size: 12px 2px, 8px 2px, 10px 2px;
  background-position: 5px 6px, 5px 10px, 5px 14px;
  background-repeat: no-repeat;
}
.mainnav { display: flex; gap: 4px; }
.mainnav a {
  padding: 6px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 500;
}
.mainnav a:hover { background: var(--surface-2); color: var(--text); }
.mainnav a.active { background: var(--accent-soft); color: var(--accent); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.userbox form { margin: 0; }
.username { color: var(--muted); }

.main { padding: 20px; max-width: 1600px; margin: 0 auto; }

/* ------------------------------------------------------------ Buttons & Felder */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; font-size: 20px; line-height: 1; }
.btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

input, select, textarea { font: inherit; color: inherit; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
.field input, .search, .inline-field input, .time-field {
  height: 36px; padding: 0 10px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--surface);
}
.inline-field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.time-field { width: 90px; }
.check { display: flex; align-items: center; gap: 8px; }
.stack { display: grid; gap: 14px; }
.stack > .btn-sm { justify-self: start; }
.narrow { max-width: 360px; }
.row-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.alert { padding: 10px 12px; border-radius: 6px; margin: 0 0 14px; }
.alert-error { background: var(--bad-soft); color: var(--bad); }

/* ------------------------------------------------------------ Anmeldung */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; margin: -20px; }
.auth-card {
  width: 100%; max-width: 380px; padding: 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 18px; color: var(--muted); }

/* ------------------------------------------------------------ Werkzeugleiste */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-title { margin: 0; }
.datenav { display: flex; align-items: center; gap: 4px; }
.datepick { position: relative; cursor: pointer; padding: 4px 10px; border-radius: 6px; }
.datepick:hover { background: var(--surface); }
.date-label { font-size: 1.15rem; font-weight: 650; }
.datepick input {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0;
}
.search { width: 200px; }

body.saving .brand-mark { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ------------------------------------------------------------ Auslastung */
.summary {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px;
}
.load-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow);
}
.load-name { font-weight: 600; }
.load-value { margin: 2px 0 8px; color: var(--muted); }
.load-value strong { font-size: 1.35rem; color: var(--text); font-variant-numeric: tabular-nums; }
.load-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.load-bar span { display: block; height: 100%; background: var(--ok); transition: width .25s; }
.load-meta { margin-top: 6px; font-size: 12px; color: var(--muted); }
.load-card.load-full .load-bar span { background: var(--warn); }
.load-card.load-over .load-bar span { background: var(--bad); }
.load-card.load-over .load-value strong { color: var(--bad); }

/* ------------------------------------------------------------ Planungstabelle */
.board-wrap {
  overflow-x: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.board { width: 100%; border-collapse: collapse; min-width: 980px; }
.board th, .board td { border-bottom: 1px solid var(--line); padding: 0; text-align: left; vertical-align: middle; }
.board thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--muted);
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
.board thead th.col-time { text-align: center; }

.col-customer { width: 15%; }
.col-project { width: 18%; }
.col-task { width: 17%; }
.col-prio { width: 92px; }
.col-time { width: 78px; }
.col-comment { width: 18%; }
.col-grp { width: 150px; }

.cell {
  display: block; width: 100%; min-height: 36px; padding: 6px 10px;
  border: 0; border-radius: 0; background: transparent; outline: none;
  text-overflow: ellipsis;
}
.cell:hover { background: var(--surface-2); }
.cell:focus { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--focus); }
.cell::placeholder { color: transparent; }
.cell:focus::placeholder { color: var(--muted); }
select.cell { cursor: pointer; appearance: none; -webkit-appearance: none; }
.cell-grp { color: var(--muted); font-size: 13px; }

.cell-time {
  text-align: center; font-variant-numeric: tabular-nums; border-left: 1px solid var(--line);
}
.cell-time::placeholder { color: var(--line-strong); }
.cell-time.has-value { font-weight: 650; color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.cell-time.invalid { box-shadow: inset 0 0 0 2px var(--bad); background: var(--bad-soft); }

.cell-prio { font-size: 13px; font-weight: 600; }
.prio-hoch { color: var(--bad); }
.prio-mittel { color: var(--warn); }
.prio-niedrig { color: var(--muted); }
.prio-none { color: var(--line-strong); }

.group-row th, .group-row td {
  background: var(--surface-2); border-top: 1px solid var(--line-strong);
  padding: 8px 10px; font-size: 13px;
}
.group-row th { box-shadow: inset 4px 0 0 var(--grp-color, var(--accent)); }
.group-name { font-weight: 700; margin-right: 8px; }
.group-count {
  display: inline-block; min-width: 22px; padding: 0 6px; margin-right: 10px;
  border-radius: 10px; background: var(--line); color: var(--muted); font-size: 12px; text-align: center;
}
.group-sum { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.grp-billable { --grp-color: var(--grp-billable); }
.grp-new_business { --grp-color: var(--grp-new_business); }
.grp-internal { --grp-color: var(--grp-internal); }
.grp-on_hold { --grp-color: var(--grp-on_hold); }
.grp-done { --grp-color: var(--grp-done); }

.empty-row td { padding: 10px; color: var(--muted); font-style: italic; }
.job-row:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }

/* On hold & abgeschlossen optisch zurücknehmen */
.grp-on_hold ~ .job-row, .grp-done ~ .job-row { color: var(--muted); }

/* ------------------------------------------------------------ Meeting-Ansicht */
body.present { --fs: 17px; }
body.present .main { max-width: none; }
body.present .cell { min-height: 44px; }
body.present .col-time { width: 96px; }
body.present .load-value strong { font-size: 1.7rem; }

.present-hint { display: none; color: var(--muted); font-size: 13px; margin-right: 6px; }
body.present .present-hint { display: inline; }
kbd {
  display: inline-block; min-width: 20px; padding: 0 5px; margin: 0 1px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px;
  background: var(--surface); font: 12px/18px var(--font); text-align: center;
}

/* Job, über den gerade gesprochen wird */
body.present .job-row { cursor: pointer; }
body.present .job-row.current td { background: var(--accent-soft); }
body.present .job-row.current td:first-child { box-shadow: inset 5px 0 0 var(--accent); }
body.present .job-row.current .cell { font-weight: 650; color: var(--text); }
body.present .job-row.current .cell-time.has-value { color: var(--accent); }

/* Von Kollegen geänderte Felder leuchten kurz auf */
.cell.flash { animation: flash 2.2s ease-out; }
@keyframes flash {
  0%, 30% { background: var(--warn-soft); box-shadow: inset 0 0 0 2px var(--warn); }
  100% { background: transparent; box-shadow: none; }
}

/* ------------------------------------------------------------ Archiv & Team */
.archive { margin-top: 16px; }
.archive #archive-list { margin-top: 10px; }
.simple-table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.simple-table th, .simple-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.simple-table thead th {
  background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em;
}
.simple-table tfoot th, .simple-table tfoot td { background: var(--surface-2); font-weight: 700; border-bottom: 0; }
.simple-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.simple-table .right { text-align: right; }
.simple-table .strong { font-weight: 700; }
.simple-table tr.inactive td { color: var(--muted); }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); max-width: 900px;
}
.panel .simple-table { border-radius: 6px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }

.badge {
  display: inline-block; padding: 1px 8px; margin-right: 4px; border-radius: 10px;
  font-size: 12px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-admin { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.dialog {
  width: min(440px, calc(100vw - 32px)); padding: 22px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
.dialog::backdrop { background: rgba(16, 24, 40, .45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 8px;
  background: var(--text); color: var(--bg); box-shadow: 0 6px 24px rgba(0, 0, 0, .2);
}
.toast[data-type="error"] { background: var(--bad); color: #fff; }

/* ------------------------------------------------------------ Schmale Bildschirme */
@media (max-width: 720px) {
  .main { padding: 16px; }
  .topbar { gap: 12px; padding: 0 16px; }
  .username { display: none; }
  .mainnav a { padding: 6px 8px; }
  .search { width: 100%; }
  .toolbar-right { width: 100%; }
  .auth { margin: -16px; }
}
