/* Procurement: Gestaltung wie Inventory (und Rami, boldr-group/olaf): Rameder-CI, Menü in Dark Teal,
   Rot für Akzente (aktiver Menüpunkt, Hauptbuttons, Fokus), Grün nur für "in Ordnung". Touch-Ziele >= 44px,
   Eingaben 16px (kein iOS-Zoom). Alle Farben stehen als Variablen in diesem Block. */
:root {
  --red: #EB2321;
  --red-strong: #C41B19;
  --red-hover: #A81715;
  --teal: #0A3437;
  --teal-2: #12464A;
  --teal-ink: #FFFFFF;
  --teal-muted: #A9C3C4;
  --green: #009D3B;
  --brand-ink: #FFFFFF;     /* Logo und Wortmarke auf dem Teal-Menü */

  --bg: #F4F4F1;
  --surface: #FFFFFF;
  --surface-2: #F7F7F4;
  --ink: #1A1A1A;
  --muted: #4C4C4C;
  --faint: #767676;
  --line: #D9D9D9;
  --line-2: #C2C2C2;
  --focus: #EB2321;
  --link: #C41B19;

  --ok: #00702A; --ok-bg: #E3F3E8;
  --warn: #8A4B00; --warn-bg: #FFF1DC;
  --bad: #B3150F; --bad-bg: #FDE8E7;

  --radius: 10px;
  --side-w: 272px;
  --sans: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --teal: #071F21; --teal-2: #0E3134;
    --bg: #101718; --surface: #182224; --surface-2: #1E2A2C; --ink: #ECEFEE; --muted: #B4BFBE; --faint: #8C9998;
    --line: #2C3B3D; --line-2: #3B4D50; --red-strong: #E0322F; --red-hover: #F0443F; --link: #FF8A80;
    --ok: #7FD39C; --ok-bg: #15301F; --warn: #F5C27A; --warn-bg: #36280F; --bad: #FF8A80; --bad-bg: #3A1B19;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --teal: #071F21; --teal-2: #0E3134;
  --bg: #101718; --surface: #182224; --surface-2: #1E2A2C; --ink: #ECEFEE; --muted: #B4BFBE; --faint: #8C9998;
  --line: #2C3B3D; --line-2: #3B4D50; --red-strong: #E0322F; --red-hover: #F0443F; --link: #FF8A80;
  --ok: #7FD39C; --ok-bg: #15301F; --warn: #F5C27A; --warn-bg: #36280F; --bad: #FF8A80; --bad-bg: #3A1B19;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 10px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.block { display: block; }
.off { font-style: normal; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; background: var(--warn-bg); color: var(--warn); margin-left: 8px; vertical-align: 2px; }

/* ---------------------------------------------------------------- layout */
#app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100dvh; }
#topbar { display: none; }
#side { grid-row: 1; grid-column: 1; position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; background: var(--teal); color: var(--teal-ink); overflow-y: auto; padding: 20px 12px calc(16px + env(safe-area-inset-bottom)); }
#main { grid-column: 2; padding: 32px clamp(16px, 4vw, 48px) 48px; min-width: 0; outline: none; max-width: 1240px; width: 100%; position: relative; }
#backdrop { display: none; }
.boot { color: var(--muted); padding: 40px 0; }

.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 18px; }
/* Oben links: Logo-Zeichen und Wortmarke "Procurement" */
.brand { display: flex; align-items: flex-end; gap: 10px; text-decoration: none; color: var(--brand-ink); }
.brand-logo { flex: none; width: 41px; height: 34px; display: block; }
.brand-name { font-size: 25px; font-weight: 900; line-height: .74; letter-spacing: .01em; color: var(--brand-ink); }
.brand-r { color: var(--red); }
#drawer-close { display: none; color: var(--teal-ink); }

