/* ========== Theme ==========
   Benny's Werkstatt – Dark UI + Dark Scrollbars
*/
:root{
  --bg:#0f1115;
  --panel:#171a21;
  --muted:#262b36;
  --text:#e8ecf1;
  --sub:#a5adba;

  --brand:#5a93a6;
  --brand-2:#8ebfd0;
  --danger:#ff5d5d;
  --ok:#4ccd8c;

  --shadow:0 10px 30px rgba(0,0,0,.35);
  --radius:16px;
  --radius-sm:10px;

  /* Scrollbar-Farben */
  --scroll-track:#101319;
  --scroll-thumb:#2b3140;
  --scroll-thumb-hover:#3a4255;
}

*{box-sizing:border-box}
html,body{height:100%}
[hidden]{display:none!important}

body{
  margin:0;
  background:
    radial-gradient(1100px 900px at 80% -150px, rgba(90,147,166,.14), transparent),
    radial-gradient(900px 700px at -200px 90%, rgba(90,147,166,.10), transparent),
    var(--bg);
  color:var(--text);
  font:16px/1.5 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,Helvetica,Arial;
}

/* ===== Header ===== */
.app-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:20px clamp(16px,4vw,40px);position:sticky;top:0;z-index:10;
  backdrop-filter:saturate(130%) blur(8px);
  background:linear-gradient(180deg, rgba(15,17,21,.9), rgba(15,17,21,.65));
  border-bottom:1px solid rgba(255,255,255,.06)
}
.brand{display:flex;gap:12px;align-items:center}
.logo{
  width:36px;height:36px;border-radius:12px;
  background:linear-gradient(135deg,var(--brand),var(--brand-2));
  box-shadow:var(--shadow);display:grid;place-items:center;
  font-weight:800;color:#0f141a
}
.brand h1{font-size:18px;margin:0}
.subtle{color:var(--sub);font-size:13px}

