:root {
  --bg: #0f1216;
  --panel: #171b21;
  --ink: #e7ebf0;
  --muted: #9aa4b2;
  --accent: #3d7eff;
  --accent-ink: #fff;
  --ok: #1f9d55;
  --warn: #b7791f;
  --danger: #c0392b;
  --border: #262c35;
  /* Semantic tokens (default = dark; light theme overrides below). Existing
     names above stay for back-compat; new UI should prefer these. */
  --danger-bg: rgba(192, 57, 43, .12);
  --danger-ink: #f3b0a8;
  --ok-ink: #6fdc9b;
  --warn-ink: #f0c274;
  --muted-chip: #9fb0c3;
  --code-bg: rgba(255, 255, 255, .06);
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

/* Light theme: override the same token names. --muted meets ≥4.5:1 on white. */
[data-theme="light"] {
  --bg: #ffffff;
  --panel: #f4f6f9;
  --ink: #1a1f27;
  --muted: #5b6673;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --ok: #157347;
  --warn: #9a6700;
  --danger: #c0392b;
  --border: #dde1e7;
  --danger-bg: rgba(192, 57, 43, .08);
  --danger-ink: #9c2c2c;
  --ok-ink: #157347;
  --warn-ink: #9a6700;
  --muted-chip: #5b6673;
  --code-bg: rgba(0, 0, 0, .06);
  --shadow: 0 8px 24px rgba(20, 30, 50, .14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  /* Sticky footer: fill the viewport and let <main> grow so the footer is
     pushed to the bottom even on short pages. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.container { flex: 1 0 auto; }

/* Password field with a show/hide eye button. */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 2.6rem; box-sizing: border-box; }
.pw-toggle { position: absolute; top: 50%; right: .4rem; transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center; padding: .3rem;
  background: transparent; border: none; color: var(--muted); cursor: pointer; }
.pw-toggle:hover { color: var(--ink); }
.pw-toggle .eye-off { display: none; }
.pw-toggle.is-shown .eye { display: none; }
.pw-toggle.is-shown .eye-off { display: inline; }

/* Row action icons (buyers / products lists): pencil · eye · X. */
.row-actions { display: inline-flex; gap: .35rem; align-items: center; }
.row-actions form { display: inline; margin: 0; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; padding: 0; border: 1px solid var(--border);
  border-radius: 7px; background: transparent; color: var(--ink); cursor: pointer;
  text-decoration: none;
}
.icon-btn:hover { background: var(--panel); text-decoration: none; }
.icon-btn.icon-danger:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.icon-btn.is-disabled { opacity: .35; cursor: not-allowed; }
.row-hidden td { opacity: .5; }

/* Invoice-detail top action bar: "back" on the left, actions on the right.
   Everything but the primary action is an icon; the primary action keeps its
   expressive text label. */
.detail-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .6rem; flex-wrap: wrap; margin-bottom: 1.2rem;
  padding-bottom: .8rem; border-bottom: 1px solid var(--border);
}
.detail-toolbar-actions { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
/* keep the icon buttons and the text action visually aligned on one line */
.detail-toolbar-actions form { display: inline-flex; margin: 0; }

/* Form submit row: an icon (e.g. PDF preview) next to the primary Save button. */
.form-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

/* Shared "PDF preview" button (macro _pdf_preview_button.html): icon + "PDF"
   label. Single source of truth — same look/text on the form and the detail
   toolbar. */
.pdf-preview-btn { display: inline-flex; align-items: center; gap: .35rem; }

/* Collapsible form section (macro _collapsible.html) — a <details> dressed as a
   .form-section. Summary stands in for the <legend>. OPTIONAL groups only. */
.form-section--toggle { padding: 0; overflow: hidden; }
.form-section--toggle > summary {
  list-style: none; display: flex; align-items: center; gap: .6rem;
  padding: .7rem 1.2rem; cursor: pointer; user-select: none; border-radius: 10px;
  transition: background .12s ease;
}
.form-section--toggle > summary::-webkit-details-marker { display: none; }
.form-section--toggle > summary::marker { content: ""; }
.form-section--toggle > summary:hover { background: var(--panel); }
.form-section--toggle[open] > summary { border-bottom: 1px solid var(--border); border-radius: 10px 10px 0 0; }
.form-section--toggle > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.section-title { flex: 0 1 auto; margin-right: auto; }
.form-section--toggle > summary:hover .section-title { filter: brightness(1.08); }
.section-opt { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: .78rem; color: rgba(255, 255, 255, .8); }
.section-chev { flex: 0 0 auto; color: var(--muted); transition: transform .15s ease; }
.form-section--toggle[open] > summary .section-chev { transform: rotate(90deg); }
/* Filled-count pill: shows the collapsed group actually holds data. */
.section-fill {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.2rem; height: 1.2rem; padding: 0 .4rem; border-radius: 999px;
  font-size: .72rem; font-weight: 700; line-height: 1; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.section-body { padding: .9rem 1.2rem 1.1rem; }
.section-body textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem;
  background: var(--bg); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; font: inherit; resize: vertical;
}

/* Totals summary laid out like the real invoice sheet: a right-aligned block
   with a net subtotal, one row per VAT rate, and an emphasised grand total (or
   the §19 / §13b exemption line). Same look on the live form and the detail
   page — single source of truth for the visual. */
.totals-box { margin: 1.4rem 0; }
.totals-mini {
  width: 100%; max-width: 25rem; margin-left: auto; border-collapse: collapse; font-size: .95rem;
}
.totals-mini td { padding: .32rem .1rem; vertical-align: baseline; }
.totals-mini td:first-child { color: var(--muted); padding-right: 1.5rem; }
.totals-mini td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.totals-mini tr.sub td:first-child { color: var(--ink); }
.totals-mini tr.grand td {
  border-top: 1px solid var(--border); padding-top: .55rem;
  font-weight: 700; font-size: 1.1rem; color: var(--ink);
}
.totals-note {
  max-width: 25rem; margin: .5rem 0 0 auto; text-align: right;
  font-style: italic; color: var(--muted); font-size: .85rem; line-height: 1.4;
}

/* ---- List page (invoices): head, search, segmented filters, table ---- */
.list-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem;
}
.list-head h1 { margin: 0; }
.list-head-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
/* icon + label buttons in the head */
.list-head-actions .btn { display: inline-flex; align-items: center; gap: .45rem; }

.list-controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem 1.5rem; flex-wrap: wrap; margin: 1.25rem 0 1.5rem;
}

