/* Orvanta Cockpit – Designsystem
   Ruhige Flächen, eine Akzentfarbe, klare Abstufungen. Hell und dunkel. */

:root {
  --accent: #2f5aa6;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 26%, transparent);
  --accent-ink: #fff;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --sidebar: #ffffff;

  --ink: #1a1f27;
  --ink-2: #515b68;
  --muted: #8a93a0;
  --line: #e7eaef;
  --line-strong: #d5dae2;

  --ok: #1d7a52;
  --warn: #9a6410;
  --danger: #b5372c;

  --r-sm: 7px;
  --r: 10px;
  --r-lg: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, .16);
  --sidebar-w: 236px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 45%, transparent);
  --bg: #0f1318;
  --surface: #161b22;
  --surface-2: #1b212a;
  --sidebar: #12171d;
  --ink: #e6eaf0;
  --ink-2: #b3bcc8;
  --muted: #7c8794;
  --line: #242c36;
  --line-strong: #333d4a;
  --ok: #4ec08a;
  --warn: #d69b3f;
  --danger: #e0736a;
  --shadow: none;
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.015em; font-weight: 600; }
input, select, textarea, button { font: inherit; color: inherit; }
::placeholder { color: var(--muted); }
.icon { flex: none; vertical-align: -.18em; }

/* ---------- Grundgeruest ---------- */

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 16px 12px;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; }
.logo .mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent);
  display: grid; place-items: center; font-weight: 650; color: var(--accent-ink); font-size: 14px;
}
.logo b { font-size: 14.5px; display: block; line-height: 1.2; color: var(--ink); }
.logo small { font-size: 10.5px; color: var(--muted); letter-spacing: .09em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; }
.nav .group {
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  padding: 18px 10px 6px; font-weight: 600;
}
.nav .group:first-child { padding-top: 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 13.5px; transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a .icon { color: var(--muted); transition: color .12s; }
.nav a:hover .icon { color: var(--ink-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.nav a.active .icon { color: var(--accent); }

.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.userchip { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; }
.userchip .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 650;
}
.userchip div b { font-size: 13px; display: block; font-weight: 550; }
.userchip div span { font-size: 11.5px; color: var(--muted); }
.sidebar-foot button {
  display: flex; align-items: center; gap: 9px; width: 100%; margin-top: 2px; padding: 7px 10px;
  background: none; border: none; border-radius: var(--r-sm); color: var(--muted);
  cursor: pointer; font-size: 13px; text-align: left;
}
.sidebar-foot button:hover { background: var(--surface-2); color: var(--ink); }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 16px 28px; background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; }
.topbar .sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.topbar .spacer { flex: 1; }
.content { padding: 24px 28px 72px; max-width: 1480px; width: 100%; }

/* ---------- Knoepfe ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 32%, var(--line)); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.icon-only { padding: 7px 9px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.iconbtn {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  background: none; border: none; cursor: pointer; color: var(--muted); border-radius: var(--r-sm);
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- Karten / Raster ---------- */

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden;
}
.card > header {
  display: flex; align-items: center; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--line);
}
.card > header h3 { font-size: 13.5px; font-weight: 600; }
.card > header .spacer { flex: 1; }
.card .body { padding: 18px; }
.card .body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.wide-left { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); }
.stack { display: grid; gap: 16px; }

