/* ==========================================================================
   EDV-Galli Cloud – Stylesheet
   Marken-Tokens identisch mit dem Kundenportal (edv-galli/public/css/app.css).
   Hell/Dunkel: folgt dem System, außer data-theme="light|dark" auf <html>.
   Abstände: 4 / 8 / 12 / 16 / 24 / 32 / 48 px.
   ========================================================================== */

:root {
  --brand: #1d6e80;
  --brand-600: #175c6d;
  --brand-700: #13505d;
  --brand-300: #5cc8d8;
  --brand-100: #e3f1f3;
  --deep: #0f2433;

  --ink: #0d1b24;
  --ink-soft: #4a5c68;
  --ink-muted: #5f707c;

  --surface: #ffffff;
  --surface-alt: #f5f9fb;
  --surface-sunk: #eef4f7;
  --line: #e4ebf0;
  --line-strong: #c9d5dd;

  --link: var(--brand);
  --focus: #1d6e80;

  --ok: #1e7a4d;      --ok-bg: #eaf3de;   --ok-line: #c3ddb0;
  --warn: #854f0b;    --warn-bg: #faeeda; --warn-line: #eccfa4;
  --err: #a32d2d;     --err-bg: #fcebeb;  --err-line: #f0a8a8;
  --info: #175c6d;    --info-bg: #e3f1f3; --info-line: #b9dce3;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-pop: 0 2px 4px rgba(13, 27, 36, .06), 0 12px 28px rgba(13, 27, 36, .14);
  --ease: cubic-bezier(.22, .68, .36, 1);

  --font: Inter, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  color-scheme: light;
}

/* Dunkle Werte – einmal für „System = dunkel“, einmal für die manuelle Wahl */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e6eef2;
    --ink-soft: #a9bac4;
    --ink-muted: #8fa1ac;
    --surface: #13212a;
    --surface-alt: #0c171e;
    --surface-sunk: #0f1c24;
    --line: #22343f;
    --line-strong: #344956;
    --brand-100: #12343d;
    --link: #6fd0de;
    --focus: #6fd0de;
    --ok: #86d3a6;   --ok-bg: #11291c;   --ok-line: #24513a;
    --warn: #f0c27a; --warn-bg: #2c210e; --warn-line: #5a4520;
    --err: #f2a0a0;  --err-bg: #2f1616;  --err-line: #5e2b2b;
    --info: #8fd8e3; --info-bg: #10303a; --info-line: #23505c;
    --shadow-pop: 0 2px 4px rgba(0, 0, 0, .3), 0 12px 28px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e6eef2;
  --ink-soft: #a9bac4;
  --ink-muted: #8fa1ac;
  --surface: #13212a;
  --surface-alt: #0c171e;
  --surface-sunk: #0f1c24;
  --line: #22343f;
  --line-strong: #344956;
  --brand-100: #12343d;
  --link: #6fd0de;
  --focus: #6fd0de;
  --ok: #86d3a6;   --ok-bg: #11291c;   --ok-line: #24513a;
  --warn: #f0c27a; --warn-bg: #2c210e; --warn-line: #5a4520;
  --err: #f2a0a0;  --err-bg: #2f1616;  --err-line: #5e2b2b;
  --info: #8fd8e3; --info-bg: #10303a; --info-line: #23505c;
  --shadow-pop: 0 2px 4px rgba(0, 0, 0, .3), 0 12px 28px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

/* ---------- Grundlagen ---------- */

*, *::before, *::after { box-sizing: border-box; }

/* „hidden“ muss immer gewinnen – auch gegen display-Regeln von Komponenten */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface-alt);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 12px; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.icon { flex: none; width: 20px; height: 20px; }

.skip-link {
  position: absolute; left: 16px; top: -48px;
  padding: 8px 12px; background: var(--surface); color: var(--ink);
  border-radius: var(--radius); z-index: 100;
}
.skip-link:focus { top: 8px; }

