:root {
  --bg: #f4f4f5;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #6b6f76;
  --line: #e1e2e5;
  --accent: #2b2f33;
  --accent-ink: #ffffff;
  --accent-soft: #e9eaec;
  --accent-text: #2b2f33;
  --brand: #6b6f76;
  --warn: #b45309;
  --warn-soft: #fdf1e3;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 22, 26, .06), 0 4px 16px rgba(20, 22, 26, .05);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #18191b;
  --card: #232427;
  --ink: #ececee;
  --muted: #9a9ca3;
  --line: #34363b;
  --accent: #d4d6da;
  --accent-ink: #18191b;
  --accent-soft: #2c2e32;
  --accent-text: #d4d6da;
  --brand: #9a9ca3;
  --warn: #f0a254;
  --warn-soft: #33261a;
  --danger: #f2766b;
  --shadow: none;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #18191b;
    --card: #232427;
    --ink: #ececee;
    --muted: #9a9ca3;
    --line: #34363b;
    --accent: #d4d6da;
    --accent-ink: #18191b;
    --accent-soft: #2c2e32;
    --accent-text: #d4d6da;
    --brand: #9a9ca3;
    --warn: #f0a254;
    --warn-soft: #33261a;
    --danger: #f2766b;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
a { color: var(--accent-text); }
h1 { font-size: 28px; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 20px; margin: 0 0 12px; letter-spacing: -.01em; }

/* ---------- inputs & buttons ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input, select, textarea {
  width: 100%;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 12px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
input[type=date] { min-height: 48px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; align-items: center; gap: 10px; margin: 2px 0 16px; font-size: 16px; }
input[type=checkbox] { width: 22px; height: 22px; padding: 0; border-radius: 6px; flex: none; position: relative; cursor: pointer; vertical-align: middle; }
input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:checked::after { content: ""; position: absolute; left: 7px; top: 3px; width: 5px; height: 11px; border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 7px 11px; font-size: 14px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; }
.btn svg { width: 20px; height: 20px; flex: none; }
.icon-btn { border: 0; background: transparent; color: var(--ink); padding: 8px; border-radius: 10px; cursor: pointer; }
.icon-btn svg { width: 24px; height: 24px; display: block; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 4px 0 10px; }

/* ---------- employee app ---------- */
.app { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 110px); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; min-height: 52px; }
.topbar-title { display: flex; justify-content: flex-start; align-items: center; min-width: 0; }
.topbar-title h1 { font-size: 22px; }
.app-logo { max-height: 42px; max-width: 210px; margin: 0; }
.who { font-size: 14px; color: var(--muted); text-align: center; margin: 2px 0 12px; }
.monthnav { display: flex; align-items: center; justify-content: space-between; margin: 8px -6px 10px; }
.monthnav span { font-weight: 600; font-size: 17px; }
.total-card {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: inset 0 -5px 0 var(--brand);
  border-radius: 18px; padding: 18px 18px 16px; margin-bottom: 18px;
}
.total-card .label { font-size: 13px; display: flex; justify-content: space-between; gap: 10px; }
.total-card .label > span:first-child { opacity: .8; }
.total-card .card-name { font-weight: 600; opacity: .95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.total-card .big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 4px; }
.total-card .sub { font-size: 13px; opacity: .85; }

