:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #6b7178;
  --line: #e4e2dc;
  --off: #efede8;
  --accent: #1f4e5f;
  --accent-ink: #ffffff;
  --today: #fff4d6;
  --radius: 10px;
  --name-w: 190px;
  --cell: 34px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
button { font: inherit; cursor: pointer; }
code { background: #ecebe6; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 44px 40px; text-align: center; max-width: 380px; }
.login-icon { font-size: 40px; }
.login-card h1 { margin: 10px 0 6px; font-size: 24px; }
.login-card p { color: var(--muted); margin: 0 0 26px; line-height: 1.5; }
.btn-slack { display: inline-flex; gap: 10px; align-items: center; background: #fff; border: 1px solid #ccc; color: #1d1c1d; padding: 11px 20px; border-radius: 8px; text-decoration: none; font-weight: 600; }
.btn-slack:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }

/* Kopfzeile */
.top { display: flex; align-items: center; gap: 16px; padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; font-size: 16px; display: flex; gap: 8px; }
.month-nav { display: flex; align-items: center; gap: 6px; margin: 0 auto; }
.month-nav h1 { font-size: 18px; margin: 0 6px; min-width: 150px; text-align: center; }
.top-right { display: flex; align-items: center; gap: 14px; }
.me { display: flex; align-items: center; gap: 8px; }
.me img { width: 28px; height: 28px; border-radius: 6px; }
.me a { color: var(--muted); font-size: 13px; }

.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); font-size: 18px; line-height: 1; }
.icon-btn:hover, .btn-ghost:hover { background: var(--off); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border: 0; padding: 8px 14px; border-radius: 8px; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: var(--card); border: 1px solid var(--line); padding: 7px 12px; border-radius: 8px; }
.btn-danger { background: none; border: 1px solid #e3b4b4; color: #b42318; padding: 7px 12px; border-radius: 8px; }
.btn-danger:hover { background: #fdf0ef; }
.btn-link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 600; }

/* Heute-Leiste und Legende */
.today-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px 24px 0; }
.today-strip strong { margin-right: 4px; }
.chip { display: inline-flex; align-items: center; gap: 7px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px 4px 9px; }
.chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.chip em { font-style: normal; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 12px 24px; color: var(--muted); font-size: 12.5px; }
.leg { display: inline-flex; align-items: center; gap: 6px; }
.leg i { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }
.half-demo { background: linear-gradient(90deg, var(--muted) 50%, transparent 50%); border: 1px solid #ccc; }
.hol-demo { background: var(--off); border: 1px solid var(--line); }

/* Kalender-Raster */
.grid-wrap { margin: 0 24px; overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.grid { border-collapse: separate; border-spacing: 0; width: 100%; }
.grid th, .grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; }
.grid thead th { font-weight: 500; font-size: 11px; color: var(--muted); padding: 7px 0; text-align: center; min-width: var(--cell); background: var(--card); }
.grid thead th span { display: block; }
.grid thead th b { display: block; font-size: 13.5px; color: var(--ink); font-weight: 600; margin-top: 1px; }
.grid thead th.off b { color: var(--muted); font-weight: 500; }
.grid thead th.today b { background: var(--accent); color: #fff; border-radius: 6px; display: inline-block; min-width: 24px; padding: 1px 0; }
.grid .name-col { position: sticky; left: 0; z-index: 2; background: var(--card); width: var(--name-w); min-width: var(--name-w); text-align: left; padding: 0 12px; border-right: 1px solid var(--line); }
.grid thead .name-col { font-size: 12px; color: var(--muted); font-weight: 600; z-index: 3; }
.grid tbody th.name-col { font-weight: 500; height: 40px; white-space: nowrap; }
.grid tbody th.name-col img, .grid tbody th.name-col .av { width: 24px; height: 24px; border-radius: 6px; vertical-align: middle; margin-right: 9px; background: var(--off); display: inline-block; }
.grid .nm { vertical-align: middle; overflow: hidden; text-overflow: ellipsis; display: inline-block; max-width: calc(var(--name-w) - 60px); }
.grid tr.is-me th.name-col { font-weight: 700; }
.grid td { height: 40px; position: relative; }
.grid tbody td.off { background: var(--off); }
.grid tbody td.today { background: var(--today); }
.grid td.can { cursor: pointer; }
.grid td.can:hover { box-shadow: inset 0 0 0 2px var(--accent); }
.grid tr > :last-child { border-right: 0; }
.grid tbody tr:last-child > * { border-bottom: 0; }

/* Firmenweit freie Tage */
.grid thead th.comp, .grid tbody td.comp { background: repeating-linear-gradient(135deg, #dcebee 0 6px, #f2f7f8 6px 12px); }
.grid thead th.comp b { color: var(--accent); }
.grid thead th.comp.can-del { cursor: pointer; }
.grid thead th.comp.can-del:hover { box-shadow: inset 0 0 0 2px var(--accent); }
.comp-demo { background: repeating-linear-gradient(135deg, #b9d6dc 0 3px, #f2f7f8 3px 6px); border: 1px solid #c9dfe3; }
.company-list { margin: 0; padding: 0 24px 10px; color: var(--accent); font-size: 13px; font-weight: 500; }
.company-list:empty { display: none; }
form .company-only { display: none; }
form.company-mode .company-only { display: flex; }
form.company-mode .no-company, form.company-mode #person-field, form.company-mode #recur-box { display: none !important; }

.bar { position: absolute; inset: 7px 2px; border-radius: 5px; background: var(--c); }
.bar.am { right: 50%; border-radius: 5px 0 0 5px; }
.bar.pm { left: 50%; border-radius: 0 5px 5px 0; }
.bar.multi::after { content: ""; position: absolute; top: -3px; right: -1px; width: 7px; height: 7px; border-radius: 50%; background: var(--ink); border: 2px solid var(--card); }

/* Meine Einträge */
.mine { margin: 24px; max-width: 760px; }
.mine h2 { font-size: 15px; margin: 0 0 10px; }
.mine ul { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.mine li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.mine li:last-child { border-bottom: 0; }
.mine li i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.mine li span { flex: 1; }

/* Dialog */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(480px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--ink); }
dialog::backdrop { background: rgba(20, 24, 28, .4); }
dialog form { padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
dialog h2 { margin: 0; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }
.field .opt { font-weight: 400; color: var(--muted); }
.field input, .field select { font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.type-pick, .seg, .weekdays { display: flex; flex-wrap: wrap; gap: 6px; }
.type-pick input, .seg input, .weekdays input { position: absolute; opacity: 0; pointer-events: none; }
.type-pick span, .seg span, .weekdays span { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-weight: 500; cursor: pointer; user-select: none; }
.type-pick span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 7px; vertical-align: 1px; }
.type-pick input:checked + span { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, white); }
.seg input:checked + span, .weekdays input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.weekdays span { min-width: 40px; text-align: center; padding: 6px 0; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.recur-box { background: var(--bg); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.error { color: #b42318; margin: 0; font-weight: 500; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.spacer { flex: 1; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 50; }

@media (max-width: 700px) {
  :root { --name-w: 120px; --cell: 30px; }
  .top { padding: 10px 14px; }
  .month-nav { order: 3; width: 100%; justify-content: center; }
  .grid-wrap { margin: 0 10px; }
  .today-strip, .legend { padding-left: 14px; padding-right: 14px; }
  .mine { margin: 20px 14px; }
  .grid tbody th.name-col img, .grid tbody th.name-col .av { display: none; }
  .grid .nm { max-width: calc(var(--name-w) - 24px); }
}
