/* =====================================================================
   EWS CRM – schlichtes, professionelles Design
   Akzent: EWS-Grün #007a5c · Standard hell, dunkel optional
   ===================================================================== */
:root, html[data-theme="light"] {
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  --radius-sm: 8px;
  --sidebar: 248px;
  --ease: cubic-bezier(.2, .8, .2, 1);

  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --text: #1b2430;
  --muted: #5b6675;
  --faint: #8a94a3;
  --border: #e2e7ee;
  --border-strong: #cfd6df;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .10);
  --input: #ffffff;

  --accent: #007a5c;
  --accent-hover: #00654c;
  --accent-soft: rgba(0, 122, 92, .09);
  --accent-text: #ffffff;
  --blue: #2457c5;
  --green: #138a55;
  --yellow: #9a6a00;
  --red: #c4314b;
  --violet: #6a4fc9;
  --blue-bg: #eaf0fc;
  --green-bg: #e7f5ee;
  --yellow-bg: #fdf4e0;
  --red-bg: #fcebee;
  --violet-bg: #f0edfb;

  /* Kompatibilität mit bestehenden Templates */
  --glass: var(--surface-2);
  --glass-strong: var(--surface-3);
  --glass-hover: var(--surface-3);
  --accent-2: var(--accent);
}

html[data-theme="dark"] {
  --bg: #0f1419;
  --surface: #161c23;
  --surface-2: #1b222a;
  --surface-3: #232c36;
  --text: #e6eaef;
  --muted: #a3adba;
  --faint: #76818f;
  --border: #27313c;
  --border-strong: #35414e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 10px 28px rgba(0, 0, 0, .45);
  --input: #12181e;

  --accent: #1fa37e;
  --accent-hover: #26b88e;
  --accent-soft: rgba(31, 163, 126, .14);
  --blue: #7aa2f7;
  --green: #4cc38a;
  --yellow: #e0b54a;
  --red: #f0707f;
  --violet: #a594f4;
  --blue-bg: rgba(122, 162, 247, .12);
  --green-bg: rgba(76, 195, 138, .12);
  --yellow-bg: rgba(224, 181, 74, .12);
  --red-bg: rgba(240, 112, 127, .12);
  --violet-bg: rgba(165, 148, 244, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
.ico { width: 1.1em; height: 1.1em; vertical-align: -0.18em; flex: none; }
h2 .ico, h3 .ico { color: var(--faint); margin-right: 4px; }
a.link, .link { color: var(--accent); }
a.link:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; letter-spacing: -.005em; }
h1 { font-size: 1.45rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 620; }
h3 { font-size: .95rem; font-weight: 620; }
p { margin: 0 0 .8em; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .88em; }
code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }

/* Hintergrund-Effekte der alten Version: ausgeschaltet */
.backdrop { display: none; }

/* ---------- Flächen ---------- */
.card, .dropdown, .toast { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }

