/* ==========================================================================
   Freigabetool – Basis-Stylesheet (Paket 1)
   Andere Pakete ergänzen eigenes CSS nur am Dateiende in einem markierten Block,
   z. B. mit der Kommentarzeile "=== reviews ===".
   ========================================================================== */

:root {
  --accent: #7a1f3d;                 /* wird in base.html aus SiteSettings.brand_color überschrieben */
  --accent-contrast: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 9%, #ffffff);
  --accent-strong: color-mix(in srgb, var(--accent) 82%, #000000);

  --bg: #f6f5f3;
  --surface: #ffffff;
  --surface-muted: #faf9f7;
  --border: #e6e3de;
  --border-strong: #d4d0c9;
  --text: #1d1b19;
  --text-muted: #6b6660;
  --text-subtle: #948e87;

  --gray: #6b6660;     --gray-bg: #efedea;
  --orange: #a65300;   --orange-bg: #fdf0e1;
  --green: #1f7a45;    --green-bg: #e5f4ea;
  --red: #b42318;      --red-bg: #fdecea;
  --blue: #1d4f91;     --blue-bg: #e8f0fb;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(29, 27, 25, .05);
  --shadow: 0 1px 3px rgba(29, 27, 25, .06), 0 6px 16px rgba(29, 27, 25, .05);
  --shadow-lg: 0 12px 40px rgba(29, 27, 25, .18);

  --sidebar-w: 272px;
  --header-h: 60px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55;
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
code, .mono { font-family: var(--font-mono); font-size: .86em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: var(--radius-sm); }
.skip-link:focus { left: 8px; }

/* --- Layout --------------------------------------------------------------- */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px; height: var(--header-h); padding: 0 20px;
  border-bottom: 1px solid var(--border); color: var(--text); font-weight: 650; flex-shrink: 0;
}
.sidebar__brand:hover { text-decoration: none; }
.sidebar__brand img { max-height: 30px; width: auto; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-contrast);
  display: inline-grid; place-items: center; font-size: .85rem; font-weight: 700;
}
.sidebar__nav { padding: 14px 10px 24px; flex: 1; }
.sidebar__label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-subtle);
  padding: 14px 10px 6px; font-weight: 600;
}
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text); font-size: .93rem;
}
.nav-link:hover { background: var(--surface-muted); text-decoration: none; }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav-link .nav-icon { width: 18px; text-align: center; color: var(--text-muted); flex-shrink: 0; }
.nav-link.is-active .nav-icon { color: var(--accent); }
.nav-ws { margin-top: 4px; }
.nav-ws > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius-sm); font-weight: 600; font-size: .92rem;
}
.nav-ws > summary::-webkit-details-marker { display: none; }
.nav-ws > summary:hover { background: var(--surface-muted); }
.nav-ws > summary::after { content: "›"; margin-left: auto; color: var(--text-subtle); transition: transform .15s; }
.nav-ws[open] > summary::after { transform: rotate(90deg); }
.nav-ws__emoji { width: 18px; text-align: center; }
.nav-ws__tag { font-size: .7rem; font-weight: 600; color: var(--text-subtle); border: 1px solid var(--border); border-radius: 99px; padding: 0 6px; }
.nav-projects { list-style: none; margin: 2px 0 6px; padding: 0 0 0 20px; }
.nav-projects .nav-link { font-size: .9rem; padding: 5px 10px; color: var(--text-muted); }
.nav-projects .nav-link.is-active { color: var(--accent-strong); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--header-h);
  display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar__spacer { flex: 1; }
.topbar .topbar__menu-btn { display: none; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: 50%; border: 1px solid transparent; background: transparent; color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); text-decoration: none; }
.icon-btn svg { width: 20px; height: 20px; }
.badge-dot {
  position: absolute; top: 4px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px;
  background: var(--red); color: #fff; font-size: .68rem; font-weight: 700; line-height: 17px; text-align: center;
  border: 2px solid var(--bg);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong);
  display: inline-grid; place-items: center; font-size: .78rem; font-weight: 700; flex-shrink: 0;
}

.content { padding: 28px; max-width: 1240px; width: 100%; }
.content--narrow { max-width: 760px; }

