/* MEQO Kompass – Gestaltung nach „MEQO Brand & Visual Style Guide“ (Feb. 2024)
   Farben: Midnight Blue #0E0F27 (primär), Limetta #D3E978 & Periwinkle #BCCAFF (sekundär), Frost Gray #F6F6F9, Clinical White #FFFFFF
   Schrift: Archivo – Überschriften Medium, Text Regular/Light, Hervorhebungen Bold. Abgerundete Ecken. WCAG AA. */

@font-face {
  font-family: "Archivo"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fonts/archivo-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Archivo"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fonts/archivo-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Markenfarben */
  --midnight: #0E0F27; --limetta: #D3E978; --periwinkle: #BCCAFF; --frost: #F6F6F9; --white: #FFFFFF;
  /* Hell */
  color-scheme: light;
  --bg: var(--frost); --panel: var(--white); --panel-2: #FAFAFC; --text: var(--midnight); --muted: #585B73; --line: #E3E4EC;
  --brand: var(--midnight); --brand-ink: #FFFFFF;           /* Primärbuttons */
  --link: #3A4BC2;                                           /* Periwinkle-Ton, AA auf Weiß */
  --accent: var(--limetta); --accent-ink: var(--midnight);   /* Hervorhebungen, aktiver Menüpunkt */
  --brand-soft: #EEF1FF;                                     /* Periwinkle-Fläche hell */
  --grey-soft: #EFEFF4;
  --green: #3E6B0F; --green-soft: #EEF6D2; --amber: #8A4B00; --amber-soft: #FFF1D6; --red: #B42318; --red-soft: #FDE8E7;
  /* Diagramm (validiert: Kontrast ≥ 3:1, farbfehlsichtig unterscheidbar) */
  --chart-in: #7A9420; --chart-out: #5B6EE0; --chart-balance: var(--midnight); --chart-grid: #E3E4EC;
  /* Seitenleiste immer Midnight */
  --side-bg: var(--midnight); --side-text: #E7E8F2; --side-muted: #9A9DB8; --side-hover: rgba(255, 255, 255, .07); --side-line: rgba(255, 255, 255, .1);
  --radius: 14px; --radius-sm: 10px;
  --font: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0A0B1E; --panel: #15172F; --panel-2: #1A1C38; --text: var(--frost); --muted: #A6A9C4; --line: #2B2E52;
  --brand: var(--limetta); --brand-ink: var(--midnight);
  --link: var(--periwinkle);
  --brand-soft: #232758; --grey-soft: #1F2240;
  --green: #B9D660; --green-soft: #26321A; --amber: #F0B454; --amber-soft: #3A2D14; --red: #F48A80; --red-soft: #3D1C1A;
  --chart-in: #839C27; --chart-out: #6F82EC; --chart-balance: var(--frost); --chart-grid: #2B2E52;
  --side-bg: #0E0F27; --side-line: rgba(255, 255, 255, .08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0A0B1E; --panel: #15172F; --panel-2: #1A1C38; --text: var(--frost); --muted: #A6A9C4; --line: #2B2E52;
    --brand: var(--limetta); --brand-ink: var(--midnight);
    --link: var(--periwinkle);
    --brand-soft: #232758; --grey-soft: #1F2240;
    --green: #B9D660; --green-soft: #26321A; --amber: #F0B454; --amber-soft: #3A2D14; --red: #F48A80; --red-soft: #3D1C1A;
    --chart-in: #839C27; --chart-out: #6F82EC; --chart-balance: var(--frost); --chart-grid: #2B2E52;
    --side-bg: #0E0F27; --side-line: rgba(255, 255, 255, .08);
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 28px; font-weight: 500; letter-spacing: -.01em; margin: 0 0 20px; }
h2 { font-size: 17px; font-weight: 500; margin: 0 0 12px; display: flex; justify-content: space-between; align-items: baseline; }
h3 { font-size: 14px; font-weight: 500; margin: 12px 0 4px; color: var(--muted); }
strong, b { font-weight: 700; }
small, .hint { color: var(--muted); }
.hint { font-size: 13px; margin: 10px 0; font-weight: 300; }
:focus-visible { outline: 3px solid var(--periwinkle); outline-offset: 2px; }

