/* ciPhone Verwaltung: Petrol als Grundfarbe, Bernstein als Akzent (Variablen wie web/style.css) */
:root {
  --bg: #f4f7f8; --surface: #ffffff; --surface-alt: #e6eef0; --text: #10242a; --muted: #4f656c; --border: #cbd8dc;
  --primary: #0b6e78; --on-primary: #ffffff; --accent: #c77d0a; --danger: #b3261e; --on-danger: #ffffff;
  --success: #1b7f4b; --on-success: #ffffff; --warn: #7a4f00; --focus: #c77d0a;
  --shadow: 0 1px 3px rgb(16 36 42 / .12);
  --top-h: 3.5rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1417; --surface: #152329; --surface-alt: #1e3138; --text: #e6f0f2; --muted: #9bb2b9; --border: #2b434b;
    --primary: #3fb6c4; --on-primary: #06191c; --accent: #f0b24a; --danger: #f2736b; --on-danger: #2a0a08;
    --success: #5bd08e; --on-success: #06191c; --warn: #f0b24a; --focus: #f0b24a; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1417; --surface: #152329; --surface-alt: #1e3138; --text: #e6f0f2; --muted: #9bb2b9; --border: #2b434b;
  --primary: #3fb6c4; --on-primary: #06191c; --accent: #f0b24a; --danger: #f2736b; --on-danger: #2a0a08;
  --success: #5bd08e; --on-success: #06191c; --warn: #f0b24a; --focus: #f0b24a; --shadow: none;
}
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
h1 { font-size: 1.5rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.boot { padding: 2rem; text-align: center; color: var(--muted); }
.ico { display: inline-block; width: 1.25rem; height: 1.25rem; flex: none; }
.ico svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Schale ---------- */
.shell { display: grid; grid-template-columns: 16rem minmax(0, 1fr); grid-template-rows: var(--top-h) 1fr; min-height: 100vh; min-height: 100dvh; }
.skip { position: absolute; left: .5rem; top: -4rem; z-index: 100; padding: .5rem .8rem; background: var(--surface); border: 2px solid var(--focus); border-radius: .4rem; }
.skip:focus { top: .5rem; }
.top { grid-column: 1 / -1; position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: .6rem; padding: 0 .75rem; background: var(--primary); color: var(--on-primary); }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: inherit; text-decoration: none; font-weight: 600; font-size: 1.1rem; white-space: nowrap; }
.logo { display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: .5rem; background: var(--on-primary); color: var(--primary); font-weight: 800; font-size: .95rem; box-shadow: inset -3px -3px 0 var(--accent); }
.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; font-size: .85rem; min-width: 0; }
.who-name { font-weight: 600; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; background: none; border: 0; border-radius: 50%; color: inherit; cursor: pointer; }
.icon-btn:hover { background: rgb(255 255 255 / .16); }
.top :focus-visible { outline-color: var(--on-primary); }
.menu-btn { display: none; margin-left: -.4rem; }

.side { background: var(--surface); border-right: 1px solid var(--border); padding: .75rem .6rem 2rem; overflow-y: auto; position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); height: calc(100dvh - var(--top-h)); }
.who-mobile { display: none; padding: .25rem .6rem .75rem; line-height: 1.25; border-bottom: 1px solid var(--border); margin-bottom: .6rem; }
.who-mobile span { display: block; color: var(--muted); font-size: .85rem; }
.tenant-box { padding: 0 .3rem .75rem; display: grid; gap: .25rem; }
.tenant-box label { font-size: .8rem; color: var(--muted); }
.nav-list { display: flex; flex-direction: column; gap: .15rem; }
.nav-group { margin: .9rem .6rem .25rem; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.nav-item { position: relative; display: flex; align-items: center; gap: .6rem; min-height: 44px; padding: .45rem .6rem; border-radius: .5rem; color: var(--text); text-decoration: none; }
.nav-item:hover:not(.disabled) { background: var(--surface-alt); }
.nav-item[aria-current="page"] { background: var(--surface-alt); font-weight: 600; color: var(--primary); }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: -.2rem; top: .5rem; bottom: .5rem; width: 4px; border-radius: 4px; background: var(--accent); }
.nav-item.disabled { color: var(--muted); cursor: default; justify-content: space-between; min-height: 36px; }
.soon { font-style: normal; font-size: .72rem; padding: .05rem .45rem; border: 1px solid var(--border); border-radius: 1rem; color: var(--muted); background: var(--surface-alt); white-space: nowrap; }
.scrim { position: fixed; inset: var(--top-h) 0 0 0; background: rgb(0 0 0 / .45); z-index: 19; }