/* Profilmenü */
.menu { position: relative; }
.menu__trigger {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 99px;
  border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text); font: inherit;
}
.menu__trigger:hover, .menu__trigger[aria-expanded="true"] { background: var(--surface); border-color: var(--border); }
.menu__name { font-size: .9rem; font-weight: 550; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 6px;
}
.menu__panel[hidden] { display: none; }
.menu__header { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu__header small { display: block; color: var(--text-muted); }
.menu__item {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text); background: none; border: 0; font: inherit; font-size: .92rem; cursor: pointer;
}
.menu__item:hover { background: var(--surface-muted); text-decoration: none; }

/* Seitenkopf */
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: .85rem; color: var(--text-muted); margin-bottom: 8px; }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs span[aria-hidden] { color: var(--text-subtle); }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-header h1 { margin: 0; }
.page-header__sub { color: var(--text-muted); margin: 4px 0 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* --- Bausteine ------------------------------------------------------------ */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); margin-bottom: 20px;
}
.card__header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card__header h2, .card__header h3 { margin: 0; }
.card__body { padding: 20px; }
.card__footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-muted); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card--flush .card__body { padding: 0; }

.grid { display: grid; gap: 20px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row--between { justify-content: space-between; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.text-sm { font-size: .86rem; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: .92rem; font-weight: 550;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-muted); border-color: var(--text-subtle); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn--secondary { background: var(--surface); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn--danger { background: var(--surface); border-color: color-mix(in srgb, var(--red) 40%, #fff); color: var(--red); }
.btn--danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn--success { background: var(--green); border-color: var(--green); color: #fff; }
.btn--success:hover { background: color-mix(in srgb, var(--green) 85%, #000); }
.btn--sm { min-height: 30px; padding: 0 10px; font-size: .84rem; }
.btn--lg { min-height: 46px; padding: 0 22px; font-size: 1rem; }
.btn--block { width: 100%; }
.inline-form { display: inline; }

/* Pillen */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px;
  font-size: .78rem; font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--review { color: var(--gray); background: var(--gray-bg); }
.pill--feedback { color: var(--orange); background: var(--orange-bg); }
.pill--approved { color: var(--green); background: var(--green-bg); }
.pill--overdue { color: var(--red); background: var(--red-bg); }
.pill--info { color: var(--blue); background: var(--blue-bg); }
.pill--neutral { color: var(--text-muted); background: transparent; border: 1px solid var(--border); }
.pill--accent { color: var(--accent-strong); background: var(--accent-soft); }

/* Tabellen */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
  text-align: left; font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-muted);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-muted); }
.table .is-muted td { color: var(--text-subtle); }
.table__title { font-weight: 600; color: var(--text); }
.table__actions { text-align: right; white-space: nowrap; }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; }
.list__item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list__item:last-child { border-bottom: 0; }
.list__main { flex: 1; min-width: 0; }
.list__title { font-weight: 600; color: var(--text); }
.list__meta { font-size: .84rem; color: var(--text-muted); }
.list__item.is-overdue { box-shadow: inset 3px 0 0 var(--red); }

/* Formulare */
.form { max-width: 640px; }
.field { margin-bottom: 18px; }
.field__label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field__required { color: var(--red); margin-left: 2px; }
.field__help { font-size: .84rem; color: var(--text-muted); margin-top: 5px; }
.field__error { font-size: .84rem; color: var(--red); margin-top: 5px; }
.field--invalid input, .field--invalid select, .field--invalid textarea { border-color: var(--red); }
.field--checkbox { display: flex; gap: 10px; align-items: flex-start; }
.field--checkbox .field__label { margin: 0; font-weight: 500; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"],
input[type="datetime-local"], input[type="search"], input[type="url"], input[type="file"], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; font: inherit; font-size: .95rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
textarea { min-height: 110px; resize: vertical; }
input[type="file"] { padding: 6px; }
input[type="color"] { width: 64px; height: 40px; padding: 3px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 17px; height: 17px; margin: 3px 0 0; flex-shrink: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input--code { font-family: var(--font-mono); font-size: 1.5rem !important; letter-spacing: .4em; text-align: center; max-width: 240px; }
.choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.choices label {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; font-weight: 450; background: var(--surface);
}
.choices label:hover { border-color: var(--border-strong); }
.choices label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choices--compact { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.form-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.form-inline .field { margin-bottom: 0; flex: 1 1 180px; }
.form-inline--nowrap { flex-wrap: nowrap; align-items: center; }
.form-inline--nowrap .field { min-width: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { margin-bottom: 0; flex: 1 1 160px; max-width: 260px; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-weight: 650; font-size: 1.02rem; margin-bottom: 12px; }

/* Hinweise */
.messages { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 8px; }
.alert {
  padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); font-size: .93rem;
}
.alert--success { border-color: color-mix(in srgb, var(--green) 30%, #fff); background: var(--green-bg); color: #14532d; }
.alert--error { border-color: color-mix(in srgb, var(--red) 30%, #fff); background: var(--red-bg); color: #7f1d1d; }
.alert--warning { border-color: color-mix(in srgb, var(--orange) 30%, #fff); background: var(--orange-bg); color: #7c3a00; }
.alert--info { border-color: color-mix(in srgb, var(--blue) 25%, #fff); background: var(--blue-bg); color: #173e72; }

/* Leerzustand */
.empty { text-align: center; padding: 44px 20px; color: var(--text-muted); }
.empty__icon {
  width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 14px; background: var(--accent-soft);
  color: var(--accent); display: grid; place-items: center; font-size: 1.3rem;
}
.empty__title { font-weight: 650; color: var(--text); margin-bottom: 4px; }
.empty__text { max-width: 420px; margin: 0 auto 14px; font-size: .93rem; }
.empty--compact { padding: 18px 20px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.empty--compact .empty__icon { width: 28px; height: 28px; margin: 0; border-radius: 8px; font-size: .9rem; }
.empty--compact .empty__title { font-weight: 500; color: var(--text-muted); margin: 0; font-size: .92rem; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; font-size: .88rem; color: var(--text-muted); }
.pagination__links { display: flex; gap: 6px; }

/* Bestätigungsdialog */
.dialog {
  border: 0; padding: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: min(440px, calc(100vw - 32px)); color: var(--text);
}
.dialog::backdrop { background: rgba(29, 27, 25, .42); }
.dialog__body { padding: 24px 24px 8px; }
.dialog__title { font-size: 1.1rem; margin-bottom: 8px; }
.dialog__text { color: var(--text-muted); margin: 0; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px 20px; }

/* Kennzahlen / Schlüssel-Wert */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; font-size: .92rem; }
.dl dt { color: var(--text-muted); }
.dl dd { margin: 0; }
.hash { font-family: var(--font-mono); font-size: .8rem; word-break: break-all; color: var(--text-muted); }

/* Abschnitte auf der Projektseite */
.section-block { margin-bottom: 24px; }
.section-block__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-block__head h2 { font-size: 1.05rem; margin: 0; }
.count { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 99px; background: var(--gray-bg); color: var(--text-muted); font-size: .76rem; font-weight: 600; text-align: center; margin-left: 6px; }

/* Anmeldung (ohne Seitenleiste) */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth__card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 32px;
}
.auth__card--wide { width: min(520px, 100%); }
.auth__brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 24px; font-weight: 650; font-size: 1.1rem; }
.auth__brand img { max-height: 40px; width: auto; }
.auth__title { text-align: center; font-size: 1.3rem; margin-bottom: 6px; }
.auth__lead { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: .93rem; }
.auth__footer { text-align: center; margin-top: 18px; font-size: .88rem; }
.auth .field input { min-height: 44px; }
.qr { display: block; width: 200px; height: 200px; margin: 0 auto 12px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
.secret { display: block; text-align: center; font-family: var(--font-mono); font-size: .9rem; letter-spacing: .08em; background: var(--surface-muted); padding: 8px; border-radius: var(--radius-sm); word-break: break-all; }

.color-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; border: 1px solid var(--border); }
.backdrop { display: none; }

/* --- Responsiv -------------------------------------------------------------- */

@media (max-width: 1024px) {
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); z-index: 60;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  /* Schatten nur bei geöffneter Navigation – sonst ragt er am linken Rand ins Bild. */
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(29, 27, 25, .35); z-index: 50; }
  .topbar { padding: 0 14px; }
  .topbar .topbar__menu-btn { display: inline-grid; }
  .menu__name { display: none; }
  .content { padding: 20px 16px 40px; }
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
  .page-header { align-items: flex-start; }
  .page-actions { width: 100%; }
  .table--responsive thead { display: none; }
  .table--responsive tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .table--responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 16px; }
  .table--responsive td::before { content: attr(data-label); color: var(--text-muted); font-size: .82rem; }
  .table--responsive td.table__actions { justify-content: flex-end; }
  .table--responsive td.table__actions::before { content: none; }
  .list__item { flex-wrap: wrap; padding: 12px 16px; }
  .btn { min-height: 42px; }
  .btn--sm { min-height: 34px; }
  .auth__card { padding: 24px 20px; }
}

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

@media print {
  .sidebar, .topbar, .page-actions, .btn { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
