body { min-height: 100vh; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 0.875rem; }
.error-text { margin: 0; color: var(--err); font-size: 0.9rem; }
.logo { width: auto; object-fit: contain; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); padding: 2rem; display: grid; gap: 1rem; justify-items: start; }
.login-card .field, .login-card .btn { width: 100%; }

.nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.nav-brand { display: flex; align-items: center; gap: 0.6rem; }
.studio { color: var(--accent-strong); font-style: italic; }
.login-brand { display: flex; align-items: center; gap: 0.75rem; font-weight: 800; font-size: 1.05rem; letter-spacing: 0.01em; }
.tabs { display: flex; gap: 0.25rem; margin-right: auto; }
.tab {
  min-height: 38px;
  padding: 0.4rem 0.9rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font: 600 0.95rem var(--font);
  cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

.main { max-width: 1240px; margin: 0 auto; padding: 1.25rem 16px 3rem; }

.customers-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.customer-list-pane { position: sticky; top: 74px; display: grid; gap: 0.75rem; }
.pane-head { display: flex; gap: 0.5rem; }
.pane-head input { min-height: 40px; padding: 0.45rem 0.75rem; }
.pane-head .btn { white-space: nowrap; flex-shrink: 0; }
.customer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; max-height: calc(100vh - 150px); overflow: auto; }
.customer-list button {
  width: 100%;
  display: grid;
  gap: 0.1rem;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.customer-list button:hover { border-color: var(--ink-soft); }
.customer-list button[aria-current="true"] { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.customer-list .c-name { font-weight: 600; display: flex; justify-content: space-between; gap: 0.5rem; }
.customer-list .c-meta { color: var(--muted); font-size: 0.82rem; }
.empty { color: var(--muted); }

.detail-placeholder { display: grid; place-items: center; min-height: 300px; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.customer-detail { padding: 1.5rem; display: grid; gap: 1.75rem; }
.detail-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; }
.detail-head h2 { margin: 0; }

.access-block { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1.5rem; align-items: center; padding: 1.25rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.qr-box { background: #fff; padding: 8px; border-radius: 10px; line-height: 0; }
.qr-box img { width: 200px; height: 200px; }
.access-info { display: grid; gap: 0.75rem; }
.access-info h3 { margin: 0; }
.access-info p { margin: 0; }
.link-row { display: flex; gap: 0.5rem; }
.link-row input { min-height: 40px; padding: 0.45rem 0.7rem; font: 0.85rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.customer-form { display: grid; gap: 1rem; }
.customer-form h3 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
fieldset.thresholds { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1rem; margin: 0; display: grid; gap: 0.6rem; }
fieldset.thresholds legend { font-weight: 600; padding: 0 0.3rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }
.check { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; flex: none; accent-color: var(--accent-strong); }
.check .hint { font-weight: 400; color: var(--muted); }

.uploads-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.uploads-head h2 { margin: 0; }
.uploads-head select { width: auto; min-width: 220px; min-height: 40px; padding: 0.4rem 0.7rem; }

.batch-list { display: grid; gap: 0.5rem; }
.batch { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.batch summary {
  display: grid;
  grid-template-columns: 130px minmax(0, 1.2fr) minmax(0, 1.5fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 1rem;
  cursor: pointer;
  list-style: none;
}
.batch summary::-webkit-details-marker { display: none; }
.batch[open] summary { border-bottom: 1px solid var(--line); }
.b-date { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: 0.9rem; }
.b-who { display: grid; min-width: 0; }
.b-who strong, .b-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-who span { color: var(--muted); font-size: 0.85rem; }
.b-badges { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: flex-end; }
.b-body { padding: 0.75rem 1rem 1rem; display: grid; gap: 0.6rem; }
.path-row { display: flex; align-items: center; gap: 0.5rem; font: 0.85rem ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-soft); word-break: break-all; }

table.files { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.files th, table.files td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.files th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
table.files td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.files td.name { word-break: break-all; }
table.files tr:last-child td { border-bottom: 0; }

@media (max-width: 900px) {
  .customers-layout { grid-template-columns: 1fr; }
  .customer-list-pane { position: static; }
  .customer-list { max-height: 260px; }
  .detail-placeholder { display: none; }
  .batch summary { grid-template-columns: minmax(0, 1fr) auto; }
  .batch summary .b-date { grid-column: 1 / -1; }
  .batch summary .b-desc { display: none; }
}

@media (max-width: 640px) {
  /* Zeile 1: Eule, Konto, Abmelden – Zeile 2: Reiter, seitlich wischbar statt Seite zu verbreitern */
  .nav { flex-wrap: wrap; row-gap: 0.4rem; }
  .nav-brand strong { display: none; }
  .tabs { order: 3; flex: 1 0 100%; margin: 0 -16px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex-shrink: 0; white-space: nowrap; }
  .access-block { grid-template-columns: 1fr; justify-items: center; }
  .access-info { width: 100%; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .customer-detail { padding: 1rem; }
  .hide-sm { display: none; }
}

/* ---------- System ---------- */
.system-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
.system-card { display: flex; flex-direction: column; gap: 0.75rem; padding: 1.1rem 1.25rem; min-width: 0; }
.system-card .grid-2 > * { min-width: 0; }
.system-card input:not([type=checkbox]) { width: 100%; min-width: 0; }
.system-card h3 { margin: 0; }
.system-card p { margin: 0; }
.system-card textarea { width: 100%; resize: vertical; font: inherit; }
.card-danger { border: 1px solid var(--err-bg); }
.card-danger.active { border-color: var(--err); box-shadow: 0 0 0 3px var(--err-bg); }
.meter { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
#nas-meter-used { background: var(--accent-strong); }
#nas-meter-reserved { background: var(--warn-bg); }
.tab-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--err); margin-left: 4px; vertical-align: middle; }

/* ---------- Anmeldung ---------- */
.login-step { display: grid; gap: 1rem; width: 100%; }
.login-step h1 { margin: 0; font-size: 1.4rem; }
.setup-qr { background: #fff; padding: 10px; border-radius: 10px; width: 220px; justify-self: center; line-height: 0; }
.setup-qr svg { width: 200px; height: 200px; }
.secret { display: block; margin-top: 0.4rem; padding: 0.5rem; background: var(--surface-2); border-radius: 6px; word-break: break-all; font-size: 0.85rem; }
.recovery-list { columns: 2 9.5rem; column-gap: 1.5rem; margin: 0; padding-left: 1.6rem; font: 0.95rem ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.8; }
.recovery-list li, .nowrap { white-space: nowrap; }

/* ---------- Übersicht ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpi { display: grid; gap: 0.2rem; padding: 1rem 1.25rem; }
.kpi-label { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.kpi strong { font-size: 1.8rem; line-height: 1.1; }
.recent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.recent-list li { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.9rem; border-bottom: 1px solid var(--line); padding-bottom: 0.45rem; }
.recent-list li:last-child { border-bottom: 0; }
.nav-user { margin-left: auto; }

/* ---------- Team & Protokoll ---------- */
.team-list { display: grid; gap: 0.6rem; margin-top: 1rem; }
.team-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; padding: 0.9rem 1.1rem; }
.team-row .who { display: grid; margin-right: auto; }
.team-row .who span { color: var(--muted); font-size: 0.85rem; }
.audit-card { padding: 0; overflow: auto; }
table.audit { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.audit th, table.audit td { text-align: left; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.audit td.when { white-space: nowrap; color: var(--muted); }
table.audit td.details { color: var(--muted); max-width: 420px; word-break: break-word; }
#audit-more { margin-top: 1rem; }
.secret-value { padding: 0.8rem; background: var(--surface-2); border-radius: 8px; font: 1.05rem ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
body.role-staff .owner-only { display: none; }

/* ---------- Vorschaubilder ---------- */
.file-cell { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.thumb { width: 48px; height: 48px; flex: none; border-radius: 6px; object-fit: cover; background: var(--surface-2); }
.thumb-empty { display: grid; place-items: center; color: var(--muted); font-size: 1.1rem; }
