/* Avyronis Go – Design-System (mobile-first, ruhig, professionell, barrierearm) */
:root {
  --brand: #16a34a;
  --brand-dark: #15803d;
  --brand-050: #f0fdf4;
  --brand-100: #dcfce7;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e5e7eb;
  --line-2: #eef2f6;
  --bg: #f6f8fa;
  --surface: #ffffff;
  --danger: #dc2626;
  --danger-050: #fef2f2;
  --warn: #b45309;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --tap: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font-family: inherit; font-size: inherit; cursor: pointer; }
a { color: var(--brand-dark); }

/* App-Shell */
#app { display: flex; flex-direction: column; min-height: 100%; }
.app-header {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-top) + 14px) 16px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.app-header .brand-badge { width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto; }
.app-header h1 { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.app-header .sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.app-header .hstack { display: flex; flex-direction: column; }
.app-header .spacer { flex: 1; }

main {
  flex: 1;
  padding: 18px 16px calc(96px + var(--safe-bottom));
  max-width: 640px; width: 100%; margin: 0 auto;
}

/* Bottom-Navigation (max. 4, immer mit Text) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.bottom-nav button {
  border: 0; background: transparent; color: var(--muted);
  min-height: 58px; padding: 8px 4px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11.5px; font-weight: 600;
}
.bottom-nav button .ic { width: 24px; height: 24px; display: block; }
.bottom-nav button[aria-current="page"] { color: var(--brand-dark); }
.bottom-nav button:active { background: var(--line-2); }

/* Typo-Bausteine */
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 16px; }
.section-label { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 22px 2px 10px; }
.greeting { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 2px; }
.greeting-sub { color: var(--muted); margin: 0 0 18px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 54px; padding: 0 18px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 700; font-size: 16px; letter-spacing: -.01em;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow); }
.btn-primary:active { background: var(--brand-dark); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:active { background: var(--line-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn[disabled] { opacity: .55; }
/* Inline-Icons in Buttons/Hinweisen/Listen fest dimensionieren (sonst dehnen sie sich auf). */
.btn > svg { width: 20px; height: 20px; flex: 0 0 auto; }
.pill-hint > svg { width: 22px; height: 22px; flex: 0 0 auto; margin-top: 1px; }
.list-item > svg, .list-item .chev { width: 20px; height: 20px; flex: 0 0 auto; color: var(--muted); }

/* Karten & Kacheln */
.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; min-height: 108px; text-align: left;
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  box-shadow: var(--shadow);
}
.tile:active { transform: translateY(1px); }
.tile .ic-wrap { width: 40px; height: 40px; border-radius: 11px; background: var(--brand-050); color: var(--brand-dark); display: flex; align-items: center; justify-content: center; }
.tile .ic-wrap svg { width: 22px; height: 22px; }
.tile .label { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.tile.primary { grid-column: 1 / -1; min-height: 96px; background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); border-color: transparent; color: #fff; flex-direction: row; align-items: center; gap: 14px; }
.tile.primary .ic-wrap { background: rgba(255,255,255,.18); color: #fff; width: 46px; height: 46px; }
.tile.primary .ic-wrap svg { width: 26px; height: 26px; }
.tile.primary .label { font-size: 18px; }
.tile.primary .hint { font-size: 12.5px; opacity: .9; font-weight: 600; }
.tile.primary .col { display: flex; flex-direction: column; gap: 2px; }

/* Karte / Liste */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card + .card { margin-top: 12px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 15px 16px; min-height: var(--tap); border-bottom: 1px solid var(--line-2); text-align: left; width: 100%; background: transparent; border-left: 0; border-right: 0; border-top: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item:active { background: var(--line-2); }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 650; font-size: 15px; }
.list-item .li-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.list-item .chev { color: var(--muted); flex: 0 0 auto; }

.stat-row { display: flex; gap: 12px; margin-bottom: 4px; }
.stat { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .num { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.stat .lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat.warn .num { color: var(--warn); }

.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--brand-100); color: var(--brand-dark); }
.badge.overdue { background: var(--danger-050); color: var(--danger); }

/* Formulare */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 650; font-size: 14px; margin-bottom: 7px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.input {
  width: 100%; min-height: 52px; padding: 0 15px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 16px; background: var(--surface); color: var(--ink);
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-050); }

/* Sticky-Aktion am Formularende */
.sticky-actions { position: sticky; bottom: 0; padding: 12px 0 calc(12px + var(--safe-bottom)); background: linear-gradient(to top, var(--bg) 72%, transparent); }

/* Zustände */
.state { text-align: center; padding: 48px 24px; color: var(--muted); }
.state .state-ic { width: 56px; height: 56px; margin: 0 auto 14px; color: var(--brand); opacity: .85; }
.state h2 { color: var(--ink); font-size: 18px; margin: 0 0 6px; }
.state p { margin: 0 auto 18px; max-width: 30ch; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login-wrap { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: calc(var(--safe-top) + 24px) 22px calc(var(--safe-bottom) + 24px); max-width: 440px; margin: 0 auto; }
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand img { width: 68px; height: 68px; border-radius: 18px; box-shadow: var(--shadow); }
.login-brand .t { font-size: 22px; font-weight: 800; margin-top: 12px; letter-spacing: -.02em; }
.login-brand .s { color: var(--muted); font-size: 14px; }
.alert { background: var(--danger-050); color: var(--danger); border: 1px solid #fecaca; border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; font-weight: 600; margin-bottom: 14px; }

/* Wizard „Ereignis melden" */
.wiz-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: calc(var(--safe-top) + 12px) 16px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.wiz-x { border: 0; background: transparent; color: var(--muted); width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 9px; }
.wiz-x svg { width: 20px; height: 20px; transform: scaleX(-1); }
.wiz-x:active { background: var(--line-2); }
.wiz-progress { flex: 1; height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.wiz-bar { height: 100%; background: var(--brand); border-radius: 999px; transition: width .25s ease; }
.wiz-count { font-size: 12.5px; color: var(--muted); font-weight: 600; flex: 0 0 auto; }
.wiz-main { flex: 1; padding: 18px 16px 96px; max-width: 640px; width: 100%; margin: 0 auto; }
.wiz-actions { position: sticky; bottom: 0; display: flex; gap: 12px; padding: 12px 16px calc(12px + var(--safe-bottom)); background: var(--surface); border-top: 1px solid var(--line); max-width: 640px; margin: 0 auto; width: 100%; }

.opt-list { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 58px; padding: 0 16px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-weight: 650; font-size: 15.5px; text-align: left; color: var(--ink); }
.opt.sel { border-color: var(--brand); background: var(--brand-050); }
.opt .opt-check { width: 22px; height: 22px; color: var(--brand-dark); flex: 0 0 auto; }
.opt:active { background: var(--line-2); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 600; font-size: 14.5px; color: var(--ink-2); }
.chip.sel { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip:active { transform: translateY(1px); }
.textarea { min-height: 120px; padding: 12px 15px; line-height: 1.5; resize: vertical; }
.muted-note { color: var(--muted); font-weight: 500; font-size: 12.5px; }

.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.thumb { position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); background: var(--line-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-x { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(15,23,42,.62); color: #fff; font-size: 18px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.thumb.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 1.5px dashed var(--brand); color: var(--brand-dark); background: var(--brand-050); font-size: 12px; font-weight: 650; text-align: center; padding: 8px; cursor: pointer; }
.thumb.add svg { width: 26px; height: 26px; }

.rev { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.rev:last-child { border-bottom: 0; }
.rev-main { flex: 1; min-width: 0; }
.rev-l { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.rev-v { font-size: 15px; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.rev-edit { flex: 0 0 auto; border: 0; background: transparent; color: var(--brand-dark); font-weight: 700; font-size: 13.5px; padding: 4px 6px; }

.ticket { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; margin: 4px auto 0; padding: 12px 22px; background: var(--brand-050); border: 1px solid var(--brand-100); border-radius: var(--radius); }
.ticket-l { font-size: 12px; color: var(--muted); font-weight: 600; }
.ticket-n { font-size: 22px; font-weight: 800; letter-spacing: -.01em; color: var(--brand-dark); }
.state-ic.success { color: var(--brand); }

.hidden { display: none !important; }
.emergency-call { background: var(--danger); color: #fff; }
.pill-hint { display:flex; gap:10px; align-items:flex-start; background: var(--brand-050); border:1px solid var(--brand-100); color: var(--ink-2); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13.5px; }
.pill-hint > span { align-self: center; }
.pill-hint.ok { margin-top: 12px; }
.pill-hint.warn { background: var(--danger-050); border-color: #fecaca; color: var(--danger); }

/* ── WP5: Maßnahmen · Dokumente · Unterweisungen ─────────────────────────── */
.list-item.tap { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.li-icon { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px; background: var(--brand-050); color: var(--brand-dark); display: grid; place-items: center; }
.li-icon svg { width: 19px; height: 19px; }
.li-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 6px; }
.li-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); }
.li-tag > svg { width: 13px; height: 13px; flex: 0 0 auto; }
.li-tag.due-over { color: var(--danger); font-weight: 650; }
.li-tag.imp { color: var(--brand-dark); font-weight: 700; }
.m-status { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.m-status.s-OFFEN { background: #eef4ff; color: #1d4ed8; }
.m-status.s-IN_BEARBEITUNG { background: #fff7ed; color: #b45309; }
.m-status.s-VERSCHOBEN { background: #f1f5f9; color: #475569; }
.m-status.s-ABGESCHLOSSEN, .m-status.s-WIRKSAM_GEPRUEFT, .m-status.s-BESTANDEN { background: var(--brand-100); color: var(--brand-dark); }
.m-status.s-VERWORFEN, .m-status.s-DURCHGEFALLEN { background: var(--danger-050); color: var(--danger); }
.m-status.s-NICHT_BEGONNEN { background: var(--line-2); color: var(--ink-2); }
.card.pad { padding: 16px; }
.detail-title { font-size: 18px; font-weight: 800; letter-spacing: -.01em; line-height: 1.3; }
.detail-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
.detail-text { font-size: 15px; line-height: 1.55; color: var(--ink-2); white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.section-h { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 4px 2px 12px; }
.cat-h { font-size: 13.5px; font-weight: 700; color: var(--ink-2); margin: 16px 2px 8px; }
.cat-h:first-of-type { margin-top: 4px; }