.text-soft { color: var(--ink-soft); }
.text-warn { color: var(--warn); font-weight: 600; }
.lead { color: var(--ink-soft); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Kopfleiste ---------- */

.topbar {
  background: var(--deep);
  color: #fff;
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto;
  height: 64px; padding: 0 16px;
  display: flex; align-items: center; gap: 24px;
}
.brand {
  display: flex; align-items: center; gap: 8px; flex: none;
  color: #fff; text-decoration: none;
}
/* Die Bildmarke enthält Schrift – unter 40 px Höhe wird sie unleserlich */
.brand img { height: 40px; width: auto; }
.brand-name { font-size: 1.125rem; font-weight: 650; letter-spacing: .01em; }

.mainnav { display: flex; gap: 4px; min-width: 0; }
.mainnav a {
  color: #c9dbe3; text-decoration: none;
  padding: 8px 12px; border-radius: var(--radius);
  font-weight: 500;
}
.mainnav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.mainnav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .12); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar :focus-visible { outline-color: var(--brand-300); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border: 0; border-radius: var(--radius);
  background: transparent; color: inherit; cursor: pointer;
}
.topbar .icon-btn { color: #c9dbe3; }
.topbar .icon-btn:hover { color: #fff; background: rgba(255, 255, 255, .08); }

.theme-icon { display: none; }
.theme-toggle[data-state="system"] .theme-icon-system,
.theme-toggle[data-state="light"] .theme-icon-light,
.theme-toggle[data-state="dark"] .theme-icon-dark { display: inline-flex; }

/* Benutzermenü (details/summary – funktioniert auch ohne JavaScript) */
.usermenu { position: relative; }
.usermenu summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 8px 0 4px; border-radius: var(--radius);
  color: #e3edf1;
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: rgba(255, 255, 255, .08); }
.usermenu summary .icon { width: 16px; height: 16px; }
.usermenu[open] summary .icon { transform: rotate(180deg); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: #fff;
  font-size: .8125rem; font-weight: 650;
}
.usermenu-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 240px; padding: 8px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}
.usermenu-meta {
  font-size: .875rem; color: var(--ink-soft);
  padding: 8px 12px; margin: 0 0 4px;
  border-bottom: 1px solid var(--line);
}
.usermenu-meta strong { color: var(--ink); }
.usermenu-panel a, .usermenu-panel button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 8px 12px; border: 0; border-radius: var(--radius);
  background: none; color: var(--ink); font: inherit; text-align: left;
  text-decoration: none; cursor: pointer;
}
.usermenu-panel a:hover, .usermenu-panel button:hover { background: var(--surface-sunk); }
.usermenu-panel .icon { color: var(--ink-soft); }
.usermenu-panel form { margin: 0; }
.topbar .usermenu-panel :focus-visible { outline-color: var(--focus); }

/* ---------- Seitenrahmen ---------- */

.page {
  max-width: 1200px; margin: 0 auto;
  padding: 24px 16px 48px;
}
.page:focus { outline: none; }
.page > .alert { margin-bottom: 16px; }

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 24px;
}
.page-head h1 { margin: 0; }
.page-head-aside { min-width: 260px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.panel-intro { color: var(--ink-soft); }

.account-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}
.panel-wide { grid-column: 1 / -1; }
@media (max-width: 860px) {
  .account-grid { grid-template-columns: minmax(0, 1fr); }
}

