/* Super-Handwerk — Desktop-first, schlank (Stil an superzeit/css/app.css orientiert) */
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --primary: #0f3d2b;
  --primary-hover: #14512f;
  --primary-soft: #e6f0ea;
  --green: #16a34a;
  --green-text: #15803d;   /* Text auf --green-bg: 4.6:1 (vorher 3.1:1) */
  --green-bg: #ecfdf3;
  --amber: #d97706;
  --amber-text: #b45309;   /* Text auf --amber-bg: 4.7:1 (vorher 3.1:1) */
  --amber-bg: #fffbeb;
  --red: #dc2626;
  --red-text: #b91c1c;     /* Text auf --red-bg: 5.9:1 (vorher 4.4:1) */
  --red-bg: #fef2f2;
  --ink: #1b1d29;
  --ink-soft: #5b6070;     /* 5.9:1 auf --bg (vorher #6b7080 = 4.5:1, an der Grenze) */
  --line: #e2e5e0;         /* Trennlinien in Karten/Tabellen */
  --line-strong: #c3c8c1;  /* Eingabefeld-Rahmen: 3:1 gegen Feldhintergrund */
  --bg-input: #fafbfa;
  --bg-hover: #f0f2f0;
  --star: #d97706;
  --star-off: #a3a8a1;
  --bg: #f4f6f4;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 22, 40, .06), 0 4px 16px rgba(20, 22, 40, .05);
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
a { color: var(--primary); }

/* Sichtbarer Tastaturfokus fuer alles Bedienbare (vorher outline:none ohne Ersatz) */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--primary); background: #fff; }

/* ===== Login ===== */
#screen-login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--primary-soft) 0%, var(--bg) 55%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  padding: 32px 28px 24px;
}
.brand { text-align: center; margin-bottom: 26px; }
.brand-logo {
  width: 56px; height: 56px; margin: 0 auto 10px;
  background: var(--primary); border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; box-shadow: 0 8px 20px rgba(15, 61, 43, .3);
}
.brand-name { font-size: 22px; font-weight: 800; letter-spacing: -.4px; }
.brand-sm { font-size: 18px; }
.brand-tenant { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.login-demo-hinweis { text-align: center; color: var(--ink-soft); font-size: 12.5px; margin-top: 10px; }
.login-error { background: var(--red-bg); color: var(--red-text); font-size: 13.5px; font-weight: 600; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }

/* ===== Felder & Buttons ===== */
/* EINE Basisregel fuer alle Eingabefelder — vorher hatten nur .field-Kinder und
   Tabellenzellen Stil, freistehende Such-/Auswahlfelder fielen auf den Browser-Default. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea {
  padding: 9px 11px; font-size: 14px;
  border: 1.5px solid var(--line-strong); border-radius: 8px; background: var(--bg-input);
  color: var(--ink); font-family: inherit; min-height: 40px;
}
select { padding-right: 28px; }
textarea { resize: vertical; min-height: 70px; }
input::placeholder, textarea::placeholder { color: #7a8090; }
input[type="checkbox"] { accent-color: var(--primary); width: 18px; height: 18px; cursor: pointer; }
.num-input { text-align: right; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; }
.field.invalid input, .field.invalid select { border-color: var(--red); background: var(--red-bg); }
.field-error { color: var(--red-text); font-size: 12.5px; font-weight: 600; margin-top: 4px; }
.row-fields { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row-fields > .field { flex: 1; min-width: 160px; }
.row-fields > .btn { margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; min-height: 40px;
  border: 1.5px solid transparent; border-radius: 9px; cursor: pointer;
  font-family: inherit; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: #eef1ee; color: var(--ink); }
.btn-ghost:hover { background: #e3e7e3; }
.btn-outline { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover { background: var(--bg-hover); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; min-height: 32px; }
.btn-danger { background: var(--red-bg); color: var(--red-text); }
.btn-danger:hover { background: #fde3e3; }

/* ===== App-Rahmen ===== */
#app { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand-sm { white-space: nowrap; }
/* Nav scrollt horizontal statt umzubrechen: 8 Ziele passen auf keinem Tablet in eine Zeile. */
.main-nav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.main-nav::-webkit-scrollbar { display: none; }
.main-nav a {
  padding: 8px 14px; border-radius: 8px; text-decoration: none; white-space: nowrap; flex-shrink: 0;
  color: var(--ink-soft); font-weight: 600; font-size: 14px;
}
.main-nav a:hover { background: var(--bg-hover); color: var(--ink); }
.main-nav a.active { background: var(--primary-soft); color: var(--primary); }
.header-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-soft); flex-shrink: 0; }