/* Search field with a magnifier button living INSIDE the input (no separate
   blue "Search" button). A clear (×) appears left of the magnifier when active. */
.search { position: relative; flex: 1 1 22rem; max-width: 32rem; margin: 0; }
.search input[type=search] {
  width: 100%; margin: 0; padding: .6rem 2.7rem .6rem .95rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--ink); font-size: .95rem;
}
.search input[type=search]:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.search.has-q input[type=search] { padding-right: 4.6rem; }
.search-btn, .search-clear {
  position: absolute; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 7px; border: none;
  background: transparent; color: var(--muted); cursor: pointer; text-decoration: none;
}
.search-btn { right: .35rem; }
.search-clear { right: 2.5rem; }
.search-btn:hover, .search-clear:hover { color: var(--ink); background: var(--bg); }

/* Segmented control replacing the row of big filter buttons. */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
}
.segmented .seg {
  padding: .42rem .9rem; border-radius: 7px; font-size: .9rem; line-height: 1.2;
  color: var(--muted); text-decoration: none; white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.segmented .seg:hover { color: var(--ink); text-decoration: none; }
.segmented .seg.is-active { background: var(--accent); color: var(--accent-ink); }

/* Data table polish: lighter header, row hover, roomier cells. */
.list-table thead th {
  font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border);
}
.list-table th, .list-table td { padding: .7rem .6rem; }
.list-table tbody tr { transition: background .1s ease; }
.list-table tbody tr:hover { background: var(--panel); }
.list-table tbody td { border-bottom: 1px solid var(--border); vertical-align: middle; }
.list-footnote { margin-top: 1.5rem; font-size: .8rem; }
.list-empty { margin: 2rem 0; }

/* Grouped form sections (company / buyer forms): a titled card per group. */
.form-section { border: 1px solid var(--border); border-radius: 10px; padding: .4rem 1.2rem 1.1rem; margin: 0 0 1.2rem; }
/* Section headings as a white-bold pill on the brand accent — expressive,
   reads as "important" at a glance (owner's request). */
.form-section > legend,
.form-section--toggle .section-title {
  background: var(--accent); color: #fff; font-weight: 700; font-size: .82rem;
  text-transform: none; letter-spacing: 0; padding: .22rem .6rem; border-radius: 6px;
}
.form-section > legend { margin-left: -.2rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  background: var(--bg);
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); margin-right: auto; }
.brand span { color: var(--muted); font-weight: 400; margin-left: .4rem; font-size: .85rem; }