.kpi-card {
  padding: 15px 17px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
}
.kpi-card .label { font-size: 11.5px; color: var(--muted); font-weight: 550; letter-spacing: .02em; }
.kpi-card .value {
  font-size: 24px; font-weight: 620; letter-spacing: -.025em; margin-top: 5px;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.kpi-card .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-card .value.ok { color: var(--ok); }
.kpi-card .value.warn { color: var(--warn); }
.kpi-card .value.danger { color: var(--danger); }

/* ---------- Tabellen ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600;
  padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.clickable { cursor: pointer; }
table.data .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .strong { font-weight: 550; }
table.data .dim { color: var(--muted); }
table.data td .row-actions { display: flex; gap: 1px; justify-content: flex-end; opacity: 0; transition: opacity .12s; }
table.data tr:hover .row-actions, table.data tr:focus-within .row-actions { opacity: 1; }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .icon { color: var(--line-strong); margin-bottom: 10px; }
.empty p { margin: 0; font-size: 13.5px; }

/* ---------- Etiketten ---------- */

.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 550;
  padding: 2px 8px; border-radius: 5px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap;
}
.tag.ok     { color: var(--ok);     background: color-mix(in srgb, var(--ok) 9%, transparent);     border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.tag.warn   { color: var(--warn);   background: color-mix(in srgb, var(--warn) 11%, transparent);  border-color: color-mix(in srgb, var(--warn) 24%, transparent); }
.tag.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.tag.info   { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.tag.dim    { color: var(--muted); }

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

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 550; color: var(--ink-2); }
.field .hint { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.field input, .field select, .field textarea,
.input {
  width: 100%; padding: 8px 11px; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); transition: border-color .12s, box-shadow .12s;
}
:root[data-theme="dark"] .field input,
:root[data-theme="dark"] .field select,
:root[data-theme="dark"] .field textarea,
:root[data-theme="dark"] .input { background: var(--surface-2); }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.field.check { flex-direction: row; align-items: center; gap: 9px; }
.field.check input { width: 15px; height: 15px; accent-color: var(--accent); }
.field.check label { font-weight: 450; color: var(--ink); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-section {
  grid-column: 1 / -1; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-top: 10px;
  font-weight: 600;
}

.search {
  display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 6px 11px; min-width: 260px;
  color: var(--muted);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { border: none; background: none; outline: none; width: 100%; font-size: 13px; color: var(--ink); }
.filterbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filterbar select {
  padding: 6px 11px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 13px;
}
.filterbar .count { color: var(--muted); font-size: 12.5px; }

/* ---------- Schublade und Dialog ---------- */

.overlay {
  position: fixed; inset: 0; background: rgba(12, 16, 22, .42); backdrop-filter: blur(1px);
  z-index: 60; opacity: 0; animation: fade .16s forwards;
}
@keyframes fade { to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100%); background: var(--bg);
  z-index: 61; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  transform: translateX(100%); animation: slide .2s cubic-bezier(.32,.72,.3,1) forwards;
}
@keyframes slide { to { transform: none; } }
.drawer > header {
  display: flex; align-items: center; gap: 12px; padding: 15px 22px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.drawer > header h2 { font-size: 16px; }
.drawer > header .spacer { flex: 1; }
.drawer .drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.drawer > footer {
  display: flex; gap: 10px; justify-content: flex-end; padding: 13px 22px;
  border-top: 1px solid var(--line); background: var(--surface);
}

.modal {
  position: fixed; z-index: 61; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(440px, calc(100% - 32px)); background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 22px; animation: pop .14s ease-out;
}
@keyframes pop { from { opacity: .5; transform: translate(-50%, -48%) scale(.98); } }
.modal h3 { margin-bottom: 8px; font-size: 16px; }
.modal p { color: var(--ink-2); margin: 0 0 18px; font-size: 13.5px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; }

.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 80; display: grid; gap: 8px; }
.toast {
  background: var(--ink); color: var(--bg); padding: 10px 15px; border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg); font-size: 13px; max-width: 380px;
  animation: toastin .18s ease-out; border-left: 3px solid var(--accent);
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Hinweisleiste ---------- */

.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 15px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface); font-size: 13px; color: var(--ink-2);
}
.notice .icon { margin-top: 1px; color: var(--muted); }
.notice b { color: var(--ink); font-weight: 600; }
.notice.ok { border-color: color-mix(in srgb, var(--ok) 26%, var(--line)); background: color-mix(in srgb, var(--ok) 6%, var(--surface)); }
.notice.ok .icon { color: var(--ok); }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 28%, var(--line)); background: color-mix(in srgb, var(--warn) 7%, var(--surface)); }
.notice.warn .icon { color: var(--warn); }
.notice.danger { border-color: color-mix(in srgb, var(--danger) 26%, var(--line)); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.notice.danger .icon { color: var(--danger); }

/* ---------- Reiter und Detailansicht ---------- */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  background: none; border: none; padding: 10px 14px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; font-size: 13.5px; white-space: nowrap; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink-2); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 550; }
.tab-count {
  display: inline-block; margin-left: 7px; font-size: 11px; padding: 0 6px; border-radius: 20px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tabs button.active .tab-count { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

dl.kv { display: grid; grid-template-columns: 130px 1fr; gap: 9px 16px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

/* ---------- Organisationen ---------- */

.org-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.org-card {
  text-align: left; font: inherit; color: inherit; cursor: pointer; display: grid; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 16px 18px; transition: border-color .12s, transform .08s;
}
.org-card:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.org-head { display: flex; align-items: center; gap: 11px; }
.org-avatar {
  width: 36px; height: 36px; flex: none; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: 12.5px;
}
.org-name { min-width: 0; flex: 1; }
.org-name b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-name small { color: var(--muted); font-size: 12px; }
.org-sparten { display: flex; flex-wrap: wrap; gap: 6px; }
.sparte {
  font-size: 11.5px; padding: 2px 8px; border-radius: 5px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--ink-2);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sparte.dim { color: var(--muted); }
.org-foot {
  display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--line); padding-top: 11px;
}
.org-foot .warnfg { color: var(--warn); font-weight: 550; }

/* ---------- Ticketverlauf ---------- */

.ticket-thread { display: grid; gap: 10px; margin-top: 20px; }
.thread-item { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; background: var(--surface); }
.thread-item.internal {
  background: color-mix(in srgb, var(--warn) 6%, var(--surface));
  border-color: color-mix(in srgb, var(--warn) 22%, var(--line));
}
.thread-item.system { background: var(--surface-2); color: var(--muted); font-size: 12.5px; }
.thread-head {
  display: flex; align-items: center; gap: 9px; font-size: 11.5px; color: var(--muted);
  margin-bottom: 6px; flex-wrap: wrap;
}
.thread-head b { color: var(--ink); font-size: 13px; font-weight: 600; }
.thread-head .iconbtn { opacity: 0; }
.thread-item:hover .thread-head .iconbtn { opacity: .7; }
.thread-body { font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; }

/* ---------- Kalender ---------- */

.cal-grid-head { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.cal-grid-head div {
  padding: 9px 12px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: minmax(108px, auto); }
.cal-day {
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 7px 8px;
  cursor: pointer; transition: background .1s; min-width: 0;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.outside { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.cal-day.outside .cal-daynum { color: var(--muted); opacity: .55; }
.cal-daynum {
  font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px;
  width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%;
  font-variant-numeric: tabular-nums;
}
.cal-day.is-today .cal-daynum { background: var(--accent); color: var(--accent-ink); }
.cal-events { display: grid; gap: 3px; }
.cal-ev {
  display: block; width: 100%; text-align: left; font: inherit; font-size: 11.5px; line-height: 1.35;
  padding: 2px 6px; border: none; border-left: 2px solid var(--accent); border-radius: 3px;
  background: var(--accent-soft); color: var(--ink); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-ev b { font-weight: 600; color: var(--ink-2); }
.cal-ev.kind-frist   { border-left-color: var(--warn);  background: color-mix(in srgb, var(--warn) 9%, transparent); }
.cal-ev.kind-wartung { border-left-color: var(--ok);    background: color-mix(in srgb, var(--ok) 9%, transparent); }
.cal-ev.kind-einsatz { border-left-color: #0e7490;      background: color-mix(in srgb, #0e7490 9%, transparent); }
.cal-ev.kind-urlaub  { border-left-color: #b4467f;      background: color-mix(in srgb, #b4467f 9%, transparent); }
.cal-ev.kind-privat  { border-left-color: #7c5cd6;      background: color-mix(in srgb, #7c5cd6 9%, transparent); }
.cal-ev.kind-aufgabe { border-left-color: var(--muted); background: var(--surface-2); }
.cal-more { font-size: 11px; color: var(--muted); padding-left: 4px; }

/* ---------- Aufgaben ---------- */

.todo-list { list-style: none; margin: 0; padding: 0; }
.todo { display: flex; align-items: flex-start; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.todo:last-child { border-bottom: none; }
.todo:hover { background: var(--surface-2); }
.todo-check {
  flex: none; width: 19px; height: 19px; margin-top: 2px; border-radius: 5px; cursor: pointer;
  border: 1.5px solid var(--line-strong); background: var(--surface); color: transparent;
  display: grid; place-items: center; padding: 0;
}
.todo-check:hover { border-color: var(--accent); }
.todo.done .todo-check { background: var(--ok); border-color: var(--ok); color: #fff; }
.todo-main { flex: 1; min-width: 0; }
.todo-title { font-size: 13.5px; font-weight: 500; }
.todo.done .todo-title { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.todo-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 2px; }
.todo-meta .late { color: var(--danger); font-weight: 550; }
.todo .row-actions { display: flex; gap: 1px; opacity: 0; transition: opacity .12s; }
.todo:hover .row-actions { opacity: 1; }

/* ---------- Belegeditor ---------- */

.doc-editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.items-table { width: 100%; border-collapse: collapse; }
.items-table th {
  font-size: 11.5px; color: var(--muted); font-weight: 600; text-align: left; padding: 0 8px 6px 0;
}
.items-table th:last-child { padding-right: 0; }
.items-table td { padding: 3px 8px 3px 0; vertical-align: top; }
.items-table td.top input { text-align: left; }
.items-table td:last-child { padding-right: 0; }
.items-table textarea, .items-table input {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface);
}
:root[data-theme="dark"] .items-table textarea,
:root[data-theme="dark"] .items-table input { background: var(--surface-2); }
.items-table textarea:focus, .items-table input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.items-table textarea { min-height: 40px; resize: vertical; }
.items-table input { text-align: right; font-variant-numeric: tabular-nums; }
.items-table input.desc { text-align: left; }
.items-table textarea.detail { font-size: 12.5px; margin-top: 4px; min-height: 34px; color: var(--ink-2); }
.items-table .line-sum { display: block; padding-top: 9px; font-variant-numeric: tabular-nums; }
.sum-line { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; color: var(--ink-2); }
.sum-line span:last-child { font-variant-numeric: tabular-nums; color: var(--ink); }
.sum-line.total {
  border-top: 1px solid var(--line); margin-top: 6px; padding-top: 11px;
  font-size: 16px; font-weight: 620; color: var(--ink);
}

/* ---------- Katalogauswahl ---------- */

.cat-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: 7px;
  background: var(--surface); cursor: pointer;
}
.cat-row:hover { border-color: var(--accent-line); }
.cat-row > input[type="checkbox"] { margin-top: 3px; width: 15px; height: 15px; accent-color: var(--accent); }
.cat-main { flex: 1; min-width: 0; }
.cat-main b { font-size: 13.5px; }
.cat-sku {
  display: inline-block; margin-left: 8px; font-size: 11px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}
.cat-detail { font-size: 12px; color: var(--muted); white-space: pre-wrap; margin-top: 3px; line-height: 1.45; }
.cat-free {
  display: flex; align-items: center; gap: 7px; margin-top: 7px; font-size: 12px;
  color: var(--accent); cursor: pointer;
}
.cat-free input { accent-color: var(--accent); }
.cat-qty { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.cat-qty input {
  width: 62px; text-align: right; padding: 5px 8px; border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); background: var(--surface); font-variant-numeric: tabular-nums;
}
.cat-price { width: 96px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------- Balkendiagramm ---------- */

.bars { display: flex; align-items: flex-end; gap: 5px; height: 148px; padding-top: 8px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 7px; height: 100%; }
.bars .bar i {
  display: block; width: 100%; background: var(--accent-soft); border-top: 2px solid var(--accent);
  border-radius: 2px 2px 0 0; min-height: 2px; transition: background .12s;
}
.bars .bar:hover i { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.bars .bar small { font-size: 10.5px; color: var(--muted); }

/* ---------- Anmeldung ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.login-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 32px;
}
.login-card .logo { justify-content: center; padding: 0 0 24px; }
.login-card .field + .field { margin-top: 14px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 22px; padding: 10px; }
.login-err { margin-top: 14px; color: var(--danger); font-size: 12.5px; text-align: center; min-height: 18px; }

/* ---------- Klein ---------- */

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: var(--sidebar-w);
    transform: translateX(-100%); transition: transform .18s; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .content { padding: 18px 16px 64px; }
  .topbar { padding: 12px 16px; }
  .doc-editor, .grid.wide-left { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (min-width: 961px) { .menu-toggle { display: none; } }

/* ---------- E-Mail ----------------------------------------------------------
   Drei Spalten: Postfächer und Ordner, Nachrichtenliste, Leseansicht.
   Die beiden hinteren Spalten scrollen eigenständig, damit die Ordner beim
   Blättern stehen bleiben.
*/
.mail-layout {
  display: grid;
  grid-template-columns: 250px 340px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  height: calc(100vh - 132px);
}

/* --- linke Spalte --- */
.mail-side {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 10px; overflow-y: auto;
}
.mail-accounts { display: grid; gap: 4px; margin-bottom: 6px; }
.mail-account {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 9px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: transparent; color: var(--ink); font: inherit; cursor: pointer;
}
.mail-account:hover { background: var(--surface-2); }
.mail-account.active { background: var(--accent-soft); border-color: var(--accent-soft); }
.mail-account.drop { border-color: var(--accent); background: var(--accent-soft); }
.mail-account-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none;
}
.mail-account-dot.shared { background: var(--warn); }
.mail-account-text { display: grid; min-width: 0; }
.mail-account-name { font-size: 13px; font-weight: 600; }
.mail-account-mail {
  font-size: 11.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.mail-side-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 9px 4px; font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
}
.mail-folders { display: grid; gap: 1px; flex: 1; }
.mail-folder-row {
  display: flex; align-items: center; border-radius: var(--r-sm);
  border: 1px solid transparent;
}
.mail-folder-row:hover { background: var(--surface-2); }
.mail-folder-row.active { background: var(--accent-soft); }
.mail-folder-row.active .mail-folder-name { color: var(--accent); font-weight: 600; }
.mail-folder-row.drop { border-color: var(--accent); background: var(--accent-soft); }
.mail-folder {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  padding: 7px 4px; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.mail-folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-badge {
  margin-left: auto; background: var(--accent); color: #fff; font-size: 10.5px;
  font-weight: 700; padding: 1px 6px; border-radius: 9px; flex: none;
}
.mail-folder-actions { display: none; gap: 1px; padding-right: 4px; }
.mail-folder-row:hover .mail-folder-actions { display: flex; }
.icon-btn {
  display: grid; place-items: center; width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--line); color: var(--ink); }
.mail-side-foot { display: flex; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.mail-side-foot .btn { flex: 1; }

/* --- Nachrichtenliste --- */
.mail-list {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow-y: auto; min-height: 0;
}
.mail-list-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 14px; background: var(--surface); border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 600;
}
.mail-item {
  display: flex; gap: 10px; width: 100%; padding: 10px 14px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.mail-item:hover { background: var(--surface-2); }
.mail-item.current { background: var(--accent-soft); }
.mail-item.dragging { opacity: .45; }
.mail-avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent-soft);
  color: var(--accent); font-size: 11.5px; font-weight: 700;
}
.mail-item-main { display: grid; gap: 2px; min-width: 0; flex: 1; }
.mail-item-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.mail-from {
  font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mail-time { font-size: 11.5px; color: var(--muted); flex: none; }
.mail-subject {
  font-size: 13px; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mail-item.unread .mail-from,
.mail-item.unread .mail-subject { font-weight: 700; color: var(--ink); }
.mail-item.unread .mail-avatar { background: var(--accent); color: #fff; }
.mail-item-meta {
  display: flex; gap: 8px; align-items: center;
  font-size: 11px; color: var(--muted); min-height: 0;
}
.mail-item-meta:empty { display: none; }

/* --- Leseansicht --- */
.mail-view {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow-y: auto; min-height: 0; padding: 0 0 18px;
}
.mail-toolbar {
  position: sticky; top: 0; z-index: 1;
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.mail-toolbar .spacer { flex: 1; }
.mail-head { padding: 16px 18px 10px; border-bottom: 1px solid var(--line); }
.mail-head h3 { margin: 0 0 8px; font-size: 17px; line-height: 1.35; }
.mail-head-row { font-size: 13px; margin-bottom: 2px; word-break: break-word; }
.mail-head-row .dim { display: inline-block; min-width: 42px; }

.mail-attachments {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px 0;
}
.mail-attachment {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px;
  border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px;
  color: var(--ink); text-decoration: none; background: var(--surface-2);
}
.mail-attachment:hover { border-color: var(--accent); color: var(--accent); }

.mail-content { padding: 16px 18px 0; }
.mail-frame {
  width: 100%; min-height: 460px; border: 0; background: #fff; border-radius: var(--r-sm);
}
.mail-text {
  white-space: pre-wrap; word-break: break-word; font: inherit;
  font-size: 13.5px; line-height: 1.6; margin: 0;
}

.mail-empty {
  display: grid; place-items: center; gap: 10px; height: 100%;
  color: var(--muted); text-align: center; padding: 40px 20px;
}
.mail-empty.small { height: auto; padding: 28px 20px; }
.mail-empty p { margin: 0; font-size: 13px; }

/* --- Verschieben-Fenster --- */
.move-list { max-height: 320px; overflow-y: auto; margin-bottom: 16px; }
.move-group {
  padding: 8px 4px 4px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); font-weight: 600;
}
.move-target {
  display: block; width: 100%; text-align: left; padding: 7px 10px;
  border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--ink); font: inherit; font-size: 13px; cursor: pointer;
}
.move-target:hover { background: var(--accent-soft); color: var(--accent); }

.dim.small, p.small { font-size: 12px; }

@media (max-width: 1250px) {
  .mail-layout { grid-template-columns: 220px minmax(0, 1fr); height: auto; }
  .mail-view { grid-column: 1 / -1; min-height: 420px; }
  .mail-side, .mail-list { max-height: 60vh; }
}
@media (max-width: 900px) {
  .mail-layout { grid-template-columns: 1fr; }
  .mail-folder-actions { display: flex; }
}
