/* Invens – dunkles Design nach Apple Human Interface Guidelines (iOS Dark Mode) */
:root {
  color-scheme: dark;
  /* iOS-Systemfarben (dunkel) */
  --bg: #000000;                         /* systemBackground */
  --bg-2: #1c1c1e;                       /* secondarySystemGroupedBackground */
  --bg-3: #2c2c2e;                       /* tertiarySystemBackground */
  --fill: rgba(118, 118, 128, 0.24);     /* tertiarySystemFill */
  --fill-2: rgba(120, 120, 128, 0.36);   /* systemFill */
  --label: #ffffff;
  --label-2: rgba(235, 235, 245, 0.6);   /* secondaryLabel */
  --label-3: rgba(235, 235, 245, 0.3);   /* tertiaryLabel */
  --sep: rgba(84, 84, 88, 0.65);         /* separator */
  --blue: #0a84ff;
  --orange: #ff9f0a;
  --red: #ff453a;
  --green: #30d158;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font: 17px/1.35 var(--font); letter-spacing: -0.01em;
  background: var(--bg); color: var(--label);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}
a { color: var(--blue); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--label-2); }
.center { text-align: center; }
.small { font-size: 13px; }

/* Navigationsleiste (transluzent) */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(22, 22, 24, 0.78);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--sep);
}
.brand { color: var(--label); font-weight: 600; font-size: 17px; }
#topbar-sub { position: absolute; right: 16px; }
#topbar-sub:empty { display: none; }

/* Kennzahlen-Leiste */
.stats {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px 2px; max-width: 760px; margin: 0 auto;
  scrollbar-width: none;
}
.stats::-webkit-scrollbar { display: none; }
.stat {
  flex: 0 0 auto; font-size: 13px; color: var(--label-2);
  background: var(--bg-2); border-radius: 20px; padding: 5px 11px; white-space: nowrap;
}
.stat b { color: var(--label); font-weight: 600; font-variant-numeric: tabular-nums; }
.stat.warn b { color: var(--orange); }
.stat.alarm { background: rgba(255, 69, 58, 0.18); color: var(--red); }
.stat.alarm b { color: var(--red); }