/* --- Header: dropdown menus, tools, avatar, theme, burger ------------------ */

.site-header .header-tools { display: flex; align-items: center; gap: .5rem; }

/* Native <details> dropdown shared by nav (burger), language and account. */
.site-header .menu { position: relative; margin: 0; }
.site-header .menu > summary {
  list-style: none; cursor: pointer; color: var(--ink);
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .35rem .6rem; border-radius: 8px; font-size: .9rem;
  border: 1px solid transparent; background: transparent; user-select: none;
}
.site-header .menu > summary::-webkit-details-marker { display: none; }
.site-header .menu > summary::marker { content: ""; }
.site-header .menu > summary:hover { background: var(--panel); }

.site-header .menu-list {
  position: absolute; top: 100%; left: 0; z-index: 1000; margin: .4rem 0 0;
  min-width: 12rem; padding: .35rem; list-style: none;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
}
.site-header .menu-list-right { left: auto; right: 0; }
.site-header .menu-list li { margin: 0; }
.site-header .menu-list a,
.site-header .menu-list button {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  padding: .45rem .6rem; border-radius: 7px; font-size: .9rem;
  color: var(--ink); text-align: left; text-decoration: none;
  background: transparent; border: none; cursor: pointer;
}
.site-header .menu-list a:hover,
.site-header .menu-list button:hover { background: var(--bg); text-decoration: none; }
.site-header .menu-list a.is-current { font-weight: 700; }
.site-header .menu-list .lang-name { flex: 1; }
.site-header .menu-list .lang-abbr,
.site-header .menu-list .check { color: var(--muted); font-size: .8rem; }
.site-header .menu-list .check { color: var(--accent); }
.site-header .menu-email {
  padding: .4rem .6rem; color: var(--muted); font-size: .82rem;
  border-bottom: 1px solid var(--border); margin-bottom: .25rem;
  word-break: break-all; cursor: default;
}
.site-header .menu-list .menu-danger { color: var(--danger); }
.site-header .menu-list .menu-danger:hover { background: var(--danger-bg); }
.site-header .logout-form { margin: 0; }

.site-header .lang-code { font-weight: 600; font-size: .82rem; }

/* Theme toggle switch. Icon chosen by [data-theme] (see below). */
.site-header .theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.1rem; height: 2.1rem; padding: 0; cursor: pointer;
  color: var(--ink); background: transparent;
  border: 1px solid var(--border); border-radius: 8px;
}
.site-header .theme-toggle:hover { background: var(--panel); }
.site-header .theme-toggle .icon-sun { display: none; }
.site-header .theme-toggle .icon-moon { display: inline; }
[data-theme="light"] .site-header .theme-toggle .icon-sun { display: inline; }
[data-theme="light"] .site-header .theme-toggle .icon-moon { display: none; }

/* Avatar = company logo (white backing, valid in both themes) or person icon. */
.site-header .avatar {
  width: 28px; height: 28px; border-radius: 50%; object-fit: contain;
  display: block; background: #fff; border: 1px solid var(--border);
}
.site-header .avatar-icon { background: transparent; border: none; color: var(--ink); }

/* Burger (nav summary): shown only on narrow screens. */
.site-header .burger { border: 1px solid var(--border); }
.burger-icon { display: inline-flex; flex-direction: column; gap: 4px; width: 18px; }
.burger-icon span { height: 2px; background: currentColor; border-radius: 2px; }

/* Narrow screens: nav collapses behind the burger (dropdown, hidden until open). */
.site-header .nav-menu { position: relative; }
.site-header .nav-menu .nav-list { display: none; }
.site-header .nav-menu.is-open .nav-list { display: flex; flex-direction: column; }

/* Wide screens: header is a 3-column grid (brand · nav centered · tools); the
   nav is inline and always visible, the burger is hidden. */
@media (min-width: 761px) {
  .site-header {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  }
  .site-header .brand { margin-right: 0; justify-self: start; }
  .site-header .nav-menu { justify-self: center; position: static; }
  .site-header .header-tools { justify-self: end; }
  .site-header .nav-menu .burger { display: none; }
  .site-header .nav-menu .nav-list {
    display: flex !important; flex-direction: row; align-items: center; gap: .25rem;
    position: static; margin: 0; padding: 0; min-width: 0;
    background: transparent; border: none; box-shadow: none;
  }
  .site-header .nav-menu .nav-list a { padding: .35rem .6rem; }
}

