@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700&display=swap');

:root {
  color-scheme: light;
  --navy: #144584;
  --green: #6bb96d;
  --slate: #323949;

  --bg: #f5f5f5;
  --surface: #ffffff;
  --sunken: #f5f5f5;
  --text: #000000;
  --text-2: #5a616f;
  --border: #e2e2e2;
  --border-2: #cdcdcd;

  --nav-bg: #144584;
  --nav-text: rgba(255, 255, 255, 0.72);
  --nav-active: #ffffff;

  --filed: #43883f;
  --unsorted: #b8760b;
  --staged: #144584;
  --nonproj: #5a616f;
  --error: #b3382b;
  --info: #144584;
  --ok: #43883f;
  --muted-badge: #5a616f;
  --unknown: #b8760b;

  --shadow: 0 1px 2px rgba(20, 69, 132, 0.06), 0 6px 20px rgba(20, 69, 132, 0.06);

  --chart-blue: #144584;
  --chart-blue-wash: rgba(20, 69, 132, 0.1);
  --chart-line-out: #6bb96d;
  --chart-line-out-wash: rgba(107, 185, 109, 0.16);
  --chart-grid: #e2e2e2;
  --chart-axis: #cdcdcd;

  --accent-wash: rgba(20, 69, 132, 0.08);
  --row-hover: var(--sunken);
  --tooltip-bg: #1b202a;
  --tooltip-text: #ffffff;
  --ok-bg: #e5f5ea;
  --error-bg: #fbe9e7;

  --role-handwerker: #1a7a6e;
  --role-behoerde: #6b3fa0;
  --role-intern: #4a5fc1;

  --radius: 9px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1b202a;
    --surface: #262c39;
    --sunken: #2e3543;
    --text: #ffffff;
    --text-2: #a9b0bf;
    --border: #3a4252;
    --border-2: #4a5364;

    --nav-bg: #0f3467;
    --nav-text: rgba(255, 255, 255, 0.66);
    --nav-active: #ffffff;

    --filed: #6bb96d;
    --unsorted: #d9a227;
    --staged: #7fa8dc;
    --nonproj: #a9b0bf;
    --error: #e0796b;
    --info: #7fa8dc;
    --ok: #6bb96d;
    --muted-badge: #a9b0bf;
    --unknown: #d9a227;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);

    --chart-blue: #7fa8dc;
    --chart-blue-wash: rgba(127, 168, 220, 0.16);
    --chart-line-out: #6bb96d;
    --chart-line-out-wash: rgba(107, 185, 109, 0.18);
    --chart-grid: #3a4252;
    --chart-axis: #4a5364;

    --accent-wash: rgba(127, 168, 220, 0.14);
    --row-hover: var(--sunken);
    --tooltip-bg: #f5f5f5;
    --tooltip-text: #0b0b0b;
    --ok-bg: rgba(107, 185, 109, 0.16);
    --error-bg: rgba(224, 121, 107, 0.16);

    --role-handwerker: #4fc3b0;
    --role-behoerde: #b48ee0;
    --role-intern: #8a9aed;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b202a;
  --surface: #262c39;
  --sunken: #2e3543;
  --text: #ffffff;
  --text-2: #a9b0bf;
  --border: #3a4252;
  --border-2: #4a5364;

  --nav-bg: #0f3467;
  --nav-text: rgba(255, 255, 255, 0.66);
  --nav-active: #ffffff;

  --filed: #6bb96d;
  --unsorted: #d9a227;
  --staged: #7fa8dc;
  --nonproj: #a9b0bf;
  --error: #e0796b;
  --info: #7fa8dc;
  --ok: #6bb96d;
  --muted-badge: #a9b0bf;
  --unknown: #d9a227;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);

  --chart-blue: #7fa8dc;
  --chart-blue-wash: rgba(127, 168, 220, 0.16);
  --chart-line-out: #6bb96d;
  --chart-line-out-wash: rgba(107, 185, 109, 0.18);
  --chart-grid: #3a4252;
  --chart-axis: #4a5364;

  --accent-wash: rgba(127, 168, 220, 0.14);
  --row-hover: var(--sunken);
  --tooltip-bg: #f5f5f5;
  --tooltip-text: #0b0b0b;
  --ok-bg: rgba(107, 185, 109, 0.16);
  --error-bg: rgba(224, 121, 107, 0.16);

  --role-handwerker: #4fc3b0;
  --role-behoerde: #b48ee0;
  --role-intern: #8a9aed;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-weight: 500;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--green); }
input, select, button, textarea { font-family: 'Poppins', sans-serif; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(107, 185, 109, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(107, 185, 109, 0); }
  100% { box-shadow: 0 0 0 0 rgba(107, 185, 109, 0); }
}
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(6px) scale(0.98); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-8px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- App shell: sidebar + main column ---- */

.shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.sidebar {
  background: var(--nav-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-head { padding: 22px 20px 18px; }

.sidebar-logo {
  background: #fff;
  border-radius: 9px;
  padding: 12px 14px;
  display: block;
}
.sidebar-logo img { width: 100%; display: block; }

.sidebar-brand {
  margin-top: 14px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.sidebar-brand-name { font-weight: 700; font-size: 17px; color: #fff; letter-spacing: 0.01em; }
.sidebar-brand-ver { font-weight: 600; font-size: 11px; color: rgba(255, 255, 255, 0.55); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 12px; flex: 1; overflow-y: auto; }

.nav-group-label {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.4); padding: 12px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 8px;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--nav-text);
  text-decoration: none;
  box-shadow: none;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.nav-item.active {
  font-weight: 700;
  background: rgba(255, 255, 255, 0.16);
  color: var(--nav-active);
  box-shadow: inset 3px 0 0 var(--green);
}
.nav-item .nav-glyph { width: 20px; text-align: center; font-size: 15px; opacity: 0.9; flex-shrink: 0; }
.nav-item .nav-label { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .nav-count {
  background: var(--green);
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  border-radius: 99px;
  padding: 2px 8px;
  min-width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-foot {
  margin-top: auto;
  padding: 16px 20px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sidebar-poller-row { display: flex; align-items: center; gap: 9px; }
.sidebar-poller-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sidebar-poller-text strong { font-weight: 700; font-size: 12px; color: #fff; }
.sidebar-poller-text span { font-weight: 500; font-size: 11px; color: rgba(255, 255, 255, 0.55); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255, 255, 255, 0.4);
}
.status-dot-on { background: var(--green); animation: pulse-ring 2s infinite; }

.sidebar-actions { display: flex; gap: 8px; }
.btn-ghost-nav {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: transparent;
  color: #fff;
  font-weight: 700;
  font-size: 11.5px;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-ghost-nav:hover { background: rgba(255, 255, 255, 0.12); }
.btn-icon-nav {
  width: 34px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: transparent;
  color: #fff;
  font-size: 13px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-icon-nav:hover { background: rgba(255, 255, 255, 0.12); }

/* ---- Main column: header + content ---- */

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 28px;
  height: 68px;
  flex-wrap: wrap;
}

.topbar-title { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 2 0 220px; }
.topbar-crumb { font-weight: 500; font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-heading { font-weight: 700; font-size: 17px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.palette-trigger {
  margin-left: auto;
  flex: 1 4 320px;
  min-width: 104px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--sunken);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s;
}
.palette-trigger:hover { border-color: var(--green); }
.palette-trigger-text { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-trigger-kbd { flex-shrink: 0; font-size: 10.5px; font-weight: 700; border: 1px solid var(--border-2); border-radius: 5px; padding: 2px 6px; color: var(--text-2); }

.topbar-right { display: flex; align-items: center; gap: 10px; flex: 0 3 auto; min-width: 0; }

.live-pill {
  display: inline-flex; align-items: center; gap: 7px; min-width: 0; overflow: hidden;
  background: var(--sunken); border: 1px solid var(--border); color: var(--text-2);
  font-weight: 600; font-size: 11.5px; border-radius: 99px; padding: 6px 12px; white-space: nowrap;
}
.live-pill-dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: var(--text-2); }
.live-pill-dot.on { background: var(--green); animation: pulse-ring 2s infinite; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0;
}

/* ---- Account menu (topbar) ---- */
.account-menu { position: relative; flex-shrink: 0; }
.account-trigger {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px;
  background: transparent; border: 1px solid transparent; border-radius: 99px;
  box-shadow: none; color: var(--text); font-weight: 600; font-size: 12px; cursor: pointer;
  max-width: 220px;
}
.account-trigger:hover { border-color: var(--border); filter: none; }
.account-trigger:active { transform: none; box-shadow: none; }
.account-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.account-caret { font-size: 10px; color: var(--text-2); flex-shrink: 0; }
.account-pop {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 240px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px; display: none; flex-direction: column; gap: 2px;
}
.account-menu.open .account-pop { display: flex; }
.account-pop-head { padding: 8px 10px 6px; display: flex; flex-direction: column; gap: 2px; }
.account-pop-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); font-weight: 700; }
.account-pop-upn { font-size: 12px; color: var(--text); word-break: break-all; }
.account-pop form { margin: 0; }
.account-pop-item {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 7px;
  background: transparent; border: none; box-shadow: none; color: var(--text);
  font-family: inherit; font-size: 12.5px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.account-pop-item:hover { background: var(--sunken); filter: none; }
.account-pop-item:active { transform: none; box-shadow: none; }
.account-pop-signout { color: var(--error); }
@media (max-width: 720px) { .account-name { display: none; } }

main.content { padding: 28px; display: flex; flex-direction: column; gap: 20px; min-width: 0; animation: page-in 0.2s ease-out; }

h1 { margin: 0 0 4px; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
h2 { margin: 0 0 14px; font-weight: 700; font-size: 15px; color: var(--text); }
p.muted, .muted { color: var(--text-2); font-weight: 500; }
section { margin-bottom: 0; }

.page-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }

/* ---- Cards, tables ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 20px;
}
.card > h2:first-child { margin-top: 0; }

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; min-width: 560px; }
.table-wrap table { border: none; box-shadow: none; border-radius: 0; }

th, td {
  text-align: left;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
  white-space: nowrap;
}
td.col-wrap { white-space: normal; word-break: break-word; }
td.col-truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.col-truncate a { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }

th {
  background: var(--sunken);
  font-weight: 600;
  color: var(--text-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--row-hover); }
tbody tr.is-link { cursor: pointer; }

code { font-size: 0.85em; background: var(--sunken); padding: 0.15em 0.4em; border-radius: 4px; word-break: break-all; }

/* ---- Badges ---- */

.badge {
  display: inline-flex; align-items: center; gap: 5px; align-self: flex-start;
  color: #fff; font-weight: 700; font-size: 11px; border-radius: 99px; padding: 4px 10px;
  white-space: nowrap;
}
.badge-icon { font-size: 0.9em; line-height: 1; }
.badge-filed { background: var(--filed); }
.badge-staged_new { background: var(--staged); }
.badge-non_project { background: var(--nonproj); }
.badge-unsorted { background: var(--unsorted); }
.badge-error { background: var(--error); }
.badge-info { background: var(--info); }
.badge-ok { background: var(--ok); }
.badge-muted { background: var(--muted-badge); }
.badge-unknown { background: var(--unknown); }
.badge-waiting { background: var(--unsorted); }
.badge-answered { background: var(--filed); }

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

button, .btn {
  padding: 9px 20px 9px 15px;
  border: none;
  background: var(--green);
  color: #fff;
  border-radius: 0 10px 10px 0;
  box-shadow: 3px 3px 0 var(--border-2);
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  transition: filter 0.15s;
}
button:hover, .btn:hover { filter: brightness(1.06); }
button:active, .btn:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--border-2); }

button.btn-danger { background: transparent; color: var(--error); border: 1px solid var(--border-2); border-radius: 7px; box-shadow: none; padding: 8px 15px; }
button.btn-danger:hover { border-color: var(--error); filter: none; }

button.btn-secondary {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-2);
  border-radius: 7px; box-shadow: none; padding: 8px 14px;
}
button.btn-secondary:hover { border-color: var(--green); filter: none; }

button.btn-sm { padding: 7px 14px 7px 10px; font-size: 11.5px; }

/* Applied to a button mid-request (see app.js's setButtonLoading) - the assign/confirm actions
   this backs can take a while (reassign/confirm involve a real file move + DB write, sometimes
   several seconds), so without this a user unsure whether their click registered would click
   again, firing a second overlapping request. `disabled` is what actually blocks the repeat
   click; the dimming + spinner is just making that state visible rather than looking frozen. */
button.is-loading, .btn.is-loading {
  opacity: 0.7;
  cursor: default;
}
.btn-spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 6px;
  vertical-align: -1px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* ---- Forms ---- */

form.filter-form, form.reassign-form, form.inline-form {
  display: inline-flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
}
form.filter-form { margin-bottom: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
form.inline-form { margin-right: 0.4rem; }

input[type="text"], input[type="email"], input[type="tel"], select, textarea {
  padding: 9px 12px;
  border: 1px solid var(--border-2);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  box-sizing: border-box;
}
textarea { font-weight: 500; resize: vertical; }
input[type="text"]:focus, input[type="email"]:focus, input[type="tel"]:focus, select:focus, textarea:focus {
  outline: 2px solid var(--green); outline-offset: 1px;
}

/* Simple vertical field-label forms (Kundenverwaltung etc.) - most existing forms are single-
   inline-field with their own bespoke label styling, so this is a dedicated, explicitly-opted-in
   class rather than a broad `form label` selector that could reach into and restyle those. */
.field-label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12.5px; font-weight: 700; color: var(--text-2);
}

.hint {
  padding: 0.85rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 500;
}

.pagination { display: flex; gap: 1rem; align-items: center; font-size: 0.88rem; }

.status-ok { color: var(--filed); font-weight: 700; }
.status-off { color: var(--text-2); font-weight: 700; }

.empty-state {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-2);
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty-state .empty-icon { font-size: 26px; color: var(--green); }

dl.mail-meta {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
dl.mail-meta dt { color: var(--text-2); font-size: 12.5px; font-weight: 600; }
dl.mail-meta dd { margin: 0; font-size: 13.5px; font-weight: 500; }

.mail-body {
  white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.6;
  max-height: 480px; overflow-y: auto;
}

.attachment-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.attachment-list li { font-size: 13.5px; }

.attachment-item { display: flex; align-items: flex-start; gap: 12px; }
.attachment-item.has-thumb { align-items: center; }
.attachment-thumb-link { flex-shrink: 0; display: block; border-radius: 7px; }
.attachment-thumb {
  display: block; width: 140px; height: 100px; object-fit: cover;
  border-radius: 7px; border: 1px solid var(--border); background: var(--sunken); cursor: zoom-in;
}
.attachment-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.attachment-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.attachment-icon { font-size: 0.95em; }
.attachment-item-meta { font-size: 12px; }

/* ---- Flash / toast ---- */

.toast-stack {
  position: fixed; right: 24px; bottom: 24px; z-index: 90;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.toast {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface); border: 1px solid var(--border-2); border-left: 4px solid var(--green);
  border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
  padding: 12px 16px; min-width: 280px; max-width: 380px;
  animation: toast-in 0.2s ease-out;
}
.toast.toast-error { border-left-color: var(--error); }
.toast-icon {
  width: 22px; height: 22px; border-radius: 50%; background: var(--green); color: #fff;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.toast.toast-error .toast-icon { background: var(--error); }
.toast-body { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.toast-title { font-weight: 700; font-size: 13px; color: var(--text); }
.toast-text { font-weight: 500; font-size: 12px; color: var(--text-2); }
.toast.is-leaving { animation: toast-out 0.18s ease-in forwards; }

/* ---- KPI tiles ---- */

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px 20px; display: flex; flex-direction: column;
}
.kpi-tile.has-action { border-color: var(--border-2); }
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-weight: 600; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.kpi-trend { font-weight: 700; font-size: 11px; border-radius: 99px; padding: 3px 9px; color: var(--text-2); background: var(--sunken); }
.kpi-trend.up { color: #fff; background: var(--filed); }
.kpi-value-row { display: flex; align-items: flex-end; gap: 10px; margin-top: 10px; }
.kpi-value { font-weight: 700; font-size: 38px; line-height: 1; letter-spacing: -0.02em; color: var(--text); }
.kpi-unit { font-weight: 600; font-size: 12px; color: var(--text-2); padding-bottom: 4px; }
.kpi-sub { font-weight: 500; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.kpi-action { margin-top: 12px; align-self: flex-start; }

/* ---- Bar charts ---- */

.mailbox-progress { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.mailbox-progress-row { display: flex; flex-direction: column; gap: 5px; }

.existing-rate { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.existing-rate-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.existing-rate-label { font-weight: 600; font-size: 12.5px; color: var(--text); }
.existing-rate-value { font-weight: 700; font-size: 18px; color: var(--filed); font-variant-numeric: tabular-nums; }
.existing-rate-sub { font-size: 11.5px; }

.bar-chart { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: flex; flex-direction: column; gap: 5px; }
.bar-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.bar-row-label { display: inline-flex; align-items: center; gap: 7px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row-dot {
  width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center;
  font-size: 10px; color: #fff; flex-shrink: 0;
}
.bar-row-count { font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.bar-track { height: 8px; border-radius: 99px; background: var(--sunken); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; transition: width 0.4s ease; }

.bar-status-unsorted { background: var(--unsorted); }
.bar-status-staged_new { background: var(--staged); }
.bar-status-filed { background: var(--filed); }
.bar-status-non_project { background: var(--nonproj); }
.bar-status-error { background: var(--error); }
.bar-sequential { background: var(--navy); }

/* Simple project bars (dashboard "Aktive Projekte") */
.plist { display: flex; flex-direction: column; }
.plist-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 96px 40px; align-items: center; gap: 12px;
  background: transparent; border: none; border-bottom: 1px solid var(--border);
  padding: 11px 4px; cursor: pointer; text-align: left; width: 100%;
  color: inherit; font-family: 'Poppins', sans-serif;
}
.plist-row:last-child { border-bottom: none; }
.plist-row:hover { background: var(--sunken); }
.plist-name { font-weight: 600; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist-track { height: 8px; border-radius: 99px; background: var(--sunken); display: block; overflow: hidden; }
.plist-count { font-weight: 700; font-size: 12.5px; color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Trend chart ---- */

.trend-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.trend-head h2 { margin: 0; }
.trend-legend { display: flex; gap: 14px; font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.trend-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.trend-legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.trend-legend-dot-in { background: var(--navy); }
.trend-legend-dot-out { background: var(--green); }
.trend-chart-wrap { width: 100%; padding-top: 8px; }
.trend-chart { width: 100%; height: auto; aspect-ratio: 600 / 140; display: block; overflow: visible; }
.trend-axis { stroke: var(--chart-axis); stroke-width: 1; }
.trend-area { stroke: none; }
.trend-area-in { fill: var(--chart-blue-wash); }
.trend-area-out { fill: var(--chart-line-out-wash); }
.trend-line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.trend-line-in { stroke: var(--navy); }
.trend-line-out { stroke: var(--green); }
.trend-dot { stroke: var(--surface); stroke-width: 2; cursor: pointer; }
.trend-dot-in { fill: var(--navy); }
.trend-dot-out { fill: var(--green); }
.trend-dot-in:hover, .trend-dot-in:focus-visible { fill: var(--green); outline: none; }
.trend-dot-out:hover, .trend-dot-out:focus-visible { opacity: 0.75; outline: none; }
.trend-axis-labels { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; color: var(--text-2); margin-top: 6px; }

.viz-tooltip {
  position: fixed; display: none; z-index: 100;
  background: var(--tooltip-bg); color: var(--tooltip-text);
  padding: 0.35rem 0.6rem; border-radius: 6px; font-size: 0.78rem; font-weight: 600;
  pointer-events: none; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); white-space: nowrap;
}

.sparkline { display: block; width: 96px; height: 28px; margin-top: 8px; }
.sparkline-line { fill: none; stroke: var(--navy); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Live activity feed (dashboard) ---- */

.activity-feed { display: flex; flex-direction: column; gap: 2px; }
.activity-row { display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.activity-row:last-child { border-bottom: none; }
.activity-time { font-weight: 600; font-size: 11.5px; color: var(--text-2); font-variant-numeric: tabular-nums; padding-top: 2px; }
.activity-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.activity-detail { font-weight: 500; font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }

.live-updated { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--text-2); }
.live-updated-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse-ring 2s infinite; }

.card-head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 14px; }
.card-head-row h2 { margin: 0; }

/* ---- Live activity: mail-loading stage vs. classification stage, per mailbox ----
   Server-rendered by templates/_live_activity.html, kept in sync by app.js::renderLiveActivity
   from /api/status. Backed by StateDB.current_activity (loader) + classifier_worker (workers). */

.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-2); flex-shrink: 0; transition: background-color 0.4s ease; }
.live-dot-on { background: var(--green); animation: pulse-ring 2s infinite; }

.live-activity {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.live-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.live-head-state { font-weight: 700; font-size: 13px; color: var(--text); }
.live-head-progress { font-size: 12px; }
.live-head-next { font-size: 12px; margin-left: auto; }

.live-mailbox { padding: 8px 0 4px; }
.live-mailbox + .live-mailbox { border-top: 1px solid var(--border); }
.live-mailbox-name { font-weight: 700; font-size: 12.5px; color: var(--text); margin-bottom: 4px; }

.live-row { display: flex; align-items: baseline; gap: 10px; font-size: 12.5px; padding: 3px 0; }
.live-row-tag { flex-shrink: 0; font-weight: 600; color: var(--text-2); min-width: 128px; }
.live-row-load .live-row-tag { color: var(--navy); }
.live-row-classify .live-row-tag { color: var(--green); }
.live-row-subject { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.live-row-meta { flex-shrink: 0; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.live-row-idle { color: var(--text-2); font-style: italic; }

.live-system { font-size: 11.5px; padding-top: 8px; border-top: 1px solid var(--border); }

.live-summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.live-summary-state { font-weight: 700; font-size: 13px; }
.live-summary-progress { font-size: 12px; }
.live-summary-spacer { flex: 1; }
.live-summary-link { font-size: 12px; font-weight: 600; text-decoration: none; color: var(--navy); }

/* ---- Dashboard hero/pipeline cards - LEGACY, no longer rendered (kept until a cleanup pass) ---- */
.hero-grid { display: flex; flex-direction: column; gap: 16px; }

/* The admin loop's own status (no specific mailbox, see main.py::_run_admin_loop) - a compact
   row, not a full hero card, since it never has mail-level detail to show. */
.hero-system { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.hero-system-name { font-weight: 700; font-size: 12.5px; }
.hero-system-detail { font-size: 12px; }

.hero-card { display: flex; flex-direction: column; gap: 6px 24px; padding: 20px 24px 18px; }
.hero-top { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; }
.hero-icon {
  width: 52px; height: 52px; flex-shrink: 0; border-radius: 13px; display: grid; place-items: center;
  font-size: 24px; font-weight: 700; color: #fff;
}
.hero-icon-info { background: var(--navy); animation: hero-ring 1.8s infinite; }
.hero-icon-ok { background: var(--green); animation: hero-ring-green 2.4s infinite; }
.hero-icon-muted { background: var(--text-2); }
.hero-title-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 320px; }
.hero-name { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.hero-title { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: var(--text); }
.hero-sub { font-weight: 500; font-size: 12.5px; color: var(--text-2); line-height: 1.4; }
.hero-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin-left: auto; }
.hero-countdown { display: flex; align-items: center; gap: 11px; background: var(--sunken); border-radius: 99px; padding: 7px 16px 7px 8px; }
.hero-countdown-ring { width: 30px; height: 30px; transform: rotate(-90deg); }
.hero-countdown-track { fill: none; stroke: var(--border-2); stroke-width: 4; }
.hero-countdown-fill { fill: none; stroke: var(--navy); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 94.2; transition: stroke-dashoffset 0.2s linear; }
.hero-countdown-text { display: flex; flex-direction: column; line-height: 1.2; }
.hero-countdown-label { font-weight: 700; font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.hero-countdown-hint { font-size: 11px; }
button.btn-slate { background: var(--slate); }

@keyframes hero-ring { 0% { box-shadow: 0 0 0 0 rgba(20,69,132,.45); } 70% { box-shadow: 0 0 0 12px rgba(20,69,132,0); } 100% { box-shadow: 0 0 0 0 rgba(20,69,132,0); } }
@keyframes hero-ring-green { 0% { box-shadow: 0 0 0 0 rgba(107,185,109,.5); } 70% { box-shadow: 0 0 0 10px rgba(107,185,109,0); } 100% { box-shadow: 0 0 0 0 rgba(107,185,109,0); } }
@keyframes hero-flow { to { background-position: 22px 0; } }
@keyframes hero-travel { 0% { left: -6px; opacity: 0; } 12% { opacity: 1; } 88% { opacity: 1; } 100% { left: 100%; opacity: 0; } }
@keyframes hero-bar-shine { 0% { transform: translateX(-100%); } 100% { transform: translateX(320%); } }

.hero-pipeline { display: flex; align-items: flex-start; padding: 10px 0 8px; }
.pipeline-node-wrap { display: flex; align-items: flex-start; flex: 1; }
.pipeline-node-wrap:last-child { flex: 0 0 auto; }
.pipeline-node { width: 108px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.pipeline-circle { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--sunken); border: 2px solid var(--border-2); }
.pipeline-circle-active { background: var(--navy); border-color: transparent; animation: hero-ring 1.6s infinite; }
.pipeline-circle-done { background: var(--green); border-color: transparent; }
.pipeline-glyph { font-size: 17px; font-weight: 700; color: var(--text-2); }
.pipeline-circle-active .pipeline-glyph, .pipeline-circle-done .pipeline-glyph { color: #fff; }
.pipeline-circle-active .pipeline-glyph { animation: hero-breathe 1.4s ease-in-out infinite; }
@keyframes hero-breathe { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
.pipeline-label { font-weight: 700; font-size: 11.5px; color: var(--text); }
.pipeline-label-active { color: var(--staged); }
.pipeline-connector { flex: 1; min-width: 22px; position: relative; height: 4px; margin-top: 23px; border-radius: 99px; overflow: hidden; background: var(--border-2); }
.pipeline-connector-done { background: var(--green); }
.pipeline-connector.is-flowing { background: repeating-linear-gradient(90deg, var(--navy) 0 8px, transparent 8px 22px); animation: hero-flow .55s linear infinite; }
.pipeline-connector-dot { position: absolute; top: -2px; width: 8px; height: 8px; border-radius: 50%; background: var(--navy); animation: hero-travel 1.1s linear infinite; }

.hero-current { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.hero-current-label { font-weight: 700; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.hero-current-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.hero-current-subject { font-weight: 700; font-size: 13.5px; color: var(--text); }
.hero-current-sender { font-size: 12px; }
.hero-progress { position: relative; height: 8px; border-radius: 99px; background: var(--sunken); overflow: hidden; }
.hero-progress-fill { height: 100%; border-radius: 99px; background: var(--navy); transition: width .3s ease; position: relative; overflow: hidden; }
.hero-progress-fill::after { content: ""; position: absolute; inset: 0; width: 34%; background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: hero-bar-shine 1.4s linear infinite; }
.hero-current-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; font-size: 11.5px; }
.hero-current-empty { display: flex; flex-direction: column; gap: 4px; padding: 4px 0; }
.hero-current-empty-title { font-weight: 700; font-size: 13.5px; color: var(--text); }

/* ---- "Wartet auf dich" cards (Review-Queue / Projektvorschläge / Fehlgeschlagene Ablage) ---- */

.waiting-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.waiting-card { display: flex; flex-direction: column; gap: 14px; border-left: 4px solid var(--border-2); }
.waiting-card-unsorted { border-left-color: var(--unsorted); }
.waiting-card-staged { border-left-color: var(--staged); }
.waiting-card-error { border-left-color: var(--error); }
.waiting-head { display: flex; align-items: flex-start; gap: 12px; }
.waiting-icon { width: 26px; height: 26px; flex-shrink: 0; border-radius: 7px; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.waiting-icon-unsorted { background: var(--unsorted); }
.waiting-icon-staged { background: var(--staged); }
.waiting-icon-error { background: var(--error); }
.waiting-title-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.waiting-title { font-weight: 700; font-size: 13.5px; color: var(--text); }
.waiting-title-wrap .muted { font-size: 12px; line-height: 1.4; }
.waiting-count { margin-left: auto; font-weight: 700; font-size: 28px; line-height: 0.9; letter-spacing: -0.02em; flex-shrink: 0; }
.waiting-count-unsorted { color: var(--unsorted); }
.waiting-count-staged { color: var(--staged); }
.waiting-count-error { color: var(--error); }
.waiting-card .btn { align-self: flex-start; }
button.btn-danger-fill { background: var(--error); }

/* ---- "Wie sicher die KI entscheidet" (Konfidenz-Histogramm / Absender-Liste / Eingespart) ---- */

.confidence-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; align-items: stretch; }
.confidence-card { display: flex; flex-direction: column; gap: 14px; }
.confidence-card-label { font-weight: 700; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.confidence-card-hint { font-size: 12px; line-height: 1.45; margin-top: -8px; }

.confidence-hist { position: relative; display: flex; align-items: flex-end; gap: 6px; height: 130px; margin-top: 12px; }
.confidence-hist-marker { position: absolute; top: 0; bottom: 16px; width: 0; border-left: 2px dashed var(--green); pointer-events: none; }
.confidence-hist-marker-label {
  position: absolute; top: -4px; left: 0; transform: translateX(-50%); background: var(--green); color: #fff;
  font-weight: 700; font-size: 9.5px; padding: 2px 7px; border-radius: 99px; white-space: nowrap;
}
.confidence-hist-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.confidence-hist-count { font-weight: 700; font-size: 10.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.confidence-hist-bar { width: 100%; min-height: 3px; border-radius: 5px 5px 0 0; }
.confidence-hist-bar-below { background: var(--unsorted); }
.confidence-hist-bar-above { background: var(--staged); }
.confidence-hist-tick { font-weight: 500; font-size: 10px; color: var(--text-2); }

.confidence-legend { display: flex; gap: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.confidence-legend-item { display: flex; flex-direction: column; gap: 2px; }
.confidence-legend-value { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.confidence-legend-value-above { color: var(--staged); }
.confidence-legend-value-below { color: var(--unsorted); }
.confidence-legend-item .muted { font-size: 11.5px; }

.sender-list { display: flex; flex-direction: column; gap: 12px; }
.sender-row { display: flex; flex-direction: column; gap: 5px; }
.sender-row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sender-row-label { font-weight: 600; font-size: 12.5px; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sender-row-count { font-weight: 700; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; flex-shrink: 0; }

.savings-card { justify-content: flex-start; }
.savings-value-row { display: flex; align-items: flex-end; gap: 8px; }
.savings-value { font-weight: 700; font-size: 42px; line-height: 0.85; letter-spacing: -0.03em; color: var(--text); }
.savings-unit { font-weight: 700; font-size: 17px; color: var(--text-2); padding-bottom: 4px; }
.savings-row { display: flex; align-items: center; gap: 12px; padding-top: 13px; border-top: 1px solid var(--border); }
.savings-row-label { flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.4; }
.savings-row-value { font-weight: 700; font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.savings-dot { width: 9px; height: 9px; flex-shrink: 0; border-radius: 50%; }
.savings-dot-filed { background: var(--filed); }
.savings-dot-open { background: var(--unsorted); }
.savings-dot-rate { background: var(--staged); }

/* ---- Grid helpers ---- */

.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.dash-grid > * { min-width: 0; }
.split-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 16px; align-items: start; }
.split-grid > * { min-width: 0; }

/* ---- Review queue ---- */

.filter-pills { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 12.5px;
  padding: 8px 14px; border-radius: 99px; cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.pill:hover { border-color: var(--navy); }
.pill.active { border-color: var(--navy); background: var(--navy); color: #fff; }
.pill-count { font-weight: 700; font-size: 11px; opacity: 0.8; }
.filter-hint { margin-left: auto; font-weight: 500; font-size: 12px; color: var(--text-2); }

.bulk-bar {
  display: none;
  flex-wrap: wrap; align-items: center; gap: 10px 12px;
  background: var(--navy); color: #fff; border-radius: var(--radius); padding: 12px 16px;
  box-shadow: var(--shadow); animation: pop-in 0.18s ease-out;
}
.bulk-bar.is-visible { display: flex; }
.bulk-bar-label { font-weight: 700; font-size: 13px; flex-shrink: 0; }
.bulk-bar select {
  flex: 1 1 180px; min-width: 0; background: rgba(255, 255, 255, 0.14); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 7px; padding: 7px 10px;
  font-size: 12.5px; font-weight: 600;
}
.bulk-bar select option { color: #000; }
.bulk-bar button.bulk-assign { flex-shrink: 0; }
.bulk-bar button.bulk-nonproj {
  flex-shrink: 0; background: transparent; color: #fff; font-weight: 600; font-size: 12.5px;
  border: 1px solid rgba(255, 255, 255, 0.35); padding: 8px 14px; border-radius: 7px; box-shadow: none;
}
.bulk-bar button.bulk-nonproj:hover { background: rgba(255, 255, 255, 0.12); filter: none; }
.bulk-bar button.bulk-clear {
  flex-shrink: 0; margin-left: auto; background: transparent; color: rgba(255, 255, 255, 0.8);
  font-weight: 600; font-size: 12.5px; border: none; box-shadow: none; padding: 6px 4px;
}
.bulk-bar button.bulk-clear:hover { color: #fff; filter: none; }

.queue-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.queue-head {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) 86px; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--sunken); border-bottom: 1px solid var(--border);
}
.queue-head span { font-weight: 600; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); }
.queue-list { max-height: 640px; overflow-y: auto; }
.queue-row {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) 86px; gap: 10px; align-items: start;
  padding: 13px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.queue-row:last-child { border-bottom: none; }
.queue-row:hover { background: var(--sunken); }
.queue-row.selected { background: var(--sunken); box-shadow: inset 3px 0 0 var(--green); }
.queue-row.hidden-row { display: none; }
/* Already-handled mail, shown only under the "Alle" pill (see confirmations_queue.html's
   is_reviewed) - a light tint so it reads as "done" at a glance without needing to open it,
   the whole point being reassurance that nothing pending got missed. */
.queue-row-reviewed { background: color-mix(in srgb, var(--green) 6%, transparent); }
.queue-row-reviewed:hover { background: color-mix(in srgb, var(--green) 12%, transparent); }
.queue-row-reviewed .queue-row-subject { opacity: 0.75; }
.queue-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--navy); cursor: pointer; margin-top: 3px; }
.queue-row-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.queue-row-subject { font-weight: 700; font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-row-meta { font-weight: 500; font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-row-conf { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.queue-row-conf-val { font-weight: 700; font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.queue-row-conf-track { width: 64px; height: 6px; border-radius: 99px; background: var(--sunken); display: block; overflow: hidden; }
.queue-row-conf-fill { display: block; height: 100%; border-radius: 99px; }

.preview-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); position: sticky; top: 96px; display: flex; flex-direction: column;
  max-height: calc(100vh - 120px); overflow-y: auto;
}
.preview-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.preview-subject { font-weight: 700; font-size: 16px; line-height: 1.3; color: var(--text); }
.preview-meta { font-weight: 500; font-size: 12.5px; color: var(--text-2); }
.preview-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.attachment-chip {
  display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 11.5px;
  color: var(--text-2); background: var(--sunken); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px;
}
.preview-ai { padding: 16px 20px; background: var(--sunken); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.preview-ai-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.preview-ai-label { font-weight: 700; font-size: 11.5px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-2); }
.preview-ai-conf { font-weight: 700; font-size: 12.5px; color: var(--text); }
.preview-ai-reasoning { font-weight: 500; font-size: 12.5px; line-height: 1.5; color: var(--text); }
.preview-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 2px; }
.preview-suggest-label { font-weight: 600; font-size: 12px; color: var(--text-2); }
.preview-suggest-value { font-weight: 700; font-size: 12.5px; color: var(--navy); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 4px 9px; }
.preview-suggest button { margin-left: auto; }
.preview-body { padding: 16px 20px; max-height: 260px; overflow-y: auto; white-space: pre-wrap; font-weight: 500; font-size: 13px; line-height: 1.6; color: var(--text); }
.preview-assign { margin-top: auto; padding: 14px 20px 18px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.preview-assign-label { font-weight: 700; font-size: 11.5px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-2); }
.preview-assign-row { display: flex; gap: 8px; }
.preview-assign-row select { flex: 1 1 0; min-width: 0; }
.preview-hint { font-weight: 500; font-size: 11.5px; color: var(--text-2); }
.preview-empty { padding: 56px 32px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.preview-empty-icon { font-size: 24px; color: var(--text-2); }

/* ---- Proposals ---- */

.proposal-banner {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--green);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px;
  display: flex; align-items: center; gap: 14px; font-weight: 500; font-size: 13px; color: var(--text); line-height: 1.5;
}
.proposal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; }
.proposal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; display: flex; flex-direction: column; gap: 14px;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.proposal-card.is-leaving { opacity: 0; transform: scale(0.97); }
.proposal-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.proposal-name { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.proposal-street { font-weight: 700; font-size: 15px; color: var(--text); line-height: 1.3; }
.proposal-city { font-weight: 500; font-size: 12.5px; color: var(--text-2); }
.proposal-kind-badge {
  align-self: flex-start; font-weight: 700; font-size: 10.5px; letter-spacing: 0.02em;
  border-radius: 99px; padding: 3px 9px; white-space: nowrap;
}
.proposal-kind-badge-new { background: var(--ok-bg); color: var(--ok); }
.proposal-kind-badge-existing { background: var(--error-bg); color: var(--error); }
.proposal-similar-hint {
  display: flex; flex-direction: column; gap: 8px; background: var(--error-bg); border: 1px solid var(--error);
  border-radius: 7px; padding: 10px 12px; font-size: 12.5px; color: var(--text); line-height: 1.5;
}
.proposal-similar-hint .proposal-edit-subform { gap: 8px; }
.proposal-count {
  display: inline-flex; align-items: center; gap: 6px; background: var(--staged); color: #fff;
  font-weight: 700; font-size: 11px; border-radius: 99px; padding: 4px 10px; white-space: nowrap;
}
.proposal-evidence { display: flex; flex-direction: column; gap: 6px; background: var(--sunken); border-radius: 7px; padding: 10px 12px; }
.proposal-evidence-label { font-weight: 600; font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-2); }
.proposal-actions { display: flex; align-items: center; gap: 8px; }
.proposal-age { margin-left: auto; font-weight: 500; font-size: 11.5px; color: var(--text-2); }

.proposal-preview-toggle, .proposal-edit-toggle {
  align-self: flex-start; background: transparent; color: var(--navy); border: 1px solid var(--border-2);
  box-shadow: none; font-weight: 600; font-size: 12px; padding: 7px 12px; border-radius: 7px;
}
.proposal-preview-toggle:hover, .proposal-edit-toggle:hover { border-color: var(--navy); filter: none; }

.proposal-edit-form { display: flex; flex-direction: column; gap: 10px; background: var(--sunken); border-radius: 7px; padding: 10px; }
.proposal-edit-form.is-collapsed { display: none; }
.proposal-edit-subform { display: flex; flex-wrap: wrap; gap: 8px; }
.proposal-edit-subform input[type="text"] { flex: 1 1 100px; min-width: 80px; padding: 7px 9px; font-size: 12.5px; }
.proposal-edit-divider { font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; border-top: 1px solid var(--border); padding-top: 10px; }

.duplicate-choice { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 13px; color: var(--text); width: 100%; }
.proposal-preview {
  display: flex; flex-direction: column; gap: 0; border-top: 1px solid var(--border);
  padding-top: 4px; margin-top: -4px; max-height: 260px; overflow-y: auto;
}
.proposal-preview.is-collapsed { display: none; }
.proposal-mail-item { border-bottom: 1px solid var(--border); }
.proposal-mail-item:last-child { border-bottom: none; }
.proposal-mail-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 4px; }
.proposal-mail-row input[type="checkbox"] { margin-top: 3px; width: 15px; height: 15px; accent-color: var(--error); cursor: pointer; flex-shrink: 0; }
.proposal-mail-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; cursor: pointer; }
.proposal-mail-subject { font-weight: 600; font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proposal-mail-meta { font-weight: 500; font-size: 11.5px; color: var(--text-2); }
.proposal-mail-row.is-excluded { opacity: 0.6; }
.proposal-mail-row.is-excluded .proposal-mail-subject { text-decoration: line-through; }

.proposal-mail-detail-toggle {
  flex-shrink: 0; background: transparent; color: var(--text-2); border: 1px solid var(--border-2);
  box-shadow: none; width: 24px; height: 24px; padding: 0; border-radius: 6px; font-size: 11px;
  line-height: 1; transition: transform 0.2s ease, border-color 0.15s;
}
.proposal-mail-detail-toggle:hover { border-color: var(--navy); filter: none; }
.proposal-mail-detail-toggle.is-open { transform: rotate(180deg); }
.proposal-mail-detail {
  padding: 0 4px 12px 39px; display: flex; flex-direction: column; gap: 8px;
}
.proposal-mail-detail.is-collapsed { display: none; }
.proposal-mail-detail-reasoning {
  font-weight: 500; font-size: 12px; line-height: 1.5; color: var(--text-2);
  background: var(--sunken); border-radius: 7px; padding: 8px 10px;
}
.proposal-mail-detail-body {
  font-weight: 500; font-size: 12.5px; line-height: 1.55; color: var(--text);
  white-space: pre-wrap; max-height: 200px; overflow-y: auto;
}
.proposal-mail-detail-link { font-weight: 600; font-size: 11.5px; align-self: flex-start; }

/* ---- Projects list ---- */

.projects-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.projects-toolbar input[type="text"] { flex: 0 1 320px; min-width: 0; border-radius: 9px; padding: 10px 12px; }
.projects-toolbar select { flex: 0 0 auto; min-width: 190px; border-radius: 9px; padding: 9px 12px; }
.plist-count-label { font-weight: 500; font-size: 12px; color: var(--text-2); margin-left: auto; }

.project-table-head, .project-table-row {
  grid-template-columns: minmax(0, 1.6fr) 150px 190px 70px 210px;
}
.project-table-row {
  width: 100%; display: grid; gap: 12px; align-items: center; min-width: 780px;
  padding: 13px 18px; background: transparent; border: none; border-bottom: 1px solid var(--border);
  text-align: left; color: inherit; font-family: 'Poppins', sans-serif;
  box-shadow: none; border-radius: 0;
}
.project-table-row:hover { background: var(--sunken); filter: none; }
.project-table-row:last-child { border-bottom: none; }
.project-row-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.project-row-street { font-weight: 700; font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-row-street:hover { text-decoration: underline; }
.project-row-contact { font-weight: 500; font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-row-contact-empty { font-style: italic; opacity: 0.75; }
.project-row-status { display: flex; }
.project-row-last-contact { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.project-row-contact-date { font-weight: 500; font-size: 11.5px; color: var(--text-2); }
.project-row-mails { font-weight: 700; font-size: 13px; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.project-row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.project-row-actions form.inline-form { margin-right: 0; }
.project-table-head {
  display: grid; gap: 12px; padding: 11px 18px; min-width: 780px;
  background: var(--sunken); border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2);
}
.project-table-head span:nth-child(4), .project-row-mails { text-align: right; }

/* ---- Project detail ---- */

.project-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.service-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; justify-content: flex-end; }
.service-tag {
  display: inline-block; background: var(--green); color: #fff; font-weight: 700; font-size: 11.5px;
  padding: 6px 14px 6px 11px; border-radius: 0 10px 10px 0; box-shadow: 3px 3px 0 var(--border-2);
}

.mail-history-row { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 6px 12px; align-items: start; padding: 12px 20px; border-top: 1px solid var(--border); }
.mail-history-row:first-child { border-top: none; }
.mail-dir {
  width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center;
  font-weight: 700; font-size: 11px; background: var(--sunken); color: var(--text-2);
}
.mail-dir.dir-out { background: var(--navy); color: #fff; }
.mail-history-main { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.mail-history-subject { font-weight: 700; font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-history-meta { font-weight: 500; font-size: 12px; color: var(--text-2); }
.mail-history-attachment { font-weight: 600; font-size: 11.5px; color: var(--text-2); }

/* Project chat */
.chat-card { display: flex; flex-direction: column; position: sticky; top: 96px; padding: 0; overflow: hidden; }
.chat-card-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 9px; }
.chat-avatar { width: 26px; height: 26px; border-radius: 6px; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 11px; flex-shrink: 0; }
.chat-card-head-text { display: flex; flex-direction: column; line-height: 1.25; }
.chat-card-head-text strong { font-weight: 700; font-size: 13.5px; color: var(--text); }
.chat-card-head-text span { font-weight: 500; font-size: 11.5px; color: var(--text-2); }

.chat-log { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; min-height: 200px; max-height: 380px; overflow-y: auto; margin: 0; }
.chat-msg { max-width: 88%; padding: 10px 13px; border-radius: 11px 11px 11px 3px; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.chat-msg p { margin: 0 0 8px; }
.chat-msg p:last-child { margin-bottom: 0; }
.chat-msg ul { margin: 0 0 8px; padding-left: 18px; }
.chat-msg ul:last-child { margin-bottom: 0; }
.chat-msg li { margin-bottom: 2px; }
.chat-msg code { font-size: 0.9em; background: rgba(0, 0, 0, 0.08); padding: 0.1em 0.35em; border-radius: 4px; }
.chat-msg-user code { background: rgba(255, 255, 255, 0.18); }
.chat-msg table { border-collapse: collapse; width: 100%; margin: 0 0 8px; font-size: 0.95em; }
.chat-msg table:last-child { margin-bottom: 0; }
.chat-msg th, .chat-msg td { border: 1px solid var(--border); padding: 4px 7px; text-align: left; white-space: normal; }
.chat-msg th { background: rgba(0, 0, 0, 0.06); font-weight: 700; }
.chat-msg-user th, .chat-msg-user td { border-color: rgba(255, 255, 255, 0.25); }
.chat-msg-user th { background: rgba(255, 255, 255, 0.12); }
.chat-msg-assistant { align-self: flex-start; background: var(--sunken); border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.chat-msg-user { align-self: flex-end; background: var(--navy); color: #fff; font-weight: 600; border-radius: 11px 11px 3px 11px; }
.chat-msg-error { align-self: flex-start; background: var(--error-bg); color: var(--error); border-bottom-left-radius: 3px; }
.chat-msg-pending { opacity: 0.6; }

.chat-suggestions { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 18px; }
.chat-suggest-btn {
  background: var(--sunken); border: 1px solid var(--border); color: var(--text-2); font-weight: 600;
  font-size: 11.5px; padding: 6px 11px; border-radius: 99px; cursor: pointer; box-shadow: none;
}
.chat-suggest-btn:hover { border-color: var(--green); color: var(--text); filter: none; }

.chat-form { display: flex; gap: 8px; padding: 12px 18px 16px; }
.chat-form input[type="text"] { flex: 1; min-width: 0; background: var(--sunken); border: 1px solid var(--border-2); border-radius: 7px; padding: 9px 11px; font-size: 12.5px; }

/* ---- Command palette ---- */

.palette-overlay {
  position: fixed; inset: 0; z-index: 80; background: rgba(20, 32, 50, 0.5); backdrop-filter: blur(3px);
  display: none; align-items: flex-start; justify-content: center; padding-top: 14vh;
  animation: fade-in 0.12s ease-out;
}
.palette-overlay.is-open { display: flex; }
.palette-box {
  width: 620px; max-width: 92vw; background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 11px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28); overflow: hidden; animation: pop-in 0.16s ease-out;
}
.palette-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.palette-input-row input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-size: 15px; font-weight: 600; padding: 0; }
.palette-kbd { font-size: 10.5px; font-weight: 700; border: 1px solid var(--border-2); border-radius: 5px; padding: 2px 6px; color: var(--text-2); }
.palette-results { max-height: 52vh; overflow-y: auto; padding: 8px; }
.palette-group { padding: 6px 8px 4px; }
.palette-group-title { font-weight: 700; font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-2); }
.palette-group-items { display: flex; flex-direction: column; margin-top: 4px; }
.palette-item {
  display: flex; align-items: center; gap: 12px; background: transparent; border: none; border-radius: 7px;
  padding: 10px 10px; cursor: pointer; text-align: left; width: 100%; box-shadow: none; color: inherit; font-family: 'Poppins', sans-serif;
}
.palette-item:hover, .palette-item.is-active { background: var(--sunken); filter: none; }
.palette-item-glyph { width: 22px; height: 22px; border-radius: 5px; background: var(--sunken); display: grid; place-items: center; font-size: 11.5px; color: var(--text-2); flex-shrink: 0; }
.palette-item-label { flex: 1; font-weight: 600; font-size: 13px; color: var(--text); }
.palette-item-hint { font-weight: 500; font-size: 11.5px; color: var(--text-2); }
.palette-empty { padding: 34px; text-align: center; font-weight: 500; font-size: 13px; color: var(--text-2); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .topbar { height: auto; padding: 14px 16px; }
  main.content { padding: 18px 16px; }
}

@media (max-width: 640px) {
  dl.mail-meta { grid-template-columns: 1fr; }
  .queue-head, .queue-row { grid-template-columns: 28px minmax(0, 1fr) 64px; }
}

/* ---- Attachment lightbox (image/PDF inline preview, see _attachments.html + app.js) ---- */

.lightbox-overlay {
  position: fixed; inset: 0; z-index: 85; background: rgba(20, 32, 50, 0.65); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 5vh 4vw;
  animation: fade-in 0.12s ease-out;
}
.lightbox-overlay.is-open { display: flex; }
.lightbox-box {
  width: min(900px, 92vw); max-height: 90vh; background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 11px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32); overflow: hidden;
  display: flex; flex-direction: column; animation: pop-in 0.16s ease-out;
}
.lightbox-head { display: flex; align-items: center; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.lightbox-title { flex: 1; font-weight: 700; font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-action {
  background: transparent; border: none; color: var(--text-2); font-size: 14px; cursor: pointer;
  padding: 5px 9px; border-radius: 6px; box-shadow: none; line-height: 1;
}
.lightbox-action:hover { background: var(--sunken); color: var(--text); filter: none; }
.lightbox-body { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; background: var(--sunken); min-height: 200px; }
.lightbox-image { max-width: 100%; max-height: 82vh; display: block; object-fit: contain; }
.lightbox-iframe { width: 100%; height: 78vh; border: none; display: block; background: #fff; }

/* ---- Searchable project select (progressive enhancement over a plain <select>, see app.js
   initSearchableSelects) - a native <select> with 100+ projects is unusable, this replaces the
   visible control with a filterable text input + dropdown while the original <select> stays in
   the DOM (hidden) as the actual form value. ---- */
.searchable-select { position: relative; flex: 1 1 0; min-width: 0; }
.searchable-select select { position: absolute; opacity: 0; pointer-events: none; height: 1px; width: 1px; }
.searchable-select-input {
  width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--border-2);
  border-radius: 7px; padding: 9px 10px; font-size: 12.5px; font-weight: 600; cursor: text;
}
.searchable-select-input:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.searchable-select-list {
  position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 260px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 9px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18); padding: 6px; display: none;
}
.searchable-select-list.is-open { display: block; }
.searchable-select-option {
  display: block; width: 100%; text-align: left; background: transparent; border: none; box-shadow: none;
  padding: 8px 10px; border-radius: 6px; font-family: 'Poppins', sans-serif; font-weight: 600;
  font-size: 12.5px; color: var(--text); cursor: pointer;
}
.searchable-select-option:hover, .searchable-select-option.is-active { background: var(--sunken); filter: none; }

/* ---- Leaflet/OpenStreetMap map views (Projekt-Detail-Mini-Karte + /map-Übersicht) ---- */
.map-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden; /* clips Leaflet's tile pane to the card's rounded corners */
  background: var(--sunken);
  /* Leaflet's internal panes use z-index up to 700+ (markers/popups/controls) - without a
     stacking context of its own here, those values compete directly with page-level overlays
     like the attachment lightbox (z-index 85) instead of staying contained, so the map won a
     fight it was never supposed to be in. position+z-index traps Leaflet's stack inside. */
  position: relative;
  z-index: 0;
}
.map-container-small { height: 220px; }
.map-container-large { height: calc(100vh - 220px); min-height: 420px; }
.map-hint { margin: 10px 0 0; font-size: 12px; color: var(--text-2); font-weight: 500; }
.leaflet-popup-content { font-family: 'Poppins', sans-serif; font-size: 12.5px; }
.leaflet-popup-content a { color: var(--navy); font-weight: 700; }

/* OSM tiles are only ever produced in a light palette - inverting them keeps the map usable
   without a jarring bright rectangle when the rest of the UI is in dark mode. Labels/markers
   get hue-rotated back so they don't end up color-inverted too. */
:root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.9); }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.9); }
.searchable-select-option.is-selected { color: var(--navy); }
.searchable-select-empty { padding: 10px; font-size: 12px; color: var(--text-2); text-align: center; }

/* ---- Contact/project network graph (see network.html, app.js::initNetworkGraph) ---- */
.network-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.network-toolbar-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#network-search { min-width: 220px; }
.network-legend { display: flex; flex-wrap: wrap; gap: 14px; }
.network-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.network-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.network-dot-project { background: var(--navy); }
.network-dot-intern { background: var(--role-intern); }
.network-dot-kunde { background: var(--green); }
.network-dot-verwalter { background: var(--unsorted); }
.network-dot-handwerker { background: var(--role-handwerker); }
.network-dot-behoerde { background: var(--role-behoerde); }
.network-dot-sonstiges { background: var(--muted-badge); }

.network-card { padding: 0; overflow: hidden; }
.network-graph { width: 100%; height: 70vh; min-height: 420px; display: block; cursor: grab; background: var(--sunken); }
.network-graph:active { cursor: grabbing; }

.network-edge { stroke: var(--border-2); stroke-opacity: 0.6; transition: stroke-opacity 0.2s ease; }
.network-edge-dim { stroke-opacity: 0.06; }
.network-node circle { stroke: var(--surface); stroke-width: 2px; cursor: pointer; }
.network-node { transition: opacity 0.2s ease; }
.network-node-dim { opacity: 0.15; }
.network-node-project circle { fill: var(--navy); }
.network-node-intern circle { fill: var(--role-intern); }
.network-node-kunde circle { fill: var(--green); }
.network-node-verwalter circle { fill: var(--unsorted); }
.network-node-handwerker circle { fill: var(--role-handwerker); }
.network-node-behoerde circle { fill: var(--role-behoerde); }
.network-node-sonstiges circle { fill: var(--muted-badge); }
.network-label { font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 10.5px; fill: var(--text); paint-order: stroke; stroke: var(--sunken); stroke-width: 3px; pointer-events: none; }
