/* Mayinger Zeitbuch · Design C „Weich & nativ“ – mobil zuerst */
:root {
  color-scheme: light;
  --ink: #1a1a18;
  --muted: #74756b;
  --paper: #efeee9;
  --surface: #ffffff;
  --soft: #f3f2ec;
  --line: #e6e5de;
  --accent: #fdc800;
  --accent-deep: #f2b800;
  --danger: #a3311f;
  --radius: 22px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  --tabbar: calc(64px + env(safe-area-inset-bottom));
  font: 16px/1.45 var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { margin: 0; font-family: var(--sans); }
h1 { font: 700 34px/1.1 var(--sans); letter-spacing: -.025em; }
h2 { font: 700 20px/1.2 var(--sans); letter-spacing: -.01em; }
h3 { font: 600 16px/1.3 var(--sans); }
p { margin: .5rem 0 0; }
small, .meta { font-size: .82rem; color: var(--muted); }
strong, .total { font-variant-numeric: tabular-nums; }
svg.i {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Kopfzeile ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: #efeee9e6;
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
}
.header-content {
  display: flex; align-items: center; gap: 10px;
  max-width: 640px; min-height: 54px; margin: auto; padding: 6px 16px;
}
.site-header img { width: 84px; height: auto; }
.site-name {
  font-size: .78rem; font-weight: 600; color: var(--muted);
  padding-inline-start: 10px; border-inline-start: 1px solid #d4d3ca;
}
.site-header button {
  margin-inline-start: auto; min-height: 36px; padding: 6px 14px;
  border-radius: 999px; background: var(--surface); border: 0; font-size: .82rem;
}
.site-header #account:not([hidden]) + #logout { margin-inline-start: 0; }

main {
  max-width: 640px; margin: auto;
  padding: 4px 16px calc(var(--tabbar) + 40px);
}
main:has(.submit-bar) { padding-bottom: calc(var(--tabbar) + 130px); }

/* ---------- Grundelemente ---------- */
button, input, select {
  min-height: 46px; max-width: 100%;
  border: 0; border-radius: 14px;
  padding: 10px 14px;
  background: var(--surface); color: var(--ink);
  font: inherit;
}
input, select { background: var(--soft); }
button { cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button:disabled, button[aria-disabled="true"] { opacity: .45; cursor: default; }
button:not(:disabled):active { transform: scale(.98); }
:focus-visible { outline: 3px solid #b08a00; outline-offset: 2px; }
.quiet { background: transparent; }
.primary { background: var(--ink); color: #fff; }
.accent { background: var(--accent); color: var(--ink); }
.danger { background: #fbeae6; color: var(--danger); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions button { flex: 1 1 auto; }

.panel, .card, .notice {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 14px;
}
.gh {
  font: 600 13px/1 var(--sans); letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); margin: 24px 6px 9px;
}

/* ---------- Seitenkopf ---------- */
.page-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 12px; margin: 10px 4px 16px; }
.page-head > .sub { grid-column: 1 / -1; }
.page-head h1 { overflow-wrap: anywhere; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.date-tools { display: flex; align-items: center; gap: 4px; background: #e2e1da; border-radius: 14px; padding: 3px; flex: none; }
.date-tools button { width: 36px; min-height: 36px; padding: 0; border-radius: 11px; background: transparent; }
.date-tools input {
  width: 122px; min-height: 36px; padding: 4px 6px; border-radius: 11px;
  background: var(--surface); font-size: .85rem; font-weight: 600; text-align: center;
}

/* ---------- Live-Karte ---------- */
.live {
  position: relative; border-radius: 28px; padding: 20px;
  background: var(--surface); margin-bottom: 12px;
}
.live.is-running {
  background: linear-gradient(150deg, #ffd83a 0%, var(--accent) 55%, var(--accent-deep) 100%);
  box-shadow: 0 18px 40px -22px #b88d00aa;
}
.live.is-paused { background: linear-gradient(150deg, #fff4c2, #ffe680); }
.live-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .82rem; font-weight: 600; }
.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink); color: var(--accent);
  border-radius: 999px; padding: 4px 10px; font-size: .72rem; font-weight: 700; white-space: nowrap;
}
.live-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; }
.is-paused .live-badge::before { animation: none; }
@keyframes pulse { 50% { opacity: .25; } }
.live .total { display: block; font: 700 clamp(46px, 14vw, 60px)/1 var(--sans); letter-spacing: -.045em; margin: 18px 0 14px; }
.live-meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .76rem; opacity: .75; }
.live-activity { margin: 10px 0 0; font-size: .86rem; font-weight: 600; }

/* ---------- Aktionskacheln ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; margin: 0 0 6px; }
.tile {
  flex-direction: column; gap: 9px; min-height: 102px; padding: 14px 6px 12px;
  border-radius: var(--radius); background: var(--surface);
  font-size: .8rem; line-height: 1.15; text-align: center;
}
.tile .ic { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--soft); }
.tile.primary { background: var(--surface); color: var(--ink); }
.tile.primary .ic { background: var(--ink); color: var(--accent); }
.tile.start { grid-column: 1 / -1; flex-direction: row; min-height: 64px; font-size: 1.05rem; background: var(--ink); color: #fff; }
.tile.start .ic { background: var(--accent); color: var(--ink); width: 38px; height: 38px; }
.tiles:has(.start) .tile:not(.start) { grid-column: 1 / -1; flex-direction: row; min-height: 56px; font-size: .95rem; }
.tiles:has(.start) .tile:not(.start) .ic { width: 34px; height: 34px; border-radius: 11px; }

/* ---------- Gruppierte Liste ---------- */
.group { background: var(--surface); border-radius: var(--radius); overflow: hidden; margin: 0 0 14px; }
.cell {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 60px; padding: 11px 16px; border-radius: 0;
  background: transparent; text-align: start; font-weight: 500; position: relative;
}
.group > .cell + .cell::before { content: ""; position: absolute; left: 62px; right: 0; top: 0; height: 1px; background: var(--line); }
.cell .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--soft); flex: none; }
.cell .ico svg { width: 18px; height: 18px; }
.cell .ico.y { background: var(--accent); }
.cell .ico.k { background: var(--ink); color: var(--accent); }
.cell .ico.g { background: #e4e8e1; color: #3c4b36; }
.cell .m { flex: 1; min-width: 0; }
.cell .m b { display: block; font-weight: 600; }
.cell .m small { display: block; }
.cell .v { display: flex; align-items: center; gap: 4px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell .v svg { width: 16px; height: 16px; }
.cell.empty { color: var(--muted); }
.cell.empty .m b { font-weight: 500; }

/* ---------- Einsätze ---------- */
.blocks .card { padding: 0; overflow: hidden; }
.block-heading { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.block-heading .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--soft); flex: none; }
.block-heading .ico svg { width: 18px; height: 18px; }
.block-heading.live-block .ico { background: var(--accent); }
.block-heading h3 { flex: 1; overflow-wrap: anywhere; }
.block-heading > strong { white-space: nowrap; color: var(--muted); font-weight: 600; }
.entries, .audit-list { padding: 0; margin: 0; list-style: none; }
.card .entries { padding: 0 16px 4px 62px; }
.entries li { border-top: 1px solid var(--line); padding: 9px 0; overflow-wrap: anywhere; }
.entry { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; }
.entry strong, .entry small { display: block; }
.entry strong { font-weight: 600; font-size: .92rem; }
.entry button { min-height: 34px; padding: 4px 12px; background: var(--soft); font-size: .82rem; flex: none; }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
.card details { border-top: 1px solid var(--line); margin: 0; }
.card details > summary {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; font-weight: 600; font-size: .9rem; color: var(--muted);
}
.card details > summary::after { content: "›"; font-size: 1.3rem; line-height: 1; transition: transform .2s; }
.card details[open] > summary::after { transform: rotate(90deg); }
.card details .actions { padding: 0 16px 16px; }
.card details .actions button { background: var(--soft); }
.card details .actions .danger { background: #fbeae6; }

/* ---------- Hinweise / Einreichen ---------- */
.notice { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: #fff6d6; }
.notice p { margin: 0; font-weight: 600; font-size: .9rem; }
.notice button { min-height: 38px; background: var(--ink); color: #fff; font-size: .85rem; }
.status-card { display: flex; align-items: center; gap: 12px; }
.status-card .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--ink); color: var(--accent); flex: none; }
.status-card h2 { font-size: 1rem; }
.status-card p { margin: 2px 0 0; }

.submit-bar {
  position: fixed; z-index: 15; left: 0; right: 0; bottom: var(--tabbar);
  padding: 12px max(16px, calc(50vw - 304px)) 12px;
  background: #ffffffe8;
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid #e3e2da;
}
.submit-bar button, .submit-bar .fake-button { width: 100%; min-height: 52px; border-radius: 16px; font-size: 1rem; }
.submit-bar button { background: var(--ink); color: #fff; }
.fake-button { display: flex; align-items: center; justify-content: center; gap: 8px; background: #e7e6df; color: #9b9c92; font-weight: 600; }
.submit-bar p { margin: 7px 0 0; text-align: center; font-size: .76rem; color: var(--muted); }

/* ---------- Tableiste ---------- */
.tabbar {
  position: fixed; z-index: 16; left: 0; right: 0; bottom: 0;
  height: var(--tabbar); padding: 6px max(8px, calc(50vw - 320px)) env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: #f7f6f2ee;
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid #dddcd4;
}
.tabbar button {
  flex-direction: column; gap: 3px; min-height: 52px; padding: 4px;
  background: transparent; color: #9b9c92; font-size: .68rem; font-weight: 600; border-radius: 12px;
}
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button[aria-current] { color: var(--ink); }
.tabbar button[aria-current] svg { fill: var(--accent); }

/* ---------- Zeitraum ---------- */
.period-total { padding: 18px; }
.period-total .label { display: flex; justify-content: space-between; color: var(--muted); font-size: .82rem; }
.period-total .total { display: block; font: 700 40px/1.05 var(--sans); letter-spacing: -.035em; margin-top: 4px; }
.rings { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 18px; }
.rings div { display: grid; justify-items: center; gap: 6px; font-size: .7rem; font-weight: 600; color: var(--muted); }
.rings svg { width: 38px; height: 38px; transform: rotate(-90deg); }
.rings .today { color: var(--ink); }

/* ---------- Büro ---------- */
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0 0 12px; }
.filters label { font-size: .75rem; font-weight: 600; color: var(--muted); }
.filters input, .filters select { margin-top: 4px; background: var(--surface); font-weight: 600; width: 100%; font-size: .92rem; padding-inline: 12px; }
.office-calendar { padding: clamp(8px, 2.5vw, 16px); }
.calendar-summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 12px; }
.calendar-summary small { color: var(--muted); }
.calendar-summary strong { display: block; font-size: 1.35rem; }
.calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calendar-days .weekday { text-align: center; font-size: .75rem; font-weight: 600; color: var(--muted); }
.calendar-day {
  display: flex; flex-direction: column; justify-content: flex-start; gap: 0;
  min-width: 0; min-height: 46px; padding: 6px 0 4px; border-radius: 8px;
  background: var(--soft); font-size: .85rem; font-variant-numeric: tabular-nums;
}
.calendar-day small { font-size: .65rem; line-height: 1.25; white-space: nowrap; }
.calendar-day.has-time { background: #fff3c4; }
.calendar-day[aria-current="date"] { box-shadow: inset 0 0 0 1px var(--ink); }
.calendar-day[aria-pressed="true"] { background: var(--ink); color: #fff; }
.month-billing { margin-top: 12px; }
.month-billing > button { width: 100%; }
.month-billing > p { margin: 6px 4px 0; }
.office-card { padding: 0; overflow: hidden; }
.office-card .cell { cursor: default; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .78rem; flex: none; background: var(--ink); color: var(--accent); }
.avatar.alt { background: var(--accent); color: var(--ink); }
.office-body { padding: 0 16px 16px; }
.strip { position: relative; height: 10px; border-radius: 6px; background: var(--soft); overflow: hidden; margin: 2px 0 5px; }
.strip span { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.strip .b { background: #cfcec5; }
.strip .b.solid { background: var(--ink); }
.strip .p { background: #dcdbd2; }
.strip .a0 { background: #1a1a18; }
.strip .a1 { background: #8a8b80; }
.strip .a2 { background: var(--accent); }
.legend { display: flex; justify-content: space-between; font-size: .68rem; color: #9b9c92; font-variant-numeric: tabular-nums; }
.timeline { display: grid; gap: 7px; margin: 12px 0 0; padding: 0; list-style: none; }
.timeline li { display: grid; grid-template-columns: 104px 1fr; gap: 10px; align-items: center; font-size: .86rem; }
.timeline .t { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline .e { font-weight: 600; padding: 8px 12px; border-radius: 12px; background: var(--soft); overflow-wrap: anywhere; }
.timeline .e small { display: block; font-weight: 500; }
.timeline .e.pause { background: transparent; border: 1.5px dashed #dcdbd3; color: var(--muted); font-weight: 500; }
.timeline .e.blk { background: #fff6d6; }
.office-sum { display: flex; justify-content: space-between; margin-top: 12px; font-size: .82rem; color: var(--muted); }
.office-card .audit-summary { margin-top: 12px; }

/* ---------- Status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  border-radius: 999px; padding: 3px 9px; font-size: .72rem; font-weight: 700;
  background: #fff3c4; color: #6b5500;
}
.badge[data-status="Eingereicht"] { background: var(--ink); color: #fff; }
.badge[data-status="Abgerechnet"] { background: #e4e8e1; color: #3c4b36; }

/* ---------- Änderungsverlauf ---------- */
.audit-summary > summary { display: flex; align-items: center; gap: 6px; padding: 12px 0 4px; font-weight: 600; font-size: .88rem; color: var(--muted); }
.audit-summary > summary::before { content: "›"; font-size: 1.2rem; transition: transform .2s; }
.audit-summary[open] > summary::before { transform: rotate(90deg); }
.history { padding: 2px 16px 10px; }
.audit-list > li { border-top: 1px solid var(--line); padding: 10px 0; font-size: .88rem; }
.audit-list p { margin-top: .2rem; }
.audit-comparison { display: grid; gap: 8px; margin-top: 8px; }
.audit-version { padding: 10px 12px; border-radius: 14px; background: var(--soft); }
.audit-version h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.audit-version .entries { padding: 0; }
.audit-version .entries li { padding: 5px 0; font-size: .82rem; }

/* ---------- Anmeldung ---------- */
.login { margin-top: 8vh; }
.login h1 { font-size: 40px; }
.login > p { color: var(--muted); margin: 6px 4px 22px; }
.login h1 { margin-inline: 4px; }
.login .cell { min-height: 68px; }
.login .cell .m b { font-size: 1.02rem; }
.login form .primary { width: 100%; margin-top: 16px; }
.login > .quiet, .login-actions { margin-top: 10px; }
.login-actions { display: flex; flex-wrap: wrap; gap: 4px; }
#account-message { margin: 8px 0; padding: 12px 14px; background: var(--surface); border-radius: 14px; }
.password-controls { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.password-controls button { background: var(--soft); }

/* ---------- Kontenverwaltung ---------- */
.admin-nav {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px;
  margin: 10px 0 18px; padding: 4px; border-radius: 16px; background: var(--soft);
}
.admin-nav button { min-width: 0; background: transparent; padding-inline: 8px; }
.admin-nav button[aria-current] { background: var(--surface); box-shadow: 0 1px 5px #1a1a1814; }
.accounts-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; }
.accounts-head h1 { font-size: clamp(24px, 8vw, 34px); }
.account-list-filter { margin: 0 0 12px; }
.account-list-filter select { background: var(--surface); }
.account-list { display: grid; gap: 8px; }
.managed-account { margin: 0; }
.managed-account-head {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 8px;
}
.managed-account-head h2, .managed-account-head p { overflow-wrap: anywhere; }
.managed-account-head h2 { font-size: 1.02rem; }
.managed-account-head p { margin: 1px 0 0; color: var(--muted); font-size: .82rem; }
.managed-account-head .avatar { width: 30px; height: 30px; font-size: .7rem; }
.account-status {
  max-width: 112px; padding: 4px 8px; border-radius: 11px; background: var(--soft);
  color: var(--ink); text-align: center; font-size: .7rem; line-height: 1.25;
}
.account-status.pending { background: #fff3c4; }
.account-status.active { background: #e4e8e1; color: #3c4b36; }
.managed-role { margin: 8px 0 0; }
.managed-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.managed-actions button { min-height: 44px; padding: 8px 12px; font-size: .82rem; }
.managed-actions button:not(.primary) { background: var(--soft); }

/* ---------- Formular als Bottom-Sheet ---------- */
dialog {
  width: 100%; max-width: 640px; max-height: calc(100dvh - 40px);
  margin: auto auto 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  border: 0; border-radius: 28px 28px 0 0;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 -10px 40px #0003;
  overscroll-behavior: contain;
}
dialog[open] { animation: sheet .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes sheet { from { transform: translateY(40px); opacity: .4; } }
dialog::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 4px; background: #d6d5cd; margin: 0 auto 14px; }
dialog::backdrop { background: #1a1a1866; }
dialog h2 { font-size: 22px; }
dialog .actions { margin-top: 18px; flex-direction: column; }
dialog .actions button { width: 100%; min-height: 52px; border-radius: 16px; }
dialog .actions #save { order: -1; }
dialog .actions #save.primary { background: var(--ink); color: #fff; }
dialog .actions #dismiss { background: transparent; color: var(--muted); }
dialog details > summary { padding: 12px 0 2px; font-weight: 600; color: var(--muted); font-size: .9rem; }
dialog details > summary::before { content: "+ "; }
label { display: block; min-width: 0; font-size: .82rem; font-weight: 600; color: var(--muted); }
label input, label select { display: block; width: 100%; margin-top: 5px; color: var(--ink); font-weight: 500; font-size: 1rem; }
input[type="datetime-local"], input[type="date"], input[type="month"] { min-width: 0; -webkit-appearance: none; appearance: none; }
.field { margin-top: 12px; }
.field-pair { display: grid; gap: 0 10px; }
fieldset { margin: 14px 0 0; padding: 0; border: 0; }
fieldset legend { padding: 0; font-size: .82rem; font-weight: 600; color: var(--muted); }
.choice { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; margin-top: 6px; border-radius: 14px; background: var(--soft); color: var(--ink); font-size: 1rem; font-weight: 500; }
.choice input { width: 20px; min-height: 20px; margin: 0; accent-color: var(--ink); }
#conflict:not(:empty), #error:not(:empty), #form-error:not(:empty) { padding: 12px 14px; border-radius: 14px; overflow-wrap: anywhere; font-size: .9rem; }
#error:not(:empty), #form-error:not(:empty) { background: #fbeae6; color: var(--danger); }
#error:empty, #form-error:empty { margin: 0; }
#error:not(:empty) { margin: 8px 0; }
#conflict:not(:empty) { margin-top: 14px; background: #fff6d6; }
#conflict p:first-child { margin-top: 0; }
#conflict .actions { margin-top: 8px; flex-direction: column; }
#conflict .actions button { background: var(--surface); }

@media (min-width: 470px) {
  .field-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-comparison { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 360px) {
  .header-content:has(#account:not([hidden])) .site-name { display: none; }
}

@media (max-width: 320px) {
  .header-content { padding-inline: 8px; gap: 6px; }
  .header-content img { width: 76px; }
  .site-header button { padding-inline: 10px; font-size: .78rem; }
}

@media (min-width: 700px) {
  dialog { margin: auto; border-radius: 28px; max-width: 520px; }
}

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