/* Keyboard focus ring on all header controls. */
.site-header summary:focus-visible,
.site-header .theme-toggle:focus-visible,
.site-header .menu-list a:focus-visible,
.site-header .menu-list button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.container { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; }

.hero { text-align: center; padding: 2rem 0 1rem; }
.hero h1 { font-size: 2rem; margin: 0 0 .5rem; }
.lead { color: var(--muted); max-width: 42rem; margin: 0 auto; }

.plans { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 2rem; }
.plan-card {
  flex: 1 1 220px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.5rem; text-align: center;
}
.plan-card h2 { margin: 0 0 .5rem; }
.price { font-size: 1.8rem; font-weight: 700; margin: .25rem 0; }
.price span { font-size: .9rem; color: var(--muted); font-weight: 400; }
.quota { color: var(--muted); margin-bottom: 1rem; }
.plan-card-current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.plan-note { font-size: .8rem; margin-top: .5rem; line-height: 1.4; }
.usage-summary { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.2rem; margin: 1rem 0; }
.usage-summary .progress { max-width: none; }
.pending-banner { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin: 1rem 0; padding: .7rem 1rem; border: 1px solid var(--border); border-radius: 10px; }

.btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 8px; padding: .6rem 1.1rem; font-size: 1rem;
  cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn-danger { background: var(--danger); padding: .35rem .7rem; font-size: .85rem; }
.btn:disabled, .btn.is-disabled { opacity: .5; cursor: not-allowed; filter: none; }

/* Two (or more) inputs side by side, e.g. Street + Nr. */
.field-row { display: flex; gap: .8rem; }
.field-row > label { flex: 1; }

/* A field disabled by JS (e.g. VAT-ID under Kleinunternehmer). */
form input.is-disabled, form input:disabled { opacity: .5; cursor: not-allowed; }

.form-card {
  max-width: 26rem; margin: 1rem auto; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; padding: 1.75rem;
}
.form-card h1 { margin-top: 0; }
form label { display: block; margin-bottom: 1rem; font-size: .9rem; color: var(--muted); }
form input, form select {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem;
  background: var(--bg); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; font-size: 1rem;
}
/* Checkboxes must NOT inherit the full-width block styling above (they would
   stretch and drop onto their own line). Keep them inline, left of the label. */
form input[type=checkbox] {
  display: inline-block; width: auto; margin: 0 .5rem 0 0;
  padding: 0; vertical-align: middle;
}
label.check { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
label.check input[type=checkbox] { margin: 0; flex: 0 0 auto; }
.muted { color: var(--muted); font-size: .9rem; }
.error {
  background: var(--danger-bg); border: 1px solid var(--danger);
  color: var(--danger-ink); padding: .6rem .8rem; border-radius: 8px;
}

.summary { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .8rem 1rem; margin: 1rem 0; }
.summary p { margin: .3rem 0; }

pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .8rem; overflow-x: auto; font-size: .85rem; }
code { background: var(--code-bg); padding: .1rem .35rem; border-radius: 4px; font-size: .9em; }
details { margin: 1rem 0; }
summary { cursor: pointer; color: var(--accent); }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; }
.badge-ok { background: rgba(31,157,85,.18); color: var(--ok-ink); }
.badge-warn { background: rgba(183,121,31,.18); color: var(--warn-ink); }
.badge-danger { background: rgba(200,54,54,.18); color: var(--danger-ink); }
.badge-muted { background: rgba(148,163,184,.16); color: var(--muted-chip); }

.btn-active { outline: 2px solid var(--accent); }
.filters { margin: .5rem 0 1rem; }
.plan-group { margin-top: 2rem; }
.coming-soon { margin-top: 2.5rem; opacity: .8; }
.preview { margin: 1rem 0; padding: .6rem .8rem; background: var(--border); border-radius: 8px; font-size: .95rem; }

.progress { width: 100%; max-width: 420px; height: 12px; background: var(--border); border-radius: 999px; overflow: hidden; margin: .3rem 0 .8rem; }
.progress-bar { height: 100%; background: var(--ok-ink); border-radius: 999px; transition: width .2s; }
.progress-bar-full { background: var(--danger); }

