/* Verpackungs-Konformität — hell/dunkel über CSS-Variablen, tastaturfreundlich */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1c2430;
  --text-muted: #5b6675;
  --border: #d7dce3;
  --accent: #1f6feb;
  --accent-contrast: #ffffff;
  --ok: #1a7f37;
  --ok-bg: #e2f5e8;
  --open: #9a6700;
  --open-bg: #fff3d1;
  --fail: #c72222;
  --fail-bg: #ffe1e1;
  --info-bg: #e7f0fd;
  --shadow: 0 1px 3px rgba(16, 24, 40, .09);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151b;
    --surface: #1a2029;
    --surface-2: #232b37;
    --text: #e6eaf0;
    --text-muted: #9aa6b5;
    --border: #333d4b;
    --accent: #4c8dff;
    --accent-contrast: #0b1220;
    --ok: #4ac26b; --ok-bg: #12341d;
    --open: #e3b341; --open-bg: #3a2d10;
    --fail: #ff6b6b; --fail-bg: #43191c;
    --info-bg: #16283f;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg: #11151b; --surface: #1a2029; --surface-2: #232b37;
  --text: #e6eaf0; --text-muted: #9aa6b5; --border: #333d4b;
  --accent: #4c8dff; --accent-contrast: #0b1220;
  --ok: #4ac26b; --ok-bg: #12341d;
  --open: #e3b341; --open-bg: #3a2d10;
  --fail: #ff6b6b; --fail-bg: #43191c;
  --info-bg: #16283f; --shadow: 0 1px 3px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, "Segoe UI", Roboto, sans-serif;
  display: flex; min-height: 100vh; flex-direction: column;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; width: 100%; }
main.wrap { flex: 1; padding-top: 1.5rem; padding-bottom: 3rem; }

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--accent);
  color: var(--accent-contrast); padding: .5rem 1rem; z-index: 100; border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Kopfzeile */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
.header-inner { display: flex; align-items: center; gap: 1.5rem; padding-top: .6rem; padding-bottom: .6rem; flex-wrap: wrap; }
.brand { display: flex; gap: .6rem; align-items: center; color: var(--text); line-height: 1.15; }
.brand:hover { text-decoration: none; }
.brand small { color: var(--text-muted); }
.brand-mark { font-size: 1.6rem; }
.main-nav { display: flex; gap: .15rem; flex-wrap: wrap; margin-left: auto; }
.main-nav a { padding: .45rem .65rem; border-radius: 7px; color: var(--text); white-space: nowrap; }
.main-nav a:hover { background: var(--surface-2); text-decoration: none; }
.main-nav a.active { background: var(--accent); color: var(--accent-contrast); }
.user-box { display: flex; align-items: center; gap: .5rem; }
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: 7px; color: var(--text); cursor: pointer; padding: .3rem .55rem; font-size: 1rem; }
.user-menu { position: relative; }
.user-menu summary { cursor: pointer; list-style: none; padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 7px; white-space: nowrap; }
.user-menu[open] summary { background: var(--surface-2); }
.user-menu-body {
  position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  min-width: 200px; padding: .4rem; display: flex; flex-direction: column; z-index: 50;
}
.user-menu-body a, .user-menu-body button { padding: .45rem .6rem; border-radius: 6px; color: var(--text); text-align: left; }
.user-menu-body a:hover, .user-menu-body button:hover { background: var(--surface-2); text-decoration: none; }

/* Fußzeile */
.site-footer { border-top: 1px solid var(--border); color: var(--text-muted); font-size: .85rem; padding: .8rem 0; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* Meldungen */
.messages { margin-bottom: 1.2rem; display: flex; flex-direction: column; gap: .5rem; }
.message { padding: .65rem .9rem; border-radius: 8px; border: 1px solid var(--border); background: var(--info-bg); }
.message.success { background: var(--ok-bg); border-color: var(--ok); }
.message.warning { background: var(--open-bg); border-color: var(--open); }
.message.error { background: var(--fail-bg); border-color: var(--fail); }

/* Überschriften & Seitenkopf */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.page-head h1 { margin: 0; font-size: 1.45rem; }
.page-head .sub { color: var(--text-muted); margin-top: .15rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Karten & KPI */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.card h2 { margin: 0 0 .8rem; font-size: 1.05rem; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: .9rem 1.1rem; }
.kpi .num { font-size: 1.9rem; font-weight: 700; line-height: 1.2; }
.kpi .lbl { color: var(--text-muted); font-size: .85rem; }
.kpi.ok .num { color: var(--ok); }
.kpi.open .num { color: var(--open); }
.kpi.fail .num { color: var(--fail); }
.kpi.deadline .num { color: var(--accent); }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .65rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-muted); font-weight: 600; white-space: nowrap; background: var(--surface-2); }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }
.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85em; }

/* Status-Ampel */
.badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  font-size: .8rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.badge.small { font-size: .72rem; padding: .05rem .45rem; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok); }
.badge.open { background: var(--open-bg); color: var(--open); border: 1px solid var(--open); }
.badge.fail { background: var(--fail-bg); color: var(--fail); border: 1px solid var(--fail); }
.badge.neutral { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* Formulare */
form.stacked p, .field { margin: 0 0 .9rem; }
label { display: block; font-weight: 600; margin-bottom: .25rem; }
input[type="text"], input[type="number"], input[type="date"], input[type="password"],
input[type="email"], input[type="file"], select, textarea {
  width: 100%; max-width: 620px; padding: .5rem .6rem; border: 1px solid var(--border);
  border-radius: 7px; background: var(--surface); color: var(--text); font: inherit;
}
input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.checkbox-row { display: flex; gap: .5rem; align-items: flex-start; }
.checkbox-row label { font-weight: 600; margin: 0; }
.helptext { display: block; color: var(--text-muted); font-size: .83rem; margin-top: .2rem; }
.errorlist { color: var(--fail); margin: .2rem 0 0; padding-left: 1.1rem; }

.btn {
  display: inline-block; background: var(--accent); color: var(--accent-contrast);
  border: 1px solid transparent; padding: .5rem .95rem; border-radius: 8px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.danger { background: var(--fail); color: #fff; }
.btn.small { padding: .25rem .6rem; font-size: .84rem; }
button.linklike { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
button.linklike:hover { text-decoration: underline; }

/* Filterzeile */
.filter-bar { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-bar > div { min-width: 150px; }
.filter-bar label { font-size: .8rem; color: var(--text-muted); }
.filter-bar input, .filter-bar select { max-width: 230px; }

/* Prüfliste auf Detailseiten */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: .6rem; padding: .45rem 0; border-bottom: 1px dashed var(--border); align-items: baseline; }
.checklist li:last-child { border-bottom: none; }
.check-icon { flex: 0 0 auto; font-weight: 700; }
.check-icon.ok { color: var(--ok); }
.check-icon.open { color: var(--open); }
.check-icon.fail { color: var(--fail); }
.check-detail { color: var(--text-muted); font-size: .87rem; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

dl.props { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.props dt { color: var(--text-muted); }
dl.props dd { margin: 0; }

.role-head td { background: var(--surface-2); font-weight: 700; color: var(--text-muted); }
.empty { color: var(--text-muted); font-style: italic; padding: 1rem 0; }

/* Login */
.login-card { max-width: 420px; margin: 8vh auto; }
