/* Bedienelemente der App, nach ARGUS24 (Phase 35/36, app/web/layout.py UI_CSS):
   Formen, Masse, Zustaende und Uebergaenge wie COPYRA, Farben aus palette.css.
   Regeln:
   - Hover aendert nur Flaeche und Text, nie Rand, Groesse oder Schriftgewicht.
   - <button> ist grau, die eine Hauptaktion eines Bereichs bekommt .primary.
   - Keine nativen Bedienelemente im Blick: Auswahllisten zeichnet ui.js, die
     Dateiauswahl ist ein eigenes Feld, Icons kommen aus templates/_icons.html.
   - Nichts springt: Scrollbalken-Platz reserviert, Schrift vorgeladen,
     Inhalt wird erst gezeigt, wenn ui.js die Auswahllisten ersetzt hat. */
:root {
  --knopf-rand: var(--line-strong); --knopf-flaeche: transparent; --knopf-text: var(--muted);
  --knopf-hover: var(--card3); --knopf-text-hover: var(--ink);
  --knopf-primaer: var(--accent); --knopf-primaer-hover: var(--accent-hi); --knopf-primaer-text: var(--on-accent);
  --knopf-rot-flaeche: rgba(255,107,71,.10); --knopf-rot-text: var(--bad);
  --field-bg: var(--bg); --field-rand: var(--line-strong); --row-hover: var(--card2);
  --radius: 14px; --radius-sm: 9px;
  --shadow-pop: 0 10px 30px rgba(0,0,0,.45);
}
html { overflow-y: scroll; scrollbar-gutter: stable; }
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  background: var(--bg); color: var(--ink); }
::selection { background: var(--accent); color: var(--on-accent); }
h2 { font-size: 1.05rem; margin: 0; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 4px; }
code { font-size: 12px; color: var(--accent); }
.ic { width: 15px; height: 15px; flex-shrink: 0; vertical-align: -2px; }
.ui-gated { transition: opacity .12s ease-out; }
html.ui-pending .ui-gated { opacity: 0; }

/* Topbar: nur der Logo-Bereich als eigener Abschnitt (ohne Link, Wunsch Frank). */
header.topbar { position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center;
  background: var(--card); border-bottom: 1px solid var(--line); }
.brand { flex-shrink: 0; width: 200px; height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 0 16px; border-right: 1px solid var(--line); }
.brand img { display: block; height: 40px; width: auto; max-width: 100%; }

main.wrap { max-width: 960px; margin: 24px auto; padding: 0 20px; }

/* Karten: nur Rand, keine eigene Flaeche. Kopf mit runder Schrittnummer. */
.card { background: transparent; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; min-height: 30px; margin: -2px 0 8px; }
.card-head .num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--card3); color: var(--muted); font-size: 11.5px; font-weight: 600;
  font-variant-numeric: tabular-nums; flex-shrink: 0; }
.hint { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; line-height: 1.55; }
.hint.lead { font-size: 13px; line-height: 1.6; }
p { margin: 0 0 8px; }
ul { margin: 0 0 12px; padding-left: 20px; }

/* Knoepfe: 30 px, Radius 7, 12,5 px. */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 30px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--knopf-rand);
  background: var(--knopf-flaeche); color: var(--knopf-text); font-family: inherit;
  font-size: 12.5px; font-weight: 500; line-height: 1.2; cursor: pointer; text-decoration: none;
  white-space: nowrap; transition: background .15s, color .15s, border-color .15s; }
button:hover:not(:disabled), .btn:hover { background: var(--knopf-hover); color: var(--knopf-text-hover);
  text-decoration: none; }
button:disabled { opacity: .45; cursor: default; }
button:focus { outline: none; }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary, .btn.primary { padding: 0 14px; border-color: transparent; background: var(--knopf-primaer);
  color: var(--knopf-primaer-text); font-weight: 600; }
button.primary:hover:not(:disabled), .btn.primary:hover { background: var(--knopf-primaer-hover);
  color: var(--knopf-primaer-text); }
button.icon { width: 30px; padding: 0; }
button.danger { border-color: transparent; background: var(--knopf-rot-flaeche); color: var(--knopf-rot-text); }
button.danger:hover:not(:disabled) { background: var(--bad); border-color: var(--bad); color: var(--on-accent); }
.row-actions { margin-top: 18px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Felder: 30 px wie die Knoepfe, Radius 8, Hover = staerkerer Rand, Fokus = Akzent.
   :where() haelt die Grundregel ohne Spezifitaet. */
label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 6px; }
:where(input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden])), textarea {
  width: 100%; background: var(--field-bg); border: 1px solid var(--field-rand); border-radius: 8px;
  color: var(--ink); font-family: inherit; font-size: 12.5px; transition: border-color .15s; }
:where(input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden])) { height: 30px; padding: 0 12px; }
input::placeholder { color: var(--muted2); }
:where(input, textarea):hover:not(:focus):not(:disabled) { border-color: var(--card4); }
input:focus, textarea:focus { border-color: var(--accent); outline: none; }
input:disabled { opacity: .5; cursor: not-allowed; }
/* Datumsfeld: natives Feld, dunkler Kalender. */
input[type=date] { color-scheme: dark; }
input[type=date]::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }

