/* SmartKomm management-agent — SWOP CI */
:root {
  --swop-orange: #ff5500;
  --swop-orange-dark: #cc4400;
  --swop-orange-light: #ffeee5;
  --bg: #fafafa;
  --bg-panel: #fff;
  --border: #e3e3e3;
  --text: #222;
  --text-dim: #777;
  --user-msg: #ff5500;
  --tool-msg: #f0f4f8;
  --tool-border: #c7d6e0;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 60px 1fr;
  grid-template-areas: "sidebar topbar" "sidebar main";
}

/* Sidebar */
.sidebar {
  grid-area: sidebar;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: .5em 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar .logo { padding: 0 1em .6em 1em; }
.sidebar .logo img { width: 100%; max-width: 160px; display: block; }

/* Nav scrollbar wenn der Inhalt zu hoch wird */
.main-nav {
  display: flex; flex-direction: column; padding: 0 .4em;
  overflow-y: auto;
  /* flex 0 0 auto: Nav nimmt nur ihren natürlichen Platz, der Rest
     der Sidebar (chat-list, user-box) bekommt den freien Platz. */
  flex: 0 0 auto;
  min-height: 0;
}
.main-nav a {
  padding: .35em .8em; color: #444; text-decoration: none; font-weight: 400;
  border-radius: 4px; margin: 0;
  font-size: .92em;
}
.main-nav a:hover { background: var(--swop-orange-light); color: var(--swop-orange); }
.main-nav a.active { background: var(--swop-orange); color: white; }

.nav-section { display: flex; flex-direction: column; padding: .15em 0; }
.nav-section + .nav-section { border-top: 1px solid var(--border); margin-top: .1em; }
.nav-heading {
  font-size: .92em; color: #222; padding: .35em .8em; font-weight: 700;
}

/* User-Box am Sidebar-Ende */
.user-box {
  margin-top: auto;
  padding: .8em 1em;
  border-top: 1px solid var(--border);
  font-size: .85em;
  color: #666;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.user-box .user-name { font-weight: 500; }
.user-box .logout-link {
  color: #888; text-decoration: none; font-size: .8em;
  padding: .2em .5em; border-radius: 3px;
}
.user-box .logout-link:hover { background: #f5f5f5; color: var(--swop-orange); }

/* Chat-List in sidebar */
.chat-list-wrap { padding: .5em; flex: 1; overflow-y: auto; min-height: 0; margin-top: .5em; border-top: 1px solid var(--border); padding-top: .8em;}
.new-chat { width: 100%; margin-bottom: .5em; }
.chat-search { display: flex; flex-direction: column; gap: .25em; margin-bottom: .5em; }
.chat-search input[type="text"] { font-size: .85em; padding: .35em .5em; }
.chat-search label { font-size: .72em; color: #888; display: flex; align-items: center; gap: .3em; cursor: pointer; }
.chat-search label input { margin: 0; }
.show-hidden-btn {
  width: 100%; margin-top: .5em; background: transparent; color: var(--swop-orange);
  border: 1px dashed var(--swop-orange-light); font-size: .8em; padding: .35em;
}
.show-hidden-btn:hover { background: var(--swop-orange-light); }
.chat-list li.hidden-chat { opacity: .55; }
.chat-list { list-style: none; padding: 0; margin: 0; }
.chat-list li {
  padding: .35em .6em; cursor: pointer; border-radius: 4px;
  color: #555;
  display: flex; align-items: center; justify-content: space-between;
  gap: .3em;
}
.chat-list li:hover { background: #f5f5f5; }
.chat-list li.active { background: var(--swop-orange-light); color: var(--swop-orange); font-weight: 600; }
.chat-list .name-wrap {
  flex: 1; min-width: 0; cursor: pointer;
  display: flex; flex-direction: column; gap: 0;
}
.chat-list .name { font-size: .9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list .ts { font-size: .72em; color: #aaa; line-height: 1; }
.chat-list li.active .ts { color: rgba(255,85,0,.65); }
.chat-list .actions { display: none; gap: .2em; }
.chat-list li:hover .actions { display: flex; }
.chat-list .actions button { padding: 0 .4em; background: transparent; color: #888; }
.chat-list .actions button:hover { color: var(--swop-orange); }

/* Topbar */
.topbar {
  grid-area: topbar;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.2em;
}
.topbar-title { font-size: 1.1em; font-weight: 600; color: #333; }

.status-box {
  display: flex; align-items: center; gap: .4em;
  background: var(--swop-orange-light);
  border: 1px solid var(--swop-orange);
  padding: .4em .8em; border-radius: 6px;
  cursor: pointer;
  font-size: .9em;
}
.status-box:hover { background: var(--swop-orange); color: white; }
.status-box:hover .lbl { color: rgba(255,255,255,.85); }
.status-box .num { font-weight: 700; color: var(--swop-orange); margin-left: .5em; }
.status-box:hover .num { color: white; }
.status-box .lbl { color: var(--text-dim); margin-right: .5em; }

/* Main */
.main { grid-area: main; overflow: auto; padding: 1.5em 2em; }

/* Generic */
button {
  background: var(--swop-orange); color: white; border: 0;
  padding: .55em 1.2em; cursor: pointer; border-radius: 4px;
  font: inherit; font-weight: 500;
}
button:hover { background: var(--swop-orange-dark); }
button.secondary { background: #888; }
button.secondary:hover { background: #555; }
button.primary { background: var(--swop-orange); }

a { color: var(--swop-orange); }
a:hover { color: var(--swop-orange-dark); }

h1 { color: var(--swop-orange); border-bottom: 2px solid var(--swop-orange); padding-bottom: .3em; }
h2 { color: #333; margin-top: 2em; }
h3 { color: #555; }

pre {
  background: #1a1a1a; color: #d0d0d0; padding: 1em; border-radius: 4px;
  overflow: auto; max-height: 500px; font-size: .85em;
}
textarea, input[type="text"] {
  width: 100%; padding: .5em; font: inherit;
  border: 1px solid var(--border); border-radius: 4px;
}
textarea:focus, input[type="text"]:focus {
  outline: none; border-color: var(--swop-orange);
}

/* Reports */
.report {
  border: 1px solid var(--border); padding: 1em; margin: 1em 0;
  border-radius: 6px; background: var(--bg-panel);
}
.report h3 { margin: 0 0 .3em 0; }
.report p { margin: 0 0 .8em 0; color: var(--text-dim); }

/* Status — kompakt */
.status-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .35em;
}
.status-card {
  background: var(--bg-panel); border: 1px solid var(--border);
  padding: .35em .55em; border-radius: 3px;
}
.status-card .lbl { font-size: .72em; color: var(--text-dim); line-height: 1.1; }
.status-card .info-tip { color: var(--swop-orange); cursor: help; margin-left: .2em; font-size: .85em; }
.status-card .info-tip:hover::after {
  content: attr(data-tip);
  position: absolute; background: #333; color: #fff; padding: .6em .8em;
  border-radius: 4px; font-size: 14px; max-width: 320px; line-height: 1.4;
  z-index: 50; margin-top: 1.2em; margin-left: -1em; white-space: normal;
  font-weight: normal;
}
.status-card .val { font-size: 1.05em; font-weight: 700; color: var(--swop-orange); line-height: 1.2; }
.status-section { margin: .9em 0; }
.status-section h3 { color: var(--swop-orange); border-bottom: 1px solid var(--swop-orange-light); padding-bottom: .15em; margin: .4em 0 .35em; font-size: .95em; }

/* Status: nach Quelle organisiert */
.source-block {
  margin: 1.2em 0 1.5em;
  padding: .8em 1em 1em;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.source-title {
  margin: 0 0 .15em;
  color: var(--swop-orange);
  font-size: 1.1em;
  border-bottom: 2px solid var(--swop-orange);
  padding-bottom: .25em;
}
.source-sub {
  display: block;
  color: #777;
  font-size: .8em;
  margin-bottom: .6em;
}
.source-block h3 {
  color: #444;
  font-size: .9em;
  margin: .8em 0 .3em;
  padding-bottom: .1em;
  border-bottom: 1px solid var(--border);
}
.source-meta {
  display: block;
  margin-top: .6em;
  color: #888;
  font-size: .8em;
}
.source-error {
  background: #fee;
  border-left: 3px solid #c33;
  padding: .5em .8em;
  color: #933;
}
.supplier-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9em;
  margin: .3em 0;
}
.supplier-table th, .supplier-table td {
  padding: .35em .6em;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.supplier-table th { background: #f8f8f8; font-weight: 600; color: #555; }
.supplier-table td.num, .supplier-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Overrides-UI */
.ovr-section {
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  padding: 1em 1.2em; margin: 0 0 1em;
}
.ovr-section h2 {
  color: var(--swop-orange); margin: 0 0 .3em; font-size: 1.05em;
  border-bottom: 2px solid var(--swop-orange); padding-bottom: .2em;
}
.ovr-section .muted { color: #888; font-size: .85em; }

.ovr-search input { width: 100%; padding: .5em; font-size: 1em; border: 1px solid var(--border); border-radius: 4px; }
.ovr-search ul { list-style: none; padding: 0; margin: .5em 0 0; max-height: 280px; overflow-y: auto; }
.ovr-search li { padding: .5em .8em; border-bottom: 1px solid var(--border); cursor: pointer; }
.ovr-search li:hover { background: var(--swop-orange-light); }
.ovr-search .inv-nr { font-weight: 600; color: var(--swop-orange); margin-right: .8em; font-family: monospace; }
.ovr-search .inv-meta { font-size: .85em; color: #555; }
.ovr-search li.error { color: #c33; }

.ovr-filters { display: flex; gap: 1em; align-items: center; margin: .5em 0 .8em; font-size: .9em; }
.ovr-filters input[type=text] { padding: .3em .5em; border: 1px solid var(--border); border-radius: 3px; min-width: 18em; }
.ovr-filters input[type=number] { padding: .3em; border: 1px solid var(--border); border-radius: 3px; }
.btn-secondary { padding: .3em .8em; background: #fff; color: #444; border: 1px solid var(--border); border-radius: 3px; cursor: pointer; }
.btn-secondary:hover { background: #f5f5f5; color: var(--swop-orange); border-color: var(--swop-orange); }

.ovr-table { width: 100%; border-collapse: collapse; font-size: .88em; }
.ovr-table th, .ovr-table td { padding: .35em .5em; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.ovr-table th { background: #f8f8f8; color: #555; font-weight: 600; font-size: .85em; }
.ovr-table td.note { color: #666; font-size: .9em; max-width: 18em; }
.ovr-table code { background: #f3f3f3; padding: 1px 4px; border-radius: 2px; font-size: .85em; }
.btn-revert { background: none; color: #888; border: 1px solid #ccc; border-radius: 3px; padding: .15em .4em; cursor: pointer; font-size: 1em; line-height: 1; }
.btn-revert:hover { background: #fee; color: #c33; border-color: #c66; }
/* Auto-Overrides (lexoffice/bank/etc.) optisch leiser, nicht revertierbar */
tr.auto-override { background: #fafafa; color: #777; }
tr.auto-override b { color: #555; }
.ovr-auto-hint { background: #fff7e0; border-left: 3px solid #f80; padding: .4em .8em; font-size: .85em; color: #555; margin: .3em 0 .6em; }

/* Invoices-Browser */
.inv-section { background:#fff; border:1px solid var(--border); border-radius:6px; padding:.8em 1em; }
.inv-tabs { display:flex; gap:.4em; margin-bottom:.6em; border-bottom:2px solid var(--border); }
.inv-tab { padding:.4em 1em; background:#f5f5f5; border:none; border-radius:4px 4px 0 0; cursor:pointer; font-size:.95em; color:#666; }
.inv-tab:hover { background:#fff5e6; }
.inv-tab.active { background:var(--swop-orange); color:#fff; font-weight:600; }
.inv-tab.active .muted { color: rgba(255,255,255,.85); }
.inv-filters { display:flex; gap:1em; align-items:center; margin:.5em 0 .8em; font-size:.9em; flex-wrap:wrap; }
.inv-filters label { display:inline-flex; align-items:center; gap:.35em; white-space:nowrap; }
.inv-filters select, .inv-filters input { padding:.3em .5em; border:1px solid var(--border); border-radius:3px; }
.inv-filters input[type=text] { min-width: 16em; }

/* Legende für Hintergrundfarben in den Browser-Tabellen */
.inv-legend {
  display:flex; gap:1.4em; flex-wrap:wrap;
  font-size:.82em; color:#666;
  margin:.3em 0 .6em; padding:.4em .8em;
  background:#fafafa; border:1px solid var(--border); border-radius:4px;
}
.inv-legend .swatch {
  display:inline-block; width:1.6em; height:1em;
  vertical-align:middle; margin-right:.35em;
  border:1px solid var(--border); border-radius:2px;
}
.inv-legend .sw-overdue, .inv-legend .sw-expired { background:#fff5f5; }
.inv-legend .sw-soon                              { background:#fff8e0; }

.inv-table-wrap { overflow-x:auto; }
.inv-table { width:100%; border-collapse:collapse; font-size:.88em; }
.inv-table th, .inv-table td { padding:.35em .5em; border-bottom:1px solid var(--border); text-align:left; vertical-align:top; }
.inv-table th { background:#f8f8f8; color:#555; font-weight:600; font-size:.85em; position:sticky; top:0; }
.inv-table td.num, .inv-table th.num { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
.inv-table td.amt-in  { color: #1a6e1a; font-weight: 600; }
.inv-table td.amt-out { color: #a02020; font-weight: 600; }
.inv-table tbody tr { cursor: pointer; }
.inv-table tr:hover { background:#fafafa; }
.inv-table tr.overdue-row { background:#fff5f5; }
.inv-table tr.overdue-row:hover { background:#ffeaea; }
.inv-table tr.expiring-soon { background:#fff8e0; }
.inv-table tr.expiring-soon:hover { background:#ffefc0; }
.ovr-table tbody tr { cursor: pointer; }
.ovr-table tbody tr:hover { background:#fafafa; }
.ovr-table tr.auto-override:hover { background:#f5f5f5; }
.inv-table code { background:transparent; font-size:.95em; }

.status-badge { padding:.1em .5em; border-radius:9px; font-size:.78em; font-weight:600; text-transform:uppercase; letter-spacing:.03em; }
.status-paid    { background:#d4f4d4; color:#1a6e1a; }
.status-open    { background:#fff5d4; color:#7a5f00; }
.status-overdue { background:#ffd0d0; color:#a02020; }
.status-voided  { background:#e0e0e0; color:#666; }
.status-draft   { background:#e8eaff; color:#445; }
.status-invalid { background:#dcdcdc; color:#333; }
.status-active   { background:#d4f4d4; color:#1a6e1a; }
.status-expiring { background:#ffe9c8; color:#7a5500; }
.status-expired  { background:#ffd0d0; color:#a02020; }

.bubble {
  display: inline-block;
  min-width: 1.5em;
  padding: .05em .45em;
  margin-left: .35em;
  border-radius: 9px;
  font-size: .82em;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
  vertical-align: baseline;
}
.bubble-ok   { background: #d4f4d4; color: #1a6e1a; }
.bubble-warn { background: #ffe9c8; color: #7a5500; }
.bubble-bad  { background: #ffd0d0; color: #a02020; }

.source-tag { background:#f0f0f0; color:#555; font-size:.78em; padding:1px 4px; border-radius:2px; }
.btn-pdf { background:none; color:#555; border:1px solid var(--border); border-radius:3px; padding:.15em .5em; cursor:pointer; font-size:1em; }
.btn-pdf:hover { background:var(--swop-orange-light); border-color:var(--swop-orange); color:var(--swop-orange); }
.btn-pdf-inline { background:#f5f5f5; color:#333; border:1px solid var(--border); border-radius:3px; padding:.25em .6em; cursor:pointer; font-size:.85em; margin-top:.2em; text-align:left; }
.btn-pdf-inline:hover { background:var(--swop-orange-light); color:var(--swop-orange); }

/* Drawer */
.inv-drawer { position:fixed; inset:0; background:rgba(0,0,0,.4); display:flex; align-items:center; justify-content:center; z-index:100; }
.inv-drawer.hidden { display:none; }
.drawer-inner { background:#fff; border-radius:6px; padding:1.2em 1.4em; width:90vw; max-width:1400px; max-height:92vh; overflow-y:auto; position:relative; }
.drawer-close { position:absolute; top:.5em; right:.8em; background:none; border:none; font-size:1.6em; cursor:pointer; color:#888; }
.drawer-close:hover { color:#333; }
.drawer-grid { display:grid; grid-template-columns: 2fr 1fr; gap:1em; transition: grid-template-columns .18s ease; }
.drawer-grid.side-collapsed { grid-template-columns: 1fr 0; }
.drawer-grid.side-collapsed .drawer-side { display: none; }
.drawer-pdf { position: relative; }
.drawer-side-toggle {
  position: absolute; top: .25em; right: .25em; z-index: 5;
  width: 1.9em; height: 1.9em;
  background: var(--swop-orange-light); border: 1px solid var(--swop-orange);
  border-radius: 4px; cursor: pointer;
  color: var(--swop-orange);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; line-height: 1;
}
.drawer-side-toggle:hover { background: var(--swop-orange); color: #fff; }
.drawer-side-toggle svg { display: block; }
.drawer-subtitle { font-size: .85em; margin: .2em 0 .1em; }
.drawer-source-path { font-size: .85em; word-break: break-all; margin: 0 0 .8em; }
.drawer-side h4 { color:var(--swop-orange); margin:.8em 0 .3em; font-size:.9em; }
.drawer-meta tr.meta-overridden td, .drawer-meta tr.meta-overridden th { background: #fff4cd; }
.drawer-meta tr.meta-overridden .meta-orig s { color: #888; }
.drawer-meta tr.meta-overridden .meta-eff b { color: #1a1a1a; }
.drawer-meta .meta-src { color: #8a5a00; font-size: .82em; margin-left: .3em; }
.drawer-meta { width:100%; font-size:.88em; }
.drawer-meta th { text-align:left; color:#666; font-weight:500; padding:.2em .5em .2em 0; width:40%; }
.drawer-meta td { padding:.2em .3em; }
.drawer-meta code { background:#f3f3f3; padding:1px 4px; border-radius:2px; font-size:.85em; }
.contract-list { list-style:none; padding:0; }
.contract-list li { background:#f9f9f9; padding:.5em .7em; margin:.3em 0; border-left:3px solid var(--swop-orange); border-radius:3px; font-size:.88em; }
.ovr-details { margin:.5em 0; font-size:.85em; }
.ovr-details summary { cursor:pointer; color:var(--swop-orange); }
.ovr-list { list-style:none; padding:.3em 0 0 .5em; font-size:.85em; }
.ovr-list li { padding:.2em 0; border-bottom:1px dotted var(--border); }
.ovr-list li code { background:#f3f3f3; padding:1px 4px; border-radius:2px; }

.ovr-modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.ovr-modal.hidden { display: none; }
.ovr-modal-inner {
  background: #fff; border-radius: 6px; padding: 1.4em 1.6em;
  max-width: 850px; max-height: 90vh; overflow-y: auto;
  position: relative;
  display: flex; flex-direction: column;
}
/* Szenario-Modal: feste Größe damit der Container beim Bearbeiten nicht
   springt — Inhalte werden intern gescrollt. */
#scenarioModal .ovr-modal-inner {
  width: calc(100vw - 100px);
  max-width: none;
  max-height: calc(100vh - 100px);
  background: #f0f0f2;
}
.modal-close {
  position: sticky; top: 0;
  align-self: flex-end;
  margin: -.6em -.6em -1.6em 0;  /* hängt rechts oben über dem Inhalt */
  background: rgba(255,255,255,.95); border: 1px solid rgba(0,0,0,.1);
  border-radius: 50%; width: 2em; height: 2em;
  font-size: 1.2em; line-height: 1; cursor: pointer; color: #666;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; z-index: 10;
}
.modal-close:hover { color: #c33; background: #fff; border-color: #c66; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1em; margin: .8em 0; }
.modal-grid > div { background: #f9f9f9; padding: .6em .8em; border-radius: 4px; font-size: .9em; line-height: 1.5; }
.modal-grid .lbl { font-size: .8em; color: #888; text-transform: uppercase; letter-spacing: .03em; margin-bottom: .3em; }
.ovr-modal-inner h4 { color: var(--swop-orange); margin: 1em 0 .3em; font-size: .95em; }
.ovr-modal-inner form label { display: inline-block; margin: .3em 0; margin-right: 1em; }
.ovr-modal-inner form select, .ovr-modal-inner form input[type=text] { padding: .3em; border: 1px solid var(--border); border-radius: 3px; }
.ovr-history { width: 100%; border-collapse: collapse; font-size: .85em; margin-top: .3em; }
.ovr-history td, .ovr-history th { padding: .3em .5em; border-bottom: 1px solid var(--border); text-align: left; }
.ovr-history th { background: #f5f5f5; color: #666; font-weight: 600; }
.batch-row {
  background: #fff8dc; border-left: 3px solid #f80;
  padding: .4em .8em; margin: .3em 0; font-size: .9em;
}

/* Wishes */
.wish {
  background: #fff8dc; border-left: 4px solid var(--swop-orange);
  padding: .8em; margin: .5em 0;
}
.wish-meta { font-size: .85em; color: var(--text-dim); }

/* Chat */
.chat-area {
  display: flex; flex-direction: column;
  height: calc(100vh - 60px - 3em);  /* topbar + main padding */
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 1em;
  background: var(--bg-panel); border-radius: 6px;
  margin-bottom: 1em;
}
.chat-empty { color: var(--text-dim); text-align: center; padding: 4em 1em; }
.chat-empty h2 { color: var(--swop-orange); }

.msg { margin: .8em 0; max-width: 85%; }
.msg.user { margin-left: auto; }
.msg.user .bubble {
  background: var(--swop-orange); color: white;
  padding: .7em 1em; border-radius: 12px 12px 2px 12px;
}
.msg.assistant .bubble {
  background: #fff; border: 1px solid var(--border);
  padding: .7em 1em; border-radius: 12px 12px 12px 2px;
}
.msg.tool .bubble {
  background: var(--tool-msg); border-left: 3px solid var(--tool-border);
  padding: .5em .8em; font-size: .85em; color: #555;
  border-radius: 4px;
}
/* Streaming: kurzer Tool-Use-Indikator zwischen den Turns */
.msg.tool-indicator .bubble {
  background: #f0f7ff; border-left: 3px solid #4488dd;
  padding: .35em .7em; font-size: .85em; color: #555; border-radius: 4px;
}
.msg.tool-indicator .bubble code { background: rgba(0,0,0,.06); padding: 0 .3em; border-radius: 2px; }
.error-msg { color: #c33; font-size: .9em; padding: .3em .5em; background: #fee; border-left: 3px solid #c33; margin: .3em 0; }

/* Finanz-Dashboard Tiles */
.fin-section { margin: 1em 0 1.5em; }
.fin-section h2 {
  color: var(--swop-orange); margin: 0 0 .4em; font-size: 1.05em;
  border-bottom: 2px solid var(--swop-orange); padding-bottom: .2em;
}
.fin-section h2 small { color: #888; font-size: .65em; font-weight: normal; }
.fin-section { margin: 1.2em 0 2em; }
.fin-section h2 small { color: #888; font-weight: 400; font-size: .7em; }
.fin-chart-wrap { position: relative; height: 320px; margin-top: .5em; background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: .5em; }
.fin-top-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5em; }
.fin-top-grid h3 { margin: 0 0 .4em; }
.fin-top-table th, .fin-top-table td { font-size: .9em; }
@media (max-width: 1100px) { .fin-top-grid { grid-template-columns: 1fr; } }

.fin-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .8em;
}
.fin-tile {
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  padding: .8em 1em;
}
.fin-tile .lbl { font-size: .8em; color: #888; margin-bottom: .25em; }
.fin-tile .val { font-size: 1.5em; font-weight: 700; color: #333; line-height: 1.1; }
.fin-tile .sub { font-size: .8em; color: #888; margin-top: .25em; }
.fin-tile .pos { color: #1a6e1a; }
.fin-tile .neg { color: #c33; }

/* Liquidität Chart-Page */
.liqui-comparison-bar {
  display: flex; gap: .6em; align-items: center; flex-wrap: wrap;
  padding: .5em .7em; margin-bottom: .8em;
  background: #fafafa; border: 1px solid var(--border); border-radius: 4px;
  font-size: .92em;
}
.liqui-comparison-bar select {
  padding: .25em .5em; border: 1px solid var(--border); border-radius: 3px;
  font-size: .95em; min-width: 18em;
}
.liqui-comparison-bar #compStatus { font-size: .85em; }
.liqui-comp-warning {
  background: #fff4d6; border: 1px solid #e0b94a;
  color: #5a4400; padding: .6em .9em; border-radius: 4px;
  margin-bottom: .8em; line-height: 1.45; font-size: .9em;
  display: flex; gap: .8em; align-items: center; flex-wrap: wrap;
}
.liqui-comp-warning button { margin-left: auto; }

.liqui-controls {
  display: flex; gap: 1em; align-items: center;
  margin-bottom: .8em; flex-wrap: wrap;
}
.liqui-range { display: inline-flex; align-items: center; gap: .8em; }
.liqui-range > label { display: inline-flex; align-items: center; gap: .25em; cursor: pointer; }
.liqui-range > label > input { margin: 0; }
.liqui-lines { margin-bottom: .8em; }
.liqui-line-row {
  display: flex; gap: .5em; align-items: center;
  margin: .3em 0; padding: .3em 0;
  border-bottom: 1px dotted var(--border);
}
.line-color {
  display: inline-block; width: 1em; height: 1em;
  border-radius: 50%; border: 1px solid #ccc;
}
.scn-pills { display: inline-flex; flex-wrap: wrap; gap: .35em; }
.scn-pill {
  display: inline-flex; align-items: center; gap: .3em;
  padding: .25em .65em !important;
  background: #f5f5f5 !important; color: #444 !important;
  border: 1px solid var(--border) !important;
  border-radius: 999px;
  font-size: .85em; font-weight: 500;
  cursor: pointer; transition: background .1s, border-color .1s;
}
.scn-pill:hover { background: var(--swop-orange-light) !important; border-color: var(--swop-orange) !important; color: var(--swop-orange-dark) !important; }
.scn-pill.active {
  background: var(--swop-orange) !important; color: #fff !important;
  border-color: var(--swop-orange-dark) !important;
}
.scn-pill.active:hover { background: var(--swop-orange-dark) !important; }
.scn-pill-mark { font-weight: 700; opacity: .8; }
.scn-pill.active .scn-pill-mark { opacity: 1; }
.scn-pill-x {
  display: inline-block; margin-left: .35em; padding: 0 .25em;
  border-radius: 50%; background: rgba(255,255,255,.25);
  cursor: pointer; font-weight: 700; line-height: 1;
}
.scn-pill-x:hover { background: rgba(255,255,255,.5); }
.scn-picker {
  padding: .25em .5em; border: 1px solid var(--border); border-radius: 3px;
  background: #fff; color: #444; font-size: .85em; cursor: pointer;
}
.scn-picker:hover { border-color: var(--swop-orange); }
.liqui-line-name { min-width: 5.5em; }
.liqui-add-line { margin: .5em 0 1em; }
.liqui-chart-wrap {
  background: #fff; padding: 1em; border: 1px solid var(--border);
  border-radius: 6px; margin: .5em 0;
  height: 480px;
}
.liqui-summary { padding: .4em .8em; font-size: .9em; }
.liqui-legend {
  display: flex; flex-wrap: wrap; gap: 1.2em;
  margin: .6em 0 .4em 0;
  padding: .4em .2em;
  font-size: .9em;
  text-align: left;
}
.liqui-legend-item { display: inline-flex; align-items: center; gap: .35em; }
.liqui-legend-swatch {
  display: inline-block; width: 1em; height: .25em;
  border-radius: 2px; vertical-align: middle;
}
.liqui-modifications { margin-top: 1.2em; }
.liqui-mods-head { margin: 0 0 .6em; }
.liqui-mods-head small { font-weight: 400; color: #888; font-size: .65em; }
.liqui-mod-line {
  border: 1px solid var(--border); border-radius: 4px;
  padding: .6em .8em; margin-bottom: .8em; background: #fafafa;
}
.liqui-mod-line-head { display: flex; align-items: center; gap: .5em; margin-bottom: .5em; flex-wrap: wrap; }
.liqui-mod-scn { padding: .35em 0 .55em; border-top: 1px dashed var(--border); margin-top: .35em; }
.liqui-mod-scn:first-of-type { border-top: 0; margin-top: 0; }
.liqui-mod-scn-head { margin-bottom: .25em; }
.liqui-mod-section { margin: .25em 0; }
.liqui-mod-section-head { font-size: .85em; color: #555; margin: .2em 0; }
.liqui-mod-table { width: 100%; border-collapse: collapse; font-size: .85em; background: #fff; }
.liqui-mod-table th, .liqui-mod-table td { padding: .25em .5em; border-bottom: 1px solid var(--border); text-align: left; }
.liqui-mod-table th { background: #f5f5f5; font-weight: 600; font-size: .82em; color: #555; }
.liqui-mod-table .num { text-align: right; }

.liqui-event-tip {
  position: fixed; display: none; z-index: 1000;
  background: #fff; color: #222;
  border: 1px solid #ccc;
  padding: .5em .75em; border-radius: 4px;
  font-size: .85em; line-height: 1.4;
  max-width: 26em;
  /* Clickable damit Pin-Toggle möglich ist */
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
  /* Bei vielen Events am gleichen Tag scrollbar machen, damit
     untere Events erreichbar bleiben. Konkrete max-height wird
     dynamisch in JS basierend auf top-Position gesetzt. */
  max-height: 60vh;
  overflow-y: auto;
}
.liqui-event-tip.pinned {
  border-color: var(--swop-orange);
  box-shadow: 0 4px 14px rgba(244,123,32,.3);
}
.liqui-event-tip b { color: #111; }
.liqui-event-tip .pin-hint { color: #888; font-size: .85em; }
.liqui-event-tip.pinned .pin-hint { color: var(--swop-orange); }

.bucket-sums { position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; }
.bucket-sum  {
  position: absolute;
  font-size: .68em; line-height: 1.2;
  text-align: center;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.bucket-sum .bs-row { pointer-events: none; }
.bucket-sum .bs-bucket-header {
  font-size: .82em; font-weight: 600; text-align: center;
  color: #666; margin-bottom: 2px;
  border-bottom: 1px solid rgba(0,0,0,.08);
  padding-bottom: 1px;
}
.bucket-sum .bs-row {
  border-left: 1px solid rgba(0,0,0,.1);
  background: rgba(255,255,255,.85);
  padding: 1px 3px;
  margin-bottom: 1px;
  display: flex; flex-direction: column;
  align-items: center;
}
.bucket-sum .bs-in  { color: #1a6e1a; }
.bucket-sum .bs-out { color: #a02020; }
.bucket-sum .bs-net-pos { color: #1a6e1a; font-weight: 600; }
.bucket-sum .bs-net-neg { color: #a02020; font-weight: 600; }
.bucket-legend {
  position: absolute;
  font-size: .68em; line-height: 1.2;
  text-align: right;
  pointer-events: none;
}
.bank-account-bar {
  display: flex; gap: 1em; flex-wrap: wrap;
  margin: .4em 0 .8em;
}
.bank-acc-card {
  display: inline-flex; flex-direction: column;
  padding: .4em .8em;
  background: var(--swop-orange-light);
  border: 1px solid var(--swop-orange);
  border-radius: 4px;
  font-size: .9em;
}
.bank-acc-card .bank-acc-label { font-weight: 600; color: var(--swop-orange); }
.bank-acc-card .bank-acc-balance {
  font-size: 1.15em; font-weight: 700; color: #1a6e1a;
  font-variant-numeric: tabular-nums; margin-top: .15em;
}
.bank-acc-card code { font-size: .82em; }

.inv-table tr.inactive-row td { opacity: .55; }
.inv-table tr.just-changed { background: #fff4cd; transition: background 1.5s ease-out; }

.emp-grid label { display: flex; flex-direction: column; gap: .15em; }
.emp-grid label.grid-full { grid-column: 1 / -1; }
.emp-grid input, .emp-grid select, .emp-grid textarea {
  padding: .35em .5em;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: .95em;
  font-family: inherit;
}
.emp-grid input:focus, .emp-grid select:focus, .emp-grid textarea:focus {
  outline: none; border-color: var(--swop-orange);
}

.rule-type {
  display: inline-block;
  padding: .1em .5em; border-radius: 3px;
  font-size: .8em; font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em;
}
.rule-type.rule-iban           { background: #d4f4d4; color: #1a6e1a; }
.rule-type.rule-glaeubiger_id  { background: #d4ebf4; color: #1a4d6e; }
.rule-type.rule-mandat_pattern { background: #f4ecd4; color: #6e5a1a; }
.rule-type.rule-name_pattern   { background: #ebe0f4; color: #5a1a6e; }

.rule-party-results {
  border: 1px solid var(--border);
  border-radius: 3px;
  max-height: 16em;
  overflow-y: auto;
  margin-top: .25em;
}
.rule-party-results:empty { display: none; }
.rule-party-cand {
  padding: .35em .6em;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.rule-party-cand:last-child { border-bottom: none; }
.rule-party-cand:hover { background: var(--swop-orange-light); }

.bucket-legend .bs-legend-spacer {
  height: 16px;  /* matcht die Bucket-Header-Höhe */
}
.bucket-legend .bs-legend-row {
  /* gleiche Höhe wie .bs-row (drei Zeilen +/−/Netto) damit Labels fluchten */
  height: 44px;
  padding: 1px 6px 1px 0;
  margin-bottom: 1px;
  display: flex; flex-direction: column; justify-content: center;
  align-items: flex-end;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Cashflow-Events: gruppierte Ansicht */
.cf-toolbar { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 1em; }
.cf-toolbar h2 { margin: 0; }
.cf-view-toggle { display: flex; gap: 1em; font-size: .9em; }
.cf-view-toggle label { display: inline-flex; align-items: center; gap: .3em; cursor: pointer; }
.cf-subhead { margin: 1.5em 0 .4em; color: #555; font-size: 1.1em; }
.cf-rec-summary { margin: .3em 0 .5em; padding: .5em .7em; background: #fafafa; border-left: 3px solid var(--swop-orange); border-radius: 3px; font-size: .92em; }
.cf-month-group { margin: .4em 0; border: 1px solid var(--border); border-radius: 4px; }
.cf-month-group > summary { cursor: pointer; padding: .55em .8em; background: #fafafa; user-select: none; list-style: none; }
.cf-month-group > summary::-webkit-details-marker { display: none; }
.cf-month-group > summary::before { content: "▸ "; color: #888; transition: transform .1s; display: inline-block; }
.cf-month-group[open] > summary::before { content: "▾ "; }
.cf-month-group .cf-month-stats { float: right; color: #666; font-size: .9em; }
.cf-month-group table { margin: 0; }
a.src-link { text-decoration: none; color: inherit; }
a.src-link code { color: var(--swop-orange); border-bottom: 1px dotted var(--swop-orange-light); }
a.src-link:hover code { color: var(--swop-orange-dark); border-bottom-color: var(--swop-orange-dark); }

/* Duplikat-Panel auf /contracts */
.duplicates-panel {
  border: 1px solid var(--swop-orange); border-radius: 5px;
  padding: .8em 1em; margin: 1em 0; background: #fff8ef;
}
.dup-head { display: flex; justify-content: space-between; align-items: start; }
.dup-head h3 { margin: 0 0 .4em; }
.dup-group { margin: .8em 0; padding: .5em .6em; background: #fff; border: 1px solid var(--border); border-radius: 4px; }
.dup-group-head { margin-bottom: .3em; }
.dup-table th, .dup-table td { padding: .35em .6em !important; }
.dup-table tr:hover td { background: var(--swop-orange-light); }
.dup-table tr.dup-path-row td { padding-top: 0 !important; padding-bottom: .55em !important; border-bottom: 1px solid var(--border); }
.dup-table tr.dup-main-row td { border-bottom: 0 !important; padding-bottom: .15em !important; }
.dup-table .dup-path { word-break: break-all; }
.dup-table .dup-path code { word-break: break-all; white-space: normal; font-size: .9em; }

.drawer-actions { display: flex; flex-direction: column; gap: .4em; margin: .8em 0; align-items: flex-start; }
.drawer-actions > button { white-space: nowrap; }
/* Wie .btn-secondary, nur rot */
.drawer-invalid-btn {
  padding: .3em .8em; background: #fff; color: #c33;
  border: 1px solid #f0bfbf; border-radius: 3px;
  cursor: pointer; font: inherit;
}
.drawer-invalid-btn:hover { background: #fbeaea; color: #a02020; border-color: #c66; }

/* Status-Boppel + Filter-Legende */
.status-dot {
  display: inline-block; width: .85em; height: .85em;
  border-radius: 50%; vertical-align: -.1em;
  border: 1px solid rgba(0,0,0,.15);
}
.status-dot.s-paid       { background: #2ca02c; }     /* grün */
.status-dot.s-open       { background: #f0a020; }     /* gelb-orange */
.status-dot.s-overdue    { background: #c33; }        /* rot */
.status-dot.s-voided     { background: #888; }        /* grau */
.status-dot.s-draft      { background: #6db; }        /* türkis */
.status-dot.s-unknown    { background: #ddd; }
.status-dot.s-active     { background: #2ca02c; }
.status-dot.s-expiring   { background: #f0a020; }
.status-dot.s-expired    { background: #c33; }
.status-dot.s-autorenew  { background: #2ca02c; box-shadow: 0 0 0 2px #cfeacf inset; }
.status-dot.s-invalid    { background: #444; }

.status-filters { display: flex; gap: .8em; flex-wrap: wrap; margin: .3em 0 .6em; align-items: center; }
.status-filters label { display: inline-flex; align-items: center; gap: .3em; cursor: pointer; font-size: .92em; }
.status-filters label input { margin: 0; }

/* Linker Status-Streifen an der Tabellen-Zeile */
.inv-table tr.has-status td:first-child {
  position: relative; border-left: 4px solid transparent; padding-left: .7em !important;
}
.inv-table tr.s-row-paid       td:first-child { border-left-color: #2ca02c; }
.inv-table tr.s-row-open       td:first-child { border-left-color: #f0a020; }
.inv-table tr.s-row-overdue    td:first-child { border-left-color: #c33; }
.inv-table tr.s-row-voided     td:first-child { border-left-color: #888; }
.inv-table tr.s-row-draft      td:first-child { border-left-color: #6db; }
.inv-table tr.s-row-unknown    td:first-child { border-left-color: #ddd; }
.inv-table tr.s-row-active     td:first-child { border-left-color: #2ca02c; }
.inv-table tr.s-row-expiring   td:first-child { border-left-color: #f0a020; }
.inv-table tr.s-row-expired    td:first-child { border-left-color: #c33; }
.inv-table tr.s-row-autorenew  td:first-child { border-left-color: #2ca02c; }
.inv-table tr.s-row-invalid    td:first-child { border-left-color: #444; }

/* Synth-Contracts: rot wenn unbestaetigt, gelb wenn manuell bestätigt */
.inv-table tr.synth-unconfirmed { background: #fbeaea; }
.inv-table tr.synth-unconfirmed:hover { background: #f8dada; }
.inv-table tr.synth-confirmed   { background: #fff7d6; }
.inv-table tr.synth-confirmed:hover   { background: #fff0b8; }

/* Datei-Typ-Badge in Listen */
.file-icon {
  display: inline-block; padding: 0 .35em; border-radius: 3px;
  font-size: .65em; font-weight: 700; line-height: 1.6;
  vertical-align: middle; margin-right: .25em;
  border: 1px solid; min-width: 2.4em; text-align: center;
}
.file-icon.fi-pdf   { color: #c33; border-color: #f0bfbf; background: #fbeaea; }
.file-icon.fi-img   { color: #0a6; border-color: #b6d8c8; background: #eafaf2; }
.file-icon.fi-doc   { color: #246; border-color: #bccede; background: #ecf2f8; }
.file-icon.fi-sheet { color: #563; border-color: #cfd5b5; background: #f3f5e8; }
.file-icon.fi-mail  { color: #846; border-color: #d8c0d0; background: #f7eaf2; }
.file-icon.fi-other { color: #666; border-color: #ccc; background: #f5f5f5; }

/* Drawer-Text-Card: zeigt extrahierten Text statt iframe für nicht-renderbare Dateien */
.drawer-text-card {
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  padding: .6em .8em; height: 70vh; display: flex; flex-direction: column; gap: .5em;
}
.text-card-head { display: flex; gap: .5em; align-items: center; flex-wrap: wrap; padding-bottom: .4em; border-bottom: 1px solid var(--border); }
.text-card-head a.btn-secondary { padding: .3em .8em !important; font-size: .85em; }
.text-card-body {
  flex: 1; overflow-y: auto; margin: 0; padding: .5em;
  background: #fafafa; border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .85em; white-space: pre-wrap; word-wrap: break-word; line-height: 1.45;
  color: #222;
}
.text-card-body.muted { color: #888; font-style: italic; font-family: inherit; }

/* Sortierbare Tabellen-Header */
.sortable-table th.sortable { cursor: pointer; user-select: none; }
.sortable-table th.sortable:hover { background: var(--swop-orange-light); }
.sort-ico { font-size: .85em; margin-left: .15em; opacity: .8; }
.sort-ico.muted { opacity: .3; }

.scn-header { margin-bottom: 1.8em; }
.scn-header h3 { margin: 0; display: flex; align-items: baseline; gap: .4em; }
.scn-header .scn-desc { margin: .15em 0 0; font-size: .9em; }
.scn-meta-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.4em; height: 1.4em;
  font-size: .7em; color: #999; text-decoration: none;
  border: 1px solid transparent; border-radius: 3px;
  margin-left: .3em;
}
.scn-meta-btn:hover { color: var(--swop-orange); border-color: var(--swop-orange-light); background: var(--swop-orange-light); }
.scn-meta-ok { color: #1a6e1a !important; border-color: #b6d8b6 !important; background: #eafbea !important; font-size: .85em !important; }
.scn-meta-ok:hover { background: #d8f0d8 !important; }
.scn-meta-cancel { color: #c33 !important; border-color: #f0bfbf !important; background: #fbeaea !important; font-size: .85em !important; }
.scn-meta-cancel:hover { background: #f5d6d6 !important; }

.scn-events-table { table-layout: fixed; font-size: 1em; background: #fff; border-radius: 4px; }
#scenarioModal .ovr-table { background: #fff; border-radius: 4px; }
#scenarioModal .ovr-table th { background: #fff; }
.scn-events-table tr.scn-row { cursor: pointer; }
.scn-events-table tr.scn-row:hover td { background: var(--swop-orange-light); }
.scn-events-table tr.scn-row-editing td { background: #fff8ef; }
/* Highlight-Animation für gerade veränderte Zeilen */
@keyframes scn-flash {
  0%   { background: #fff4cd; }
  60%  { background: #fffbe5; }
  100% { background: transparent; }
}
.scn-events-table tr.scn-row-flash td { animation: scn-flash 2.8s ease-out; }
.scn-edit-actions { white-space: nowrap; text-align: right; }
.scn-save-btn, .scn-abort-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.8em; height: 1.8em;
  border: 0; border-radius: 3px;
  cursor: pointer; padding: 0;
  margin: 0 .1em;
  vertical-align: middle;
}
.scn-save-btn svg, .scn-abort-btn svg, .scn-delete-btn svg { display: block; }
.scn-delete-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.8em; height: 1.8em;
  background: transparent; color: #c33;
  border: 1px solid #f0bfbf; border-radius: 3px;
  cursor: pointer; padding: 0;
}
.scn-delete-btn:hover { background: #fbeaea; color: #a02020; border-color: #c66; }

/* Direction-Toggle in Edit-Mode (statt select) */
.dir-toggle {
  display: inline-block;
  width: 1.7em; height: 1.7em;
  border: 1px solid var(--border); border-radius: 3px;
  background: #fafafa;
  font-size: 1.1em; font-weight: 700; line-height: 1;
  cursor: pointer; padding: 0;
}
.dir-toggle.pos, .dir-toggle[data-dir="in"] { color: #1a6e1a; background: #eafbea; border-color: #b6d8b6; }
.dir-toggle.neg, .dir-toggle[data-dir="out"] { color: #c33; background: #fbeaea; border-color: #f0bfbf; }
.dir-toggle:hover { filter: brightness(1.05); }

/* Sektions-Untertitel im Szenario-Modal (Modifikationen-Block) */
.scn-mod-section-head { font-size: .9em; color: #555; font-weight: 600; margin: .4em 0 .2em; }

/* Modify-Picker (vereinheitlichter Base-Event-Editor) */
.mod-edit-orig {
  background: #fafafa; border: 1px solid var(--border); border-radius: 4px;
  padding: .6em .8em; margin: .4em 0 1em;
}
.mod-edit-modes { display: flex; flex-direction: column; gap: .35em; margin-bottom: .9em; }
.mod-mode { padding: .35em .55em; border: 1px solid var(--border); border-radius: 3px; cursor: pointer; }
.mod-mode:hover { background: #fafafa; }
.mod-mode input { margin-right: .3em; }
.mod-edit-fields { display: flex; gap: 1em; flex-wrap: wrap; margin-bottom: 1em; }
.mod-field { display: flex; align-items: center; gap: .4em; }
.mod-field input { padding: .3em .5em; border: 1px solid var(--border); border-radius: 3px; font: inherit; }
.mod-edit-actions { display: flex; gap: .5em; justify-content: flex-end; padding-top: .6em; border-top: 1px solid var(--border); }
.manual-add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8em 1em; margin-bottom: 1em; }
.manual-add-grid label { display: flex; flex-direction: column; font-size: .9em; color: #555; gap: .25em; }
.manual-add-grid label input, .manual-add-grid label select { padding: .35em .5em; border: 1px solid var(--border); border-radius: 3px; font: inherit; font-size: 1em; color: #222; }
.manual-add-grid .grid-full { grid-column: 1 / -1; }
.scn-save-btn { background: #2ca02c; color: #fff !important; }
.scn-save-btn:hover { background: #1a7c1a; }
.scn-abort-btn { background: #c33; color: #fff !important; }
.scn-abort-btn:hover { background: #a02020; }
.scn-events-table td, .scn-events-table th {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  vertical-align: middle; padding: .35em .5em;
  font-size: 1em;
}
/* Aktion-Zelle: NIE truncaten + immer rechtsbündig */
.scn-events-table td.scn-edit-actions,
.scn-events-table tr.scn-row > td:last-child {
  overflow: visible; text-overflow: clip; padding: .25em .3em;
  text-align: right;
}
.scn-events-table td.num, .scn-events-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scn-events-table td.num input { text-align: right; }
.scn-events-table td #edt-amount { text-align: right; }
.scn-events-table td input,
.scn-events-table td select {
  box-sizing: border-box;
  padding: .25em .4em; border: 1px solid var(--border); border-radius: 3px;
  font: inherit;
  margin: 0;
}
/* In Edit-Mode: Inputs füllen ihre Spalte komplett — keine Sprünge */
.scn-events-table td input[type="text"],
.scn-events-table td input[type="number"],
.scn-events-table td input[type="date"] { width: 100%; }
/* Recurrence-Spalte: select + date nebeneinander, kompakt */
.scn-events-table td #edt-rec { width: 100%; max-width: 100%; margin-bottom: .15em; }
.scn-events-table td #edt-until { width: 100%; }
.scn-events-table td #edt-dir { width: 100%; }
.scn-events-table td .btn-mini { padding: .1em .35em !important; }
.scn-diff-box {
  padding: .6em .8em; background: var(--swop-orange-light);
  border-left: 3px solid var(--swop-orange); border-radius: 3px;
  margin-bottom: 1em; font-size: .95em;
}
.scn-add-exclusion { margin-top: .5em; }
.scn-helper-buttons { margin: .3em 0 .8em; display: flex; gap: .8em; align-items: center; flex-wrap: wrap; }
.scn-manual-add { margin: .3em 0 1em; }
.scn-manual-add > summary { cursor: pointer; padding: .35em 0; color: var(--swop-orange); font-size: .92em; }
.scn-manual-add[open] > summary { font-weight: 500; }
.scn-modal-footer {
  display: flex; gap: .6em; align-items: center; flex-wrap: wrap;
  margin-top: 1.2em; padding-top: .8em;
  border-top: 1px solid var(--border);
}
.scn-modal-footer .scn-modal-close-btn { margin-left: auto; }
.scn-help { margin: 0 0 .6em; font-size: .9em; }
.scn-help summary { cursor: pointer; color: var(--swop-orange); padding: .2em 0; }
.scn-help ul { margin: .3em 0; padding-left: 1.4em; }
.scn-chat {
  margin-bottom: 0;
}
#scenarioModal .ovr-modal-inner h4:first-of-type { margin-top: .3em; }
.scn-chat-history {
  max-height: 200px; overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 3px;
  padding: .5em .6em; margin-bottom: .5em; font-size: .92em;
}
.scn-chat-msg { margin: .35em 0; line-height: 1.45; }
.scn-chat-role { font-weight: 600; margin-right: .3em; }
.scn-chat-user .scn-chat-role { color: var(--swop-orange); }
.scn-chat-assistant .scn-chat-role { color: #1a6e1a; }
.scn-chat-empty { font-style: italic; margin: .2em 0; }
.scn-chat-input { display: flex; gap: .5em; align-items: stretch; }
.scn-chat-input textarea {
  flex: 1; padding: .4em .55em; border: 1px solid var(--border);
  border-radius: 3px; font: inherit; resize: vertical;
  background: #fff; color: #222;
}
.scn-chat-input button { white-space: nowrap; }
.scn-chat-status { font-size: .85em; margin-top: .3em; min-height: 1.3em; }
.scn-spinner {
  display: inline-block; width: 1em; height: 1em;
  border: 2px solid var(--swop-orange-light);
  border-top-color: var(--swop-orange);
  border-radius: 50%;
  animation: scn-spin 1s linear infinite;
  vertical-align: -.15em;
}
@keyframes scn-spin { to { transform: rotate(360deg); } }
.scn-chat-msg._loading { color: #888; font-style: italic; }
.btn-mini { padding: .15em .45em !important; font-size: .85em; line-height: 1; }
.pos { color: #1a6e1a; }
.neg { color: #c33; }
tr.ev-past td { opacity: .55; }
tr.ev-past td:first-child small { opacity: 1; color: #888; font-style: italic; }

.scenario-section { margin: 1em 0 1.5em; }
.scenario-section h2 {
  color: var(--swop-orange); border-bottom: 2px solid var(--swop-orange);
  padding-bottom: .2em; margin: 0 0 .5em; font-size: 1.05em;
}
.scenario-section form input,
.scenario-section form select { margin-right: .4em; padding: .3em .5em; border: 1px solid var(--border); border-radius: 3px; }
.event-form { display: flex; flex-wrap: wrap; gap: .4em; align-items: center; margin: .5em 0; }
.event-form input, .event-form select {
  padding: .3em .5em; border: 1px solid var(--border); border-radius: 3px;
}
.event-form .field-inline { display: inline-flex; align-items: center; gap: .3em; color: #666; font-size: .9em; }
.event-form .field-inline input { margin: 0; }

/* Doc-Pfad-Links im Chat: erkannt aus Agent-Text, Klick oeffnet PDF-Modal */
a.doc-link {
  display: inline-block;
  background: #fff5e6; color: var(--swop-orange);
  padding: .05em .45em; margin: 0 .15em;
  border: 1px solid #ffd9a0; border-radius: 3px;
  font-size: .9em; text-decoration: none; cursor: pointer;
}
a.doc-link:hover { background: var(--swop-orange); color: #fff; border-color: var(--swop-orange); }
.msg .bubble { word-wrap: break-word; }
.msg.user .bubble { white-space: pre-wrap; }
.msg pre { font-size: .8em; max-height: 250px; }
.msg .md-table {
  border-collapse: collapse; margin: .5em 0; font-size: .9em;
  background: #fafafa;
}
.msg .md-table th, .msg .md-table td {
  border: 1px solid #d8d8d8; padding: .35em .6em; text-align: left;
}
.msg .md-table th { background: var(--swop-orange-light); color: var(--swop-orange-dark); font-weight: 600; }
.msg .md-table tr:nth-child(even) td { background: #fff; }
.msg .bubble code { background: rgba(0,0,0,.06); padding: 0 .25em; border-radius: 2px; font-size: .9em; }
.msg .bubble h1, .msg .bubble h2, .msg .bubble h3 { color: var(--swop-orange); margin: .8em 0 .3em; }
.msg .bubble h3 { font-size: 1em; }
.msg .bubble ul, .msg .bubble ol { padding-left: 1.4em; margin: .4em 0; }
.msg .bubble p { margin: .35em 0; }
.msg .bubble hr { border: 0; border-top: 1px solid #ddd; margin: .6em 0; }

.chat-input-bar {
  display: flex; gap: .5em; align-items: flex-end;
}
.chat-input-bar textarea {
  flex: 1; min-height: 60px; max-height: 200px; resize: vertical;
}
.chat-input-bar button { white-space: nowrap; }

.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--swop-orange-light);
  border-top-color: var(--swop-orange);
  border-radius: 50%; animation: spin 1s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-bg {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff; border-radius: 8px; padding: 1.2em 1.5em;
  width: 90%; max-width: 720px; max-height: 90vh; overflow: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.modal h2 { margin-top: 0; color: var(--swop-orange); }
.modal label { display: block; font-size: .85em; color: #555; margin: .8em 0 .2em; font-weight: 500; }
.modal textarea { min-height: 180px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .9em; }
.modal-actions { display: flex; gap: .5em; justify-content: flex-end; margin-top: 1em; }
.modal-loading { text-align: center; padding: 2em; color: #888; }

@media (max-width: 700px) {
  body { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .sidebar { display: none; }
}