.facts { margin: 0 0 24px; display: grid; gap: 8px; }
.facts > div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: .8125rem; font-weight: 600;
  background: var(--surface-sunk); color: var(--ink-soft);
}
.badge .icon { width: 14px; height: 14px; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- Speicherplatz ---------- */

.quota-text {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px;
  font-size: .875rem; margin-bottom: 4px;
}
.quota-label { font-weight: 600; }
.quota-value { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.quota progress {
  display: block; width: 100%; height: 8px;
  appearance: none; border: 0; border-radius: 999px;
  background: var(--surface-sunk); overflow: hidden;
}
.quota progress::-webkit-progress-bar { background: var(--surface-sunk); border-radius: 999px; }
.quota progress::-webkit-progress-value { background: var(--brand); border-radius: 999px; }
.quota progress::-moz-progress-bar { background: var(--brand); border-radius: 999px; }
.quota-warn progress::-webkit-progress-value { background: #c27a12; }
.quota-warn progress::-moz-progress-bar { background: #c27a12; }
.quota-crit progress::-webkit-progress-value { background: var(--err); }
.quota-crit progress::-moz-progress-bar { background: var(--err); }
.quota-note { font-size: .875rem; color: var(--err); margin: 8px 0 0; }

/* ---------- Formulare ---------- */

.form { display: grid; gap: 16px; }
.form h3 { margin-bottom: 0; }
.field { display: grid; gap: 4px; }
.field label { font-size: .875rem; font-weight: 600; }

input[type="text"], input[type="password"], input[type="email"], input[type="number"], select {
  width: 100%; height: 44px; padding: 0 12px;
  font: inherit; font-size: 1rem; /* 16px verhindert das Hineinzoomen auf iOS */
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:hover { border-color: var(--ink-muted); }
input:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
}
input[aria-invalid="true"] { border-color: var(--err); }
input::placeholder { color: var(--ink-muted); }

.input-code {
  max-width: 180px;
  font-family: var(--font-mono); font-size: 1.25rem !important; letter-spacing: .2em;
  font-variant-numeric: tabular-nums;
}
.input-mono { font-family: var(--font-mono); }

.field-hint { font-size: .875rem; color: var(--ink-soft); margin: 0; }
.field-error {
  display: flex; align-items: flex-start; gap: 4px;
  font-size: .875rem; color: var(--err); margin: 0;
}
.field-error .icon { width: 16px; height: 16px; margin-top: 2px; }

.form-actions, .button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.form-inline { grid-template-columns: auto; align-items: end; }
@media (min-width: 560px) {
  .form-inline { grid-template-columns: auto auto; justify-content: start; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  font: inherit; font-weight: 600; line-height: 1.2;
  border: 1px solid transparent; border-radius: var(--radius);
  cursor: pointer; text-decoration: none;
  transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-primary:active { background: var(--brand-700); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface-sunk); }
.btn-danger { background: var(--surface); color: var(--err); border-color: var(--err-line); }
.btn-danger:hover { background: var(--err-bg); }
.btn-block { width: 100%; min-height: 44px; }
.btn-small { min-height: 32px; padding: 4px 12px; font-size: .875rem; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .65; cursor: progress; }
@media (pointer: coarse) { .btn { min-height: 44px; } }

.link-button {
  border: 0; padding: 0; background: none;
  font: inherit; color: var(--link); text-decoration: underline; text-underline-offset: 2px;
  cursor: pointer;
}

/* ---------- Meldungen ---------- */

.alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; margin-bottom: 16px;
  border: 1px solid; border-radius: var(--radius);
}
.alert p { margin: 0; }
.alert .icon { margin-top: 2px; }
.alert-ok   { background: var(--ok-bg);   border-color: var(--ok-line);   color: var(--ok); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.alert-err  { background: var(--err-bg);  border-color: var(--err-line);  color: var(--err); }
.alert-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }

/* ---------- Zwei-Faktor ---------- */

.steps { margin: 0 0 16px; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 24px; }
.steps > li { position: relative; padding-left: 44px; counter-increment: step; }
.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: -2px;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-100); color: var(--brand-700);
  font-weight: 650; font-size: .875rem;
}
:root[data-theme="dark"] .steps > li::before { color: var(--link); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .steps > li::before { color: var(--link); }
}
.steps h3 { margin-bottom: 4px; }

.totp-setup { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 24px; margin-top: 12px; }
.qr:empty { display: none; }
.qr {
  padding: 12px; background: #fff; /* QR-Codes brauchen hellen Hintergrund – auch im Dunkelmodus */
  border: 1px solid var(--line); border-radius: var(--radius);
  line-height: 0;
}
.qr img, .qr svg { width: 180px; height: 180px; }
.secret {
  font-family: var(--font-mono); font-size: 1.0625rem; letter-spacing: .04em;
  word-spacing: .3em; overflow-wrap: anywhere;
  padding: 8px 12px; margin: 4px 0 8px;
  background: var(--surface-sunk); border-radius: var(--radius);
  user-select: all;
}

.recovery-codes {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 24px;
  margin: 0 0 16px; padding: 16px 16px 16px 40px;
  font-family: var(--font-mono); font-size: 1rem;
  background: var(--surface-sunk); border-radius: var(--radius);
}
.recovery-codes li::marker { color: var(--ink-muted); font-size: .8125rem; }

.split-forms {
  display: grid; gap: 24px; grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px; padding-top: 24px; border-top: 1px solid var(--line);
}
@media (max-width: 700px) { .split-forms { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Leerer Zustand ---------- */

.empty-state {
  text-align: center; padding: 48px 16px;
  background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius-lg);
}
.empty-state .icon { width: 40px; height: 40px; color: var(--ink-muted); margin-bottom: 12px; }
.empty-state p { max-width: 60ch; margin: 0 auto; color: var(--ink-soft); }

/* ---------- Anmeldeseiten ---------- */

body.auth { background: var(--surface-alt); }
.auth-main {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
  padding: 48px 16px 24px;
}
.auth-brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 24px; color: var(--ink);
}
.auth-brand img { height: 40px; width: auto; }
.auth-brand-name { font-size: 1.5rem; font-weight: 650; }
.logo-on-dark { display: none; }
:root[data-theme="dark"] .logo-on-light { display: none; }
:root[data-theme="dark"] .logo-on-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-on-light { display: none; }
  :root:not([data-theme="light"]) .logo-on-dark { display: block; }
}

.auth-box {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 32px 24px;
}
.auth-box h1 { font-size: 1.375rem; }
.auth-note { margin: 16px 0 0; font-size: .875rem; color: var(--ink-soft); }
.auth-foot { margin-top: 24px; color: var(--ink-soft); }
.auth-foot .icon-btn:hover { background: var(--surface-sunk); }

.disclosure { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.disclosure summary { cursor: pointer; color: var(--link); font-weight: 500; }
.disclosure[open] summary { margin-bottom: 12px; }
.disclosure p { font-size: .875rem; color: var(--ink-soft); }

/* ---------- Dateiverwaltung ---------- */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.page-head-main { min-width: 0; }
.page-intro { margin: 8px 0 0; max-width: 70ch; }

.breadcrumb ol { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 4px; padding: 0; list-style: none; }
.breadcrumb li { display: flex; align-items: center; gap: 4px; font-size: .875rem; min-width: 0; }
.breadcrumb a { color: var(--ink-soft); text-decoration: none; overflow-wrap: anywhere; }
.breadcrumb a:hover { color: var(--link); text-decoration: underline; }
.breadcrumb .icon { width: 14px; height: 14px; color: var(--ink-muted); }
.page-head h1 { overflow-wrap: anywhere; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar-note { margin: 0; }

.search-form { display: flex; align-items: center; gap: 4px; width: min(320px, 100%); }
.search-form input { height: 40px; }
.search-form .icon-btn { color: var(--ink-soft); flex: none; }
.search-form .icon-btn:hover { background: var(--surface-sunk); }
.search-form-wide { width: min(560px, 100%); gap: 8px; margin-bottom: 24px; }
.search-form-wide input { height: 44px; }
input[type="search"] {
  width: 100%; padding: 0 12px; font: inherit; font-size: 1rem;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
}
input[type="search"]:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }

select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235f707c' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

.selection-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 8px 12px; margin-bottom: 12px;
  background: var(--brand-100); border-radius: var(--radius);
  font-weight: 600; font-size: .9375rem;
}
.selection-bar[hidden] { display: none; }

.drop-zone { position: relative; border-radius: var(--radius-lg); }
.drop-zone.is-dragging { outline: 2px dashed var(--brand); outline-offset: 4px; }
.drop-overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 160px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-radius: var(--radius-lg);
  color: var(--brand-700); font-weight: 600; font-size: 1.0625rem;
  pointer-events: none;
}
.drop-overlay[hidden] { display: none; }
.drop-overlay .icon { width: 32px; height: 32px; }
:root[data-theme="dark"] .drop-overlay { color: var(--link); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .drop-overlay { color: var(--link); } }

