/* Wattmeter – Stylesheet. Farben ausschliesslich über CSS-Variablen. */

:root {
  --primary: #0b5cd5;
  --primary-hover: #094bb0;
  --primary-text: #ffffff;
  --accent: #ffd23f;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #d7dce3;
  --text: #14171c;
  --text-muted: #59616d;
  --success: #137a3a;
  --success-bg: #e3f5ea;
  --warning: #8a5a00;
  --warning-bg: #fff4d6;
  --danger: #b3261e;
  --danger-bg: #fde7e6;
  --info-bg: #e6efff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
  --radius: 12px;
  --radius-sm: 8px;
  --touch: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --abs-ferien: #d9ecff;
  --abs-krank: #ffe1e1;
  --abs-schule: #efe4ff;
  --abs-militaer: #e4eedb;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --primary: #5b9bff;
  --primary-hover: #7cb0ff;
  --primary-text: #0b1220;
  --accent: #ffd23f;
  --bg: #0e1116;
  --surface: #171b22;
  --surface-2: #20252e;
  --border: #323844;
  --text: #e8eaed;
  --text-muted: #a3abb8;
  --success: #6fdc95;
  --success-bg: #12301f;
  --warning: #ffd479;
  --warning-bg: #3a2c0a;
  --danger: #ff8a80;
  --danger-bg: #3d1513;
  --info-bg: #15243d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
  --abs-ferien: #1d3550;
  --abs-krank: #4a2020;
  --abs-schule: #33264d;
  --abs-militaer: #27361d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5;
  background: var(--bg); color: var(--text);
}
img { max-width: 100%; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }
.boot { min-height: 80vh; display: grid; place-content: center; text-align: center; color: var(--text-muted); }
.noscript { padding: 2rem; text-align: center; }
.muted { color: var(--text-muted); }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.grid2 { display: grid; gap: .75rem 1rem; grid-template-columns: 1fr; }
.grid3 { display: grid; gap: .75rem 1rem; grid-template-columns: 1fr; }
@media (min-width: 700px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: repeat(3, 1fr); }
  .span2 { grid-column: span 2; }
}

/* --- Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--touch); padding: 0 1.1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { min-height: 36px; padding: 0 .75rem; font-size: .9rem; }
.btn.block { width: 100%; }
.icon-btn { min-width: var(--touch); padding: 0; }

/* --- Formulare ------------------------------------------------------- */
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .3rem; }
.field { min-width: 0; }
.field .hint { font-size: .82rem; color: var(--text-muted); margin-top: .25rem; }
.field .err { font-size: .85rem; color: var(--danger); margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url], input[type=number],
input[type=date], input[type=time], input[type=month], input[type=search], select, textarea {
  width: 100%; min-height: var(--touch); padding: .55rem .75rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 2px solid var(--primary); outline-offset: 0; }
input[aria-invalid=true], select[aria-invalid=true], textarea[aria-invalid=true] { border-color: var(--danger); }
.check { display: flex; gap: .6rem; align-items: center; font-weight: 500; min-height: var(--touch); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0; }
legend { font-weight: 700; padding: 0 .4rem; }