.content { padding: 1.25rem 1.5rem 3rem; min-width: 0; max-width: 78rem; width: 100%; }
.content:focus { outline: none; }

@media (max-width: 899px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-grid; }
  .who { display: none; }
  .who-mobile { display: block; }
  .side { position: fixed; z-index: 20; left: 0; top: var(--top-h); bottom: 0; height: auto; width: min(19rem, 88vw); transform: translateX(-102%); visibility: hidden; transition: transform .18s ease, visibility 0s .18s; box-shadow: 4px 0 18px rgb(0 0 0 / .25); }
  .side[data-open] { transform: none; visibility: visible; transition: transform .18s ease; }
  .content { padding: 1rem 1rem 3rem; }
  .logout .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .logout { width: 44px; padding: 0; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none !important; } }

/* ---------- Bausteine ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1:focus { outline: none; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .45rem 1rem; border: 1px solid var(--border); border-radius: .55rem; background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer; font-weight: 500; }
.btn:hover:not(:disabled) { background: var(--surface-alt); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--primary); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: var(--danger); color: var(--on-danger); }
.btn.small { min-height: 36px; padding: .25rem .7rem; font-size: .9rem; }
.btn.block { width: 100%; }
.btn.on-top { background: transparent; color: var(--on-primary); border-color: rgb(255 255 255 / .55); }
.btn.on-top:hover { background: rgb(255 255 255 / .16); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: .75rem; padding: 1rem 1.1rem; margin: 0 0 1rem; box-shadow: var(--shadow); min-width: 0; }
.alert { padding: .65rem .9rem; border-radius: .55rem; border: 1px solid var(--border); border-left-width: 5px; background: var(--surface); margin: .5rem 0; }
.alert.error { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.alert.success { border-color: var(--success); background: color-mix(in srgb, var(--success) 10%, var(--surface)); }
.alert.info { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.alert.warn { border-color: var(--accent); }
.note-warn { margin: 0 0 .75rem; padding: .45rem .7rem; border-left: 5px solid var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-radius: .3rem; font-size: .92rem; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); border: 2px dashed var(--border); border-radius: .75rem; }
.loading { display: flex; align-items: center; gap: .6rem; color: var(--muted); padding: 1rem 0; }
.spin { width: 1.1rem; height: 1.1rem; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } }
.badge { display: inline-block; justify-self: start; align-self: start; padding: .1rem .55rem; border-radius: 1rem; font-size: .8rem; font-weight: 600; border: 1px solid var(--border); background: var(--surface-alt); }
.badge.ok { border-color: var(--success); color: var(--success); background: color-mix(in srgb, var(--success) 10%, var(--surface)); }
.badge.bad { border-color: var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.crumb { margin: 0 0 .4rem; font-size: .9rem; color: var(--muted); }
.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.danger-zone { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--border); }
.soon-note { margin-top: 1.5rem; }

/* Formulare */
.field { display: grid; gap: .3rem; margin: 0 0 .9rem; min-width: 0; }
.field label { font-weight: 600; font-size: .92rem; }
.req { color: var(--danger); }
.hint { font-size: .82rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], select { width: 100%; min-height: 44px; padding: .45rem .7rem; border: 1px solid var(--border); border-radius: .5rem; background: var(--surface); color: var(--text); }
input:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--text); }
input[readonly] { background: var(--surface-alt); }
.field.check label { display: flex; align-items: center; gap: .6rem; font-weight: 500; min-height: 36px; }
input[type=checkbox] { width: 1.25rem; height: 1.25rem; accent-color: var(--primary); flex: none; }
fieldset { border: 1px solid var(--border); border-radius: .6rem; padding: .8rem 1rem .2rem; margin: 0 0 1rem; min-width: 0; }
legend { padding: 0 .4rem; font-weight: 700; }
.narrow-form { max-width: 34rem; }
.ext-form { max-width: 44rem; }
.form-error:empty { display: none; }
.toolbar { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: .75rem; margin-bottom: .5rem; }
.inline-form { display: grid; grid-template-columns: 2fr 1fr auto; gap: .75rem; align-items: end; }
.inline-form .btn { margin-bottom: .9rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.2rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* Tabellen */
.tbl-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: .75rem; overflow: hidden; margin: 0 0 1rem; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { background: var(--surface-alt); font-size: .85rem; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.row-actions { text-align: right !important; }
.code-small { font-size: .75rem; }
@media (max-width: 719px) {
  .toolbar, .inline-form { grid-template-columns: 1fr; }
  .tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { padding: .5rem .8rem; border-bottom: 1px solid var(--border); }
  .tbl tr:last-child { border-bottom: 0; }
  .tbl td { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: .5rem; border: 0; padding: .15rem 0; }
  .tbl td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; }
  .tbl td.row-actions { display: block; text-align: left !important; padding-top: .4rem; }
  .tbl td.row-actions::before { content: none; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dd { margin-bottom: .5rem; }
}

/* Kennzahlen */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--primary); border-radius: .75rem; padding: .9rem 1rem; box-shadow: var(--shadow); }
.stat:nth-child(4) { border-top-color: var(--accent); }
.stat-val { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-weight: 600; }

