/* projectcost.css (v8+ / erweitert um optionale Unterpositionen + Plus-Button + colgroup-Layout für Ausgaben) */
:root{
  --bg:#141a26;
  --bg2:#202d42;
  --panel:#202d42;
  --panel2:#3b4556;
  --accent:#f2cc83;
  --accent2:#f7d89a;
  --text:#f9fafb;
  --muted:#9ca3af;
  --border:rgba(148,163,184,.5);
  --danger:#e34242;
  --ok:#22c55e;
  --warn:#f59e0b;
  --shadow:0 18px 45px rgba(0,0,0,.22);
  --r-xl:1.4rem;
  --r:1rem;
  --r-pill:999px;
  --t:150ms ease-out;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

body.theme-light{
  --bg:#f7ecd4;
  --bg2:#faefdc;
  --panel:#fff7e7;
  --panel2:#f2cc83;
  --accent:#296117;
  --accent2:#3b7f22;
  --text:#111827;
  --muted:#4b5563;
  --border:rgba(148,119,81,.6);
  --danger:#b91c1c;
  --ok:#296117;
  --warn:#b45309;
  --shadow:0 18px 45px rgba(0,0,0,.14);
}

*{box-sizing:border-box; min-width:0;}
html,body{margin:0; padding:0; min-height:100vh; font-family:system-ui,-apple-system,"Segoe UI",sans-serif; background:var(--bg); color:var(--text);}
a{color:inherit;}
button,input,select,textarea{font:inherit;}
.hidden{display:none!important;}

.wrap{max-width:1340px; margin:0 auto; padding:18px 18px 32px;}
.shell{
  background:var(--bg2);
  border:1px solid var(--border);
  border-radius:1.8rem;
  box-shadow:var(--shadow);
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:14px;
}

.topbar{display:flex; gap:10px; align-items:flex-start; justify-content:space-between; flex-wrap:wrap;}
.brand{
  display:flex; gap:10px; align-items:center; text-decoration:none;
  border:1px solid var(--border);
  background:rgba(0,0,0,.08);
  border-radius:var(--r-pill);
  padding:6px 10px;
  transition:transform var(--t), background var(--t), box-shadow var(--t);
}
body.theme-light .brand{background:rgba(0,0,0,.03);}
.brand:hover{transform:translateY(-1px); background:var(--panel2); box-shadow:0 10px 22px rgba(0,0,0,.18);}
.brand img{width:22px; height:22px; border-radius:6px; border:1px solid var(--border); display:block;}
.brand .bt{display:flex; flex-direction:column; line-height:1.1;}
.brand .bt strong{font-size:.85rem; font-weight:900; white-space:nowrap;}
.brand .bt span{font-size:.72rem; color:var(--muted); white-space:nowrap;}

.actions{display:flex; gap:8px; flex-wrap:wrap; align-items:center; justify-content:flex-end;}

.btn{
  border:none; cursor:pointer;
  padding:10px 14px;
  border-radius:1rem;
  background:var(--accent);
  color:#111827;
  font-weight:900;
  letter-spacing:.02em;
  transition:transform var(--t), box-shadow var(--t), background var(--t), filter var(--t);
  box-shadow:0 12px 26px rgba(0,0,0,.28);
  display:inline-flex; gap:8px; align-items:center;
  text-decoration:none; user-select:none;
}
body.theme-light .btn{color:#fff; background:var(--accent); box-shadow:0 12px 26px rgba(0,0,0,.18);}
.btn:hover{transform:translateY(-1px); filter:saturate(1.05); background:var(--accent2); box-shadow:0 16px 34px rgba(0,0,0,.34);}
body.theme-light .btn:hover{box-shadow:0 16px 34px rgba(0,0,0,.22);}
.btn:active{transform:translateY(0); box-shadow:0 10px 22px rgba(0,0,0,.28);}
body.theme-light .btn:active{box-shadow:0 10px 22px rgba(0,0,0,.18);}
.btn.ghost{background:transparent; color:var(--text); border:1px solid var(--border); box-shadow:none;}
.btn.ghost:hover{background:var(--panel2); box-shadow:0 10px 22px rgba(0,0,0,.18);}
.btn.small{padding:8px 12px; border-radius:.9rem; font-size:.85rem;}
.btn.danger{background:var(--danger); color:#fff;}
body.theme-light .btn.danger{background:var(--danger); color:#fff;}
body.theme-light .btn.danger:hover{background:var(--danger);}

.section{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--r-xl);
  padding:14px;
  box-shadow:0 12px 30px rgba(0,0,0,.18);
}
.sectionHead{
  display:flex; gap:10px; align-items:flex-start; justify-content:space-between; flex-wrap:wrap;
  margin-bottom:10px;
}
.h2{margin:0; font-size:.95rem; text-transform:uppercase; letter-spacing:.08em; color:var(--muted);}

.projGrid{display:grid; grid-template-columns: 1.2fr .8fr; gap:12px;}
.projTitle{display:flex; flex-direction:column; gap:10px;}
.projTitle h1{margin:0; font-size:1.4rem; font-weight:950; letter-spacing:.02em; word-break:break-word;}
.projTitle h1 .em{color:var(--accent);}
.projAddr{color:var(--muted); font-size:.9rem; line-height:1.35;}

.projMetaBox{
  border:1px dashed var(--border);
  border-radius:1rem;
  padding:10px;
  background:rgba(0,0,0,.06);
}
body.theme-light .projMetaBox{background:rgba(0,0,0,.03);}
.note{margin:0; color:var(--muted); font-size:.78rem; line-height:1.35;}

.badges{display:flex; gap:8px; flex-wrap:wrap;}
.badge{
  display:inline-flex; align-items:center; gap:6px;
  padding:3px 10px;
  border-radius:var(--r-pill);
  background:var(--panel2);
  border:1px solid var(--accent);
  font-size:11px;
  letter-spacing:.04em;
  text-transform:uppercase;
  white-space:nowrap;
}
.dot{width:7px; height:7px; border-radius:999px; background:var(--accent);}

.projLeads{
  border:1px solid var(--border);
  border-radius:1rem;
  background:rgba(0,0,0,.06);
  padding:10px;
}
body.theme-light .projLeads{background:rgba(0,0,0,.03);}
.leadHead{
  display:flex; gap:10px; justify-content:space-between; align-items:baseline; flex-wrap:wrap;
  margin-bottom:8px;
}
.leadHint{color:var(--muted); font-size:.78rem;}
.leadList{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:10px;
}
.leadCard{
  border:1px solid var(--border);
  border-radius:1rem;
  padding:10px;
  background:var(--panel);
  box-shadow:0 10px 22px rgba(0,0,0,.12);
  display:flex;
  flex-direction:column;
  gap:6px;
}
.leadRow{display:flex; gap:10px; justify-content:space-between; align-items:baseline; flex-wrap:wrap;}
.leadName{font-weight:950;}
.leadFunc{color:var(--muted); font-size:.85rem;}
.leadTags{color:var(--muted); font-size:.82rem; line-height:1.35;}
.leadMail a{color:inherit; text-decoration:none; border-bottom:1px dashed var(--border);}
.leadMail a:hover{border-bottom-color:var(--accent);}

.sticky{
  position:sticky;
  top:10px;
  z-index:20;
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--bg2) 88%, transparent);
  border-radius:1.2rem;
  border:1px solid color-mix(in srgb, var(--border) 65%, transparent);
  padding:10px;
}

.kpiGrid{
  display:grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap:10px;
}
.kpi{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:1.1rem;
  padding:10px;
  box-shadow:0 10px 22px rgba(0,0,0,.14);
  display:flex;
  flex-direction:column;
  gap:6px;
}
.kpi .k{color:var(--muted); font-size:.72rem; text-transform:uppercase; letter-spacing:.08em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.kpi .v{font-variant-numeric:tabular-nums; font-weight:950; font-size:1.05rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.v.ok{color:var(--ok);}
.v.bad{color:var(--danger);}
.v.warn{color:var(--warn);}

.blockGrid{display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:10px;}
.block{
  border:1px solid var(--border);
  border-radius:1.2rem;
  padding:12px;
  background:rgba(0,0,0,.06);
}
body.theme-light .block{background:rgba(0,0,0,.03);}
.blockTitle{display:flex; justify-content:space-between; align-items:baseline; gap:10px; flex-wrap:wrap; margin-bottom:8px;}
.blockTitle strong{font-weight:950; letter-spacing:.02em;}
.blockLine{display:flex; gap:12px; flex-wrap:wrap; color:var(--muted); font-size:.88rem; line-height:1.35;}
.blockLine b{color:var(--text);}
.blockActions{margin-top:10px; display:flex; gap:8px; flex-wrap:wrap;}

.toolbar{display:flex; gap:10px; flex-wrap:wrap; align-items:flex-end; justify-content:space-between;}
.toolbar .group{display:flex; gap:10px; flex-wrap:wrap; align-items:flex-end;}
label{display:flex; flex-direction:column; gap:4px; font-size:.82rem;}
.labRow{display:flex; justify-content:space-between; gap:10px;}
.labRow strong{white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.hint{color:var(--muted); font-size:.72rem; white-space:nowrap;}

input[type=text], input[type=search], input[type=date], input[type=email], textarea, select{
  width:100%;
  padding:8px 10px;
  border-radius:.75rem;
  border:1px solid var(--border);
  background:var(--panel2);
  color:var(--text);
  font-size:.85rem;
  outline:none;
  transition:border-color var(--t), box-shadow var(--t), transform var(--t);
}
textarea{resize:vertical; min-height:84px;}
input:focus, select:focus, textarea:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 1px var(--accent2), 0 0 0 5px rgba(0,0,0,.25);
  transform:translateY(-1px);
}

.chipRow{display:flex; gap:6px; flex-wrap:wrap;}
.chip{
  display:inline-flex;
  gap:8px;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:transparent;
  color:var(--text);
  cursor:pointer;
  user-select:none;
  font-size:.82rem;
  font-weight:900;
  transition:background var(--t), transform var(--t);
}
.chip:hover{background:var(--panel2); transform:translateY(-1px);}
.chip.on{background:var(--accent2); color:#111827; border-color:var(--accent);}
body.theme-light .chip.on{color:#fff;}

.ledger{display:flex; flex-direction:column; gap:12px;}
.sep{height:1px; background:var(--border); margin:4px 0;}

.details{
  border:1px solid var(--border);
  border-radius:1.2rem;
  background:rgba(0,0,0,.06);
  overflow:hidden;
}
body.theme-light .details{background:rgba(0,0,0,.03);}
.details summary{
  list-style:none;
  cursor:pointer;
  user-select:none;
  padding:12px 12px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  font-weight:950;
}
.details summary::-webkit-details-marker{display:none;}
.sumRight{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:flex-end;
  color:var(--muted);
  font-weight:700;
  font-size:.86rem;
}
.sumRight b{color:var(--text); font-variant-numeric:tabular-nums;}
.sumRight .mono{font-family:var(--mono);}
.details .inside{padding:0 12px 12px;}

.tableWrap{
  overflow-x:auto;
  border:1px solid var(--border);
  border-radius:1rem;
  background:var(--panel);
}
table{width:100%; border-collapse:collapse; min-width:1040px;}
th, td{padding:10px; border-bottom:1px solid var(--border); font-size:.84rem; vertical-align:middle;}
th{
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.08em;
  font-size:.72rem;
  text-align:left;
  background:rgba(0,0,0,.06);
}
body.theme-light th{background:rgba(0,0,0,.03);}
td.num, th.num{text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap;}
td.dim{color:var(--muted);}
.rowActions{display:inline-flex; gap:8px; justify-content:flex-end; flex-wrap:wrap;}

.mini{
  padding:7px 10px;
  border-radius:.85rem;
  border:1px solid var(--border);
  background:transparent;
  color:var(--text);
  cursor:pointer;
  transition:background var(--t), transform var(--t);
  font-weight:900;
  font-size:.78rem;
  white-space:nowrap;
}
.mini:hover{background:var(--panel2); transform:translateY(-1px);}
.mini.danger{border-color:rgba(227,66,66,.7); color:var(--danger);}
.mini.danger:hover{background:rgba(227,66,66,.12);}

.catRow{background:rgba(0,0,0,.06);}
body.theme-light .catRow{background:rgba(0,0,0,.03);}
.catName{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
.toggleBtn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:34px;
  height:30px;
  border-radius:.85rem;
  border:1px solid var(--border);
  background:transparent;
  color:var(--text);
  cursor:pointer;
  transition:background var(--t), transform var(--t);
  font-weight:950;
}
.toggleBtn:hover{background:var(--panel2); transform:translateY(-1px);}
.toggleBtn[aria-expanded="true"]{background:rgba(0,0,0,.14);}
body.theme-light .toggleBtn[aria-expanded="true"]{background:rgba(0,0,0,.05);}

.subWrap{
  margin-top:10px;
  border:1px solid var(--border);
  border-radius:1rem;
  overflow:hidden;
  background:rgba(0,0,0,.06);
}
body.theme-light .subWrap{background:rgba(0,0,0,.03);}
.subHead{
  padding:10px 12px;
  display:flex;
  gap:10px;
  justify-content:space-between;
  align-items:center;
  flex-wrap:wrap;
  border-bottom:1px solid var(--border);
}
.subHead strong{font-weight:950;}
.subHead .dim{color:var(--muted); font-size:.82rem;}

.pillStatus{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:3px 10px;
  border-radius:var(--r-pill);
  border:1px solid var(--border);
  background:rgba(0,0,0,.08);
  color:var(--muted);
  font-size:.72rem;
  letter-spacing:.08em;
  text-transform:uppercase;
}
body.theme-light .pillStatus{background:rgba(0,0,0,.03);}
.pillStatus.ok{border-color:rgba(34,197,94,.55); color:var(--ok);}
.pillStatus.bad{border-color:rgba(227,66,66,.55); color:var(--danger);}
.pillStatus.warn{border-color:rgba(245,158,11,.55); color:var(--warn);}

.foot{text-align:right; font-size:.75rem; color:var(--muted);}

/* Positionen / Unterpositionen */
.posGroup{
  border-top:1px solid var(--border);
}
.posGroup:first-child{
  border-top:none;
}
.posHead{
  padding:10px 12px;
  display:flex;
  gap:10px;
  justify-content:space-between;
  align-items:center;
  flex-wrap:wrap;
  background:rgba(0,0,0,.05);
}
body.theme-light .posHead{background:rgba(0,0,0,.025);}
.posHead strong{font-weight:950;}

.posHeadMain{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
.posMeta{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  color:var(--muted);
  font-size:.82rem;
}
.posBody{
  padding:0;
}
.posSoloHint{
  color:var(--muted);
  font-size:.78rem;
}
.subPosBadge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:2px 8px;
  border-radius:999px;
  border:1px solid var(--border);
  font-size:.72rem;
  color:var(--muted);
  background:rgba(0,0,0,.05);
}
body.theme-light .subPosBadge{background:rgba(0,0,0,.025);}

/* Plus-Button */
.inlinePlusBtn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:30px;
  height:30px;
  border-radius:999px;
  border:1px solid var(--border);
  background:transparent;
  color:var(--text);
  cursor:pointer;
  font-weight:950;
  font-size:1rem;
  line-height:1;
  transition:background var(--t), transform var(--t), border-color var(--t);
}
.inlinePlusBtn:hover{
  background:var(--panel2);
  transform:translateY(-1px);
  border-color:var(--accent);
}

/* NEU: fixes Spaltenlayout nur für die Ausgaben-Tabelle */
.expenseTable{
  table-layout:fixed;
  width:100%;
  min-width:1140px;
}
.expenseTable th,
.expenseTable td{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.expenseTable td:nth-child(3),
.expenseTable th:nth-child(3){
  white-space:normal;
  word-break:break-word;
}

dialog{
  border:1px solid var(--border);
  border-radius:1.4rem;
  background:var(--bg2);
  color:var(--text);
  box-shadow:0 18px 45px rgba(0,0,0,.35);
  width:min(980px, 96vw);
  padding:0;
  overflow:hidden;
  max-height:92vh;
}
dialog::backdrop{background:rgba(0,0,0,.55);}

.dlgHead{
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  background:rgba(0,0,0,.08);
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
}
body.theme-light .dlgHead{background:rgba(0,0,0,.03);}
.dlgHead h3{
  margin:0;
  font-size:.95rem;
  text-transform:uppercase;
  letter-spacing:.08em;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.dlgBody{
  padding:14px;
  overflow:auto;
  max-height:calc(92vh - 120px);
}
.dlgFoot{
  padding:12px 14px;
  border-top:1px solid var(--border);
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:flex-end;
}
.grid{display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:10px 12px;}
.grid.one{grid-template-columns:1fr;}

.leadEditorHead{
  grid-column:1 / -1;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  padding-top:4px;
}
.leadEditorHead strong{font-weight:950;}
.leadEditorHint{color:var(--muted); font-size:.78rem;}
.leadEditorWrap{
  grid-column:1 / -1;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.leadEditorCard{
  border:1px solid var(--border);
  border-radius:1rem;
  padding:10px;
  background:rgba(0,0,0,.06);
}
body.theme-light .leadEditorCard{background:rgba(0,0,0,.03);}
.leadEditorTop{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom:8px;
}
.leadEditorTop strong{font-weight:950;}
.leadEditorGrid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:10px 12px;
}

@media (max-width: 980px){
  .wrap{padding:12px;}
  .shell{padding:14px; border-radius:1.4rem;}
  .projGrid{grid-template-columns:1fr;}
  .kpiGrid{grid-template-columns:1fr;}
  .blockGrid{grid-template-columns:1fr;}
  table{min-width:980px;}
  .expenseTable{min-width:1140px;}
  .leadList{grid-template-columns:1fr;}
  .sticky{
    position:static;
    top:auto;
    z-index:auto;
    backdrop-filter:none;
    background:var(--panel);
    border:1px solid var(--border);
    padding:14px;
  }
}
@media (max-width: 520px){
  .actions{justify-content:flex-start;}
  .btn{width:100%; justify-content:center;}
  .btn.ghost{width:auto;}
  .leadEditorGrid{grid-template-columns:1fr;}
}