/* ===== Inputs & Buttons ===== */
.select, input[type="text"], input[type="tel"], input[type="number"], input[type="date"], input[type="password"], select, textarea{
  background:var(--panel);color:var(--text);
  border:1px solid var(--muted);padding:10px 12px;border-radius:var(--radius-sm);
  outline:none;min-height:40px
}
input::placeholder, textarea::placeholder{color:#92a0b7}
button{
  background:var(--brand);color:#0f141a;border:none;padding:10px 14px;border-radius:var(--radius-sm);
  font-weight:700;cursor:pointer;box-shadow:var(--shadow);transition:transform .05s,filter .15s,background .15s
}
button:hover{filter:brightness(1.08)}
button:active{transform:translateY(1px)}
button.ghost{background:transparent;color:var(--text);border:1px dashed var(--muted);box-shadow:none}
button.danger{background:var(--danger);color:#fff}
button.ok{background:var(--ok);color:#0b1116}
button:disabled{opacity:.55;pointer-events:none}
.checkline{display:inline-flex;align-items:center;gap:10px}

/* ===== Layout ===== */
.container{padding:clamp(16px,4vw,40px);max-width:1200px;margin:0 auto}
.tabs{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:18px}
.tab{
  padding:10px 14px;border-radius:999px;background:var(--panel);color:var(--sub);
  border:1px solid var(--muted);cursor:pointer
}
.tab.active{
  background:linear-gradient(135deg, rgba(90,147,166,.25), rgba(90,147,166,.05));
  color:var(--text);border-color:rgba(90,147,166,.45)
}

.grid{display:grid;grid-template-columns:1.2fr 1fr;gap:18px;align-items:start;}
@media (max-width:980px){.grid{grid-template-columns:1fr}}

.card{
  background:linear-gradient(180deg, rgba(255,255,255,.02), transparent), var(--panel);
  border:1px solid var(--muted);border-radius:var(--radius);box-shadow:var(--shadow);
  padding:18px;display:flex;flex-direction:column;gap:14px
}
.card h2{margin:0;font-size:18px}
.row{display:flex;gap:10px;flex-wrap:wrap}
.row>*{flex:1}
.toolbar{display:flex;gap:10px;align-items:center;justify-content:space-between;flex-wrap:wrap}
.hint{color:var(--sub);font-size:13px}

.inline-error{
  font-size:13px;color:#ffd1d1;background:#3a1f23;border:1px solid #5a2b31;
  padding:8px 10px;border-radius:8px
}

/* ===== Tabellen ===== */
.table-wrap{overflow:auto}
table{width:100%;border-collapse:collapse;border-radius:12px;overflow:hidden}
thead th{
  text-align:left;font-size:12px;color:var(--sub);font-weight:600;
  padding:8px 10px;background:rgba(255,255,255,.03);border-bottom:1px solid var(--muted)
}
tbody td{padding:10px;border-bottom:1px solid rgba(255,255,255,.06)}
tbody tr:hover{background:rgba(255,255,255,.02)}

.tag{
  font-size:12px;padding:4px 10px;border-radius:999px;
  background:rgba(90,147,166,.18);border:1px solid rgba(90,147,166,.4);color:var(--brand-2);
  white-space:nowrap;display:inline-flex;align-items:center
}

/* ===== Kundenliste: eigener Scrollbereich ===== */
#customersList .table-wrap{
  max-height:480px;overflow:auto;
  scrollbar-gutter:stable both-edges;
}

/* ===== Divider im Modal ===== */
.divider{border-color:rgba(255,255,255,.08)}

/* ===== Modal ===== */
.modal-backdrop{
  position:fixed; inset:0; display:none; align-items:center; justify-content:center;
  background:rgba(0,0,0,.55); backdrop-filter:blur(2px); z-index:1000; padding:20px;
}
.modal-backdrop.show{display:flex}
.modal{
  width:min(900px,96vw); max-height:min(80vh,900px); overflow:auto;
  background:var(--panel); border:1px solid var(--muted); border-radius:var(--radius);
  box-shadow:var(--shadow); padding:18px; display:flex; flex-direction:column; gap:14px
}
body.modal-open{overflow:hidden}

/* ========== Dark Scrollbars (global) ========== */
/* Firefox */
*{scrollbar-width:thin; scrollbar-color:var(--scroll-thumb) var(--scroll-track)}
/* WebKit (Chrome/Edge/Safari) */
*::-webkit-scrollbar{width:10px;height:10px}
*::-webkit-scrollbar-track{background:var(--scroll-track)}
*::-webkit-scrollbar-thumb{
  background-color:var(--scroll-thumb);
  border-radius:10px;border:2px solid var(--scroll-track);
}
*::-webkit-scrollbar-thumb:hover{background-color:var(--scroll-thumb-hover)}

/* Optional: noch etwas dunkler speziell in großen Listen */
#customersList .table-wrap::-webkit-scrollbar-thumb{background-color:#2a3140}
#customersList .table-wrap::-webkit-scrollbar-track{background:#0f131a}

/* ===== Info-Reader Sheet (Bottom-Sheet) ===== */
.sheet-backdrop{
  position:fixed; inset:0; display:none;
  align-items:flex-end; justify-content:center;
  background:rgba(0,0,0,.55); backdrop-filter:blur(2px);
  z-index:1000; padding:20px;
}
.sheet-backdrop.show{ display:flex; }

.sheet{
  width:min(900px,96vw);
  max-height:min(80vh,920px);
  background:var(--panel);
  border:1px solid var(--muted);
  border-radius:24px 24px 16px 16px;
  box-shadow:var(--shadow);
  overflow:auto;
  padding:18px;
  display:flex; flex-direction:column; gap:10px;
  transform:translateY(10px); opacity:0;
  transition:transform .15s ease, opacity .15s ease;
}
.sheet-backdrop.show .sheet{ transform:translateY(0); opacity:1; }

.sheet-header{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.sheet-title{ margin:0; font-size:20px; }
.iv-meta{ margin-top:-2px; }
.iv-body{
  margin-top:6px;
  padding:12px; border:1px solid rgba(255,255,255,.06);
  border-radius:12px; background:rgba(255,255,255,.02);
  line-height:1.6; white-space:pre-wrap; word-wrap:break-word;
}
.sheet-footer{ display:flex; align-items:center; gap:10px; }
.sheet-footer .spacer{ flex:1; }

/* mobile: oben statt unten fixieren? → hier reicht unten */
@media (max-width:640px){
  .sheet{ width:100%; border-radius:16px 16px 0 0; }
}

/* Infos-Liste: Titel + PREVIEW kompakt */
.info-title{ font-weight:700; margin:0 0 2px 0; }
.info-preview{
  color:var(--sub);
  font-size:13px;
  white-space:nowrap;        /* nur 1 Zeile */
  overflow:hidden;           /* alles was nicht passt, ausblenden */
  text-overflow:ellipsis;    /* … am Ende */
}

/* Zeilen etwas kompakter & inhalt oben beginnen */
#tab-infos tbody td{ vertical-align: top; }

/* === Action-Spalte: Buttons untereinander === */
/* In allen 4 Tabs ist die Aktionsspalte die letzte Spalte */
#tab-kunden tbody td:last-child,
#tab-rechnungen tbody td:last-child,
#tab-mitarbeiter tbody td:last-child,
#tab-infos tbody td:last-child{
  display:flex;
  flex-direction:column;   /* untereinander */
  gap:8px;
  align-items:flex-start;  /* nicht volle Breite */
}

/* Einheitliche Mindestbreite (optional) */
#tab-kunden tbody td:last-child button,
#tab-rechnungen tbody td:last-child button,
#tab-mitarbeiter tbody td:last-child button,
#tab-infos tbody td:last-child button{
  min-width:120px;
}

/* === "Bearbeiten" grün machen === */
/* Egal, ob der Button bisher .ghost hatte – wir überschreiben es gezielt */
button[data-act="edit"]{
  background:var(--ok);
  color:#0b1116;
  border:none;             /* überschreibt .ghost-dashed */
}
button[data-act="edit"]:hover{ filter:brightness(1.08); }

/* (Bereits vorhanden:) Löschen ist rot über .danger */

/* Nur im Infos-Tab: Verhältnis der Spalten ändern */
#tab-infos {
  grid-template-columns: 0.7fr 1.3fr; /* links : rechts  (bei Bedarf 0.6/1.4, 0.8/1.2, …) */
}