.list { list-style: none; padding: 0; margin: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list li { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.list li:first-child { border-top: 0; }
.list li:active { background: var(--accent-soft); }
.thumb { width: 46px; height: 46px; border-radius: 10px; flex: none; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg { width: 22px; height: 22px; }
.grow { flex: 1; min-width: 0; }
.line1 { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.line2 { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); margin-left: 6px; vertical-align: 1px; }
.badge.card { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; background: var(--card); border-radius: var(--radius); }
.empty b { color: var(--ink); display: block; margin-bottom: 4px; }

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.bottombar .inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
.bottombar .btn { padding: 15px 12px; }

/* ---------- sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet .backdrop { position: absolute; inset: 0; background: rgba(12, 13, 15, .45); opacity: 0; transition: opacity .2s; }
.sheet .panel {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 10px 18px calc(env(safe-area-inset-bottom) + 18px);
  transform: translateY(100%); transition: transform .22s ease-out;
}
.sheet.open .backdrop { opacity: 1; }
.sheet.open .panel { transform: none; }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; }
.actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 6px; }
@media (min-width: 700px) {
  .sheet { align-items: center; }
  .sheet .panel { border-radius: 20px; }
}

.photo-pick {
  display: grid; place-items: center; text-align: center;
  min-height: 150px; border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--muted); margin-bottom: 16px; cursor: pointer; overflow: hidden;
}
.photo-pick svg { width: 34px; height: 34px; color: var(--accent-text); margin-bottom: 6px; }
.photo-pick img { max-width: 100%; max-height: 300px; display: block; }
.photo-pick.has { border-style: solid; padding: 0; }
.calc { background: var(--accent-soft); color: var(--accent-text); border-radius: 10px; padding: 12px 14px; margin: 0 0 16px; font-weight: 600; font-variant-numeric: tabular-nums; }

.menu { background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 10px; }
.menu button, .menu a { display: block; width: 100%; text-align: left; font: inherit; font-size: 17px; padding: 15px 16px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--ink); text-decoration: none; cursor: pointer; }
.menu > :first-child { border-top: 0; }
.tip { background: var(--card); border-radius: var(--radius); padding: 14px 16px; font-size: 14px; color: var(--muted); margin-bottom: 10px; }

.detail-img { width: 100%; border-radius: var(--radius); display: block; margin-bottom: 14px; background: var(--card); }
dl.kv { margin: 0 0 16px; background: var(--card); border-radius: var(--radius); padding: 4px 16px; }
dl.kv div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
dl.kv div:first-child { border-top: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; text-align: right; font-weight: 500; overflow-wrap: anywhere; }

/* ---------- login ---------- */
.login { max-width: 380px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12vh) 20px 40px; }
.logo { width: 60px; height: 60px; border-radius: 16px; display: block; margin-bottom: 18px; }
.login h1 { margin-bottom: 6px; }
.login p { margin: 0 0 26px; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 15px;
  z-index: 100; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- admin ---------- */
.admin { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.admin-head .brand { display: flex; align-items: center; gap: 12px; }
.admin-head .brand img { width: 40px; height: 40px; border-radius: 11px; }
.tabs { display: flex; gap: 4px; background: var(--card); padding: 4px; border-radius: 12px; box-shadow: var(--shadow); }
.tabs button { font: inherit; font-size: 15px; font-weight: 600; border: 0; background: none; color: var(--muted); padding: 8px 14px; border-radius: 9px; cursor: pointer; }
.tabs button.on { background: var(--accent-soft); color: var(--accent-text); }
.panel-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .monthnav { margin: 0; gap: 6px; }
.toolbar .monthnav span { min-width: 130px; text-align: center; }
.toolbar .tools { display: flex; gap: 8px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat.hl .v { color: var(--accent-text); }
.stat.hl { box-shadow: var(--shadow), inset 4px 0 0 var(--brand); }
table.t { width: 100%; border-collapse: collapse; font-size: 15px; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.t td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t .acts { text-align: right; white-space: nowrap; }
table.t .acts .btn { margin-left: 4px; }
table.t tr.sub > td { background: var(--bg); padding: 0 10px 10px; }
table.t tr.sub table.t { font-size: 14px; background: var(--card); border-radius: 10px; }
table.t tr.sub table.t td, table.t tr.sub table.t th { padding: 8px 10px; }
.status { font-size: 13px; font-weight: 600; }
.status.ok { color: var(--accent-text); }
.status.open { color: var(--warn); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.inactive td { opacity: .5; }
@media (max-width: 760px) {
  .stats { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  table.t { font-size: 14px; }
  .admin { padding: 16px 12px 40px; }
  .scroll-x { overflow-x: auto; }
}

.vtag { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; align-self: flex-end; margin-bottom: 4px; }
.settings-grid:not(.hidden) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 18px; align-items: start; }
.settings-grid .panel-card { margin-bottom: 0; }
@media (max-width: 860px) { .settings-grid:not(.hidden) { grid-template-columns: 1fr; } }

/* Firmenlogo */
.brandlogo { display: block; object-fit: contain; }
.login-logo { max-height: 64px; max-width: 240px; margin-bottom: 22px; }
.admin-head .brand img.brandlogo { width: auto; height: auto; max-height: 44px; max-width: 170px; border-radius: 0; }
.logo-box { display: grid; place-items: center; min-height: 90px; padding: 14px; border: 1px dashed var(--line); border-radius: 12px; margin-bottom: 10px; background: var(--bg); }
.logo-box img { max-height: 70px; max-width: 100%; }
/* Hinterlegung nur bei Logos, die auf dem Hintergrund sonst schlecht lesbar wären */
:root[data-theme="dark"] .brandlogo.needs-light-bg,
:root[data-theme="light"] .brandlogo.needs-dark-bg { padding: 4px 8px; border-radius: 8px; }
:root[data-theme="dark"] .brandlogo.needs-light-bg { background: #fff; }
:root[data-theme="light"] .brandlogo.needs-dark-bg { background: #2b2f33; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .brandlogo.needs-light-bg { background: #fff; padding: 4px 8px; border-radius: 8px; }
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] .brandlogo.needs-dark-bg { background: #2b2f33; padding: 4px 8px; border-radius: 8px; }
}

.colorfield { display: grid !important; grid-template-columns: 48px 1fr; gap: 8px; margin: 0 !important; }
.colorfield input[type=color] { padding: 4px; height: 48px; cursor: pointer; }

.avatar { width: 38px; height: 38px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent-soft); color: var(--accent-text); font: inherit; font-size: 14px; font-weight: 700; letter-spacing: .02em;
  box-shadow: 0 0 0 2px var(--brand); display: grid; place-items: center; padding: 0; }
.avatar:active { transform: scale(.95); }
.admin-user { font-size: 13px; color: var(--muted); text-align: right; margin-top: 6px; }
.admin-user a { cursor: pointer; }
.admin-head .right { display: flex; flex-direction: column; align-items: flex-end; }

.sheet.forced .icon-btn[data-close], .sheet.forced .btn[data-close] { display: none; }
.sheet.forced .actions { grid-template-columns: 1fr; }