/* Tags (Kapseln) */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500; line-height: 1.2;
  padding: 3px 8px; border-radius: 6px;
  background: var(--fill); color: var(--label-2);
}
.tag-ocker { background: rgba(255, 159, 10, 0.18); color: var(--orange); }
.tag-rot { background: rgba(255, 69, 58, 0.2); color: var(--red); }
.tag-light { background: var(--fill); color: var(--label-2); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-edit { background: rgba(10, 132, 255, 0.18); color: #64aaff; font-size: 14px; padding: 4px 4px 4px 10px; }
.tag-x {
  border: 0; background: rgba(255, 255, 255, 0.12); color: var(--label); width: 20px; height: 20px; border-radius: 10px;
  font-size: 13px; line-height: 20px; padding: 0; cursor: pointer;
}

main { max-width: 760px; margin: 0 auto; padding: 8px 16px 16px; }
h1 { font: 700 34px/1.15 var(--font-display); letter-spacing: 0.01em; margin: 10px 0 16px; }
h2 {
  font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: 0.02em;
  color: var(--label-2); margin: 26px 16px 7px;
}

/* Karten / gruppierte Zellen */
.card {
  background: var(--bg-2); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
}
.card.away { box-shadow: inset 3px 0 0 var(--orange); }
.card.overdue { box-shadow: inset 3px 0 0 var(--red); }
.item-card { display: flex; gap: 12px; align-items: center; color: inherit; padding: 10px 14px 10px 10px; }
.item-card:active { background: var(--bg-3); }
.item-card .thumb {
  width: 60px; height: 60px; flex: 0 0 60px; border-radius: 9px; object-fit: cover;
  background: var(--bg-3); display: flex; align-items: center; justify-content: center;
  color: var(--label-3); font-size: 22px;
}
.item-card .body { min-width: 0; flex: 1; }
.item-card .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-card .meta { margin-top: 5px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.item-card::after { content: '›'; color: var(--label-3); font-size: 24px; margin-left: 4px; }
.card.group { padding: 0; overflow: hidden; }
.card.group .item-card { padding: 10px 14px 10px 10px; }
.card-actions { border-top: 0.5px solid var(--sep); padding: 8px 10px; }

/* Formulare */
label { display: block; font-size: 13px; color: var(--label-2); margin: 14px 4px 6px; }
.label-row { display: flex; justify-content: space-between; align-items: center; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 17px; padding: 11px 14px;
  border: 0; border-radius: 10px; background: var(--bg-2); color: var(--label);
  -webkit-appearance: none; appearance: none;
}
.card input, .card select, .card textarea { background: var(--bg-3); }
input::placeholder, textarea::placeholder { color: var(--label-3); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--label-2) 50%), linear-gradient(135deg, var(--label-2) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
  padding-right: 34px;
}
input[type="date"] { min-height: 44px; }
input[type="search"] { background: var(--fill); padding-left: 14px; }
textarea { min-height: 96px; resize: vertical; }
.tag-input { padding: 8px 12px; font-size: 15px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.row-tight { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 8px; }
details { margin-top: 14px; }
summary { cursor: pointer; color: var(--blue); font-size: 15px; padding: 4px; }
.link-btn { border: 0; background: none; color: var(--blue); font: inherit; font-size: 13px; cursor: pointer; padding: 0; }
.link-btn:disabled { opacity: .4; }

/* Buttons (iOS-Stil) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
  font: inherit; font-size: 17px; font-weight: 600; padding: 10px 18px; border-radius: 12px;
  border: 0; background: var(--fill); color: var(--blue); cursor: pointer;
}
.btn:active { opacity: .7; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.ocker { background: var(--orange); color: #1a1000; }
.btn.ghost { background: var(--fill); color: var(--blue); }
.btn.danger { background: rgba(255, 69, 58, 0.16); color: var(--red); }
.btn.small { min-height: 32px; padding: 5px 12px; font-size: 15px; font-weight: 500; border-radius: 9px; }
.btn.block { width: 100%; }
.btn.active { background: var(--red); color: #fff; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.actions .btn { flex: 1; }

/* Segmente / Filter */
.chips { display: flex; gap: 2px; margin: 12px 0; padding: 2px; background: var(--fill); border-radius: 9px; overflow-x: auto; }
.chip {
  flex: 1; font: inherit; font-size: 13px; font-weight: 500;
  padding: 6px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--label); cursor: pointer; white-space: nowrap;
}
.chip.on { background: #636366; box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); }

/* Fotos */
.photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .photos { grid-template-columns: repeat(4, 1fr); } }
.photo { position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--bg-2); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .badge { position: absolute; top: 8px; left: 8px; background: rgba(0, 0, 0, .55); color: var(--orange); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.photo .tools { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 6px; padding: 8px; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.photo .tools .btn { flex: 1; min-height: 32px; padding: 4px; font-size: 14px; background: rgba(40, 40, 42, .8); color: #fff; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.photo.empty {
  display: flex; align-items: center; justify-content: center; cursor: pointer; margin: 0;
  color: var(--blue); font-size: 14px; text-align: center; padding: 8px; border: 1.5px dashed var(--fill-2);
}
.photo.empty input { display: none; }

/* Orte */
.loc-head { display: flex; align-items: center; gap: 8px; padding-bottom: 6px; }
.loc-head .name { font-weight: 600; flex: 1; font-size: 17px; }
.sub-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-top: 0.5px solid var(--sep); }
.sub-row .name { flex: 1; color: var(--label); }
.sub-row .name::after { content: ' ›'; color: var(--label-3); }

/* Tab-Leiste unten (transluzent) */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; padding: 6px 0 calc(4px + env(safe-area-inset-bottom));
  background: rgba(22, 22, 24, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tabs a { flex: 1; text-align: center; color: #8e8e93; font-size: 10px; font-weight: 500; padding: 2px; }
.tabs a .ico { display: block; font-size: 22px; line-height: 28px; }
.tabs a.on { color: var(--blue); }

/* Hinweis (HUD) */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(12px);
  background: rgba(58, 58, 60, 0.92); color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 15px;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90vw; z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: rgba(255, 69, 58, 0.95); }

/* Desktop / großer Bildschirm: Navigation oben in der Kopfzeile statt unten */
@media (min-width: 820px) and (hover: hover) {
  body { padding-bottom: 24px; }
  .topbar { justify-content: flex-start; padding: 0 24px; height: 52px; }
  #topbar-sub { position: static; margin-left: 4px; }
  .tabs {
    top: 0; bottom: auto; left: auto; right: 24px; z-index: 11;
    height: 52px; padding: 0; gap: 4px; align-items: center;
    background: transparent; border: 0;
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .tabs a {
    flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
    font-size: 14px; padding: 6px 12px; border-radius: 8px; color: var(--label-2);
  }
  .tabs a .ico { display: inline; font-size: 15px; line-height: 1; }
  .tabs a:hover { background: var(--fill); color: var(--label); }
  .tabs a.on { background: var(--fill); color: var(--blue); }
  .toast { bottom: 32px; }
  main, .stats { padding-left: 24px; padding-right: 24px; }
}

/* Nachrichten / Admin */
.stat.info { background: rgba(10, 132, 255, 0.2); color: #64aaff; }
.stat.info b { color: #fff; }
.stat-link { cursor: pointer; }
.tag-blau { background: rgba(10, 132, 255, 0.2); color: #64aaff; }
.tabs a { position: relative; }
.badge-count {
  position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}
@media (min-width: 820px) and (hover: hover) { .badge-count { position: static; margin-left: 4px; } }
.msgs { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 12px; }
.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.them { align-self: flex-start; align-items: flex-start; }
.bubble { padding: 9px 14px; border-radius: 18px; white-space: pre-wrap; word-break: break-word; font-size: 16px; }
.msg.me .bubble { background: var(--blue); color: #fff; border-bottom-right-radius: 5px; }
.msg.them .bubble { background: var(--bg-3); color: var(--label); border-bottom-left-radius: 5px; }
.msg-meta { font-size: 11px; color: var(--label-3); margin: 3px 6px 0; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer .compose { min-height: 44px; height: 44px; resize: none; flex: 1; border-radius: 22px; padding: 11px 16px; }
.composer .compose:focus { height: 96px; }
.composer .btn { border-radius: 22px; }
.avatar { font-weight: 700; font-size: 22px; color: var(--blue) !important; border-radius: 30px !important; }
.user-card.disabled { opacity: .6; }
.h1-small { font-size: 26px; word-break: break-all; }

.login { max-width: 400px; margin: 40px auto; }
.login .card { padding: 22px 20px; }
.login h1 { margin-top: 0; }
.empty-state { text-align: center; padding: 40px 10px; color: var(--label-2); }
.kv { display: flex; justify-content: space-between; gap: 10px; }