#view { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px; }
/* Ein Seitentitel-Stil fuer alle Ansichten (vorher div.view-title neben nacktem h2) */
.view-title, .view-header h1, .view-header h2 { font-size: 21px; font-weight: 800; letter-spacing: -.3px; margin-bottom: 4px; line-height: 1.25; }
.view-sub { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 18px; }
.view-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.view-header .view-sub { margin-bottom: 0; }
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* Zurueck-Link oben statt Fussnote unten */
.link-back { display: inline-block; color: var(--ink-soft); font-size: 13.5px; font-weight: 600; text-decoration: none; margin-bottom: 8px; }
.link-back:hover { color: var(--primary); text-decoration: underline; }

/* ===== Karten ===== */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.card h4 { font-size: 13.5px; font-weight: 700; margin-bottom: 8px; }
.card details > summary { cursor: pointer; font-weight: 700; font-size: 14px; color: var(--ink); }
.card details[open] > summary { margin-bottom: 12px; }

/* ===== Tabs (Katalog-Gruppen) ===== */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab-btn {
  padding: 7px 14px; border-radius: 999px; border: 1.5px solid var(--line-strong);
  background: #fff; color: var(--ink-soft); font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
.tab-btn:hover { background: var(--bg-hover); color: var(--ink); }
.tab-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== Tabelle ===== */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-soft); padding: 8px 10px; border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data td input[type="text"], table.data td input[type="number"] {
  width: 100%; min-width: 70px; padding: 5px 7px; border-radius: 6px; font-size: 14px; min-height: 34px;
}
table.data td select { padding: 5px 24px 5px 7px; border-radius: 6px; font-size: 14px; min-height: 34px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
table.data td.empty-row { color: var(--ink-soft); padding: 18px 10px; text-align: center; }
/* Hover nur, wo die Zeile wirklich klickbar ist (vorher auf allen Tabellen) */
.link-row { cursor: pointer; }
.link-row:hover { background: var(--primary-soft); }
.link-row a { color: var(--primary); font-weight: 600; text-decoration: none; }
.link-row a:hover { text-decoration: underline; }

.star-btn { background: none; border: none; font-size: 18px; line-height: 1; cursor: pointer; color: var(--star-off); padding: 4px 6px; border-radius: 6px; }
.star-btn:hover { background: var(--bg-hover); }
.star-btn.active { color: var(--star); }

/* ===== Chips ===== */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip-green { background: var(--green-bg); color: var(--green-text); }
.chip-amber { background: var(--amber-bg); color: var(--amber-text); }
.chip-gray { background: #eef1ee; color: var(--ink-soft); }
.chip-red { background: var(--red-bg); color: var(--red-text); }
.text-red { color: var(--red-text); font-weight: 700; }

/* ===== Paginierung ===== */
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; font-size: 13px; color: var(--ink-soft); }

/* ===== Import ===== */
.upload-box { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 28px; text-align: center; margin-bottom: 16px; }
.fehler-liste { list-style: none; font-size: 13px; color: var(--red-text); }
.fehler-liste li { padding: 3px 0; }

/* ===== Summenblock (Angebot) ===== */
.summen { max-width: 320px; margin-left: auto; font-size: 14px; }
.summen .zeile { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; }
.summen .zeile.brutto { border-top: 1.5px solid var(--line); margin-top: 4px; padding-top: 8px; font-weight: 800; font-size: 16px; }

/* ===== Toast ===== */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 600;
  padding: 11px 18px; border-radius: 999px; z-index: 60;
  max-width: 88vw; text-align: center; box-shadow: 0 6px 20px rgba(20, 22, 40, .25);
}
#toast.toast-fehler { background: var(--red); }

