:root {
  --navy: #16324f; --navy-2: #22476d; --bg: #f3f5f8; --card: #fff; --line: #dfe4ea;
  --text: #1b2430; --muted: #5d6b7a; --ok: #1f8a4c; --ok-bg: #e3f5ea; --bad: #c0392b; --bad-bg: #fdeaea;
  --warn: #a86a00; --warn-bg: #fff3d6; --accent: #f5b83d; --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg);
  -webkit-text-size-adjust: 100%; }
a { color: var(--navy-2); }
h1 { font-size: 1.4rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
p { margin: .3rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }

/* Layout */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: .7rem 1rem; }
.brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; }
.brand img { width: 28px; height: 28px; }
.topnav { display: none; gap: .25rem; flex: 1; }
.topnav a { color: #d7e2ee; text-decoration: none; padding: .45rem .7rem; border-radius: 8px; font-size: .95rem; }
.topnav a.active, .topnav a:hover { background: var(--navy-2); color: #fff; }
.who { margin-left: auto; font-size: .875rem; color: #c8d6e5; display: flex; gap: .6rem; align-items: center; }
.who button { background: transparent; color: #fff; border: 1px solid #5a7896; padding: .3rem .6rem; font-size: .85rem; }
main { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem calc(5.5rem + var(--safe-b)); }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line);
  display: flex; z-index: 10; padding-bottom: var(--safe-b); }
.bottomnav a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: .72rem; padding: .45rem .2rem .5rem; position: relative; }
.bottomnav a .ico { display: block; font-size: 1.3rem; line-height: 1.4; }
.bottomnav a.active { color: var(--navy); font-weight: 600; }
.dot { display: inline-block; min-width: 1.15rem; padding: 0 .3rem; border-radius: 1rem; background: var(--bad); color: #fff;
  font-size: .7rem; line-height: 1.15rem; font-weight: 700; text-align: center; }
.bottomnav .dot { position: absolute; top: .2rem; left: 55%; }
@media (min-width: 820px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  main { padding-bottom: 2rem; }
}

/* Karten & Raster */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: .8rem; }
.card.link { cursor: pointer; }
.card.link:hover { border-color: #b8c4d1; }
.grid { display: grid; gap: .8rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem; text-align: center; }
.stat b { display: block; font-size: 1.5rem; color: var(--navy); }
.stat span { font-size: .8rem; color: var(--muted); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.empty { color: var(--muted); padding: .8rem 0; }
.list-item { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.clickable { cursor: pointer; }

/* Badges */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 1rem; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.neutral { background: #eaeef3; color: var(--muted); }
.checks-mini { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }

/* Formulare */
label { display: block; font-weight: 600; margin: .8rem 0 .3rem; }
input, select, textarea { width: 100%; font: inherit; padding: .7rem .75rem; border: 1px solid #c4ced8; border-radius: 10px; background: #fff; color: inherit; }
textarea { min-height: 4.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
button, .btn { font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: .7rem 1rem; cursor: pointer;
  background: var(--navy); color: #fff; text-decoration: none; display: inline-block; text-align: center; }
button:disabled { opacity: .55; cursor: default; }
button.secondary, .btn.secondary { background: #e6ebf1; color: var(--navy); }
button.danger { background: var(--bad); }
button.success { background: var(--ok); }
button.small, .btn.small { padding: .4rem .7rem; font-size: .875rem; }
button.block { width: 100%; padding: .95rem; font-size: 1.05rem; }
.error { color: var(--bad); background: var(--bad-bg); padding: .6rem .8rem; border-radius: 10px; margin: .6rem 0; }
.hint { background: var(--warn-bg); color: #6d4b00; padding: .7rem .9rem; border-radius: 10px; margin: .6rem 0; }
.info { background: #e7f0fa; color: #1c4167; padding: .7rem .9rem; border-radius: 10px; margin: .6rem 0; }

/* Segment-Auswahl (ok / nicht ok, Dieselstand) */
.seg { display: flex; gap: .4rem; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label { flex: 1; margin: 0; text-align: center; padding: .75rem .3rem; border: 2px solid #c4ced8; border-radius: 10px;
  background: #fff; cursor: pointer; font-weight: 600; user-select: none; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.seg label.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.seg label.on.ok { border-color: var(--ok); background: var(--ok); }
.seg label.on.bad { border-color: var(--bad); background: var(--bad); }
.check-row { padding: .8rem 0; border-top: 1px solid var(--line); }
.check-row:first-of-type { border-top: 0; }
.check-row .title { font-weight: 600; margin-bottom: .45rem; }
.refill { margin-top: .6rem; padding: .7rem; background: var(--bad-bg); border-radius: 10px; }
.refill .title { font-size: .92rem; }

/* Login */
.auth { max-width: 380px; margin: 8vh auto 0; padding: 0 1rem; }
.auth .logo { text-align: center; margin-bottom: 1rem; }
.auth .logo img { width: 64px; height: 64px; }

/* Tabellen (Desktop) */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .3px; }
tr.clickable:hover td { background: #f7f9fb; }

/* Dialog */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 1.5rem)); max-height: calc(100vh - 2rem); }
dialog::backdrop { background: rgba(10, 25, 40, .45); }
#modal-body { padding: 1.2rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.cred { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.1rem; background: #f0f3f7; padding: .7rem .9rem; border-radius: 10px; margin: .3rem 0; word-break: break-all; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(5rem + var(--safe-b)); background: #1b2430; color: #fff;
  padding: .7rem 1.1rem; border-radius: 10px; z-index: 50; max-width: calc(100vw - 2rem); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
@media (min-width: 820px) { .toast { bottom: 2rem; } }
.tabs { display: flex; gap: .4rem; margin-bottom: .8rem; flex-wrap: wrap; }
.tabs button { background: #e6ebf1; color: var(--navy); padding: .45rem .8rem; font-size: .9rem; }
.tabs button.on { background: var(--navy); color: #fff; }
.success-box { text-align: center; padding: 2rem 1rem; }
.success-box .big { font-size: 3rem; }
input[type=checkbox], input[type=radio] { width: auto; }
.role-select { width: auto; }
