/* NaKu Dashboard – Leitstand. Naku-Grün #3F8242, Lato (lokal gehostet). */
@font-face { font-family: Lato; font-weight: 400; font-display: swap; src: url(/assets/fonts/lato-latin-400.woff2) format("woff2"); }
@font-face { font-family: Lato; font-weight: 700; font-display: swap; src: url(/assets/fonts/lato-latin-700.woff2) format("woff2"); }
@font-face { font-family: Lato; font-weight: 900; font-display: swap; src: url(/assets/fonts/lato-latin-900.woff2) format("woff2"); }

:root {
  --paper: #f3f5f1;
  --surface: #ffffff;
  --ink: #16241b;
  --muted: #5d6b61;
  --line: #d9dfd6;
  --brand: #3f8242;   /* feste Markenfarbe, auch im Dunkelmodus (weißer Text erreicht AA) */
  --naku: #3f8242;
  --naku-deep: #2c6030;
  --naku-wash: #e6f0e4;
  --lead: #15779b;
  --lead-wash: #e1eff5;
  --alert: #c9472f;
  --alert-wash: #fbe9e5;
  --new: #a86f00;
  --new-wash: #fbf0d6;
  --focus: #15779b;
  --radius: 6px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #121a15; --surface: #1a251e; --ink: #e8efe9; --muted: #98a89d; --line: #2c3a31;
  --naku: #62a866; --naku-deep: #7fbf83; --naku-wash: #1f3324;
  --lead: #5bb3d4; --lead-wash: #17303b; --alert: #ee7a63; --alert-wash: #3a211c;
  --new: #e0aa3c; --new-wash: #3a2e14; --focus: #5bb3d4;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121a15; --surface: #1a251e; --ink: #e8efe9; --muted: #98a89d; --line: #2c3a31;
    --naku: #62a866; --naku-deep: #7fbf83; --naku-wash: #1f3324;
    --lead: #5bb3d4; --lead-wash: #17303b; --alert: #ee7a63; --alert-wash: #3a211c;
    --new: #e0aa3c; --new-wash: #3a2e14; --focus: #5bb3d4;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.5 Lato, "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2 { font-weight: 900; letter-spacing: -0.015em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.3rem); }
h2 { font-size: 1.5rem; }
a { color: var(--naku-deep); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

/* Schaltflächen und Formularfelder */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 700 1rem/1 Lato, sans-serif; padding: .85rem 1.25rem; border-radius: var(--radius); cursor: pointer;
}
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #2c6030; border-color: #2c6030; }
.link { appearance: none; background: none; border: 0; padding: 0; color: var(--naku-deep); font: inherit; text-decoration: underline; cursor: pointer; text-align: left; }
.field { display: grid; gap: .35rem; margin-block: 1rem; }
.field > span { font-weight: 700; font-size: .9rem; }
.field input {
  font: inherit; padding: .75rem .85rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); min-height: 44px;
}
.notice { padding: .75rem 1rem; border-radius: var(--radius); margin-block: 1rem; font-weight: 700; }
.notice-error { background: var(--alert-wash); color: var(--alert); border: 1px solid var(--alert); }

/* Anmeldung */
body.guest { min-height: 100vh; }
.guest-shell { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); min-height: 100vh; }
.guest-brand { background: var(--brand); color: #fff; padding: clamp(1.5rem, 5vw, 4rem); display: flex; flex-direction: column; justify-content: center; gap: 1.25rem; }
.guest-brand h1 { font-size: clamp(1.8rem, 1.2rem + 2vw, 2.9rem); max-width: 16ch; }
.guest-brand p { max-width: 38ch; margin: 0; font-size: 1.1rem; opacity: .92; }
.guest-logo { border-radius: 14px; background: #fff; }
.guest-form { display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: min(100%, 26rem); }
.auth-card h2 { margin-bottom: .5rem; }
.auth-card .btn { width: 100%; margin-top: .5rem; }
.qr { width: 200px; margin: 1rem 0; background: #fff; padding: 8px; border-radius: var(--radius); border: 1px solid var(--line); }
.qr svg { display: block; width: 100%; height: auto; }
code { background: var(--naku-wash); padding: .1rem .35rem; border-radius: 4px; word-break: break-all; }
@media (max-width: 760px) { .guest-shell { grid-template-columns: 1fr; } .guest-brand { padding-block: 1.5rem; } .guest-logo { width: 64px; height: 64px; } }

/* App-Rahmen */
.app { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--surface); border-right: 1px solid var(--line); padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 0; height: 100vh; }
.rail-brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--ink); font-weight: 900; font-size: 1.15rem; }
.rail-brand img { border-radius: 8px; }
.rail ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }
.rail ul a { display: block; padding: .6rem .75rem; border-radius: var(--radius); text-decoration: none; color: var(--ink); font-weight: 700; }
.rail ul a:hover { background: var(--naku-wash); }
.rail ul a[aria-current="page"] { background: var(--brand); color: #fff; }
.rail-user { margin-top: auto; display: grid; gap: .35rem; font-size: .9rem; }
.rail-user form { margin: 0; }
.main { padding: clamp(1rem, 3vw, 2.25rem); max-width: 80rem; width: 100%; min-width: 0; }
.page-head { margin-bottom: 1.5rem; }
.page-head p { margin: .35rem 0 0; }

/* Lagebalken */
.statusbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.stat { display: grid; gap: .1rem; padding: .9rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-left-width: 5px; border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.stat strong { font-size: 1.6rem; font-weight: 900; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .9rem; }
.stat-new { border-left-color: var(--new); background: var(--new-wash); }
.stat-alert { border-left-color: var(--alert); background: var(--alert-wash); }
.stat:hover { border-color: var(--ink); }

/* Werkzeugleiste */
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 700 .9rem Lato, sans-serif; padding: .5rem .85rem; border-radius: 999px; cursor: pointer; min-height: 36px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.search input { font: inherit; padding: .55rem .85rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); min-width: min(100%, 18rem); min-height: 40px; }

/* Tabelle */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-size: .85rem; font-weight: 700; color: var(--muted); padding: .7rem 1rem; border-bottom: 1px solid var(--line); background: var(--paper); }
.grid td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: var(--naku-wash); }
.name { display: block; font-weight: 700; }
.nak { display: block; font-size: .8rem; color: var(--muted); }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); margin: 0; }