/* --- Karten, Tabellen, Badges --------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.tbl tr.klickbar { cursor: pointer; }
.tbl tr.klickbar:hover td { background: var(--surface-2); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.badge.geplant { background: var(--info-bg); }
.badge.in_arbeit { background: var(--warning-bg); color: var(--warning); }
.badge.abgeschlossen { background: var(--success-bg); color: var(--success); }
.badge.abgerechnet { background: var(--surface-2); color: var(--text-muted); }
.badge.aktiv { background: var(--success-bg); color: var(--success); }
.badge.ausstehend, .badge.eingeladen { background: var(--warning-bg); color: var(--warning); }
.badge.deaktiviert, .badge.abgelehnt { background: var(--danger-bg); color: var(--danger); }
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid transparent; }
.alert.info { background: var(--info-bg); }
.alert.warn { background: var(--warning-bg); color: var(--warning); }
.alert.error { background: var(--danger-bg); color: var(--danger); }
.alert.ok { background: var(--success-bg); color: var(--success); }
.kpis { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.kpi .wert { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .titel { color: var(--text-muted); font-size: .85rem; }
.leer { text-align: center; color: var(--text-muted); padding: 2rem 1rem; }

/* --- Layout App ------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .5rem; padding: .4rem max(.75rem, env(safe-area-inset-left));
  min-height: 60px;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.brand:hover { color: var(--text); }
.firma-box { display: flex; align-items: center; gap: .6rem; min-width: 0; padding-left: .6rem; border-left: 1px solid var(--border); }
.firma-logo { height: 34px; max-width: 120px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px 4px; }
.topbar .firma { color: var(--text-muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
main { max-width: 1200px; margin: 0 auto; padding: 1rem max(1rem, env(safe-area-inset-left)) 4rem; }
main.wide { max-width: none; }
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.banner { background: var(--warning-bg); color: var(--warning); padding: .6rem 1rem; text-align: center; font-weight: 600; }
.banner a { color: inherit; }

/* Dropdown-Menü */
.menu { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: .4rem; z-index: 30;
}
.menu-panel a, .menu-panel button {
  display: flex; width: 100%; align-items: center; min-height: var(--touch); padding: 0 .8rem; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; text-align: left;
}
.menu-panel a:hover, .menu-panel button:hover, .menu-panel a.aktiv { background: var(--surface-2); }
.menu-panel a.aktiv { font-weight: 700; }
.menu-panel hr { border: 0; border-top: 1px solid var(--border); margin: .3rem 0; }
@media (max-width: 640px) {
  .menu-panel { position: fixed; left: 0; right: 0; top: 60px; border-radius: 0 0 var(--radius) var(--radius); max-height: calc(100vh - 60px); overflow: auto; }
  .topbar .firma-box:has(.firma-logo) .firma { display: none; }
  .topbar .firma { max-width: 30vw; }
  .brand span.brand-text { display: none; }
}

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: var(--surface); color: var(--text); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto;
  border-radius: var(--radius) var(--radius) 0 0; padding: 1.1rem 1rem calc(1rem + env(safe-area-inset-bottom));
}
.modal.gross { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.modal-head h2 { margin: 0; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.2rem; }
@media (min-width: 700px) { .modal-bg { align-items: center; } .modal { border-radius: var(--radius); padding: 1.4rem; } }

/* Toasts */
#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: .5rem; width: min(92vw, 460px); }
.toast { background: var(--text); color: var(--bg); padding: .8rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.toast.error { background: var(--danger); color: #fff; }
.toast.warn { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning); }

/* Tabs / Segment */
.segment { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.segment button { min-height: 40px; padding: 0 1rem; border: 0; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.segment button[aria-pressed=true] { background: var(--primary); color: var(--primary-text); font-weight: 700; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs button { min-height: var(--touch); padding: 0 1rem; border: 0; background: none; color: var(--text-muted); font: inherit; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button[aria-selected=true] { color: var(--primary); border-bottom-color: var(--primary); }

/* --- Öffentliche Seiten --------------------------------------------- */
.pub-head { display: flex; align-items: center; gap: .75rem; padding: .75rem max(1rem, env(safe-area-inset-left)); max-width: 1100px; margin: 0 auto; }
.pub-head nav { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; }
.pub-head nav a.lnk { padding: .5rem .7rem; color: var(--text); text-decoration: none; font-weight: 600; }
@media (max-width: 640px) { .pub-head nav a.lnk.opt { display: none; } }
.hero { max-width: 1100px; margin: 0 auto; padding: 2.5rem 1rem 2rem; display: grid; gap: 2rem; align-items: center; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 3rem); letter-spacing: -.02em; }
.hero .lead { font-size: 1.15rem; color: var(--text-muted); max-width: 40ch; }
.hero-visual { background: linear-gradient(135deg, var(--primary), #0a3d8f); border-radius: 20px; padding: 1.2rem; color: #fff; box-shadow: var(--shadow); }
.hero-visual .mock { background: rgba(255, 255, 255, .12); border-radius: 12px; padding: .9rem; margin-top: .6rem; font-size: .9rem; }
.hero-visual .mock b { color: var(--accent); }
@media (min-width: 860px) { .hero { grid-template-columns: 1.1fr .9fr; padding-top: 4rem; } }
.section { max-width: 1100px; margin: 0 auto; padding: 2.5rem 1rem; }
.section h2 { font-size: 1.6rem; }
.features { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.feature .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--info-bg); display: grid; place-items: center; font-size: 1.4rem; margin-bottom: .6rem; }
.preise { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.preis { text-align: center; }
.preis .betrag { font-size: 2.2rem; font-weight: 800; }
.preis.empfohlen { border: 2px solid var(--primary); }
.footer { border-top: 1px solid var(--border); padding: 1.5rem 1rem 2.5rem; text-align: center; color: var(--text-muted); font-size: .9rem; }
.footer a { margin: 0 .5rem; }
.legal { max-width: 800px; }
.auth-box { max-width: 460px; margin: 2rem auto; }
.code-box { font-family: var(--mono); font-size: 1.8rem; letter-spacing: .15em; text-align: center; padding: 1rem; background: var(--surface-2); border-radius: var(--radius); font-weight: 700; }
.recovery { display: grid; grid-template-columns: repeat(2, 1fr); gap: .3rem; font-family: var(--mono); background: var(--surface-2); padding: .8rem; border-radius: var(--radius-sm); }
.qr svg { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 8px; }

/* --- Kalender -------------------------------------------------------- */
.kal-nav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.kal-nav .titel { font-weight: 700; flex: 1; min-width: 160px; text-align: center; }
.tag-block { margin-bottom: 1rem; }
.tag-block h3 { font-size: .95rem; color: var(--text-muted); margin-bottom: .4rem; }
.tag-block.heute h3 { color: var(--primary); }
.einsatz { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--primary); border-radius: var(--radius-sm); padding: .75rem .9rem; margin-bottom: .5rem; cursor: pointer; color: var(--text); font: inherit; min-height: var(--touch); }
.einsatz:hover { background: var(--surface-2); }
.einsatz .zeit { font-weight: 700; font-variant-numeric: tabular-nums; }
.einsatz .proj { font-weight: 600; }
.einsatz .ok { color: var(--success); font-size: .85rem; font-weight: 600; }
.abw { border-radius: var(--radius-sm); padding: .5rem .8rem; margin-bottom: .5rem; font-size: .92rem; }
.abw.ferien { background: var(--abs-ferien); }
.abw.krankheit_unfall { background: var(--abs-krank); }
.abw.berufsschule { background: var(--abs-schule); }
.abw.militaer_zivildienst { background: var(--abs-militaer); }
.woche { display: grid; gap: .5rem; }
@media (min-width: 900px) { .woche { grid-template-columns: repeat(var(--tage, 5), 1fr); } }

/* --- Planung (Raster) ----------------------------------------------- */
.plan-layout { display: grid; gap: 1rem; }
@media (min-width: 1000px) { .plan-layout { grid-template-columns: 240px 1fr; } }
.projekt-palette { max-height: 70vh; overflow: auto; }
.chip { display: block; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .4rem; background: var(--surface); cursor: grab; font-size: .9rem; user-select: none; }
.chip:active { cursor: grabbing; }
.plan-grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 760px; table-layout: fixed; }
.plan-grid th, .plan-grid td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: .35rem; vertical-align: top; }
.plan-grid th { background: var(--surface-2); font-size: .85rem; position: sticky; top: 0; }
.plan-grid th.heute { color: var(--primary); }
.plan-grid td.name { font-weight: 600; width: 150px; background: var(--surface); font-size: .9rem; }
.plan-grid td.zelle { min-height: 70px; height: 70px; background: var(--surface); }
.plan-grid td.zelle.drop { background: var(--info-bg); outline: 2px dashed var(--primary); outline-offset: -3px; }
.plan-grid td.zelle.abwesend { background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 8px, var(--surface-2) 8px, var(--surface-2) 16px); }
.karte { background: var(--info-bg); border-left: 4px solid var(--primary); border-radius: 6px; padding: .3rem .4rem; margin-bottom: .3rem; font-size: .8rem; cursor: grab; line-height: 1.3; word-break: break-word; }
.karte .z { font-weight: 700; }
.karte.abw-karte { background: var(--warning-bg); border-left-color: var(--warning); cursor: default; }
.plan-add { width: 100%; min-height: 28px; border: 1px dashed var(--border); background: none; color: var(--text-muted); border-radius: 6px; cursor: pointer; font-size: .8rem; }

/* --- Rapport ---------------------------------------------------------- */
.block-zeile { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; align-items: end; margin-bottom: .5rem; }
.mat-zeile, .mess-karte { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem; margin-bottom: .6rem; background: var(--surface); }
.mat-grid { display: grid; gap: .5rem; grid-template-columns: 1fr 1fr; }
.mat-grid .bez { grid-column: 1 / -1; }
@media (min-width: 760px) { .mat-grid { grid-template-columns: 150px 1fr 110px 130px auto; align-items: end; } .mat-grid .bez { grid-column: auto; } }
.autocomplete { position: relative; }
.ac-liste { position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); z-index: 10; max-height: 240px; overflow: auto; }
.ac-liste button { display: block; width: 100%; text-align: left; padding: .6rem .7rem; min-height: var(--touch); border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; }
.ac-liste button:hover, .ac-liste button:focus { background: var(--surface-2); }
.thumbs { display: flex; flex-wrap: wrap; gap: .5rem; }
.thumb { position: relative; width: 96px; height: 96px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); display: grid; place-items: center; font-size: .75rem; text-align: center; padding: 2px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .x { position: absolute; top: 2px; right: 2px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .65); color: #fff; cursor: pointer; }
.sign-wrap { border: 2px dashed var(--border); border-radius: var(--radius-sm); background: #fff; touch-action: none; }
.sign-wrap canvas { display: block; width: 100%; height: 200px; }
.sign-bild { background: #fff; border-radius: var(--radius-sm); max-height: 120px; }
.speicherleiste { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom)); margin: 1rem -1rem -4rem; display: flex; gap: .6rem; justify-content: flex-end; z-index: 15; }
.warnungen { margin-top: .5rem; }

/* --- Projekt-Detail -------------------------------------------------- */
.rapport-karte { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem; margin-bottom: .6rem; }
.rapport-karte .kopf { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-weight: 600; }
.verlauf-eintrag { border-left: 3px solid var(--border); padding: .3rem .8rem; margin-bottom: .8rem; }
.verlauf-eintrag pre { white-space: pre-wrap; word-break: break-word; font-size: .8rem; background: var(--surface-2); padding: .5rem; border-radius: 6px; margin: .3rem 0 0; max-height: 220px; overflow: auto; }

@media print {
  .topbar, .speicherleiste, .btn, #toasts { display: none !important; }
  body { background: #fff; color: #000; }
}