/* Geheimnis / Token */
.secret-box { border: 2px solid var(--accent); border-radius: .6rem; padding: .8rem 1rem; margin: .75rem 0; background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.secret-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.secret-row input { flex: 1 1 14rem; min-width: 0; }
.secret { flex: 1 1 14rem; min-width: 0; padding: .5rem .7rem; background: var(--surface); border: 1px solid var(--border); border-radius: .4rem; font-size: 1.05rem; user-select: all; }
.token-card { display: grid; grid-template-columns: minmax(0, 17rem) minmax(0, 1fr); gap: 1.25rem; align-items: start; margin-top: 1rem; }
.qr-wrap { background: #ffffff; padding: .5rem; border: 1px solid var(--border); border-radius: .5rem; }
.qr-wrap.expired { opacity: .15; }
.qr { display: block; width: 100%; height: auto; }
.countdown { font-size: 1.05rem; margin: 0 0 .5rem; }
@media (max-width: 719px) { .token-card { grid-template-columns: minmax(0, 1fr); } .qr-wrap { max-width: 17rem; } }

/* Dialog */
dialog.dlg { width: min(30rem, calc(100vw - 2rem)); border: 1px solid var(--border); border-radius: .8rem; padding: 1.2rem; background: var(--surface); color: var(--text); }
dialog.dlg::backdrop { background: rgb(0 0 0 / .5); }
.dlg-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }

/* Anmeldung / Einladung */
.public { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, var(--bg), var(--surface-alt)); }
.public-card { width: min(26rem, 100%); background: var(--surface); border: 1px solid var(--border); border-top: 5px solid var(--primary); border-radius: .9rem; padding: 1.5rem 1.4rem; box-shadow: var(--shadow); }
.brand-big { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.2rem; margin-bottom: 1rem; color: var(--primary); }
.brand-big .logo { background: var(--primary); color: var(--on-primary); }
.public-card h1 { margin-bottom: .4rem; }
