:root {
  color-scheme: light;
  /* Farbwelt wie TDAY (absolutGPS) */
  --ink: #17352f;
  --ink-soft: #55706a;
  --muted: #55706a;
  --bg: #eaf4f1;
  --surface: #ffffff;
  --surface-soft: #f3f8f6;
  --line: #dce8e4;
  --accent: #176d65;
  --accent-strong: #153b59;
  --accent-soft: #e3f4ef;
  --teal: #287c73;
  --cyan: #27b4df;
  --green: #6cc67e;
  --lime: #bed31f;
  --ok: #216c55;
  --warn: #b56a00;
  --bad: #a62e3b;
  --via: #7b3fa0;
  --radius: 0.85rem;
  --shadow: 0 12px 35px rgb(22 71 64 / 10%);
  --shadow-strong: 0 24px 70px rgb(12 67 63 / 22%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--ink-soft); }
.error { color: var(--bad); }
.small { font-size: 13px; }

/* Marke */
.brand { display: inline-flex; align-items: center; gap: 0.8rem; color: var(--ink); text-decoration: none; }
.company-logo { display: block; width: 5.2rem; height: auto; }
.product-name { padding-left: 0.8rem; border-left: 1px solid var(--line); font-size: 0.82rem; font-weight: 850; letter-spacing: 0.14em; }

