/* Korundex Kundenübersicht — Farben und Schrift aus dem Website-Styleguide (korundex.de) */
:root {
  --primaer: #17CAB9;        /* Korundex Türkis */
  --primaer-dunkel: #129c8f;
  --primaer-tief: #0f857a;
  --sekundaer: #404451;      /* Anthrazit */
  --sekundaer-tief: #292c35;
  --tertiaer: #C8C936;       /* Limette */
  --text: #4d4d4d;
  --text-leise: #728197;
  --linie: #cdd3c8;
  --flaeche: #e7e9e4;
  --karte: #ffffff;
  --warn: #FD0B04;
  --plus: #0f857a;
  --minus: #c2410c;
  --link: #1756CA;
  --balken: rgba(23, 202, 185, 0.16);
  --balken-neg: rgba(253, 11, 4, 0.18);
  --radius: 2px;
  --schrift: "freight-sans-pro", "Segoe UI", Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; font-family: var(--schrift); color: var(--text); background: var(--flaeche); line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--sekundaer); font-weight: 600; line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; margin-bottom: .6rem; }
h2 small { font-weight: 400; color: var(--text-leise); font-size: .8rem; margin-left: .5rem; }
small { font-size: .82em; }
.leer { color: var(--text-leise); }
.fehler { color: var(--warn); }
.r { text-align: right; }
.tag { display: inline-block; font-size: .72rem; padding: 0 .4em; border-radius: var(--radius); background: var(--flaeche); color: var(--text); vertical-align: middle; font-weight: 400; }
.tag.warn { background: #fde8e7; color: #b30b06; }
.tag.offen { background: var(--tertiaer); color: var(--sekundaer-tief); font-weight: 600; }

/* ---------- Kopfzeile */
.kopf { display: flex; align-items: center; gap: 1.5rem; padding: .55rem 1.5rem; background: var(--sekundaer); color: #fff; }
.marke { display: flex; align-items: center; gap: .8rem; color: #fff; font-weight: 600; white-space: nowrap; }
.marke img { height: 26px; display: block; }
.marke:hover { text-decoration: none; color: var(--tertiaer); }
.kopf-suche { display: flex; flex: 1; max-width: 34rem; position: relative; }
.kopf-suche input { flex: 1; padding: .4rem .6rem; border: 0; border-radius: var(--radius) 0 0 var(--radius); font: inherit; }
.kopf-suche button { padding: .4rem .9rem; border: 0; border-radius: 0 var(--radius) var(--radius) 0; background: var(--primaer); color: var(--sekundaer-tief); font: inherit; font-weight: 600; cursor: pointer; }
.kopf-rechts { margin-left: auto; display: flex; gap: 1.2rem; align-items: center; font-size: .9rem; }
.kopf-rechts a { color: #fff; opacity: .85; }
.datenstand { color: var(--tertiaer); font-weight: 600; }
.inhalt { max-width: 1500px; margin: 0 auto; padding: 1.2rem 1.5rem 2rem; }
.fuss { text-align: center; color: var(--text-leise); font-size: .8rem; padding: 1rem; }
.karte { background: var(--karte); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1.2rem; box-shadow: 0 1px 2px rgba(0,0,0,.05); }

/* ---------- Schlichte Seiten (Login, Fehler) */
body.schlicht { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.schlicht-box { background: var(--karte); padding: 2rem 2.5rem; width: min(26rem, 92vw); border-radius: var(--radius); border-top: 4px solid var(--primaer); }
.schlicht-logo { height: 40px; margin-bottom: 1.2rem; }
.login-form label { display: block; font-weight: 600; margin-bottom: .3rem; }
.login-form input { width: 100%; padding: .55rem .7rem; font: inherit; border: 1px solid var(--linie); border-radius: var(--radius); margin-bottom: 1rem; }
.knopf, .login-form button { background: var(--primaer); color: var(--sekundaer-tief); border: 0; padding: .5rem 1.1rem; font: inherit; font-weight: 600; border-radius: var(--radius); cursor: pointer; }
.knopf:hover, .login-form button:hover { background: var(--primaer-dunkel); color: #fff; }
.knopf-leise { background: transparent; border: 1px solid var(--linie); color: var(--text); padding: .3rem .7rem; font: inherit; font-size: .85rem; border-radius: var(--radius); cursor: pointer; }
.knopf-leise:hover { border-color: var(--primaer); color: var(--primaer-tief); }

/* ---------- Suche */
.suche-start { text-align: center; padding: 2.5rem 0 1.5rem; }
.suche-start h1 { font-size: 2rem; }
.suche-form { display: flex; max-width: 40rem; margin: 1rem auto .5rem; position: relative; }
.suche-form input { flex: 1; font: inherit; font-size: 1.15rem; padding: .7rem 1rem; border: 2px solid var(--sekundaer); border-right: 0; border-radius: var(--radius) 0 0 var(--radius); }
.suche-form input:focus, .kopf-suche input:focus { outline: 2px solid var(--primaer); outline-offset: -2px; }
.suche-form button { font: inherit; font-size: 1.05rem; font-weight: 600; padding: .7rem 1.4rem; border: 0; background: var(--primaer); color: var(--sekundaer-tief); border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer; }
.hinweis { color: var(--text-leise); font-size: .9rem; }
.vorschlaege { position: absolute; top: 100%; left: 0; right: 0; z-index: 50; background: #fff; border: 1px solid var(--linie); border-top: 0; box-shadow: 0 6px 16px rgba(0,0,0,.12); text-align: left; max-height: 22rem; overflow: auto; }
.vorschlaege a { display: grid; grid-template-columns: 4.5rem 1fr auto; gap: .8rem; padding: .45rem .8rem; color: var(--text); border-bottom: 1px solid var(--flaeche); font-size: .95rem; }
.vorschlaege a:hover, .vorschlaege a.aktiv { background: #e8faf8; text-decoration: none; }
.vorschlaege .vs-nr { color: var(--text-leise); }
.vorschlaege .vs-name strong { color: var(--sekundaer); }
.vorschlaege .vs-name small { color: var(--text-leise); display: block; }
.vorschlaege .vs-datum { color: var(--text-leise); font-size: .8rem; white-space: nowrap; }
.treffer tr.klick { cursor: pointer; }
.treffer tr.klick:hover td { background: #e8faf8; }

/* ---------- Tabellen */
.tabelle { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabelle th, .tabelle td { padding: .4rem .55rem; border-bottom: 1px solid var(--flaeche); vertical-align: top; text-align: left; }
.tabelle th { color: var(--text-leise); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--linie); }
.tabelle th small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.tabelle tr.laufend td { background: #f3fcfb; }
.tabelle.jahre { max-width: 66rem; }
.tabelle tfoot td, .tabelle tr.summe td { border-top: 2px solid var(--linie); font-weight: 600; background: #fafbf9; }
.dp.plus, .v-plus .dp, .v-neu, .stich-wert.plus .sw-zahl { color: var(--plus); }
.dp.minus, .v-minus .dp, .v-weg, .stich-wert.minus .sw-zahl { color: var(--minus); }
.dp.stabil, .v-stabil .dp { color: var(--text); }
.v-ruhend { color: var(--text-leise); }
.v small { display: block; color: var(--text-leise); font-weight: 400; }
.v .dp { font-weight: 600; display: block; }
.v-neu .dp { font-size: .9em; }
.v-weg { font-weight: 600; }
.v-weg small { font-weight: 400; }

/* ---------- Kundenkopf */
.kundenkopf { display: flex; gap: 2rem; align-items: flex-start; background: var(--karte); border-left: 5px solid var(--primaer); padding: 1rem 1.2rem; margin-bottom: 1rem; border-radius: var(--radius); }
.kk-haupt { flex: 1; min-width: 0; }
.kundenkopf h1 .nr { color: var(--text-leise); font-weight: 400; font-size: 1.1rem; margin-left: .4rem; }
.kk-adresse { margin: .1rem 0 .4rem; }
.kk-merkmale { margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.kk-merkmale span { background: var(--flaeche); border-radius: var(--radius); padding: .05rem .5rem; font-size: .82rem; }
.kk-stichtag { text-align: right; min-width: 18rem; }
.stich-wert .sw-zahl { display: block; font-size: 1.7rem; font-weight: 700; color: var(--sekundaer); line-height: 1.1; }
.stich-wert .sw-label { color: var(--text-leise); font-size: .85rem; }
.stich-vergleich { font-size: .9rem; margin-top: .3rem; }
.stich-vergleich .dp { font-weight: 700; }
.stich-vergleich small { color: var(--text-leise); }

/* ---------- Werkzeugleiste */
/* Ebene 1 (oben): Zeiträume gelten für alles, rechts der Druck. Ebene 2 (an der Kaufhistorie): Tabs und leise Optionen. */
.werkzeuge { display: flex; flex-wrap: wrap; gap: .6rem 1.6rem; align-items: center; margin: 0 0 1rem; font-size: .92rem; }
.wz-primaer { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; background: var(--karte); border-radius: var(--radius); padding: .45rem .8rem; border-left: 5px solid var(--sekundaer); }
.wz-titel { font-weight: 700; color: var(--sekundaer); margin-right: .4rem; }
.wz-schalter { display: inline-flex; border: 1px solid var(--linie); border-radius: var(--radius); overflow: hidden; }
.wz-schalter a { padding: .3rem .8rem; color: var(--text); border-right: 1px solid var(--linie); }
.wz-schalter a:last-child { border-right: 0; }
.wz-schalter a:hover { background: var(--flaeche); text-decoration: none; }
.wz-schalter a.aktiv { background: var(--sekundaer); color: #fff; font-weight: 600; }
.wz-schalter.leise a { padding: .15rem .55rem; font-size: .82rem; }
.wz-schalter.leise a.aktiv { background: var(--flaeche); color: var(--sekundaer); }
.wz-aktionen { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
.wz-label { color: var(--text-leise); margin-right: .4rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.wz-check { display: flex; align-items: center; gap: .3rem; color: var(--text); font-size: .85rem; }
.karte-kopf { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .6rem 1rem; border-bottom: 2px solid var(--linie); margin-bottom: .2rem; }
.tabs { display: flex; gap: .2rem; }
.tabs a { display: block; padding: .5rem 1rem; margin-bottom: -2px; border-bottom: 3px solid transparent; color: var(--text); font-weight: 600; font-size: 1.05rem; }
.tabs a:hover { text-decoration: none; color: var(--primaer-tief); }
.tabs a.aktiv { color: var(--sekundaer); border-bottom-color: var(--primaer); }
.karte-optionen { display: flex; align-items: center; gap: .6rem; padding-bottom: .4rem; }
.untertitel { color: var(--text-leise); font-size: .82rem; margin: .3rem 0 .6rem; }

/* ---------- Kaufhistorie-Matrix */
.matrix { table-layout: fixed; }
.matrix th.art, .matrix td.art { width: 27%; }
.matrix th.vgl, .matrix td.v { width: 11%; }
.matrix th.zul, .matrix td.zul { width: 7%; font-size: .82rem; color: var(--text-leise); }
.matrix td.z { text-align: right; white-space: nowrap; background-image: linear-gradient(to top, var(--balken) var(--bar, 0%), transparent var(--bar, 0%)); background-size: 100% 100%; }
.matrix td.z.neg { background-image: linear-gradient(to top, var(--balken-neg) 100%, transparent 100%); }
.matrix td.z span { display: block; line-height: 1.3; }
.matrix td.z .u { font-weight: 600; color: var(--sekundaer); }
.matrix td.z .m { color: var(--text-leise); font-size: .82em; }
.matrix td.z .g { font-size: .8em; color: var(--text-leise); margin-top: .1rem; }
.matrix td.z .g b { display: inline-block; font-weight: 600; color: var(--primaer-tief); background: rgba(23, 202, 185, .14); padding: 0 .35em; border-radius: var(--radius); }
.matrix td.z.ges .u { color: var(--sekundaer-tief); }
.matrix td.z i, .matrix td.z .m i { font-style: normal; font-size: .9em; }
.matrix td.zul small.m { display: block; }
.zellen-legende { text-transform: none; letter-spacing: 0; font-weight: 400; }
.zellen-legende span { display: none; }
.detail-1 .zellen-legende .l1, .detail-2 .zellen-legende .l2, .detail-3 .zellen-legende .l3 { display: inline; }
/* Feste Zeilenhöhe (drei Zeilen), damit die Balken auch bei "nur Umsatz" den Verlauf zeigen */
.matrix td.z, .matrix td.leer, .matrix td.v, .matrix td.zul, .matrix td.art { height: 3.9rem; }
.matrix td.z { vertical-align: bottom; }
.matrix td.leer { text-align: right; color: var(--linie); }
.matrix td.art .artnr { color: var(--text-leise); margin-right: .3rem; }
.matrix td.art .bez { font-weight: 600; color: var(--sekundaer); }
.matrix td.art .wg-tag { display: block; color: var(--text-leise); margin-left: 1.3rem; }
.matrix .pfeil { display: inline-block; width: 1rem; color: var(--primaer-dunkel); transition: transform .15s; }
.matrix tr.klapp { cursor: pointer; }
.matrix tr.klapp:hover td { background-color: #f3fcfb; }
.matrix tr.klapp.auf .pfeil { transform: rotate(90deg); }
.matrix tr.wg-zeile td { background-color: #f1f3ef; border-top: 2px solid var(--linie); }
.matrix tr.in-wg td.art { padding-left: 1.6rem; }
.matrix tr.zu { display: none; }
.matrix tr.detail td { background: #fafbf9; border-bottom: 2px solid var(--linie); padding: .6rem 1rem 1rem 2.2rem; }
.detail-inhalt { display: flex; gap: 2rem; flex-wrap: wrap; }
.detail-inhalt .stamm { margin: 0; flex: 0 1 22rem; font-size: .88rem; }
.detail-inhalt .stamm div { display: grid; grid-template-columns: 6.5rem 1fr; gap: .5rem; padding: .12rem 0; border-bottom: 1px dotted var(--linie); }
.detail-inhalt .stamm dt { color: var(--text-leise); }
.detail-inhalt .stamm dd { margin: 0; }
.detail-inhalt .belege { flex: 1 1 28rem; font-size: .85rem; }
.detail-inhalt .belege tr.storno td { color: var(--minus); }
.legende { color: var(--text-leise); font-size: .8rem; margin: .8rem 0 0; }

/* Detailstufen: 1 = Umsatz, 2 = Menge + Umsatz, 3 = + Gewinn/Marge */
.detail-1 .matrix .m, .detail-1 .matrix .g, .detail-1 .m-spalte, .detail-1 .g-spalte { display: none; }
.detail-2 .matrix .g, .detail-2 .g-spalte { display: none; }
.detail-1 .v small.m { display: none; }

/* ---------- Vorgänge */
.vorgaenge .tabelle { max-width: 60rem; }

.print-only { display: none; }

/* ---------- Kleine Bildschirme */
@media (max-width: 900px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .kopf { flex-wrap: wrap; gap: .6rem; padding: .5rem 1rem; }
  .kopf-suche { order: 3; flex-basis: 100%; max-width: none; }
  .kopf-suche input { min-width: 0; }
  .werkzeuge { gap: .5rem; }
  .wz-aktionen { margin-left: 0; }
  .inhalt { padding: .8rem; }
  .kundenkopf { flex-direction: column; gap: .8rem; }
  .kk-stichtag { text-align: left; }
  .karte.historie { overflow-x: auto; }
  .matrix { min-width: 900px; }
}

/* ---------- Druck: A4 quer, Korundex-Kopf, ohne Bedienelemente */
@media print {
  @page { size: A4 landscape; margin: 11mm 10mm 12mm; }
  html { font-size: 9.5pt; }
  body { background: #fff; color: #222; }
  .no-print { display: none !important; }
  .print-only { display: flex; }
  h2.print-only { display: block; }
  .druckkopf { align-items: center; gap: 1rem; border-bottom: 2px solid var(--primaer); padding-bottom: .4rem; margin-bottom: .6rem; font-size: .85rem; color: var(--text-leise); }
  .druckkopf img { height: 34px; }
  .inhalt { max-width: none; padding: 0; }
  .karte, .kundenkopf { box-shadow: none; padding: 0; margin-bottom: .9rem; border-radius: 0; }
  .kundenkopf { border-left: 0; border-bottom: 1px solid var(--linie); padding-bottom: .5rem; }
  .kk-merkmale span { background: none; padding: 0; }
  .kk-merkmale span + span::before { content: "· "; color: var(--text-leise); }
  .tabelle { font-size: 8.5pt; }
  .tabelle th, .tabelle td { padding: .22rem .35rem; }
  .matrix td.z { background-image: linear-gradient(to top, #dfe3dd var(--bar, 0%), transparent var(--bar, 0%)); }
  .matrix tr.zu { display: none; }
  .matrix tr.detail td { padding-left: 1rem; }
  .matrix .pfeil { display: none; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  .karte.historie { break-before: auto; }
  /* Gewinn und Marge nur mit ausdrücklicher Wahl drucken */
  body:not(.druck-marge) .g, body:not(.druck-marge) .g-spalte { display: none !important; }
  body:not(.druck-marge) .zellen-legende .l3 { display: none; }
  body:not(.druck-marge).detail-3 .zellen-legende .l2 { display: inline; }
  .vorgaenge { break-inside: avoid; }
  a { color: inherit; }
}