/* Tabelle */
.file-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  font-size: .9375rem;
}
.file-table th, .file-table td { padding: 8px 12px; text-align: left; vertical-align: middle; }
.file-table thead th {
  font-size: .8125rem; font-weight: 600; color: var(--ink-soft);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.file-table thead th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.file-table thead th a:hover { color: var(--ink); }
.file-table thead th .icon { width: 14px; height: 14px; }
.file-table tbody td { border-bottom: 1px solid var(--line); }
.file-table tbody tr:last-child td { border-bottom: 0; }
.file-table tbody tr:hover { background: var(--surface-alt); }
.file-table tbody tr:has([data-select]:checked) { background: var(--brand-100); }
.col-check { width: 44px; }
.col-check input { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; vertical-align: middle; }
.col-size { width: 120px; text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-soft); }
.col-date { width: 150px; white-space: nowrap; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.col-location { color: var(--ink-soft); overflow-wrap: anywhere; }
.col-location a { color: inherit; }
.col-actions { width: 56px; text-align: right !important; }
.col-trash-actions { width: 1%; white-space: nowrap; }
.col-trash-actions .button-row { flex-wrap: nowrap; justify-content: flex-end; }
.col-trash-actions form { margin: 0; }

.col-name { min-width: 0; }
.node-link {
  display: inline-flex; align-items: center; gap: 12px; min-width: 0; max-width: 100%;
  color: var(--ink); text-decoration: none; font-weight: 500;
  padding: 4px 0;
}
a.node-link:hover .node-name { text-decoration: underline; text-underline-offset: 2px; }
.node-name { overflow-wrap: anywhere; }
.node-icon { display: inline-flex; color: var(--ink-muted); }
.node-icon-folder { color: var(--brand); }
:root[data-theme="dark"] .node-icon-folder { color: var(--link); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .node-icon-folder { color: var(--link); } }
.node-meta { display: none; font-size: .8125rem; color: var(--ink-soft); padding-left: 32px; }
.node-meta a { color: inherit; }
.node-meta-always { display: block; }

/* Zeilenmenü */
.row-menu { position: relative; display: inline-block; }
.row-menu summary { list-style: none; color: var(--ink-soft); }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu summary:hover, .row-menu[open] summary { background: var(--surface-sunk); color: var(--ink); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 15;
  min-width: 220px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); text-align: left;
}
.menu-panel form { margin: 0; }
.menu-panel a, .menu-panel button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 8px 12px; border: 0; border-radius: var(--radius);
  background: none; color: var(--ink); font: inherit; font-size: .9375rem;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-sunk); }