/* Login wie TDAY */
.login {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 1.25rem; z-index: 50;
  background:
    radial-gradient(circle at 78% 12%, rgb(214 238 37 / 74%), transparent 30rem),
    radial-gradient(circle at 20% 90%, rgb(31 176 229 / 82%), transparent 34rem),
    linear-gradient(145deg, #62c1b2 4%, #76c77f 50%, #b8d51e 100%);
}
.login-card {
  width: min(100%, 27rem); padding: clamp(1.85rem, 7vw, 2.5rem);
  border: 1px solid rgb(255 255 255 / 70%); border-radius: 1.5rem;
  background: rgb(255 255 255 / 97%); box-shadow: var(--shadow-strong);
  display: grid; gap: 14px;
}
.login-card > .brand { width: 100%; justify-content: center; }
.login-card .company-logo { width: 5.65rem; }
.login-copy { margin: 1.4rem auto 0.6rem; text-align: center; }
.login-copy h1 { margin: 0 auto 0.5rem; font-size: clamp(1.55rem, 6vw, 2rem); font-weight: 650; line-height: 1.2; letter-spacing: -0.035em; }
.login-copy p:last-child { margin: 0; color: var(--ink-soft); line-height: 1.55; }
.eyebrow { margin: 0 0 0.5rem; color: #248f83; font-size: 0.74rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.error-message { margin: 0; color: var(--bad); font-weight: 700; font-size: 0.85rem; }
.primary-button {
  display: flex; width: 100%; min-height: 3.3rem; align-items: center; justify-content: center; margin-top: 4px;
  border: 0; border-radius: 999px; background: var(--accent-strong); color: #fff; cursor: pointer;
  font-size: 1rem; font-weight: 650; transition: transform 150ms ease, box-shadow 150ms ease;
}
.primary-button:hover { box-shadow: 0 10px 24px rgb(21 59 89 / 22%); transform: translateY(-1px); }

label { display: grid; gap: 5px; font-size: 13px; font-weight: 650; color: var(--ink); }
label > input, label > select, label > textarea { font-size: 15px; font-weight: 500; }
input, select, textarea { min-height: 2.6rem; border: 1px solid var(--line); border-radius: 0.55rem; padding: 0.5rem 0.65rem; background: #fff; color: var(--ink); min-width: 0; font-weight: 500; }
textarea { min-height: 70px; resize: vertical; }
input[type="color"] { padding: 3px; }
input[type="checkbox"] { min-height: 0; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 3px solid rgb(47 184 205 / 30%); outline-offset: 0; border-color: #6ab7ad; }

/* Buttons wie TDAY-Aktionen */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.45rem;
  padding: 0.5rem 0.85rem; border: 1px solid var(--line); border-radius: 0.55rem; background: #fff;
  color: var(--ink); font-size: 0.86rem; font-weight: 760; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: border-color 160ms ease, background-color 160ms ease;
}
.btn:hover { border-color: #8bcfc5; background: #f7fcfb; }
.btn:focus-visible { outline: 3px solid rgb(47 184 205 / 35%); outline-offset: 2px; }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; border-radius: 999px; padding: 0.5rem 1.1rem; }
.btn.primary:hover { background: #1d4c72; }
.btn.ok { border-color: #6ab7ad; color: var(--accent); background: #fff; }
.btn.ok:hover { background: #eef9f6; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: #e2b0b5; background: #fff8f8; }
.btn.small { min-height: 2rem; padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn.active { background: var(--accent-soft); border-color: #6ab7ad; color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 0.5rem; color: var(--ink-soft); min-height: 0; }
.icon-btn:hover { background: var(--surface-soft); color: var(--ink); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Topbar */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: 60px; display: flex; align-items: center; gap: 20px; padding: 0 18px; background: rgb(255 255 255 / 96%); border-bottom: 1px solid var(--line); z-index: 20; }
.search { position: relative; flex: 0 1 380px; }
.search input { width: 100%; }
.search-results { position: absolute; top: 46px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 60vh; overflow: auto; }
.search-results button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; cursor: pointer; }
.search-results button:hover, .search-results button.focus { background: var(--accent-soft); }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav-btn { border: 0; background: none; padding: 8px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; color: var(--teal); font-weight: 750; }
.nav-btn:hover { background: var(--surface-soft); }
.nav-btn.active { background: #dff3e8; color: var(--ok); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #17211d; color: #fff; font-size: 12px; line-height: 18px; text-align: center; }
.badge:empty { display: none; }
.me { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

/* Layout */
.layout { position: fixed; top: 60px; left: 0; right: 0; bottom: 0; display: flex; }
.map { flex: 1; position: relative; }
.panel { width: 460px; max-width: 100vw; background: var(--surface-soft); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.panel { position: relative; }
.panel-resize { position: absolute; left: -5px; top: 0; bottom: 0; width: 10px; cursor: col-resize; z-index: 6; touch-action: none; }
.panel-resize::after { content: ""; position: absolute; left: 4px; top: 50%; width: 2px; height: 44px; margin-top: -22px; border-radius: 2px; background: var(--line); transition: background 120ms ease, height 120ms ease; }
.panel-resize:hover::after, .panel-resize.dragging::after { background: #6ab7ad; height: 72px; margin-top: -36px; }
body.resizing { cursor: col-resize; user-select: none; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.panel-title { flex: 1; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-body { overflow: auto; padding: 16px 18px; display: grid; gap: 14px; align-content: start; }
.section { display: grid; gap: 8px; }
.section h3 { margin: 0; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.14em; color: #248f83; font-weight: 800; }
.card { border: 1px solid var(--line); border-radius: 1.15rem; padding: 14px 16px; display: grid; gap: 8px; background: var(--surface); box-shadow: var(--shadow); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 13px; cursor: pointer; font-size: 13px; font-weight: 700; color: var(--ink-soft); min-height: 0; }
.tab.active { background: #17211d; color: #fff; border-color: #17211d; }

.list { display: grid; gap: 4px; }
.item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 0.7rem; cursor: pointer; background: var(--surface); border: 1px solid transparent; }
.item:hover { border-color: var(--line); box-shadow: 0 6px 18px rgb(22 71 64 / 6%); }
.item.sel { background: var(--accent-soft); }
.item .grow { min-width: 0; }
.item .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 0.74rem; font-weight: 800; background: #eef2f0; color: var(--ink-soft); white-space: nowrap; }
.pill.offen { background: #f3f1e4; color: #746a2f; }
.pill.klaeren { background: #f7e7e2; color: #914a35; }
.pill.abgestimmt, .pill.geklaert, .pill.bestaetigt { background: #dff3e8; color: #216c55; }
.pill.vorschlag { background: #f1e9f7; color: #5d2b7d; }
.pill.verworfen { background: #eee; color: #777; text-decoration: line-through; }
.pill.bestand { background: #e8f0fb; color: #1f5fbf; }
.pill.bedarf { background: #e3f4ea; color: #146c3a; }
.pill.entfall { background: #fde8e8; color: #9b1c1c; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }

/* Prüfliste der Zielspinne */
.check { display: grid; gap: 6px; padding: 10px 12px; border-radius: 0.8rem; border: 1px solid var(--line); border-left: 4px solid var(--line); background: var(--surface); }
.check.fehlt { border-left-color: var(--bad); }
.check.richtung { border-left-color: var(--warn); }
.check.unerreichbar { border-left-color: #6b21a8; }
.check.fuehrt { border-left-color: var(--ok); }
.check .head { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check .head b { flex: 1; font-weight: 600; }
.counts { display: flex; gap: 6px; flex-wrap: wrap; }
.count { padding: 6px 12px; border-radius: 999px; font-size: 13px; background: var(--surface); border: 1px solid var(--line); }
.count b { font-size: 15px; }
.count.fehlt b { color: var(--bad); }
.count.richtung b { color: var(--warn); }
.count.fuehrt b { color: var(--ok); }

/* Schildtafel */
.board { display: grid; gap: 10px; }
.arm { border: 1px solid var(--line); border-radius: 0.9rem; overflow: hidden; background: var(--surface); }
.arm-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: linear-gradient(145deg, #f1faf8, #f6f9ea); font-weight: 700; }
.arm-head .dir { width: 30px; height: 30px; border-radius: 0.6rem; display: grid; place-items: center; background: linear-gradient(145deg, #e3f7f4, #eef6cf); color: #217c73; font-size: 13px; font-weight: 850; }
.entry { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; padding: 6px 10px; border-top: 1px solid var(--line); align-items: center; }
.entry.unknown input { border-color: var(--warn); background: #fff8ef; }
.entry .tools { display: flex; gap: 0; }
.entry .tools .icon-btn { padding: 2px 5px; font-size: 14px; }

/* Legende & Modusleiste */
.legend { position: fixed; left: 14px; bottom: 28px; background: rgb(255 255 255 / 96%); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); padding: 10px 12px; display: grid; gap: 5px; font-size: 13px; z-index: 5; max-width: 260px; }
.legend label { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; font-weight: 500; cursor: pointer; }
.legend .sym { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); flex: none; }
.legend .line { width: 18px; height: 4px; border-radius: 2px; flex: none; }
.legend input { margin: 0; }
.legend hr { border: 0; border-top: 1px solid var(--line); margin: 3px 0; width: 100%; }
.modebar { position: fixed; top: 74px; left: 50%; transform: translateX(-50%); background: #17211d; color: #fff; border-radius: 20px; padding: 8px 8px 8px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow); z-index: 15; font-size: 14px; }
.modebar .btn { background: #fff; color: var(--ink); border: 0; border-radius: 14px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #17211d; color: #fff; padding: 11px 18px; border-radius: 999px; box-shadow: var(--shadow); z-index: 60; display: flex; gap: 12px; align-items: center; }
.toast.err { background: var(--bad); }
.toast button { background: none; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 6px; padding: 2px 8px; cursor: pointer; }

.loading { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; z-index: 40; color: var(--ink-soft); background: radial-gradient(circle at 100% 0, rgb(190 211 31 / 20%), transparent 26rem), linear-gradient(180deg, #f8fbfa 0%, #eaf4f1 100%); }
.spinner { width: 36px; height: 36px; border: 4px solid var(--line); border-top-color: var(--cyan); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.drag-marker { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--ink), var(--shadow); cursor: grab; }
.maplibregl-popup-content { padding: 8px 10px; font-size: 13px; border-radius: 6px; }
.history-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
.history-item.undone { opacity: .5; }
.history-item .meta { font-size: 12px; color: var(--muted); }
table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
table.users td, table.users th { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }

@media (max-width: 900px) {
  .search { display: none; }
  .panel { position: absolute; right: 0; top: 0; bottom: 0; width: 100% !important; z-index: 10; }
  .panel-resize { display: none; }
  .nav-btn { padding: 8px 6px; font-size: 13px; }
  .brand { display: none; }
}