/* ---------- Seitenleiste ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 224px; background: var(--side-bg); color: var(--side-text); padding: 20px 0 16px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 20px 18px; font-size: 16px; color: #fff; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand > span { white-space: nowrap; }
.brand .word-meqo { font-weight: 500; letter-spacing: .06em; }
.brand .word-product { font-weight: 700; }
.logo-mark { flex: none; display: block; }
.nav-group { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); padding: 16px 20px 6px; }
.nav-link { display: block; margin: 1px 10px; padding: 7px 12px; border-radius: var(--radius-sm); color: var(--side-text); }
.nav-link:hover { background: var(--side-hover); text-decoration: none; }
.nav-link.active { background: var(--limetta); color: var(--midnight); font-weight: 600; }
.nav-user { padding: 16px 20px 0; font-size: 12px; color: var(--side-muted); border-top: 1px solid var(--side-line); margin-top: 16px; }
.nav-user a { color: var(--periwinkle); }
.theme-toggle { display: flex; align-items: center; gap: 8px; width: calc(100% - 40px); margin: 14px 20px 0; justify-content: center; font-size: 12px;
  background: transparent; color: var(--side-text); border: 1px solid var(--side-line); }
.theme-toggle:hover { border-color: var(--periwinkle); }
main.with-sidebar { margin-left: 224px; padding: 28px 32px 64px; max-width: 1800px; }
main.centered { max-width: 460px; margin: 10vh auto; padding: 0 16px; }
@media (max-width: 900px) {
  .sidebar { position: static; width: auto; }
  main.with-sidebar { margin-left: 0; padding: 16px; }
}

/* ---------- Flächen ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card.narrow { max-width: 460px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid2.crud { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
@media (max-width: 1100px) { .grid2, .grid2.crud { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi span { display: block; font-size: 12px; color: var(--muted); }
.kpi strong { display: block; font-size: 26px; font-weight: 500; letter-spacing: -.01em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi:first-child { background: var(--midnight); border-color: var(--midnight); color: #fff; }
.kpi:first-child span, .kpi:first-child small { color: #B9BBD3; }

/* ---------- Tabellen ---------- */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); font-variant-numeric: tabular-nums; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 500; background: var(--panel-2); white-space: nowrap; }
.tbl.sticky { overflow: visible; }
.tbl.sticky thead th { position: sticky; top: 0; z-index: 1; }
.tbl.compact td, .tbl.compact th { padding: 5px 8px; font-size: 13px; }
.tbl tr:hover td { background: var(--grey-soft); }
.tbl .num, .num { text-align: right; white-space: nowrap; }
.tbl tfoot td, .tbl tr.total td, .tbl tr.subtotal td { font-weight: 700; border-top: 2px solid var(--line); }
.tbl tr.section td { background: var(--grey-soft); font-weight: 700; font-size: 12px; letter-spacing: .05em; }
.tbl tr.group-start td { border-top: 2px solid var(--line); }
.tbl tr.sub td { color: var(--muted); font-size: 12px; }
.tbl tr.selected td { background: var(--brand-soft); }
.row-warn td { background: var(--amber-soft); }
.row-err td { background: var(--red-soft); }
.liq th.forecast { color: var(--link); }
.scroll-x { overflow-x: auto; }
.neg { color: var(--red); } .pos { color: var(--green); } .warn { color: var(--amber); }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.muted-row td { opacity: .5; }

