/* Mobile Zeiterfassung – FRUHEN Corporate Design */
:root {
  --green: #00C800;
  --green-dark: #297932;
  --green-ink: #063306;
  --green-tint: #EAF9EA;
  --green-tint-2: #F5FCF5;
  --grey: #575756;
  --grey-light: #9D9D9D;
  --line: #DADDDA;
  --bg: #F6F7F6;
  --card: #FFFFFF;
  --text: #1E201E;
  --muted: #666A66;
  --danger: #C62828;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --stripe-w: 0px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
}
[hidden] { display: none !important; }

/* grünes Dreiecksmuster wie im Briefbogen */
.stripe {
  position: fixed; inset: 0 auto 0 0;
  width: var(--stripe-w);
  background: var(--green) url("pattern.svg") top left / 100% auto repeat-y;
  z-index: 0;
}
.shell {
  position: relative; z-index: 1;
  margin-left: var(--stripe-w);
  max-width: 820px;
  padding: 0 16px calc(120px + env(safe-area-inset-bottom));
}
@media (min-width: 900px) {
  :root { --stripe-w: 72px; }
  .shell { margin-left: calc(var(--stripe-w) + max(24px, (100vw - var(--stripe-w) - 820px) / 2)); padding-bottom: 48px; }
}

/* Kopf */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0 12px;
  border-top: 5px solid var(--green);
  margin: 0 -16px; padding-left: 16px; padding-right: 16px;
  background: #fff;
}
@media (min-width: 900px) { .topbar { border-top: 0; margin: 0; background: transparent; padding: 28px 0 18px; flex-direction: row-reverse; } }
.logo { height: 40px; width: auto; display: block; }
@media (min-width: 900px) { .logo { height: 54px; } }
.user { font-size: 14px; color: var(--muted); display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
@media (min-width: 900px) { .user { align-items: flex-start; } }
.user span { font-weight: 600; color: var(--text); }

.offline {
  background: #FFF6D6; color: #6B5300; border: 1px solid #F1DC8C;
  border-radius: 10px; padding: 8px 12px; margin: 12px 0 0; font-size: 14px;
}

h1 { font-size: 26px; line-height: 1.15; margin: 22px 0 6px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0; }
.lead { color: var(--muted); margin: 0 0 18px; }
.muted { color: var(--muted); }
.opt { font-weight: 400; color: var(--muted); font-size: 13px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 16px 0;
  border: 1px solid #EEF0EE;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; }

label { display: block; font-weight: 600; font-size: 14px; margin: 0 0 14px; color: #2c2f2c; }
input, select {
  display: block; width: 100%;
  margin-top: 6px;
  font: inherit; font-size: 17px; font-weight: 400;
  padding: 12px 14px;
  min-height: 50px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff; color: var(--text);
  -webkit-appearance: none; appearance: none;
}
input[type="date"], input[type="time"] { min-height: 50px; }
input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(0,200,0,.18); }
input.invalid, select.invalid { border-color: var(--danger); background-color: #FFF7F7; }
select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(0,200,0,.18); }
select {
  padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23297932' stroke-width='2.2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.sendto { background: var(--green-tint-2); border: 1.5px solid #CFEFCF; border-radius: 10px; padding: 12px 14px; margin: 0 0 14px; font-size: 15px; }
.sendto b { color: var(--green-dark); }
.sendto ul { margin: 6px 0 0; padding-left: 20px; }
.tag.pl { background: #EEF0EE; color: #3d403d; }
input.mono { font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; margin-top: 5px; }

.grid2 { display: grid; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(0,1.15fr) minmax(0,.9fr); gap: 8px; }
.grid3 input { min-width: 0; }
.grid3 label { margin-bottom: 8px; }
.grid3 input { padding: 12px 4px; text-align: center; font-size: 16px; }
.grid3 label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 500; font-size: 15px; padding: 14px; background: var(--green-tint-2); border: 1.5px solid #CFEFCF; border-radius: 10px; cursor: pointer; }
.check input { width: 26px; height: 26px; min-height: 0; margin: 0; flex: none; accent-color: var(--green-dark); -webkit-appearance: checkbox; appearance: auto; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 16px;
  padding: 12px 18px; min-height: 48px;
  border-radius: 12px; border: 0; cursor: pointer;
  transition: transform .06s ease, filter .15s ease, background .15s;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.big { width: 100%; min-height: 56px; font-size: 17px; }
.btn.primary { background: var(--green); color: var(--green-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.05); }
.btn.dark { background: var(--grey); color: #fff; }
.btn.ghost { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn.danger { color: var(--danger); border-color: #F0C8C8; }
.btn:focus-visible, .link:focus-visible, .chips button:focus-visible { outline: 3px solid rgba(0,200,0,.5); outline-offset: 2px; }
.link { background: none; border: 0; padding: 4px 0; font: inherit; font-size: 14px; color: var(--green-dark); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.back { margin-top: 18px; }
.icon { background: #F1F2F1; border: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; cursor: pointer; color: var(--grey); }

.actions { display: grid; gap: 10px; margin-top: 18px; }
.actions.sticky {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  grid-template-columns: 1fr 1fr;
}
@media (min-width: 900px) {
  .actions.sticky { position: static; background: none; border: 0; padding: 0; backdrop-filter: none; margin-top: 20px; }
}

.chip { font-family: var(--mono); font-size: 13px; background: var(--green-tint); color: var(--green-dark); padding: 4px 10px; border-radius: 99px; font-weight: 700; }
.chip:empty { display: none; }

/* Summen */
.totals {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid #EEF0EE; overflow: hidden;
}
.totals > div { padding: 12px 6px; text-align: center; border-right: 1px solid #EEF0EE; }
.totals > div:last-child { border-right: 0; }
.totals .total { background: var(--green); color: var(--green-ink); }
.totals .num { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.totals .lbl { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.totals .total .lbl { color: var(--green-ink); opacity: .8; }

/* Tagesliste */
.daylist { margin-top: 18px; }
.weekhead { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 2px 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.weekhead b { color: var(--green-dark); font-variant-numeric: tabular-nums; }
.day { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid #EEF0EE; margin-bottom: 10px; overflow: hidden; }
.day-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--green-tint-2); border-bottom: 1px solid #E3F3E3; border-left: 5px solid var(--green); }
.day-head .d { font-weight: 700; }
.day-head .d small { font-weight: 500; color: var(--muted); margin-left: 6px; }
.day-head .sum { font-weight: 800; font-variant-numeric: tabular-nums; }
.entry { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 14px; width: 100%; background: none; border: 0; border-bottom: 1px solid #F0F1F0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.entry:last-of-type { border-bottom: 0; }
.entry:hover { background: #FAFBFA; }
.entry .time { font-weight: 700; font-variant-numeric: tabular-nums; }
.entry .net { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.entry .meta { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }
.entry .tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--green-tint); color: var(--green-dark); margin-right: 6px; }
.entry .tag.reise { background: #EDEDED; color: var(--grey); }
.day .addrow { display: block; width: 100%; padding: 10px; border: 0; border-top: 1px dashed #E2E4E2; background: #fff; color: var(--green-dark); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }

.empty { text-align: center; color: var(--muted); padding: 30px 20px; }
.empty strong { color: var(--text); }

/* Dialog */
dialog {
  border: 0; padding: 0; width: min(560px, 100%); max-height: 100dvh;
  border-radius: 18px 18px 0 0; margin: auto auto 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.18);
}
@media (min-width: 640px) { dialog { border-radius: 18px; margin: auto; max-height: 92dvh; } }
dialog::backdrop { background: rgba(20,30,20,.45); }
dialog form { padding: 16px 18px calc(18px + env(safe-area-inset-bottom)); }
dialog.small { max-width: 420px; padding: 20px; border-radius: 16px; margin: auto; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.dlg-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 12px; }
.dlg-actions .btn.primary { flex: 1 1 140px; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; }
legend { font-weight: 600; font-size: 14px; margin-bottom: 8px; padding: 0; color: #2c2f2c; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  font: inherit; font-size: 15px; font-weight: 600;
  padding: 10px 14px; min-height: 44px;
  border-radius: 99px; border: 1.5px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer;
}
.chips button[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.chips button.reise[aria-pressed="false"] { border-style: dashed; }
.chips.small { margin: -2px 0 14px; }
.chips.small button { min-height: 36px; padding: 6px 12px; font-size: 14px; }
#kstFree { margin-top: 10px; }

.calc { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: 10px; background: var(--green-tint); color: var(--green-ink); }
.calc strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.calc small { flex-basis: 100%; color: var(--green-dark); font-weight: 600; }
.calc small:empty { display: none; }
.error { color: var(--danger); font-weight: 600; font-size: 14px; margin: 10px 0 0; }

/* Vorschau Wochenzettel */
.sheets { display: grid; gap: 16px; }
.sheet { background: #fff; border: 1px solid #000; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sheet table { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 13px; }
.sheet th, .sheet td { border: 1px solid #000; padding: 4px 6px; }
.sheet th { background: var(--green-tint); font-size: 11.5px; }
.sheet .title { font-size: 16px; font-weight: 800; }
.sheet .dayrow td { background: var(--green-tint-2); font-weight: 700; border-top: 2px solid #000; }
.sheet .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sheet .c { text-align: center; }
.sheet .b { font-weight: 700; }
.sheet .sum td { border-top: 2px solid #000; font-weight: 700; }
.swipe { display: none; font-size: 13px; color: var(--muted); margin: 0; }
@media (max-width: 700px) { .swipe { display: block; } .sheet .emptyday { display: none; } }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-radius: 12px; overflow: hidden; }
.summary div { background: #fff; padding: 10px; text-align: center; }
.summary div.g { background: var(--green); color: var(--green-ink); }
.summary b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }
.summary span { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.done { text-align: center; padding: 32px 22px; }
.tick { width: 72px; height: 72px; border-radius: 50%; background: var(--green); color: var(--green-ink); font-size: 40px; font-weight: 800; display: grid; place-items: center; margin: 0 auto 8px; }

.foot { margin-top: 36px; font-size: 12px; color: var(--grey-light); text-align: center; }

@media print {
  .stripe, .topbar .user, .actions, .foot, .back, #viewReview .card, .offline { display: none !important; }
  .shell { margin: 0; padding: 0; max-width: none; }
  body { background: #fff; }
  .sheet { break-after: page; overflow: visible; }
  .sheet table { min-width: 0; }
}

@media (max-width: 640px) {
  input[type="time"]::-webkit-calendar-picker-indicator { display: none; }
  input[type="time"] { text-align: center; }
}
.warn { color: var(--danger); font-weight: 700; }