.menu-panel .icon { width: 18px; height: 18px; color: var(--ink-soft); }
.menu-panel .menu-danger { color: var(--err); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); margin-top: 4px; }
.menu-panel .menu-danger .icon { color: var(--err); }

/* Dialoge */
.dialog {
  width: min(480px, calc(100vw - 32px)); padding: 24px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}
.dialog::backdrop { background: rgba(9, 20, 28, .55); }
.dialog h2 { font-size: 1.25rem; margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.dialog-preview {
  width: min(1100px, calc(100vw - 32px)); height: min(860px, calc(100vh - 32px));
  padding: 0; display: none; flex-direction: column; overflow: hidden;
}
.dialog-preview[open] { display: flex; }
.preview-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line);
}
.preview-head h2 { flex: 1; min-width: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-head .icon-btn:hover { background: var(--surface-sunk); }
.preview-body { flex: 1; min-height: 0; overflow: auto; background: var(--surface-sunk); display: flex; flex-direction: column; }
.preview-body img { margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; display: block; padding: 16px; }
.preview-body iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.preview-body pre {
  margin: 0; padding: 16px 20px; flex: 1;
  font-family: var(--font-mono); font-size: .875rem; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4;
  background: var(--surface); color: var(--ink);
}
.preview-status { padding: 12px 20px; margin: 0; color: var(--ink-soft); font-size: .875rem; }

/* Upload-Liste */
.upload-panel {
  position: fixed; right: 16px; bottom: 16px; z-index: 30;
  width: min(400px, calc(100vw - 32px)); max-height: min(60vh, 520px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}
.upload-panel[hidden] { display: none; }
.upload-head { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.upload-head h2 { font-size: 1rem; margin: 0; }
.upload-summary { flex: 1; font-size: .875rem; color: var(--ink-soft); }
.upload-head .icon-btn:hover { background: var(--surface-sunk); }
.upload-list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; }
.upload-item {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center;
  padding: 8px 16px;
}
.upload-item + .upload-item { border-top: 1px solid var(--line); }
.upload-name { font-size: .9375rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-cancel { width: 32px; height: 32px; color: var(--ink-soft); }
.upload-cancel:hover { background: var(--surface-sunk); }
.upload-item progress {
  grid-column: 1 / -1; width: 100%; height: 6px; appearance: none; border: 0;
  border-radius: 999px; background: var(--surface-sunk); overflow: hidden;
}
.upload-item progress::-webkit-progress-bar { background: var(--surface-sunk); }
.upload-item progress::-webkit-progress-value { background: var(--brand); border-radius: 999px; }
.upload-item progress::-moz-progress-bar { background: var(--brand); border-radius: 999px; }
.upload-status { grid-column: 1 / -1; font-size: .8125rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.upload-item[data-state="done"] progress::-webkit-progress-value { background: var(--ok); }
.upload-item[data-state="done"] progress::-moz-progress-bar { background: var(--ok); }
.upload-item[data-state="done"] .upload-status { color: var(--ok); }
.upload-item[data-state="error"] .upload-status { color: var(--err); }
.upload-item[data-state="error"] progress, .upload-item[data-state="cancelled"] progress { display: none; }

@media (max-width: 760px) {
  .col-date, .col-size, .col-location { display: none; }
  .node-meta { display: block; }
  .file-table th, .file-table td { padding: 8px; }
  .col-trash-actions .button-row { flex-direction: column; align-items: stretch; }
  .col-trash-actions .btn { width: 100%; }
}
@media (max-width: 480px) {
  .col-trash-actions .btn { font-size: 0; gap: 0; padding: 8px; }
  .col-trash-actions .btn .icon { width: 20px; height: 20px; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1; }
  .search-form { width: 100%; }
}

/* ---------- Freigaben ---------- */

.share-flag {
  display: inline-flex; vertical-align: middle; margin-left: 8px;
  color: var(--brand); border-radius: 4px;
}
.share-flag .icon { width: 16px; height: 16px; }
:root[data-theme="dark"] .share-flag { color: var(--link); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .share-flag { color: var(--link); } }

.stack-narrow { display: grid; gap: 16px; max-width: 760px; }

.title-with-icon { display: flex; align-items: center; gap: 12px; }
.title-with-icon .icon { width: 24px; height: 24px; }

.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 480px) { .field-row { grid-template-columns: minmax(0, 1fr); } }
input[type="date"] {
  width: 100%; height: 44px; padding: 0 12px; font: inherit; font-size: 1rem;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
}
input[type="date"]:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }

.section-title { font-size: 1rem; margin: 24px 0 8px; }
.share-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.share-list-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.share-item { display: grid; gap: 8px; padding: 16px 0; border-top: 1px solid var(--line); }
.share-item:first-child { border-top: 0; padding-top: 0; }
.share-list-panel .share-item { padding: 16px; }
.share-list-panel .share-item:first-child { padding-top: 16px; }
.share-item-new { background: var(--ok-bg); margin: 0 -12px; padding-left: 12px !important; padding-right: 12px !important; border-radius: var(--radius); }
.share-item-inactive .share-url input { color: var(--ink-muted); text-decoration: line-through; }
.share-item form { margin: 0; }
.share-node { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0; }
.share-location { font-size: .875rem; }
.share-url { display: flex; gap: 8px; }
.share-url input { height: 36px; font-size: .875rem; min-width: 0; flex: 1; background: var(--surface-sunk); }
.share-details { margin: 0; font-size: .875rem; color: var(--ink-soft); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.badge-muted { background: var(--surface-sunk); color: var(--ink-soft); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.link-danger { color: var(--err); font-size: .875rem; }

/* Öffentliche Seiten */
.public-head { background: var(--surface); border-bottom: 1px solid var(--line); }
.public-head-inner {
  max-width: 1000px; margin: 0 auto; height: 64px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.public-head .auth-brand { margin: 0; }
.public-head .auth-brand img { height: 35px; }
.public-head .auth-brand-name { font-size: 1.25rem; }
.public-head .icon-btn { color: var(--ink-soft); }
.public-head .icon-btn:hover { background: var(--surface-sunk); }
.page-public { max-width: 1000px; }
.public-meta { font-size: .9375rem; color: var(--ink-soft); margin-bottom: 16px; }
.public-meta p { margin: 0; }
.public-box {
  max-width: 420px; margin: 32px auto 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 32px 24px;
}
.public-box h1 { font-size: 1.375rem; }
.public-file-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.public-file-icon .icon { width: 32px; height: 32px; }
.public-file-title { flex: 1; min-width: 200px; }
.public-file-title h1 { font-size: 1.25rem; margin: 0 0 4px; overflow-wrap: anywhere; }
.public-file-title p { margin: 0; }
.public-preview {
  margin-top: 24px; border-radius: var(--radius); overflow: hidden;
  background: var(--surface-sunk); display: flex; justify-content: center;
}
.public-preview img { max-width: 100%; max-height: 75vh; object-fit: contain; display: block; }
.public-preview iframe { width: 100%; height: 75vh; border: 0; background: #fff; }
.public-preview pre {
  margin: 0; padding: 16px 20px; width: 100%; max-height: 75vh; overflow: auto;
  font-family: var(--font-mono); font-size: .875rem; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.icon-btn-quiet { color: var(--ink-soft); }
.icon-btn-quiet:hover { background: var(--surface-sunk); color: var(--ink); }

/* ---------- Verwaltung ---------- */

.tabs {
  display: flex; gap: 4px; margin: -8px 0 24px;
  box-shadow: inset 0 -1px 0 var(--line); /* Linie ohne Überstand – kein Scrollbalken */
  overflow-x: auto; overflow-y: hidden;
}
.tabs a {
  padding: 8px 12px; white-space: nowrap;
  color: var(--ink-soft); text-decoration: none; font-weight: 500;
  border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px;
  margin: 0 0 24px;
}
.stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; }
.stats dt { font-size: .8125rem; color: var(--ink-soft); font-weight: 600; }
.stats dd { margin: 4px 0 0; font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stats dd.stat-note { font-size: .8125rem; font-weight: 400; color: var(--ink-soft); margin-top: 2px; }
.stats dd.stat-note.text-warn { color: var(--warn); font-weight: 600; }

.avatar-small { width: 32px; height: 32px; font-size: .75rem; flex: none; }
.user-sub { display: block; font-size: .8125rem; color: var(--ink-soft); font-weight: 400; }
.col-status { white-space: nowrap; }
.col-status .badge + .badge { margin-left: 4px; }
.col-usage { width: 220px; }
.usage-text { display: block; font-size: .8125rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; margin-bottom: 4px; white-space: nowrap; }
.usage progress {
  display: block; width: 100%; height: 6px; appearance: none; border: 0; border-radius: 999px;
  background: var(--surface-sunk); overflow: hidden;
}
.usage progress::-webkit-progress-bar { background: var(--surface-sunk); }
.usage progress::-webkit-progress-value { background: var(--brand); border-radius: 999px; }
.usage progress::-moz-progress-bar { background: var(--brand); border-radius: 999px; }
.usage-warn progress::-webkit-progress-value { background: #c27a12; }
.usage-warn progress::-moz-progress-bar { background: #c27a12; }
.usage-crit progress::-webkit-progress-value { background: var(--err); }
.usage-crit progress::-moz-progress-bar { background: var(--err); }
.badge-err { background: var(--err-bg); color: var(--err); }

.temp-password { margin-bottom: 16px; border-color: var(--ok-line); background: var(--ok-bg); }
.temp-password .share-url { max-width: 480px; }
.temp-password-value { font-size: 1.125rem !important; letter-spacing: .04em; height: 44px !important; background: var(--surface) !important; }

.action-list { display: grid; gap: 16px; }
.action-list form { margin: 0; display: grid; gap: 4px; justify-items: start; }
.panel-danger { border-color: var(--err-line); }
.panel-danger h2 { color: var(--err); }

.filter-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 16px; }
.filter-bar .field { min-width: 180px; flex: 1; max-width: 280px; }
.filter-bar select { height: 40px; }

.log-table td { vertical-align: top; }
.log-action { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.log-action .icon { width: 16px; height: 16px; color: var(--warn); }
.log-details { display: block; font-size: .8125rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.log-warn .log-action { color: var(--warn); }
.col-ip { white-space: nowrap; color: var(--ink-soft); font-family: var(--font-mono); font-size: .8125rem; }
.log-ip-mobile { display: none; }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; }

@media (max-width: 760px) {
  .col-usage, .col-status, .col-ip { display: none; }
  .log-ip-mobile { display: block; font-size: .75rem; color: var(--ink-muted); font-family: var(--font-mono); }
  .log-table .col-date { display: table-cell; white-space: normal; width: 90px; font-size: .8125rem; }
  .filter-bar .field { max-width: none; }
}

/* ---------- WebDAV / App-Passwörter ---------- */

.dav-facts > div { grid-template-columns: 140px minmax(0, 1fr); align-items: center; }
.dav-facts .share-url { max-width: 520px; }
.howto { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 4px; }
.app-password-item { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.app-password-item strong { margin-right: 8px; }
.app-password-form { margin-top: 16px; }

/* ---------- Kleine Bildschirme ---------- */

@media (max-width: 600px) {
  /* Zwei Zeilen: oben Logo + Aktionen, darunter die Navigation (bei Bedarf seitlich scrollbar) */
  .topbar-inner { flex-wrap: wrap; height: auto; gap: 0 8px; padding: 8px 8px 0 12px; }
  .brand img { height: 36px; }
  .mainnav {
    order: 3; flex: 1 0 100%; margin: 4px -8px 0 -12px; padding: 0 8px 4px;
    overflow-x: auto; scrollbar-width: none;
  }
  .mainnav::-webkit-scrollbar { display: none; }
  .mainnav a { padding: 8px 10px; white-space: nowrap; font-size: .9375rem; }
  .topbar-actions { gap: 4px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stats > div { padding: 12px; }
  .stats dd { font-size: 1.25rem; }
  .usermenu-name { display: none; }
  .page { padding-top: 16px; }
  .panel { padding: 16px; }
  .facts > div { grid-template-columns: 1fr; gap: 0; }
  .page-head-aside { min-width: 0; width: 100%; }
  .auth-main { padding-top: 32px; }
  .auth-box { padding: 24px 16px; }
}