/* ---------- Grundlayout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 16px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.brand img { width: 34px; height: 34px; border-radius: 6px; background: #fff; padding: 2px; object-fit: contain; border: 1px solid var(--border); }
.brand b { display: block; font-size: .98rem; font-weight: 650; }
.brand small { font-size: .74rem; }
.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 7px; color: var(--muted);
  font-weight: 520; font-size: .92rem; position: relative; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.on::before { content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav a .ico { width: 18px; height: 18px; }
.nav .sep { height: 1px; background: var(--border); margin: 8px 4px; }
.nav .cnt { margin-left: auto; background: var(--red); color: #fff; font-size: .7rem; font-weight: 650; border-radius: 99px; padding: 0 7px; line-height: 18px; }
.side-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: .8rem;
  background: var(--accent-soft); color: var(--accent); flex: none;
}

.main { min-width: 0; padding: 0 28px 40px; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: 60px;
  margin: 0 -28px 22px; padding: 0 28px; background: var(--bg); background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar .title { font-weight: 600; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .search { flex: 1; max-width: 460px; margin-left: auto; position: relative; }
.topbar .search input { padding-left: 34px; height: 38px; background: var(--surface); }
.topbar .search > .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--faint); }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .ico { width: 18px; height: 18px; }
.menu-btn { display: none; }
.net-status { font-size: .78rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--yellow-bg); color: var(--yellow); white-space: nowrap; }
.net-status.hide { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 4px; font-size: .9rem; }

/* ---------- Karten / Raster ---------- */
.card { border-radius: var(--radius); padding: 18px; min-width: 0; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
a.card { display: block; transition: border-color .15s, box-shadow .15s; }
a.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.mt { margin-top: 16px; } .mt-s { margin-top: 10px; } .mb { margin-bottom: 16px; }
.right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.hide { display: none !important; }

/* ---------- Kennzahlen ---------- */
.kpi { position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding-right: 40px; }
.kpi .value { font-size: 1.75rem; font-weight: 680; letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; }
.kpi .hint { font-size: .8rem; color: var(--faint); margin-top: 4px; }
.kpi .ico-bg { position: absolute; right: 14px; top: 14px; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.kpi .ico-bg .ico { width: 17px; height: 17px; }
.tone-red .ico-bg { background: var(--red-bg); color: var(--red); }
.tone-blue .ico-bg { background: var(--blue-bg); color: var(--blue); }
.tone-green .ico-bg { background: var(--green-bg); color: var(--green); }
.tone-yellow .ico-bg { background: var(--yellow-bg); color: var(--yellow); }
.tone-violet .ico-bg { background: var(--violet-bg); color: var(--violet); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; font-weight: 560;
  cursor: pointer; transition: background .15s, border-color .15s; white-space: nowrap; line-height: 1.25;
}
.btn:hover { background: var(--surface-3); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn .ico { width: 16px; height: 16px; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.pri:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.ok { background: var(--green-bg); border-color: transparent; color: var(--green); }
.btn.danger { background: var(--surface); border-color: var(--border-strong); color: var(--red); }
.btn.danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: .82rem; border-radius: 7px; }
.btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn.queued { border-style: dashed; border-color: var(--yellow); color: var(--yellow); background: var(--yellow-bg); }
.btn[disabled] { opacity: .5; pointer-events: none; }
form.inline { display: inline; }

/* ---------- Formulare ---------- */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input:not([type]), input[type=text], input[type=search], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=datetime-local], input[type=month], input[type=url], input[type=tel],
input[type=file], select, textarea {
  width: 100%; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--input);
  color: var(--text); font: inherit; font-size: .92rem; outline: none; transition: border-color .15s, box-shadow .15s; min-height: 38px;
}
textarea { min-height: 96px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
html[data-theme="dark"] select option { background: var(--surface); color: var(--text); }
html[data-theme="dark"] input[type=date]::-webkit-calendar-picker-indicator, html[data-theme="dark"] input[type=time]::-webkit-calendar-picker-indicator { filter: invert(.8); }
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
input[readonly] { background: var(--surface-2); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: middle; }
.field { margin-bottom: 13px; }
.field .help { font-size: .77rem; color: var(--faint); margin-top: 4px; }
.field .err, .errorlist { color: var(--red); font-size: .8rem; margin: 4px 0 0; padding: 0; list-style: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks > div { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label, label.check {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--text); font-weight: 500; font-size: .86rem; cursor: pointer; margin: 0;
}
.checks ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.checks li { margin: 0; }

.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.filters .field { margin: 0; }
details.more > summary { cursor: pointer; color: var(--accent); font-weight: 560; font-size: .88rem; list-style: none; margin-top: 12px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸ "; }
details.more[open] > summary::before { content: "▾ "; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
table.t th {
  text-align: left; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); font-weight: 650;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
table.t th a { display: inline-flex; gap: 4px; align-items: center; }
table.t th a.on { color: var(--accent); }
table.t td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.t tbody tr:hover { background: var(--surface-2); }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t tr.clickable { cursor: pointer; }
table.t .title-cell b { display: block; font-weight: 600; }
table.t .title-cell small { display: block; }

/* ---------- Tags ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 5px; font-size: .74rem; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); white-space: nowrap; margin: 1px 2px 1px 0; line-height: 1.6;
}
.tag.red { color: var(--red); background: var(--red-bg); border-color: transparent; }
.tag.green { color: var(--green); background: var(--green-bg); border-color: transparent; }
.tag.blue { color: var(--blue); background: var(--blue-bg); border-color: transparent; }
.tag.yellow { color: var(--yellow); background: var(--yellow-bg); border-color: transparent; }
.tag.violet { color: var(--violet); background: var(--violet-bg); border-color: transparent; }
.tag.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); }
.dot.green { background: var(--green); } .dot.red { background: var(--red); } .dot.yellow { background: var(--yellow); }

/* ---------- Listen / Verlauf ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .meta { font-size: .8rem; color: var(--faint); }
a.list-item:hover { background: var(--surface-2); border-radius: 6px; }
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl { position: relative; padding: 0 0 14px; }
.tl::before { content: ""; position: absolute; left: -19px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--blue); }
.tl.visit::before { border-color: var(--accent); }
.tl.note::before { border-color: var(--violet); }
.tl.order::before { border-color: var(--green); }
.tl.termin::before { border-color: var(--yellow); }
.tl .when { font-size: .77rem; color: var(--faint); }
.empty { text-align: center; color: var(--faint); padding: 26px 10px; font-size: .9rem; }
.empty .ico { width: 28px; height: 28px; opacity: .5; margin-bottom: 6px; display: block; margin-inline: auto; }

/* ---------- Detailfelder ---------- */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 7px 14px; font-size: .91rem; margin: 0; }
.kv dt { color: var(--faint); font-weight: 560; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Reiter ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 560; font-size: .88rem; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a .cnt { color: var(--faint); font-weight: 500; margin-left: 5px; font-size: .8rem; }

/* ---------- Diagramme ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; overflow: hidden; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .bar i { display: block; width: 100%; max-width: 32px; border-radius: 3px 3px 0 0; min-height: 2px; background: var(--accent); opacity: .85; }
.bars .bar:hover i { opacity: 1; }
.bars.blue .bar i { background: var(--blue); }
.bars.green .bar i { background: var(--green); }
.bars .bar span { font-size: .68rem; color: var(--faint); margin-top: 6px; white-space: nowrap; }
.bars .bar b { font-size: .7rem; color: var(--muted); margin-bottom: 3px; font-weight: 560; }
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar { display: grid; grid-template-columns: 150px 1fr 60px; gap: 10px; align-items: center; font-size: .86rem; }
.hbar .track { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.kanban .col { border-radius: var(--radius); padding: 12px; background: var(--surface-3); min-height: 200px; }
.kanban .col h3 { font-size: .82rem; color: var(--muted); display: flex; justify-content: space-between; text-transform: uppercase; letter-spacing: .03em; }
.task-card { display: block; padding: 11px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 8px; border-left: 3px solid var(--blue); box-shadow: var(--shadow); }
.task-card:hover { border-color: var(--border-strong); }
.task-card.p-hoch { border-left-color: var(--red); }
.task-card.p-niedrig { border-left-color: var(--faint); }
.task-card.over { background: var(--red-bg); }

/* ---------- Seitenwechsel ---------- */
.pager { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 12px; flex-wrap: wrap; border-top: 1px solid var(--border); }
.pager a, .pager span { padding: 5px 11px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); font-size: .85rem; }
.pager a:hover { background: var(--surface-3); }
.pager .on { background: var(--surface-3); border-color: var(--border-strong); font-weight: 600; }

/* ---------- Meldungen ---------- */
.toasts { position: fixed; right: 18px; top: 72px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(400px, calc(100vw - 36px)); }
.toast { border-radius: 8px; padding: 11px 14px; display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; box-shadow: var(--shadow-lg); border-left: 3px solid var(--blue); animation: toastIn .25s var(--ease); }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--yellow); }
.toast .x { margin-left: auto; cursor: pointer; color: var(--faint); background: none; border: 0; font-size: 1.15rem; line-height: 1; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- Dropdown / Suche ---------- */
.dropdown { position: absolute; left: 0; right: 0; top: calc(100% + 4px); border-radius: 8px; padding: 4px; z-index: 60; max-height: 360px; overflow-y: auto; box-shadow: var(--shadow-lg); }
.dropdown a, .dropdown button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; background: none; border: 0; color: var(--text); font: inherit; font-size: .9rem; cursor: pointer; }
.dropdown a:hover, .dropdown button:hover, .dropdown .act { background: var(--surface-3); }
.dropdown small { display: block; color: var(--faint); }
.picker { position: relative; }
.user-menu { position: relative; }
.user-menu .dropdown { left: auto; width: 230px; }

/* ---------- Karte ---------- */
.map { height: 380px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }

/* ---------- Anmeldung ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: min(410px, 100%); border-radius: 12px; padding: 32px 28px; box-shadow: var(--shadow-lg); }
.auth-card .brand { justify-content: center; border: 0; margin: 0; padding-bottom: 8px; }
.auth-card .brand img { width: 52px; height: 52px; }
.auth-card h1 { text-align: center; font-size: 1.3rem; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 20px; font-size: .92rem; }
.qr { background: #fff; border-radius: 8px; padding: 10px; width: 210px; margin: 0 auto; border: 1px solid var(--border); }
.qr svg { width: 100%; height: auto; display: block; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; font-family: ui-monospace, Menlo, monospace; font-size: 1rem; }
.codes div { padding: 8px 12px; border-radius: 6px; background: var(--surface-2); border: 1px dashed var(--border-strong); text-align: center; }

.bottomnav { display: none; }
.scrim { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-side { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 84vw); transform: translateX(-105%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 15, 20, .4); z-index: 35; }
  .menu-btn { display: inline-grid; }
  .main { padding: 0 12px 88px; }
  .topbar { margin: 0 -12px 14px; padding: 0 12px; height: 56px; }
  .topbar .search { max-width: none; }
  .topbar .title { display: none; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .g4.kpis, .g3.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { margin-top: 8px; }
  .card { padding: 14px; }
  h1 { font-size: 1.25rem; }
  .kpi .value { font-size: 1.45rem; }
  .kpi .label { font-size: .72rem; padding-right: 34px; }
  .kpi .ico-bg { width: 28px; height: 28px; right: 10px; top: 10px; }
  .hbar { grid-template-columns: 100px 1fr 46px; }
  .bars { gap: 3px; }
  .bars .bar span { font-size: .58rem; }
  .bars .bar b { font-size: .62rem; }
  .bars .bar:nth-child(even) span { visibility: hidden; }
  .kanban { grid-template-columns: repeat(4, 82vw); scroll-snap-type: x mandatory; }
  .kanban .col { scroll-snap-align: start; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tabs a { white-space: nowrap; }
  table.t.responsive thead { display: none; }
  table.t.responsive, table.t.responsive tbody, table.t.responsive tr, table.t.responsive td { display: block; width: 100%; }
  table.t.responsive tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  table.t.responsive td { border: 0; padding: 2px 0; }
  table.t.responsive td[data-label]::before { content: attr(data-label) ": "; color: var(--faint); font-size: .76rem; font-weight: 600; }
  table.t.responsive td.title-cell::before { content: none; }
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    justify-content: space-around; background: var(--surface); border-top: 1px solid var(--border);
  }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 8px; color: var(--muted); font-size: .67rem; font-weight: 560; position: relative; }
  .bottomnav a .ico { width: 20px; height: 20px; }
  .bottomnav a.on { color: var(--accent); }
  .bottomnav .cnt { position: absolute; top: 2px; right: 20%; background: var(--red); color: #fff; font-size: .6rem; border-radius: 99px; padding: 0 5px; }
  .toasts { top: auto; bottom: 78px; }
  .page-head { align-items: flex-start; }
}

/* ---------- Druck ---------- */
@media print {
  .sidebar, .topbar, .bottomnav, .no-print, .toasts { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .app { display: block; }
  .main { padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  table.t th, table.t td { border-bottom: 1px solid #ccc; color: #000; padding: 5px 6px; background: none; }
  .tag { border: 1px solid #999; color: #000; background: none; }
  a { color: #000; }
}

/* =====================================================================
   Touren
   ===================================================================== */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px; }
.toolbar select { width: auto; min-width: 150px; }
.search-field { position: relative; flex: 1 1 280px; }
.search-field .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 16px; }
.search-field input { padding-left: 34px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg a, .seg button { padding: 7px 12px; font-size: .85rem; font-weight: 560; color: var(--muted); background: var(--surface); border: 0; border-right: 1px solid var(--border); cursor: pointer; font-family: inherit; }
.seg a:last-child, .seg button:last-child { border-right: 0; }
.seg a:hover, .seg button:hover { background: var(--surface-3); color: var(--text); }
.seg .on { background: var(--accent-soft); color: var(--accent); }

.tgroup { margin-bottom: 10px; }
.tgroup > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.tgroup > summary::-webkit-details-marker { display: none; }
.tgroup > summary:hover { background: var(--surface-2); }
.tgroup .chev { width: 18px; color: var(--faint); font-size: 1.2rem; transition: transform .15s; flex: none; text-align: center; }
.tgroup[open] .chev { transform: rotate(90deg); }
.tgroup[open] > summary { border-bottom: 1px solid var(--border); }
.tg-name { flex: 1; min-width: 0; }
.tg-name b { display: block; font-weight: 620; }
.tg-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.tg-last { font-size: .84rem; color: var(--muted); min-width: 120px; text-align: right; }
.cov { display: inline-block; width: 90px; height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; vertical-align: middle; }
.cov.sm { width: 60px; }
.cov i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.cov-n { font-size: .8rem; color: var(--muted); min-width: 36px; }
.tour-table tr.is-due td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.day-badge { display: inline-block; min-width: 30px; padding: 0 6px; margin-right: 6px; border-radius: 5px; background: var(--surface-3); color: var(--text); font-size: .76rem; font-weight: 650; text-align: center; }
.match { color: var(--accent) !important; }

/* Tourdetail */
.tour-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; padding: 0; overflow: hidden; }
.tour-kpis > div { padding: 12px 16px; border-right: 1px solid var(--border); }
.tour-kpis > div:last-child { border-right: 0; }
.tour-kpis .l { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--faint); font-weight: 650; }
.tour-kpis .v { font-size: 1.2rem; font-weight: 650; margin-top: 2px; }
.progress { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: var(--green); }
.daytabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 14px; }
.daytabs a { flex: none; padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: .85rem; line-height: 1.25; }
.daytabs a b { display: block; font-weight: 650; }
.daytabs a small { color: var(--faint); font-size: .74rem; }
.daytabs a.on { border-color: var(--accent); background: var(--accent-soft); }
.daytabs a.on b { color: var(--accent); }
.tour-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.tour-layout .map-col { position: sticky; top: 76px; }
.tour-layout .map { height: calc(100vh - 110px); min-height: 420px; }
.stoplist { padding: 0; }
.stop { border-bottom: 1px solid var(--border); }
.stop:last-child { border-bottom: 0; }
.stop > summary { list-style: none; display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; padding: 10px 14px; cursor: pointer; }
.stop > summary::-webkit-details-marker { display: none; }
.stop > summary:hover, .stop.focus > summary { background: var(--surface-2); }
.stop .num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: var(--surface-3); color: var(--text); }
.stop.done .num { background: var(--green); color: #fff; }
.stop.done .sname { color: var(--muted); }
.stop .sname { font-weight: 600; display: block; line-height: 1.3; }
.stop .sloc { font-size: .8rem; color: var(--faint); }
.stop .icons { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ib { display: inline-grid; place-items: center; height: 22px; min-width: 22px; padding: 0 6px; border-radius: 5px; font-size: .7rem; font-weight: 700; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.ib.termin { background: var(--yellow-bg); color: var(--yellow); }
.ib.rathaus { background: var(--violet-bg); color: var(--violet); }
.ib.rw { background: var(--blue-bg); color: var(--blue); }
.ib.bk-ja { background: var(--green-bg); color: var(--green); }
.ib.bk-tor { background: var(--red-bg); color: var(--red); }
.ib.stale { background: transparent; color: var(--faint); border: 1px dashed var(--border-strong); }
.stop .sdetail { padding: 4px 14px 14px 56px; font-size: .88rem; }
.stop .sdetail .row { margin-top: 8px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); padding: 10px 14px; border-top: 1px solid var(--border); }
.legend span { display: inline-flex; gap: 5px; align-items: center; }

/* Unterwegs */
.next-card { border: 2px solid var(--accent); }
.next-card .lbl { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); font-weight: 700; }
.next-card h2 { font-size: 1.35rem; margin: 4px 0 2px; }
.big-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.big-actions .btn, .big-actions form .btn { width: 100%; padding: 14px 8px; font-size: 1rem; flex-direction: column; gap: 4px; }
.big-actions .btn .ico { width: 22px; height: 22px; }
.big-actions form { margin: 0; }
.map-pin { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font: 700 12px/26px var(--font); text-align: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.map-pin.done { background: var(--green); }
.map-pin.start { background: #1b2430; }
.map-pin.focus { transform: scale(1.35); background: var(--red); z-index: 1000; }

@media (max-width: 1100px) {
  .tour-layout { grid-template-columns: 1fr; }
  .tour-layout .map-col { position: static; }
  .tour-layout .map { height: 320px; min-height: 0; }
  .tour-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tour-kpis > div:nth-child(3) { border-right: 0; }
  .tour-kpis > div:nth-child(-n+3) { border-bottom: 1px solid var(--border); }
}
@media (max-width: 900px) {
  .tgroup > summary { flex-wrap: wrap; }
  .tg-meta { width: 100%; justify-content: flex-start; padding-left: 30px; }
  .tg-last { min-width: 0; text-align: left; }
  .toolbar select { flex: 1; }
  .stop .sdetail { padding-left: 14px; }
}
.trip-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; flex-wrap: wrap; }
.trip-bar .progress { min-width: 120px; }
@media (max-width: 900px) { .page-head .row .btn { padding: 7px 10px; } }
