:root {
  /* Swiss Style Palette */
  --bg-app: #F5F5F7;       
  --bg-card: #FFFFFF;
  
  --text-primary: #111111;
  --text-secondary: #444444; 
  --text-light: #777777;
  
  --line-color: #DDDDDD;   
  --brand-red: #E30613;    
  
  --font-main: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-main);
  padding: 40px;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.swiss-layout {
  max-width: 1400px;
  margin: 0 auto;
  display: flex; flex-direction: column; gap: 32px;
}

/* HEADER */
.header {
  display: flex; justify-content: space-between; align-items: flex-end;
  padding-bottom: 20px; border-bottom: 2px solid var(--text-primary);
}
.header-main { display: flex; gap: 16px; align-items: center; }
.brand-dot { width: 14px; height: 14px; background: var(--brand-red); } 
.title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0; line-height: 1.1; }
.subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.header-meta { display: flex; gap: 32px; align-items: center; }
.meta-item { display: flex; flex-direction: column; text-align: right; }
.meta-item .label { font-size: 10px; text-transform: uppercase; font-weight: 600; color: var(--text-light); margin-bottom: 2px; }
.meta-item .value { font-size: 13px; font-weight: 500; color: var(--text-primary); }

.btn-ghost {
  background: white; border: 1px solid var(--text-secondary);
  padding: 8px 16px; border-radius: 4px;
  font-family: var(--font-main); font-size: 12px; font-weight: 600;
  color: var(--text-primary); cursor: pointer;
  display: flex; align-items: center; gap: 8px; transition: all 0.1s;
}
.btn-ghost:hover { background: var(--text-primary); color: white; border-color: var(--text-primary); }
.btn-ghost:active { transform: translateY(1px); }

/* CARDS */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line-color);
  border-radius: 4px;
  padding: 24px;
  display: flex; flex-direction: column;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}
.card-active { border: 1px solid var(--brand-red); background: #FFFBFB; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.border-none { margin-bottom: 0; }
.card-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); }
.label-red { color: var(--brand-red); }

/* KPIS */
.grid-kpi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-kpi .card { height: 160px; justify-content: space-between; }
.kpi-value { font-family: var(--font-mono); font-size: 34px; font-weight: 500; letter-spacing: -0.04em; color: var(--text-primary); }
.kpi-text { font-family: var(--font-main); font-size: 20px; font-weight: 600; line-height: 1.3; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.text-red { color: var(--brand-red); }
.card-foot { font-size: 12px; color: var(--text-secondary); border-top: 1px solid var(--line-color); padding-top: 12px; margin-top: auto; }

/* CHARTS GRID */
.grid-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-charts .card { height: 380px; padding: 24px; }

.chart-wrapper { 
  flex-grow: 1; position: relative; width: 100%; min-height: 0; 
  margin-top: 16px;
}

.legend-inline { display: flex; gap: 16px; }
.leg-item { font-size: 11px; display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-weight: 500; }
.dot { width: 10px; height: 10px; border-radius: 2px; }
.dot.grey { background: #999; }
.dot.red { background: var(--brand-red); }

/* BOXPLOT LAYOUT */
.boxplot-container {
  flex-grow: 1; width: 100%; position: relative; min-height: 0;
  display: flex; align-items: center;
}
#boxplotCanvas { width: 100%; height: 100%; }

/* LEGENDE MIT FARB-MARKERN */
.stats-footer {
  display: flex; justify-content: space-between;
  border-top: 1px solid var(--line-color);
  padding-top: 16px; margin-top: 10px;
}
.stat-item { display: flex; flex-direction: column; }
.stat-item.center { align-items: center; }
.stat-item.right { align-items: flex-end; }

.legend-row { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.mark { width: 4px; height: 12px; display: inline-block; }
.mark-red { background: var(--brand-red); }
.mark-grey { background: var(--text-secondary); }

.stat-item .label { font-size: 10px; text-transform: uppercase; color: var(--text-light); font-weight: 600; }
.stat-item .val { font-size: 14px; font-weight: 500; color: var(--text-primary); }

/* TABLE */
.table-card { padding: 0; overflow: hidden; }
.table-card .card-head { padding: 20px 24px 0 24px; margin-bottom: 16px; align-items: flex-end; }
.head-right { display: flex; align-items: center; gap: 10px; }
.label-sub { font-size: 11px; color: var(--text-secondary); font-family: var(--font-mono); }
.label-tiny { font-size: 10px; color: var(--text-light); text-transform: uppercase; font-weight: 600; }

.select-ghost {
  border: 1px solid var(--line-color); background: #fff;
  padding: 4px 8px; border-radius: 4px; font-family: var(--font-main);
  font-size: 11px; color: var(--text-primary); outline: none; cursor: pointer;
}
.select-ghost:hover { border-color: var(--text-primary); }

.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th { text-align: left; font-size: 10px; font-weight: 700; color: var(--text-secondary); padding: 12px 24px; border-bottom: 1px solid var(--line-color); background: #f8f8f8; text-transform: uppercase; }
td { padding: 14px 24px; border-bottom: 1px solid var(--line-color); font-size: 13px; color: var(--text-primary); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* GROUP HEADERS */
.group-row td { background: #EFEFEF; font-weight: 600; font-size: 11px; text-transform: uppercase; padding: 10px 24px; border-bottom: 1px solid #ccc; color: #000; }
.group-total { float: right; font-family: var(--font-mono); }

/* Columns */
.col-status { width: 10%; min-width: 100px; }
.col-date { width: 10%; min-width: 100px; }
.col-nr { width: 15%; min-width: 140px; }
.col-supp { width: 25%; min-width: 200px; }
.col-amt { width: 15%; min-width: 120px; }
.col-due { width: 15%; min-width: 130px; }
.col-action { width: 50px; text-align: center; }

/* Utils */
.mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.msg { text-align: center; padding: 40px; color: var(--text-light); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.b-paid { color: #666; background: #e0e0e0; }
.b-open { color: #fff; background: var(--brand-red); }

/* MODAL */
.modal-backdrop { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 999; backdrop-filter: blur(2px); justify-content: center; align-items: center; }
.modal-sheet { background: white; width: 500px; max-width: 90%; max-height: 90vh; box-shadow: 0 20px 50px rgba(0,0,0,0.2); display: flex; flex-direction: column; }
.sheet-header { padding: 20px; border-bottom: 1px solid #eee; display:flex; justify-content:space-between; align-items:center;}
.sheet-title { font-size: 14px; font-weight: 700; text-transform:uppercase; margin:0; }
.btn-close { border:none; background:none; font-size:18px; cursor:pointer; color:#999; }
.btn-close:hover { color: var(--brand-red); }
.sheet-body { padding: 24px; overflow-y:auto; }

.inv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.inv-col h4 { font-size: 10px; color:#888; text-transform:uppercase; margin-bottom: 6px; }
.inv-val { font-size: 14px; font-weight:500; }
.line-table { width: 100%; margin-top: 10px; border-collapse: collapse;}
.line-table th { background: #fff; border-bottom: 2px solid #000; padding: 8px 0; color:#000; font-size: 11px; text-align: left; }
.line-table td { padding: 10px 0; border-bottom: 1px solid #eee; font-size: 13px; }

.btn-icon { background: white; border: 1px solid #ddd; width: 28px; height: 28px; border-radius: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #666; transition: all 0.1s; }
.btn-icon:hover { border-color: #000; color: #000; }

@media (max-width: 1100px) {
  .grid-kpi, .grid-charts { grid-template-columns: 1fr; height: auto; }
  .grid-kpi .card { height: 160px; }
  .grid-charts .card { height: 350px; }
}