table.keys { width: 100%; border-collapse: collapse; margin-top: .5rem; }
table.keys th, table.keys td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
code.key { word-break: break-all; }

.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .8rem; text-align: center; padding: 1.5rem; }

/* Company logo: interactive top widget (banner -> toolbar -> editor). */
.logo-widget { margin: 0 0 1.2rem; }
.logo-banner { display: flex; align-items: center; justify-content: center; min-height: 90px; padding: 1rem; background: var(--border); border-radius: 10px; cursor: pointer; transition: outline-color .15s; outline: 2px solid transparent; }
.logo-banner:hover, .logo-banner:focus-visible { outline-color: var(--accent, #4a90d9); }
.logo-banner img { max-height: 110px; max-width: 320px; object-fit: contain; }
.logo-banner--empty { color: var(--muted); font-size: .95rem; border: 1px dashed var(--muted); background: transparent; }

/* The [hidden] attribute must beat the explicit display:flex below. */
.logo-toolbar[hidden], .logo-editor[hidden], .logo-confirm[hidden] { display: none; }
.logo-toolbar, .logo-confirm { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; }
.logo-confirm { font-size: .9rem; }
.btn.btn-sm { padding: .35rem .8rem; font-size: .88rem; }
.btn.btn-danger { background: #b23636; }
.btn.btn-danger:hover { background: #9c2c2c; }
.btn.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--ink); }
.btn.btn-ghost:hover { background: var(--border); }

/* Invoice line: read-only description opens a modal editor on click; the ⋮ button
   toggles an expandable detail row that holds the line-level discount fields. */
input.desc-cell { cursor: pointer; width: 100%; min-width: 8rem; text-overflow: ellipsis; }
td.line-actions { white-space: nowrap; text-align: right; }
.line-extra > td { background: var(--panel); padding: .5rem .6rem; }
.line-extra-inner { display: flex; gap: 1.2rem; align-items: flex-end; flex-wrap: wrap; }
.line-extra-inner label { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; color: var(--muted); }

/* Buyer VIES status on the invoice form (cross-border USt-IdNr check). */
.buyer-vies { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: -.2rem 0 .7rem; font-size: .85rem; }
.buyer-vies .bv-info { color: var(--muted); }
.logo-thumb { max-height: 60px; max-width: 160px; object-fit: contain; background: #fff; border-radius: 4px; padding: .2rem; }

.logo-editor { margin-top: .7rem; padding: .9rem; border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; gap: .6rem; }
.logo-drop { display: flex; flex-direction: column; align-items: center; gap: .3rem; justify-content: center; min-height: 78px; padding: 1rem; border: 2px dashed var(--muted); border-radius: 8px; text-align: center; cursor: pointer; color: var(--muted); transition: border-color .15s, background .15s; }
.logo-drop:hover, .logo-drop:focus-visible { border-color: var(--accent, #4a90d9); }
.logo-drop.is-drag { border-color: var(--accent, #4a90d9); background: rgba(74,144,217,.12); }
.logo-drop-file { font-size: .85rem; word-break: break-all; }
.logo-editor-actions { display: flex; gap: .5rem; }
.logo-link-label { display: block; font-size: .9rem; }
.logo-link-label input { display: block; width: 100%; box-sizing: border-box; margin-top: .3rem; }
.logo-link-caption { font-size: .82rem; }

/* Type-ahead picker (static/picker.js): a combobox with a rich candidate list. */
.picker { position: relative; display: block; }
.picker .picker-input { width: 100%; }
.picker-list {
  /* The result panel is decoupled from the (often narrow) input/cell width so
     candidates like "Stunde — Std. (HUR)" read in full. It floats above the
     form, its own width, clamped so it never runs off-screen. */
  position: absolute; z-index: 1000; left: 0; top: 100%;
  min-width: 340px; width: max-content; max-width: min(90vw, 560px);
  margin-top: 2px; max-height: 260px; overflow-y: auto; overflow-x: hidden;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow);
}
.picker-item {
  padding: .4rem .6rem; cursor: pointer; font-size: .9rem;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.picker-item:last-child { border-bottom: none; }
.picker-item.is-active, .picker-item:hover { background: rgba(61,126,255,.18); }
.picker-item .pk-main { color: var(--ink); }
.picker-item .pk-sub { color: var(--muted); font-size: .82rem; margin-left: .35rem; }
.picker-create { color: var(--accent); font-weight: 600; }
/* "Open full list" row — separated from the results, quieter than a match. */
.picker-item.picker-browse-row { border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; }
.picker-error { color: var(--danger-ink); font-size: .82rem; margin-top: .25rem; }

/* Invoice line-item table: keep the dynamic picker cells compact. */
#lines td { vertical-align: top; }
#lines .picker-input { min-width: 5.5rem; }

/* Right-align numeric cells (per-line Netto/Brutto, VAT breakdown). */
td.num, th.num { text-align: right; white-space: nowrap; }

/* Invoice detail: embedded PDF preview + "XML im PDF" viewer. */
/* Service-period end date with a × to clear it (→ single delivery date). */
.date-clear-wrap { display: inline-flex; align-items: center; gap: .4rem; }
.date-clear { display: inline-flex; align-items: center; justify-content: center; padding: .35rem; background: transparent; border: 1px solid var(--border); border-radius: 7px; color: var(--muted); cursor: pointer; }
.date-clear:hover { color: var(--danger); border-color: var(--danger); }
.svc-hint { font-size: .82rem; margin-top: -.5rem; }
/* Service period on one line: "von [date] bis [date] ×", labels inline. */
.svc-row { display: flex; align-items: center; gap: .6rem 1.4rem; flex-wrap: wrap; }
.svc-row .svc-field { display: inline-flex; align-items: center; gap: .5rem; margin: 0; }
.svc-row .svc-field input[type=date] { width: auto; margin: 0; }

/* Liability note: content is the customer's responsibility; einvid guarantees
   format-validity, PDF/A, correct totals and faithful rendering of the input. */
.disclaimer {
  font-size: .8rem; color: var(--muted); line-height: 1.5; margin: 1rem 0;
  padding: .55rem .8rem; border-left: 3px solid var(--border);
  background: var(--panel); border-radius: 0 8px 8px 0;
}
.disclaimer strong { color: var(--ink); font-weight: 600; }

/* Row "⋯" menu (invoice list) — native <details>, enhanced by menu.js. The
   header's .menu styles are scoped to .site-header, so restyle here. */
.row-menu-cell { text-align: right; }
.row-menu { position: relative; display: inline-block; }
.row-menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border: 1px solid var(--border); border-radius: 7px; color: var(--ink); }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu > summary::marker { content: ""; }
.row-menu > summary:hover { background: var(--panel); }
.row-menu .menu-list { position: absolute; top: 100%; right: 0; z-index: 1000; margin: .3rem 0 0; min-width: 12rem; padding: .35rem; list-style: none; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); text-align: left; }
.row-menu .menu-list li { margin: 0; }
.row-menu .menu-list form { margin: 0; }
.row-menu .menu-list a, .row-menu .menu-list button { display: block; width: 100%; padding: .45rem .6rem; border-radius: 7px; font-size: .9rem; color: var(--ink); text-align: left; text-decoration: none; background: transparent; border: none; cursor: pointer; }
.row-menu .menu-list a:hover, .row-menu .menu-list button:hover { background: var(--bg); text-decoration: none; }
.row-menu .menu-list .menu-danger { color: var(--danger); }
.row-menu .menu-list .menu-danger:hover { background: var(--danger-bg); }
.row-menu .menu-list .menu-item-disabled { display: block; padding: .45rem .6rem; font-size: .9rem; color: var(--muted); cursor: not-allowed; }

/* Document list (invoice detail): PDF/XML rows, each with view + download. */
.doc-list td { vertical-align: middle; }
.doc-list .doc-actions { white-space: nowrap; text-align: right; }
.doc-hint { font-size: .8rem; }

/* Document modal — view PDF/XML full-size with its own scroll (no page trap). */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 2vh 2vw; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.modal-box { position: relative; z-index: 1; display: flex; flex-direction: column; width: min(1000px, 96vw); height: 92vh; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.modal-head-actions { display: inline-flex; align-items: center; gap: .5rem; }
.modal-body { flex: 1 1 auto; overflow: auto; background: var(--bg); }
.modal-pdf { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
.modal-body .xmlview { max-height: none; height: 100%; margin: 0; border-radius: 0; box-sizing: border-box; }

/* Entity-picker modal (static/entitypicker.js) — a compact, auto-height dialog
   (unlike the full-size document viewer) with its own scrolling result list. */
.entpick-modal .modal-box { height: auto; max-height: 88vh; width: min(560px, 96vw); }
.entpick-modal .modal-body { padding: 1rem; background: var(--panel); }
.entpick-search { width: 100%; box-sizing: border-box; margin-bottom: .7rem; }
.entpick-list { max-height: 52vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.entpick-row { display: flex; align-items: center; gap: .5rem; padding: .4rem .6rem; border-bottom: 1px solid var(--border); }
.entpick-row:last-child { border-bottom: none; }
.entpick-row:hover { background: rgba(61,126,255,.10); }
.entpick-row.is-hidden { opacity: .5; }
.entpick-main { flex: 1 1 auto; cursor: pointer; white-space: normal; }
.entpick-eye { flex: 0 0 auto; }
.entpick-empty { padding: .7rem; }
.entpick-foot { margin-top: .8rem; }
.entpick-create label { display: block; margin: .4rem 0; }

/* "Browse…" trigger sits inline to the right of a modal-enabled picker input. */
.picker[data-modal="1"] { display: flex; align-items: center; gap: .35rem; }
.picker[data-modal="1"] .picker-input { flex: 1 1 auto; width: auto; }
.picker-browse { flex: 0 0 auto; }

/* Syntax-highlighted e-invoice XML (static/xmlview.js). A code block: kept dark
   in BOTH themes (a code palette reads best dark), mirroring the ERPNext donor. */
.xmlview {
  max-height: 70vh; overflow: auto; margin: .6rem 0 0;
  background: #0e1b32; color: #aebfd8; border-radius: 8px;
  padding: 14px 16px; font-size: 12px; line-height: 1.55;
  white-space: pre; tab-size: 2;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}
/* Element names stand out — bold white on the dark-blue sheet. */
.xmlview .x-tag { color: #ffffff; font-weight: 700; }
.xmlview .x-attr { color: #8fb4ff; }
.xmlview .x-val { color: #a5e075; }
.xmlview .x-decl { color: #6b7c99; }
.xmlview .x-cmt { color: #6b7c99; font-style: italic; }

/* ───── M1 cabinet additions (auth header, small buttons, inline forms) ───── */
.header-nav { display: flex; gap: .75rem; margin-right: auto; margin-left: 1rem; }
.header-nav a { color: var(--muted); text-decoration: none; font-size: .9rem; }
.header-nav a:hover { color: var(--ink); }
.btn-small { padding: .3rem .6rem; font-size: .85rem; }
.inline-form { display: inline; }
.header-tools { display: flex; align-items: center; gap: .6rem; }
.header-tools .muted { font-size: .85rem; }
/* Period/status filter bar of the lines list: one row, inputs only as wide as needed. */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.filters label { color: var(--muted); font-size: .9rem; margin-left: .4rem; }
.filters input, .filters select { width: auto; min-width: 9rem; margin: 0; }
.filters .muted { font-size: .85rem; }
/* Totals of the shown period: a compact box, not a full-width block. */
.totals-box { display: flex; flex-direction: column; align-items: flex-start; max-width: 28rem;
  margin: 1rem 0; padding: .8rem 1rem; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; }
.totals-box .totals-mini { width: 100%; }
.totals-box .totals-note { text-align: left; }

/* Cabinet forms: label in a fixed column, field next to it (einvid .field-row puts
   two whole fields side by side, which squeezes a long German label). */
.cab-form .field-row { display: grid; grid-template-columns: 13rem minmax(0, 1fr);
  align-items: center; gap: .8rem; margin-bottom: .7rem; }
.cab-form .field-row > label { margin: 0; }
.cab-form .field-row > input, .cab-form .field-row > select { margin-top: 0; }
.form-wide { max-width: 72rem; }
/* The per-rate table needs room; on a narrow screen it scrolls instead of squeezing. */
.table-scroll { overflow-x: auto; }
.parts-table { min-width: 56rem; }
.parts-table th { font-size: .75rem; white-space: nowrap; }
.parts-table td { padding: .3rem .35rem; }
.parts-table input, .parts-table select { margin-top: 0; padding: .4rem .45rem; }
.parts-table td:nth-child(1) input { min-width: 6.5rem; }
.parts-table td:nth-child(2) input { min-width: 4.5rem; }
.parts-table td:nth-child(3) select { min-width: 11rem; }
.parts-table td:nth-child(4) select { min-width: 12rem; }
.parts-table td:nth-child(5) input, .parts-table td:nth-child(6) input { min-width: 5rem; }
.parts-table td:nth-child(n+7) input { min-width: 4rem; }