/* Dateiauswahl: eigenes Feld, das native liegt unsichtbar darueber (Name, Pflicht und
   erlaubte Endungen bleiben am Formular, Klick und Ablegen gehen an das native Feld). */
.file { position: relative; display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 12px 0 0;
  border: 1px solid var(--field-rand); border-radius: 8px; background: var(--field-bg); cursor: pointer;
  transition: border-color .15s; }
.file:hover { border-color: var(--card4); }
.file:has(input:focus-visible) { border-color: var(--accent); }
.file > input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file .file-btn { display: inline-flex; align-items: center; gap: 6px; height: 100%; padding: 0 12px;
  border-right: 1px solid var(--field-rand); color: var(--muted); font-size: 12.5px; font-weight: 500;
  white-space: nowrap; transition: background .15s, color .15s; border-radius: 7px 0 0 7px; }
.file:hover .file-btn { background: var(--knopf-hover); color: var(--ink); }
.file .file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px;
  color: var(--muted2); }
.file.has-file .file-name { color: var(--ink); }

/* Auswahlliste (ui.js ersetzt jedes <select> durch .sel, das native bleibt versteckt
   fuer Wert und Formular). */
.sel { position: relative; display: block; width: 100%; }
.sel > select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.sel-btn { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px;
  width: 100%; height: 30px; min-height: 30px; padding: 0 10px 0 12px; border: 1px solid var(--field-rand);
  border-radius: 8px; background: var(--field-bg); color: var(--ink); font-weight: 400; text-align: left; }
.sel-btn:hover:not(:disabled) { background: var(--field-bg); color: var(--ink); border-color: var(--card4); }
.sel-btn[aria-expanded=true], .sel-btn:focus-visible { border-color: var(--accent); outline: none; }
.sel-btn > .sel-label { overflow: hidden; text-overflow: ellipsis; }
.sel-btn > .ic { color: var(--muted); transition: transform .15s; }
.sel-btn[aria-expanded=true] > .ic { transform: rotate(180deg); }
.sel-pop { position: fixed; z-index: 1300; padding: 4px; background: var(--card); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); max-height: 300px; overflow-y: auto;
  animation: pop-in .1s ease-out; }
.sel-opt { display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 8px; border-radius: 6px;
  font-size: 12.5px; color: var(--ink); cursor: pointer; white-space: nowrap; }
.sel-opt .ic { width: 14px; height: 14px; visibility: hidden; color: var(--accent); }
.sel-opt.hl { background: var(--card3); }
.sel-opt[aria-selected=true] { color: var(--accent); }
.sel-opt[aria-selected=true] .ic { visibility: visible; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* Raster der Formularfelder. */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0 16px; }

/* Positionstabelle: Rand und Kopfzeile wie ARGUS24, ohne Sortierung (die Reihenfolge
   der Zeilen ist die Reihenfolge der Rechnungspositionen). */
.tbl-scroll { overflow-x: auto; margin-top: 4px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 620px; font-size: 12.5px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; text-align: left; }
tr:last-child > td { border-bottom: 0; }
th { color: var(--muted); font-weight: 600; background: var(--bg); }
tr:has(> td) > td { transition: background .15s; }
tr:has(> td):hover > td { background: var(--row-hover); }
td.act { width: 46px; text-align: center; }
/* Felder in der Tabelle haben keine Eigenbreite (width 100 %): jede Spalte bekommt eine
   Mindestbreite fuer ihren laengsten ueblichen Wert (53.43, 2.25000000, Pauschal, 19). */
#lines td:nth-child(2) input { min-width: 84px; }
#lines td:nth-child(3) .sel { min-width: 104px; }
#lines td:nth-child(4) input { min-width: 112px; }
#lines td:nth-child(5) .sel { min-width: 72px; }

/* Hinweise: Kasten mit Rand und Toenung, bleibt stehen (Fehlerlisten muessen lesbar
   bleiben, bis sie korrigiert sind). */
.note { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; margin-bottom: 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-size: 13px; line-height: 1.5; }
.note > .ic { margin-top: 2px; }
.note.ok { border-color: rgba(182,242,67,.45); background: rgba(182,242,67,.07); }
.note.ok > .ic { color: var(--ok); }
.note.err { border-color: var(--bad); background: rgba(255,107,71,.07); }
.note.err > .ic { color: var(--bad); }
.list-err { color: var(--bad); font-size: 13px; }
.list-warn { color: var(--warn); font-size: 13px; }
.hint.err { color: var(--bad); }

/* Ergebnis: Summen und Versand. */
.totals { font-size: 14px; line-height: 1.7; margin: 4px 0 0; }
.totals .big { display: inline-block; margin-top: 4px; font-size: 26px; font-weight: 650; line-height: 1.2;
  color: var(--accent); font-variant-numeric: tabular-nums; }
.send { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.send .row-actions { margin-top: 12px; }
.final-hint { margin-top: 16px; }
.form-hint { margin: 0 0 16px; }
.add-row { margin-top: 10px; }
label.note-label { margin-top: 16px; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--card4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted2); }

/* Handybreite. */
@media (max-width: 640px) {
  .brand { width: auto; padding: 0 14px; }
  .brand img { height: 34px; }
  main.wrap { margin: 16px auto; padding: 0 12px; }
  .card { padding: 16px; }
  .grid, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