/* --- Infos: Titel/Preview nur einzeilig zeigen --- */
#tab-infos .table-wrap table { table-layout: fixed; }
#tab-infos thead th:nth-child(1){ width:48px }      /* 📌  */
#tab-infos thead th:nth-child(3){ width:160px }     /* Autor */
#tab-infos thead th:nth-child(4){ width:160px }     /* Datum */
#tab-infos thead th:nth-child(5){ width:160px }     /* Aktionen */

/* Spalte mit Titel/Preview darf den restlichen Platz einnehmen */
#tab-infos tbody td:nth-child(2){ width:auto; }

/* Einzeilig, mit … */
.info-title{
  font-weight:600; margin:2px 0 2px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.info-preview{
  color:var(--sub); font-size:13px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  margin-bottom:2px;
}

/* Klick-Hover für Lesesheet */
.info-title, .info-preview { cursor:pointer; }
.info-title:hover, .info-preview:hover { text-decoration:underline; }

#customersTbody td:nth-child(3){ text-align:center; width:120px; }


/* Rechnungsarchiv: interner Scroll */
#invoicesList .table-wrap{
  max-height: 600px;
  overflow: auto;
  overscroll-behavior: contain; /* verhindert "Durchscrollen" der Seite */
}

/* Optional: Header beim Scrollen fixieren */
#invoicesList thead th{
  position: sticky;
  top: 0;
  z-index: 1;
}
