/* Portal: ruhige Schiefer-Töne, Apps bringen ihre eigene Farbe mit */
:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --surface-2: #e7e9ee;
  --fg: #1a1d24;
  --muted: #5f6573;
  --line: #d9dce3;
  --accent: #34507a;
  --accent-soft: #dfe6f2;
  --on-accent: #ffffff;
  --ok: #2f8a4c;
  --warn: #b7791f;
  --danger: #c2412d;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141a;
    --surface: #1b1e26;
    --surface-2: #252935;
    --fg: #e7e9ef;
    --muted: #9aa1b0;
    --line: #2f3442;
    --accent: #8fb0e3;
    --accent-soft: #233149;
    --on-accent: #0d1420;
    --ok: #5cc27a;
    --warn: #e0a64a;
    --danger: #ef7a63;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 16px/1.45 var(--font); -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap {
  max-width: 720px; margin: 0 auto; display: grid; gap: 16px;
  padding: calc(env(safe-area-inset-top) + 20px) max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 32px) max(16px, env(safe-area-inset-left));
}
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head h1 { font-size: 1.6rem; letter-spacing: -.02em; }
.head .sub { color: var(--muted); font-size: .95rem; }
.card { background: var(--surface); border-radius: 16px; padding: 16px; display: grid; gap: 12px; min-width: 0; }
.card h2 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.hint { font-size: .87rem; color: var(--muted); margin: 0; }
.error { color: var(--danger); margin: 0; font-size: .9rem; }

label { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); font-weight: 600; }
input, select { width: 100%; min-width: 0; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); font-size: 1rem; font-weight: 400; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 460px) { .row { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--fg); font-size: .95rem; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 11px; padding: 11px 16px; font-weight: 650; cursor: pointer; background: var(--surface-2); color: var(--fg); min-height: 44px; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: .88rem; border-radius: 9px; }
.btn:disabled { opacity: .55; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left)); }
.login .card { width: 100%; max-width: 360px; padding: 26px 22px; gap: 16px; box-shadow: 0 10px 40px rgb(0 0 0 / .08); }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 750; font-size: 1.3rem; }

/* App-Kacheln */
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tile { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: center; padding: 18px 16px; background: var(--surface); border-radius: 16px; color: var(--fg); text-decoration: none; border: 1px solid transparent; }
.tile:hover { border-color: var(--line); }
.tile .ico { grid-row: span 2; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; color: #fff; }
.tile .ico svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tile b { font-size: 1.05rem; }
.tile span.d { color: var(--muted); font-size: .88rem; }

/* Admin */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.seg button { border: 0; background: none; border-radius: 9px; padding: 9px 6px; font-weight: 650; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }
.user-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.user-head .who { min-width: 0; }
.user-head .who b { font-size: 1.05rem; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: .75rem; font-weight: 700; border-radius: 99px; padding: 2px 9px; background: var(--surface-2); color: var(--muted); }
.badge.admin { background: var(--accent-soft); color: var(--accent); }
.badge.off { color: var(--danger); background: transparent; border: 1px solid currentColor; }
.grant-row { display: grid; grid-template-columns: 1fr 160px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.grant-row:first-of-type { border-top: 0; }
@media (max-width: 420px) { .grant-row { grid-template-columns: 1fr 130px; } }
.grant-row select.read { border-color: var(--warn); }
.grant-row select.write { border-color: var(--ok); }
.edit { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 12px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 50; background: var(--fg); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: .92rem; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgb(0 0 0 / .2); }