/* Status-Marken: Kunde = gefüllt, Lead = Umriss (Form trägt die Information) */
.tag { display: inline-block; font-weight: 700; font-size: .82rem; padding: .2rem .65rem; border-radius: 999px; border: 2px solid transparent; }
.tag-customer { background: var(--brand); color: #fff; }
.tag-lead { background: transparent; color: var(--lead); border-color: var(--lead); }
.tag-guest { background: var(--new-wash); color: var(--new); margin-left: .35rem; border-color: transparent; }

/* Dreiklang: Odoo – vTiger – Shop */
.trio { display: block; overflow: visible; }
.trio .link { stroke: var(--naku); stroke-width: 2; }
.trio .link.broken { stroke: var(--alert); stroke-dasharray: 2 3; }
.dot { stroke-width: 2; }
.dot-ok { fill: var(--naku); stroke: var(--naku); }
.dot-diff { fill: var(--surface); stroke: var(--alert); stroke-width: 3; }
.dot-missing { fill: none; stroke: var(--muted); stroke-dasharray: 2 2; }
.legend { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.legend svg { overflow: visible; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; padding: .75rem 1rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail ul { display: flex; flex-wrap: wrap; }
  .rail-user { margin-top: 0; margin-left: auto; }
  .statusbar { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .stat, .chip, .btn, .grid tbody tr { transition: background-color .12s, border-color .12s; }
}

/* Liste, Kundenakte, Abweichungen */
a.chip { text-decoration: none; display: inline-flex; align-items: center; }
.rowlink { color: var(--ink); text-decoration: none; }
.rowlink:hover { text-decoration: underline; text-decoration-color: var(--brand); text-underline-offset: 3px; }
.count-alert { display: inline-block; min-width: 1.6rem; text-align: center; font-weight: 900; color: var(--alert); background: var(--alert-wash); border: 1px solid var(--alert); border-radius: 999px; padding: 0 .5rem; }
.tag-small { font-size: .72rem; padding: .05rem .5rem; margin-left: .5rem; }
.spaced { margin-top: 1rem; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1rem; }
.back { margin: 0 0 .75rem; }
.head-tags { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; margin: .5rem 0 0; }
.search input { width: 100%; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.25rem; }
.panel h2 { font-size: 1.1rem; margin-bottom: .75rem; }
.panel-alert { border-left: 5px solid var(--alert); background: var(--alert-wash); }
.panel-ok { border-left: 5px solid var(--brand); background: var(--naku-wash); }
.panel-ok p { margin: 0; }
.issue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.issue-rule { font-weight: 700; margin-right: .35rem; }
.issue-rule::after { content: ":"; }

.compare th[scope="row"] { background: var(--paper); font-weight: 700; width: 11rem; }
.compare td { min-width: 12rem; }
.cell-diff { background: var(--alert-wash); box-shadow: inset 4px 0 0 var(--alert); font-weight: 700; }
.cell-gap { background: var(--new-wash); box-shadow: inset 4px 0 0 var(--new); }
.grid thead th a { color: inherit; text-decoration: none; }
.grid thead th a:hover { text-decoration: underline; }
.grid thead th a[aria-sort]::after { content: attr(aria-sort); position: absolute; width: 1px; height: 1px; overflow: hidden; }
.grid thead th a[aria-sort="ascending"]::before { content: "↑ "; }
.grid thead th a[aria-sort="descending"]::before { content: "↓ "; }
.grid tbody tr { cursor: default; }

/* Bestellungen */
.badge { display: inline-block; margin-left: .5rem; min-width: 1.4rem; padding: 0 .4rem; text-align: center; font-size: .78rem; font-weight: 900; line-height: 1.4rem; border-radius: 999px; background: var(--new); color: #fff; }
.rail ul a[aria-current="page"] .badge { background: #fff; color: var(--brand); }
.badge[hidden] { display: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-new { background: var(--new-wash); box-shadow: inset 4px 0 0 var(--new); }
.tag-new { background: var(--new); color: #fff; margin-left: .4rem; }
.status { display: inline-block; font-weight: 700; font-size: .85rem; padding: .15rem .6rem; border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line); }
.status-processing { background: var(--lead-wash); border-color: var(--lead); color: var(--lead); }
.status-completed { background: var(--naku-wash); border-color: var(--brand); color: var(--naku-deep); }
.status-pending, .status-on-hold { background: var(--new-wash); border-color: var(--new); color: var(--new); }
.status-cancelled, .status-failed, .status-refunded { background: var(--alert-wash); border-color: var(--alert); color: var(--alert); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
.big-sum { font-size: 1.8rem; font-weight: 900; margin: .25rem 0; }
form.inline { display: inline; margin: 0; }
.toolbar form { margin: 0; }

/* Hinweis bei neuer Bestellung */
.toast { position: fixed; right: 1.25rem; bottom: 1.25rem; max-width: 24rem; background: var(--ink); color: var(--paper); padding: .9rem 1.1rem; border-radius: var(--radius); border-left: 5px solid var(--new); box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 10; }
.toast[hidden] { display: none; }
.toast a { color: inherit; font-weight: 700; }
@media (prefers-reduced-motion: no-preference) { .toast:not([hidden]) { animation: toast-in .25s ease-out; } @keyframes toast-in { from { transform: translateY(12px); opacity: 0; } } }
@media (max-width: 860px) { .statusbar { grid-template-columns: 1fr 1fr; } }

/* Bearbeiten, Vorschau, Verlauf */
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 0 0 1.25rem; }
.actions form { margin: 0; }
a.btn { text-decoration: none; display: inline-block; }
.btn-small { padding: .45rem .8rem; font-size: .9rem; }
.btn-link { appearance: none; background: none; border: 0; padding: 0; margin-top: .3rem; color: var(--naku-deep); font: 700 .82rem Lato, sans-serif; text-decoration: underline; cursor: pointer; display: block; }
.take { margin: 0; }
.cell-input { width: 100%; min-width: 11rem; font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); min-height: 40px; }
.cell-input:focus-visible { border-color: var(--focus); }
.panel-warn { border-left: 5px solid var(--new); background: var(--new-wash); }
.diff-old { color: var(--alert); text-decoration: line-through; text-decoration-thickness: 1px; }
.diff-new { color: var(--naku-deep); font-weight: 700; }
.history, .history-rows { list-style: none; margin: 0; padding: 0; }
.history > li { padding: .9rem 0; border-top: 1px solid var(--line); }
.history > li:first-child { border-top: 0; padding-top: 0; }
.history > li.is-undone { opacity: .6; }
.history-head { display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center; margin-bottom: .3rem; }
.history-rows { display: grid; gap: .15rem; margin-bottom: .6rem; }
.flash { padding: .8rem 1.1rem; border-radius: var(--radius); margin-bottom: 1.25rem; font-weight: 700; border: 1px solid; }
.flash-ok { background: var(--naku-wash); border-color: var(--brand); color: var(--naku-deep); }
.flash-error { background: var(--alert-wash); border-color: var(--alert); color: var(--alert); }

.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 700; flex-basis: 100%; }
.check input { margin-top: .3rem; width: 1.1rem; height: 1.1rem; }

.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 700; flex-basis: 100%; }
.check input { margin-top: .3rem; width: 1.1rem; height: 1.1rem; }

/* Benutzerverwaltung */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0 1.25rem; align-items: end; }
.form-grid .field { margin-block: .5rem; }
.form-actions { margin-block: .5rem; }
.field select { font: inherit; padding: .75rem .85rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); min-height: 44px; }
.field small { font-weight: 400; }
.narrow { max-width: 32rem; }
.secret { font: 700 1.6rem/1.3 "Cascadia Mono", Consolas, monospace; letter-spacing: .04em; background: var(--surface); border: 1px dashed var(--ink); border-radius: var(--radius); padding: .8rem 1rem; word-break: break-all; user-select: all; }
.btn-danger { color: var(--alert); border-color: var(--alert); }
.btn-danger:hover { background: var(--alert-wash); }
.tag-off { background: var(--alert-wash); color: var(--alert); border-color: var(--alert); }
.tag-lock { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.is-off { opacity: .65; }

/* Sync */
.status-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .45rem; }
fieldset.conf { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 0 0 1.25rem; background: var(--surface); }
fieldset.conf legend { font-weight: 900; padding: 0 .4rem; }
fieldset.conf:disabled { opacity: .85; }
.field textarea { font: inherit; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); width: 100%; }
.inline-check { display: inline-flex; flex-basis: auto; margin-right: .75rem; }
.run-live { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin: 0; }