/* ---------- Badges & Produkt-Chips (Farbzuordnung laut Style Guide) ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 500; background: var(--grey-soft); color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.chip { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .02em; background: var(--grey-soft); color: var(--text); border: 1px solid transparent; white-space: nowrap; }
.chip.clinic { background: var(--limetta); color: var(--midnight); }
.chip.connect { background: var(--periwinkle); color: var(--midnight); }
.chip.other { background: transparent; border-color: var(--line); }

/* ---------- Meldungen ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 12px; background: var(--green-soft); color: var(--green); }
.flash.error { background: var(--red-soft); color: var(--red); }
.flash.warn { background: var(--amber-soft); color: var(--amber); }
.flash.info { background: var(--brand-soft); color: var(--text); }
.flash ul { margin: 6px 0; padding-left: 20px; }

/* ---------- Formulare & Buttons ---------- */
input, select, textarea, button, .btn { font: inherit; color: inherit; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--brand-soft); border-color: var(--link); }
button, .btn { display: inline-block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 14px; cursor: pointer; white-space: nowrap; font-weight: 500; color: var(--text); }
button:hover, .btn:hover { border-color: var(--text); text-decoration: none; }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
button.primary:hover, .btn.primary:hover { filter: brightness(1.15); }
button.danger { color: var(--red); border-color: var(--red); background: transparent; }
button.small, .btn.small { padding: 3px 10px; font-size: 12px; }
.btn.active { background: var(--limetta); border-color: var(--limetta); color: var(--midnight); }
button:disabled { opacity: .5; cursor: not-allowed; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 18px; }
.form-grid .wide, .form-grid .actions, .form-grid h3, .form-grid table, .form-grid .flash { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
label.field:has(.wide) { grid-column: 1 / -1; }
.calc { padding: 8px 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.sticky-bottom { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--line); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters label { display: flex; gap: 6px; align-items: center; }
form.inline { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
form.inline select { max-width: 340px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--limetta); }

/* ---------- Diverses ---------- */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: 0; }
.checks li.error { color: var(--red); } .checks li.warn { color: var(--amber); }
.bar { height: 8px; background: var(--grey-soft); border-radius: 999px; overflow: hidden; }
.bar div { height: 100%; background: var(--limetta); border-radius: 999px; box-shadow: inset 0 0 0 1px rgba(14, 15, 39, .18); }
.bar div.high { background: var(--amber); } .bar div.over { background: var(--red); }
.import-box { display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap; }
.progress { width: 100%; height: 24px; background: var(--grey-soft); border-radius: 999px; position: relative; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--limetta); transition: width .3s; }
.progress span { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 24px; color: var(--text); }
.hidden { display: none; }

.chat #chat-log { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.msg { padding: 12px 16px; border-radius: var(--radius); max-width: 92%; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--periwinkle); color: var(--midnight); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--grey-soft); white-space: normal; border-bottom-left-radius: 4px; }
.msg.assistant table { border-collapse: collapse; margin: 6px 0; }
.msg.assistant td, .msg.assistant th { border: 1px solid var(--line); padding: 3px 6px; }
.msg.pending { opacity: .6; font-style: italic; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.quick button { font-size: 12px; border-radius: 999px; }
#chat-form { display: flex; gap: 8px; }
#chat-form textarea { flex: 1; }

.doc-review { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(0, 1.4fr); gap: 16px; align-items: start; }
.doc-review iframe { width: 100%; height: 82vh; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; position: sticky; top: 12px; }
.doc-review select { max-width: 460px; }
.doc-review select.check { border-color: var(--amber); }
.doc-review select.ok { border-color: var(--green); }
@media (max-width: 1100px) { .doc-review { grid-template-columns: 1fr; } .doc-review iframe { height: 60vh; position: static; } }
.upload-box { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; }
.dropzone { flex: 1; min-width: 260px; border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; position: relative; }
.dropzone:hover { border-color: var(--limetta); color: var(--text); background: var(--grey-soft); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- Login ---------- */
.login { display: flex; flex-direction: column; gap: 16px; padding: 28px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.login-brand .name { font-size: 22px; }
.login-brand .name .word-meqo { font-weight: 500; letter-spacing: .06em; }
.login-brand .name .word-product { font-weight: 700; }
.login-brand small { display: block; font-size: 13px; }
.btn.google { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px; font-weight: 600; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.login form { display: flex; flex-direction: column; gap: 12px; }
main.centered h1 { display: none; }

/* ---------- Rechnungen ---------- */
.invoices th.grp { text-align: center; border-bottom: 3px solid var(--periwinkle); color: var(--text); }
.invoices .grp-start { border-left: 2px solid var(--line); }
a.pdf { font-size: 10px; font-weight: 600; padding: 0 5px; border: 1px solid var(--line); border-radius: 6px; margin-left: 4px; }
.partial-row td { background: var(--amber-soft); font-size: 13px; }
.partial-row input { padding: 3px 7px; }
