:root {
  --bg: #ffffff;
  --card: #ffffff;
  --text: #2b241d;
  --muted: #7a6e62;
  --line: #e6ddd0;
  --primary: #6b4a32;     /* warmes Braun */
  --primary-2: #4f7d3a;   /* Blattgrün */
  --accent: #4f8a3c;
  --danger: #dc2626;
  --warn: #d97706;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.05);
}
/* Inhalt immer hell auf Weiß – Kopf- und Reiterleiste bleiben dunkel (siehe .topbar/.tabs) */
:root { color-scheme: light; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.screen { min-height: 100vh; padding: 20px; }
.center { display: flex; align-items: center; justify-content: center; }
.container { max-width: 1100px; margin: 0 auto; padding: 16px; padding-bottom: 60px; }
h1 { font-size: 1.4rem; margin: 0 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 16px 0 8px; }
code { background: var(--line); padding: 1px 5px; border-radius: 4px; }
a { color: var(--primary-2); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px; }
.card.narrow { width: 100%; max-width: 380px; }
.logo { font-size: 44px; text-align: center; }
.logo-sm { font-size: 20px; }
#login-form h1 { text-align: center; }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
input, select, textarea {
  width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
textarea { min-height: 180px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-2); outline-offset: -1px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > .shrink { flex: 0 0 auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.go { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.stop { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.block { width: 100%; margin-top: 6px; }
.btn.big { width: 100%; padding: 18px; font-size: 1.15rem; border-radius: 14px; }
.btn.link { border: none; background: none; color: var(--primary-2); padding: 2px 4px; }

.error { color: var(--danger); min-height: 1em; font-size: .9rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between;
  align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--primary); color: #fff; }
.topbar .brand { font-weight: 700; font-size: 1.05rem; }
.topbar .who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; }
.topbar .btn { color: #fff; border-color: rgba(255,255,255,.4); background: transparent; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .75rem;
  font-weight: 700; background: rgba(0,0,0,.08); }
.topbar .badge { background: rgba(255,255,255,.2); }
.badge.green { background: #dcfce7; color: #166534; }
.badge.gray { background: #e5e7eb; color: #374151; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.amber { background: #fef3c7; color: #92400e; }

.tabs { position: sticky; top: 52px; z-index: 15; display: flex; gap: 4px; overflow-x: auto;
  background: #29231d; border-bottom: 1px solid #3d342b; padding: 0 10px; }
.tabs button { flex: 0 0 auto; border: none; background: none; padding: 12px 14px; font: inherit;
  color: #a89c8e; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.active { color: #8cbf6a; border-bottom-color: #8cbf6a; }
@media (max-width: 700px) { .tabs { position: static; } }
.tabs .sep { flex: 0 0 1px; background: var(--line); margin: 10px 6px; }

.clock { text-align: center; }
.clock .timer { font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 1px; margin: 6px 0; }
.clock .activity-pill { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: 0 0 12px; }
.gps { font-size: .85rem; margin-top: 10px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat .v { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .l { font-size: .8rem; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.day-head td { background: var(--bg); font-weight: 700; }

.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }

#map { height: 380px; border-radius: var(--radius); z-index: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }

.note-preview { white-space: pre-wrap; }

select.small-select { width: auto; margin: 0; padding: 4px 8px; font-size: .85rem; }

/* Werkstatt-Nachrichten */
.grid-ws { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .grid-ws { grid-template-columns: 1fr; } }
.prio-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.prio-opt { display: flex; align-items: center; gap: 4px; margin: 0; cursor: pointer; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--text); }
.prio-opt input { width: auto; margin: 0; }
.prio-opt:has(input:checked) { border-color: var(--primary-2); background: rgba(79,125,58,.10); }
.msg { border-left: 5px solid #9ca3af; }
.msg.prio-dringend { border-left-color: var(--danger); }
.msg.prio-hoch { border-left-color: var(--warn); }
.msg.prio-niedrig { border-left-color: var(--line); }
.msg-done { opacity: .65; }
.msg-actions { margin-top: 10px; justify-content: flex-start; }
.msg-actions > * { flex: 0 0 auto; }
.status-line { margin-top: 10px; padding: 6px 10px; background: var(--bg); border-radius: 8px; color: var(--muted); }
.tab-count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn);
  color: #fff; font-size: .7rem; line-height: 18px; text-align: center; }
.tab-count.urgent { background: var(--danger); }

/* Maschinenvermietung */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; flex: 1 1 auto; }
.price-box { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 6px 0 10px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .9rem; }
label.check input { width: auto; margin: 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: middle; }
table.cal { border-collapse: separate; border-spacing: 0; font-size: .75rem; table-layout: fixed; width: max-content; }
table.cal th, table.cal td { padding: 0; border-bottom: 1px solid var(--line); text-align: center; width: 30px; min-width: 30px; max-width: 30px; height: 32px; }
table.cal th { font-size: .7rem; padding: 4px 0; text-transform: none; letter-spacing: 0; }
table.cal th span { font-weight: 400; opacity: .7; }
table.cal .cal-name { position: sticky; left: 0; z-index: 5; background: var(--card); text-align: left; padding: 0 10px;
  width: 170px; min-width: 170px; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: .8rem; }
table.cal .cal-we { background: rgba(127,127,127,.07); }
table.cal .cal-today { box-shadow: inset 2px 0 0 var(--primary-2), inset -2px 0 0 var(--primary-2); }
table.cal .cal-free { cursor: pointer; }
table.cal .cal-free:hover { background: rgba(79,125,58,.15); }
table.cal .cal-maint { background: repeating-linear-gradient(45deg, rgba(217,119,6,.25) 0 4px, transparent 4px 8px); }
table.cal .cal-busy { cursor: pointer; padding: 3px 0; }
.cal-bar { height: 24px; color: #fff; font-size: .7rem; font-weight: 600; line-height: 24px; position: relative; z-index: 1; }
.cal-bar.start { z-index: 2; border-radius: 4px 0 0 4px; }
.cal-bar span { position: absolute; left: 4px; top: 0; white-space: nowrap; pointer-events: none; text-shadow: 0 1px 1px rgba(0,0,0,.3); }

.modal { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { background: var(--card); border-radius: var(--radius); padding: 20px; width: 100%;
  max-width: 460px; max-height: 90vh; overflow: auto; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--danger); }

.spinner { width: 36px; height: 36px; border: 4px solid var(--line); border-top-color: var(--primary-2);
  border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 600px) { .subtabs { justify-content: flex-start !important; } .subtabs .btn { flex: 0 0 auto; } }
input[type="radio"], input[type="checkbox"] { accent-color: var(--primary-2); }

/* Bilder an Nachrichten */
.img-pick { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 96px; height: 96px; padding: 0; border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; background: var(--bg); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-x { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.65); color: #fff; font-size: 16px; line-height: 24px; cursor: pointer; padding: 0; }

/* Lohnarbeiten */
.quote { margin: 10px 0 6px; padding: 8px 12px; border-left: 3px solid var(--line); background: var(--bg); border-radius: 0 8px 8px 0; font-style: italic; }
.lw-fields { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 99px; background: rgba(79,125,58,.12); color: var(--primary-2); font-weight: 700; font-size: .85rem; }
.msg.prio-normal { border-left-color: var(--primary-2); }
.tagline { text-align: center; color: var(--muted); margin: -8px 0 16px; font-size: .9rem; letter-spacing: .04em; }
.logo-sm { vertical-align: -6px; border-radius: 6px; margin-right: 4px; }
.logo { text-align: center; margin-bottom: 6px; }

/* Maschinen-Kopplung */
.coupled { color: var(--primary-2); font-weight: 600; margin-top: 2px; }
.office { color: var(--primary); font-weight: 600; margin-top: 2px; }

/* Flotte */
.fleet-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.fleet-dot.live { background: #16a34a; } .fleet-dot.stale { background: #d97706; } .fleet-dot.parked { background: #78716c; }
.fleet-label { font-weight: 700; font-size: 12px; padding: 1px 6px; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: var(--bg); }
.fleet-focus { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; margin-bottom: 8px;
  border-radius: 10px; background: var(--primary-2); color: #fff; }
.fleet-focus .muted { color: rgba(255,255,255,.8); }
.fleet-focus .btn { background: #fff; color: var(--primary); }
.list-item.focused { background: color-mix(in srgb, var(--primary-2) 14%, transparent); border-radius: 8px; }
.field-swatch { display: inline-block; width: 12px; height: 10px; border: 1.5px solid #facc15; background: rgba(250,204,21,.15); vertical-align: middle; }
/* Flotte im Vollbild */
.fleet-full { position: fixed; left: 0; right: 0; bottom: 0; top: 100px; z-index: 5; background: #1f2a1a; }
.fleet-full #map { position: absolute; inset: 0; height: auto !important; border-radius: 0; }
.fleet-full:fullscreen { top: 0 !important; }
.fleet-full .fleet-focus { position: absolute; top: 10px; left: 56px; right: 56px; z-index: 1000; margin: 0; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.fleet-fs { position: absolute; z-index: 1000; left: 10px; bottom: 24px; width: 40px; height: 40px; border-radius: 8px; border: 0;
  background: #fff; color: #333; font-size: 22px; line-height: 40px; cursor: pointer; box-shadow: 0 1px 6px rgba(0,0,0,.35); }
.fleet-follow { bottom: 74px; font-size: 20px; }
.fleet-follow.on { background: #16a34a; color: #fff; box-shadow: 0 0 0 3px rgba(22,163,74,.35), 0 1px 6px rgba(0,0,0,.35); }
.fleet-follow.none { opacity: .55; }
.fleet-gear { bottom: 124px; font-size: 19px; }
.fleet-settings { position: absolute; z-index: 1001; left: 60px; bottom: 24px; width: 250px; padding: 12px 14px; border-radius: 12px;
  background: var(--card, #fff); color: var(--text, #222); box-shadow: 0 4px 18px rgba(0,0,0,.35); display: grid; gap: 8px; }
.fleet-settings label { margin: 0; }
/* Hinweis: Push einschalten */
.push-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px;
  background: #fef3c7; color: #78350f; font-size: 14px; border-bottom: 1px solid #fcd34d; }

/* weiße Karten auf weißem Grund: feiner Rand */
.card { border: 1px solid var(--line); }

/* Betriebsname im Kopf */
.org-name { font-size: 12px; font-weight: 500; color: #a89c8e; margin-left: 4px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
.org-name:empty { display: none; }
@media (max-width: 480px) { .org-name { max-width: 28vw; } }

/* Demo-Hinweis */
.demo-bar { background: #e0f2fe; color: #075985; font-size: 13px; padding: 7px 14px; border-bottom: 1px solid #bae6fd; }
.demo-bar.urgent { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.demo-bar a { color: inherit; font-weight: 600; }
.badge.orange { background: #ffedd5; color: #9a3412; }

/* Hinweise im Dialog */
.ok-box { background: #dcfce7; color: #166534; border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.warn-box { background: #fef3c7; color: #92400e; border-radius: 8px; padding: 8px 10px; font-size: 14px; }

/* Leaflet-Ebenenschalter (globale label/input-Stile neutralisieren) */
.leaflet-control-layers label { display: flex; align-items: center; gap: 6px; margin: 2px 0; font-size: 13px; color: #231c16; font-weight: 500; }
.leaflet-control-layers input { width: auto; height: auto; margin: 0; padding: 0; box-shadow: none; }
.leaflet-control-layers-base label > span, .leaflet-control-layers-overlays label > span { display: flex; align-items: center; gap: 6px; }
.home-pin { font-size: 28px; line-height: 34px; text-align: center; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); cursor: grab; }