#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-apps { display: flex; flex-direction: column; gap: 2px; }
.nav-item[hidden] { display: none; }
.nav-search-wrap { position: relative; margin: 10px 0 2px; color: var(--teal-muted); }
.nav-search-wrap .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.nav-search { width: 100%; min-height: 42px; padding: 8px 12px 8px 38px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .08); color: var(--teal-ink); font: inherit; font-size: 16px; }
.nav-search::placeholder { color: var(--teal-muted); }
.nav-search:focus { outline: 2px solid var(--red); outline-offset: 1px; }
.nav-empty { color: var(--teal-muted); font-size: 14px; padding: 8px 12px; margin: 0; }
.nav-empty[hidden], .nav-label[hidden] { display: none; }
#nav-foot { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid rgba(255, 255, 255, .15); padding-top: 12px; margin-top: 12px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--teal-muted); padding: 14px 12px 6px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 8px 12px; border-radius: 8px; color: var(--teal-ink); text-decoration: none; font-size: 16px; }
.nav-item:hover { background: rgba(255, 255, 255, .07); }
.nav-item.on { background: var(--teal-2); font-weight: 700; }
.nav-item.on::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 4px; border-radius: 2px; background: var(--red); }
.nav-item .ico { flex: none; color: var(--teal-muted); }
.nav-item.on .ico { color: var(--teal-ink); }
.nav-item .off { margin-left: auto; }
.nav-item.subtle { color: var(--teal-muted); font-size: 15px; }
.nav-knopf { width: 100%; border: 0; background: transparent; font: inherit; text-align: left; cursor: pointer; }
/* desktop: menu collapsed to a narrow bar with the icons (button #side-toggle, remembered per browser) */
#side-toggle { color: var(--teal-muted); flex: none; }
.side-toggle-arrow { transition: transform .15s ease; transform-origin: 14px 12px; }
@media (min-width: 900px) {
  body.side-collapsed { --side-w: 72px; }
  body.side-collapsed #side { padding-left: 10px; padding-right: 10px; overflow-x: hidden; }
  body.side-collapsed .side-head { flex-direction: column; align-items: center; padding: 0 0 12px; gap: 10px; }
  body.side-collapsed .brand-name, body.side-collapsed .nav-item > span, body.side-collapsed .nav-item .off,
  body.side-collapsed .nav-search-wrap, body.side-collapsed .nav-label, body.side-collapsed .nav-empty, body.side-collapsed .who { display: none; }
  body.side-collapsed .nav-item { justify-content: center; padding: 8px; }
  body.side-collapsed .side-toggle-arrow { transform: scaleX(-1); }
}
@media (max-width: 899px) { #side-toggle { display: none; } }

/* phones and small tablets: menu becomes a drawer from the left */
@media (max-width: 899px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  #topbar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 30; background: var(--teal); color: var(--teal-ink); padding: calc(6px + env(safe-area-inset-top)) 12px 6px 6px; min-height: 56px; }
  #top-title { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #menu-btn { color: var(--teal-ink); }
  #side { position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(86vw, 320px); transform: translateX(-102%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .25); padding-top: calc(20px + env(safe-area-inset-top)); }
  #drawer-close { display: inline-flex; }
  body.drawer-open #side { transform: none; }
  body.drawer-open #backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); }
  body.drawer-open { overflow: hidden; }
  #main { grid-column: 1; grid-row: 2; padding: 20px 16px calc(40px + env(safe-area-inset-bottom)); }
  h1 { font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) { #side { transition: none; } }

body.loading #nav, body.loading #nav-foot { visibility: hidden; }
body.fatal #app { display: block; }
.gate { max-width: 480px; margin: 12vh auto; padding: 0 16px; }
.gate { --brand-ink: var(--ink); }
.gate .brand { margin-bottom: 28px; }
.gate .btn { margin: 6px 6px 0 0; }

/* ---------------------------------------------------------------- page parts */
.page-head { margin-bottom: 22px; }
.page-head p { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.tile { display: flex; align-items: center; gap: 14px; padding: 16px; min-height: 84px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.tile:hover { border-color: var(--red); }
.tile-ico { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 10px; background: var(--teal); color: #FFFFFF; }
.tile-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.tile-text .muted { font-size: 14px; }
.tile-go { color: var(--faint); }
.empty { background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 28px 20px; text-align: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.card-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
/* Apps settings: cards are draggable to set the menu order */
.app-card { cursor: grab; }
.app-card .app-move { margin-left: auto; display: flex; gap: 2px; }
.app-card.dragging { opacity: .5; }
.app-card.drop-target { outline: 2px dashed var(--red); outline-offset: 2px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 14px; }
.cards .card { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.note { border-radius: 8px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); margin: 0 0 10px; }
.note.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.note.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

/* ---------------------------------------------------------------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; font-weight: 600; font-size: 15px; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--red-strong); border-color: var(--red-strong); color: #FFFFFF; }
.btn.primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.iconbtn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; font-size: 28px; line-height: 1; color: inherit; }
.iconbtn.small { width: 36px; height: 36px; }
.iconbtn:hover { background: rgba(127, 127, 127, .14); }
.input { min-height: 44px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-size: 16px; width: 100%; }
textarea.input { resize: vertical; }
select.input { padding-right: 32px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: 14px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--red-strong); }
.link { color: var(--link); font-weight: 600; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.toolbar-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar-group.grow { flex: 1; min-width: min(100%, 320px); }
.toolbar-group.grow .input[type="search"] { flex: 2; min-width: 200px; }
.toolbar-group.grow select { flex: 1; width: auto; min-width: 140px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 600; }
.tab.on { color: #FFFFFF; background: var(--teal); border-radius: 999px; border-bottom-color: transparent; }

.chip { display: inline-block; font-size: 13px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); margin: 2px 4px 2px 0; white-space: nowrap; }
.chip.strong { background: var(--teal); border-color: var(--teal); color: #FFFFFF; }
.chip.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; margin-left: 6px; }
.chip.dim { color: var(--muted); }
.chip.own { border-color: var(--ink); font-weight: 600; } /* app right set on the person (Einstellungen → Nutzer) */
.chip.grp { border-style: dashed; border-color: var(--ink); } /* app right from a group (Einstellungen → Gruppen) */
.chip.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.chip.k-new { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.chip.k-deactivate, .chip.k-blocked { color: var(--warn); background: var(--warn-bg); border-color: transparent; }

/* tables, stacked into cards on phones */
table.list { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--line); }
.list td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list tr:last-child td { border-bottom: 0; }
.list tr.click { cursor: pointer; }
.list tr.click:hover td { background: var(--surface-2); }
.list tr.inactive td { opacity: .6; }
.list.compact td { padding: 8px 10px; font-size: 14px; }
.count { margin: 4px 0 8px; }
@media (max-width: 699px) {
  table.list, .list tbody, .list tr, .list td { display: block; width: 100%; }
  .list thead { display: none; }
  table.list { border: 0; background: transparent; }
  .list tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 6px 0; }
  .list td { border: 0; padding: 6px 14px; }
  .list td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }
  .list td[data-label="Nutzer"]::before { display: none; }
  .toolbar-group:not(.grow) { width: 100%; }
  .toolbar-group:not(.grow) .btn { flex: 1; }
}

/* dialog: centered on desktop, full screen on phones */
.dlg { border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.dlg[open] { display: flex; flex-direction: column; }
.dlg::backdrop { background: rgba(0, 0, 0, .5); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 10px 10px 20px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 19px; overflow: hidden; text-overflow: ellipsis; }
/* flex-basis auto, not 0: Safari otherwise collapses the body of a dialog without fixed height (Rami) */
.dlg-body { padding: 18px 20px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex-wrap: wrap; }
.dlg-foot .btn.danger { margin-right: auto; }
@media (max-width: 699px) {
  .dlg { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .dlg-foot .btn { flex: 1; }
}
.form { display: flex; flex-direction: column; gap: 14px; }
fieldset.rights { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 14px 10px; margin: 0; }
fieldset.rights legend { font-weight: 600; font-size: 14px; padding: 0 6px; }
fieldset.rights.dim .right-row, fieldset.rights.dim .gruppen-wahl { opacity: .45; pointer-events: none; }
.gruppen-wahl { display: flex; flex-direction: column; gap: 6px; padding: 6px 0; }
fieldset.rights.dim::after { content: "Admins haben automatisch alle Rechte."; display: block; color: var(--muted); font-size: 13px; padding-top: 6px; }
.right-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.right-row:last-of-type { border-bottom: 0; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span { display: inline-flex; align-items: center; min-height: 42px; padding: 0 14px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg-opt + .seg-opt span { border-left: 1px solid var(--line-2); }
.seg-opt input:checked + span { background: var(--teal); color: #FFFFFF; }
.seg-opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }
.role-hints { flex-basis: 100%; margin: 0; }
@media (max-width: 699px) {
  .right-row .seg { width: 100%; }
  .seg-opt { flex: 1; }
  .seg-opt span { width: 100%; justify-content: center; padding: 0 6px; font-size: 13px; text-align: center; }
}
.summary { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 10px; }
.list .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* new version banner (above the content, below the toasts) */
#update-banner { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); width: min(520px, calc(100vw - 32px)); display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }
#update-banner span { flex: 1; font-weight: 600; }
#update-banner .iconbtn { color: inherit; }

/* toasts */
#toasts { position: fixed; z-index: 100; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); transition: opacity .4s; }
.toast.bad { background: var(--bad); color: #FFFFFF; }
.toast.out { opacity: 0; }