.hint { color: var(--ink-soft); font-size: 13px; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.flex-gap { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.check-label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink-soft); cursor: pointer; min-height: 32px; }
details.gruppen-verwaltung summary { cursor: pointer; font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.empty-state { color: var(--ink-soft); padding: 18px 4px; }
.empty-state a { font-weight: 600; }
/* Kurzer Status-/Warnhinweis mit Aktion (z. B. fehlende Firmendaten, keine Nummernkreise) */
.callout { background: var(--amber-bg); border: 1px solid #f3dca0; color: #7c4a03; border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.callout a { color: inherit; font-weight: 700; }

/* M2.2: Dashboard-KPIs */
.dash-kpis { display: flex; gap: 12px; flex-wrap: wrap; }
.dash-kpi { min-width: 200px; text-decoration: none; display: block; color: var(--ink); }
.dash-kpi:hover { box-shadow: 0 1px 3px rgba(20, 22, 40, .08), 0 6px 20px rgba(20, 22, 40, .1); }
.dash-kpi-titel { font-size: 13px; color: var(--ink-soft); }
.dash-kpi-wert { font-size: 28px; font-weight: 700; color: var(--primary); }

/* M2.2: Positions-Picker-Modal */
#overlay { position: fixed; inset: 0; background: rgba(20, 22, 40, .45); z-index: 40;
  display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 10px; width: min(860px, 94vw);
  max-height: 86dvh; display: flex; flex-direction: column; padding: 16px; }
.modal-body { overflow-y: auto; flex: 1; }
.modal-fuss { display: flex; gap: 8px; justify-content: flex-end; padding-top: 12px; }
.pick-zeile { cursor: pointer; }
.pick-zeile:hover { background: var(--bg-hover); }
.pick-zeile-gewaehlt, .pick-zeile-gewaehlt:hover { background: var(--primary-soft); }
/* Stern-Spalte im Picker: nur Anzeige, erklaert die Sortierung "Favoriten oben". */
.pick-stern { width: 1.4em; color: var(--star); text-align: center; }
.pick-menge { width: 80px; }
/* Bestandsregel table.data td input[type="text"] ist spezifischer -> hier nachziehen */
table.data td input.pick-menge { width: 80px; }

/* ===== Mobil & Touch (Baustelle: Tablet/Handy) =====
   Bis 900px: Header zweizeilig (Marke + Nutzer / scrollende Nav), weniger Rand,
   Modal vollflaechig. Touch-Ziele >= 44px und Eingabefelder 16px (iOS zoomt sonst
   bei jedem Feldfokus) gelten auf schmalen Viewports UND auf Touch-Geraeten. */
@media (max-width: 900px) {
  .app-header { flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; }
  .header-user { margin-left: auto; }
  .main-nav { order: 3; flex-basis: 100%; margin: 0 -12px; padding: 0 12px; }
  .main-nav a { padding: 10px 12px; }
  #view { padding: 12px; }
  .card { padding: 14px; margin-bottom: 12px; }
  .view-header { flex-direction: column; align-items: stretch; }
  .summen { max-width: none; }
  .modal { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; padding: 12px; }
  .row-fields > .field { min-width: 140px; }
  /* Handys/Tablets betten PDFs meist nicht ein — statt eines leeren Rahmens
     fuehrt dort nur der "Ansehen"-Button zum Briefbogen. */
  .briefbogen-vorschau { display: none; }
}
@media (max-width: 900px), (pointer: coarse) {
  .btn, .tab-btn, .main-nav a { min-height: 44px; }
  .btn-sm { min-height: 40px; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea,
  table.data td input[type="text"], table.data td input[type="number"], table.data td select { font-size: 16px; min-height: 44px; }
  table.data td input[type="text"], table.data td input[type="number"] { min-width: 84px; }
  input[type="checkbox"] { width: 22px; height: 22px; }
  .star-btn { padding: 8px 10px; font-size: 20px; }
  table.data td, table.data th { padding: 10px 8px; }
}
