/* ============================================================
   Design-System — Rechnungseingang
   Tokens, Reset, Components
   ============================================================ */

/* ---- §10.2 Farb-Tokens ------------------------------------ */
:root {
  --primary: #2563eb;   --primary-hover: #1d4ed8;
  --btn-bg:  #2563eb;   --btn-bg-hover: #1d4ed8;
  --danger:  #dc2626;   --success: #16a34a;
  --bg:      #f8fafc;   --card: #ffffff;
  --border:  #cbd5e1;   --border-light: #e2e8f0;
  --text:    #1e293b;   --text-muted: #64748b;
  --input-bg: transparent; --input-focus-bg: #ffffff;
  --btn-secondary-bg: #f1f5f9;
  --th-bg:   #dbeafe;   --th-text: #1e3a8a;
  --hover-row: #eff6ff;
  --shadow:  0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --group-bg: #eff6ff;  --group-border: #93c5fd;
  --app-header-h: 48px;
}
[data-theme="dark"] {
  --primary: #3b82f6;   --primary-hover: #2563eb;
  --btn-bg:  #3b82f6;   --btn-bg-hover: #2563eb;
  --danger:  #ef4444;   --success: #22c55e;
  --bg:      #212121;   --card: #292929;
  --border:  #3a4150;   --border-light: #2c3340;
  --text:    #ffffff;   --text-muted: #c4c4cc;
  --input-bg: transparent; --input-focus-bg: #2c3340;
  --btn-secondary-bg: #1e1e1e;
  --th-bg:   #1e3a5f;   --th-text: #93c5fd;
  --hover-row: #333333;
  --shadow:  0 1px 3px rgba(0,0,0,.4);
  --group-bg: #1e3a5f;  --group-border: #3b82f6;
}

/* ---- §10.5 Body-Reset ------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
}
html, body { overscroll-behavior-y: none }

/* ---- §10.4 Container -------------------------------------- */
.container {
  max-width: 1700px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ---- §10.6 App-Header ------------------------------------- */
header.app-header {
  background: linear-gradient(135deg, #1e40af, #2563eb);
  color: #fff;
  padding: .4rem 1.5rem;
  padding-left:  calc(1.5rem + env(safe-area-inset-left,  0px));
  padding-right: calc(1.5rem + env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  position: sticky;
  top: 0;
  z-index: 200;
}
[data-theme="dark"] header.app-header {
  background: linear-gradient(135deg, #18181b, #27272a);
  border-bottom: 1px solid #3f3f46;
}
/* Touch-PWA (iPad) — größerer Header */
@media (display-mode: standalone) and (pointer: coarse) {
  header.app-header {
    padding-top: calc(1.25rem + constant(safe-area-inset-top));
    padding-top: calc(1.25rem + env(safe-area-inset-top, 0px));
    padding-bottom: .6rem;
  }
}
/* iPhone-PWA — überschreibt zurück auf kompakt + safe-area */
@media (display-mode: standalone) and (pointer: coarse) and (max-width: 640px) {
  header.app-header {
    padding-top: constant(safe-area-inset-top);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: .35rem;
  }
}
/* Desktop-PWA (Windows) — pointer: fine, kein Override nötig → Basis-Stil greift */
.hdr-left  { display: flex; align-items: center; gap: .75rem }
.hdr-right { display: flex; align-items: center; gap: .5rem }
.hdr-title { font-size: 1.15rem; font-weight: 600 }
.hdr-sub   { font-size: .78rem; opacity: .75 }

.hdr-btn {
  width: 34px; height: 34px; padding: 0;
  border: none; border-radius: 6px; cursor: pointer;
  background: rgba(128,128,128,.15); color: inherit;
  font-size: .82rem; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
a.hdr-btn { text-decoration: none }
.hdr-btn img { width: 18px; height: 18px; object-fit: contain; display: block }
.hdr-btn svg { width: 16px; height: 16px; fill: currentColor }
.hdr-btn.stroke svg { fill: none; stroke: currentColor; stroke-width: 2;
                       stroke-linecap: round; stroke-linejoin: round }
.theme-icon { display: inline-flex; align-items: center; justify-content: center; line-height: 1 }
.theme-icon svg { width: 16px; height: 16px; display: block }
[data-theme="light"] .theme-icon-dark  { display: none }
[data-theme="dark"]  .theme-icon-light { display: none }
@media (hover: hover) {
  .hdr-btn:hover { background: rgba(128,128,128,.25) }
}

/* ---- Status pill in header ------------------------------- */
.hdr-status {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .35rem .75rem; border-radius: 999px;
  background: rgba(128,128,128,.14);
  color: inherit; text-decoration: none;
  font-size: .8rem; font-weight: 500;
  white-space: nowrap; line-height: 1;
  transition: background .15s;
  max-width: 22rem;
  /* Reset <button> defaults so a <button class="hdr-status">
     looks identical to an <a class="hdr-status">. */
  border: 0; margin: 0; font-family: inherit; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
@media (hover: hover) { .hdr-status:hover { background: rgba(128,128,128,.26) } }
.hdr-status-dot {
  width: .55rem; height: .55rem; border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(255,255,255,0);
}
.hdr-status[data-state="running"] .hdr-status-dot {
  background: #38bdf8;
  animation: hdrPulse 1.4s ease-in-out infinite;
}
.hdr-status[data-state="idle"] .hdr-status-dot     { background: #22c55e }
.hdr-status[data-state="error"] .hdr-status-dot    { background: #f87171 }
.hdr-status[data-state="disabled"] .hdr-status-dot { background: #9ca3af }
.hdr-status[data-state="update"]  .hdr-status-dot  {
  background: #fbbf24;
  animation: hdrPulse 1.8s ease-in-out infinite;
  --hdr-pulse-color: rgba(251,191,36,.7);
}
/* `hidden` attribute is overridden by the inline-flex display on .hdr-status,
   so make it explicit. */
.hdr-status[hidden] { display: none !important }
.hdr-status-text {
  overflow: hidden; text-overflow: ellipsis; max-width: 18rem;
}
.hdr-status-progress {
  font-variant-numeric: tabular-nums;
  font-size: .75rem; opacity: .9;
  padding-left: .35rem; border-left: 1px solid rgba(128,128,128,.35);
  margin-left: .15rem;
}
@keyframes hdrPulse {
  0%   { box-shadow: 0 0 0 0 var(--hdr-pulse-color, rgba(56,189,248,.7)); transform: scale(1) }
  70%  { box-shadow: 0 0 0 9px transparent; transform: scale(1.18) }
  100% { box-shadow: 0 0 0 0 transparent; transform: scale(1) }
}
@media (max-width: 640px) {
  .hdr-status-text { max-width: 9rem }
  .hdr-status-progress { display: none }
}

/* ---- §10.7 Buttons ---------------------------------------- */
.btn {
  padding: .5rem 1.25rem;
  border: 1px solid transparent; border-radius: 8px;
  font-size: .9rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: .4rem;
  text-decoration: none;
  transition: outline .1s, border-color .1s, box-shadow .1s, filter .1s, color .1s;
}
.btn-primary  { background: var(--btn-secondary-bg); color: var(--text); border-color: var(--border) }
.btn-save     { background: var(--btn-secondary-bg); color: var(--text); border-color: var(--border) }
.btn-save:disabled  { background: var(--btn-secondary-bg); color: #94a3b8; border-color: var(--border); cursor: default; outline: none }
.btn-danger   { background: var(--btn-secondary-bg); color: var(--text); border-color: var(--border) }
.btn-secondary {
  background: var(--btn-secondary-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
}
.btn-outline {
  background: var(--btn-secondary-bg); border: 1px solid var(--border);
  color: var(--text); padding: .4rem .8rem;
  font-size: .82rem; font-weight: 500; border-radius: 8px;
}

@media (hover: hover) {
  .btn-primary:hover  { border-color: var(--primary); color: var(--primary) }
  .btn-save:hover     { border-color: var(--success); color: var(--success) }
  .btn-save:disabled:hover { outline: none; filter: none; border-color: var(--border); color: #94a3b8 }
  .btn-danger:hover   { border-color: var(--danger); color: var(--danger) }
  .btn-secondary:hover { border-color: var(--primary); color: var(--primary) }
  .btn-outline:hover  { border-color: var(--primary); color: var(--primary) }
}

/* Action buttons (list rows) */
.action-btn {
  width: auto; min-width: 30px; height: 30px;
  padding: 0 .55rem;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--card); color: var(--text);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  gap: .3rem; font-size: .82rem;
  font-family: inherit;
  transition: border-color .1s, color .1s, filter .1s;
}
.action-btn.icon { width: 30px; padding: 0; font-size: 1rem }
.action-btn.primary { background: var(--btn-bg, var(--primary));
                      border-color: var(--btn-bg, var(--primary)); color: #fff }
.action-btn:disabled { opacity: .5; cursor: not-allowed }

@media (hover: hover) {
  .action-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary) }
  .action-btn.primary:hover:not(:disabled) { filter: brightness(1.08); color: #fff }
}
.action-cell {
  display: flex; align-items: flex-start;
  justify-content: flex-end; flex-wrap: wrap; gap: .3rem;
}
.action-stack {
  display: inline-flex; flex-direction: column; gap: .25rem; min-width: 9rem;
}
.action-stack .action-btn { margin-left: 0; width: 100%; justify-content: center }

/* ---- §10.7b Icon buttons (row icons, edit buttons) -------- */
.row-icon-ph { display: inline-flex; width: 28px; height: 28px; }
.row-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  padding: 0; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--text-muted);
  cursor: pointer; text-decoration: none; font-family: inherit;
  transition: background .12s, color .12s, border-color .12s, transform .1s, box-shadow .12s;
}
.row-icon:hover {
  background: rgba(37,99,235,.09); color: var(--primary);
  border-color: rgba(37,99,235,.2);
  transform: translateY(-1px); box-shadow: 0 2px 6px rgba(37,99,235,.15);
}
.row-icon-sepa:hover {
  background: rgba(22,163,74,.09); color: #16a34a;
  border-color: rgba(22,163,74,.25); box-shadow: 0 2px 6px rgba(22,163,74,.15);
}
.row-icon-danger:hover {
  color: var(--danger); background: rgba(220,38,38,.08);
  border-color: rgba(220,38,38,.25); box-shadow: 0 2px 6px rgba(220,38,38,.15);
}

/* ---- §10.8 Inputs ----------------------------------------- */
.field { display: flex; flex-direction: column; gap: .25rem }
.field label {
  font-size: .7rem; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
}
.field input, .field textarea {
  padding: .45rem .7rem;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: .9rem; background: var(--card); color: var(--text);
  width: 100%; font-family: inherit;
}
.field select { width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,.12);
}
[data-theme="dark"] .field input:focus,
[data-theme="dark"] .field select:focus {
  box-shadow: 0 0 0 2px rgba(96,165,250,.2);
}

/* ---- §10.8b Global select --------------------------------- */
select {
  appearance: none; -webkit-appearance: none;
  background-color: var(--btn-secondary-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6rem center;
  padding: .4rem 2rem .4rem .7rem;
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: .88rem; font-family: inherit;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,.12);
}
[data-theme="dark"] select:focus {
  box-shadow: 0 0 0 2px rgba(96,165,250,.2);
}

/* ---- §10.9 Tabelle ---------------------------------------- */
.table-wrap {
  background: var(--card); border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow); overflow: auto;
}
table {
  width: 100%; border-collapse: collapse;
  font-size: .83rem; table-layout: fixed;
  font-variant-numeric: tabular-nums;
}
thead th {
  background: var(--th-bg);
  padding: .55rem .5rem;
  text-align: left; font-weight: 600;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .5px;
  color: var(--th-text);
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap; overflow: hidden; user-select: none;
}
tbody td {
  padding: .25rem .4rem;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  vertical-align: middle; height: 32px;
}
@media (hover: hover) { tbody tr:hover { background: var(--hover-row) } }
tbody tr.row-active td {
  background: rgba(59,130,246,.06);
  box-shadow: inset 0 0 0 1px rgba(59,130,246,.12);
}
tbody tr.row-active td:first-child {
  box-shadow: inset 2px 0 0 0 var(--primary), inset 0 0 0 1px rgba(59,130,246,.12);
}

/* ---- §10.10 Settings-Modal -------------------------------- */
.s-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 24px 24px;
  z-index: 1500;
  opacity: 0; transition: opacity .15s ease;
  pointer-events: none;
}
.s-modal-overlay.show { opacity: 1; pointer-events: auto; }
.s-modal-overlay[hidden] { display: none !important }
.s-modal {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  width: 100%; max-width: min(1320px, calc(100vw - 48px));
  max-height: calc(100vh - 90px);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
  transform: translateY(8px); transition: transform .15s ease;
}
.s-modal-overlay.show .s-modal { transform: translateY(0) }
.s-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.s-modal-header h2 { margin: 0; font-size: 1.05rem; font-weight: 600 }
.s-modal-close {
  width: 34px; height: 34px; border: none; background: transparent;
  color: var(--text-muted); border-radius: 6px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.s-modal-close:hover { background: var(--hover-row); color: var(--text) }
.s-modal-close svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.s-modal-tabs {
  display: flex; gap: 2px; padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg); overflow-x: auto; flex-shrink: 0;
}
.s-modal-tab {
  background: transparent; border: none;
  padding: 12px 14px; border-bottom: 2px solid transparent;
  cursor: pointer; color: var(--text-muted);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: inherit; text-decoration: none;
}
.s-modal-tab:hover { color: var(--text) }
.s-modal-tab.active { color: var(--primary); border-bottom-color: var(--primary) }
.s-modal-body { padding: 18px 22px 22px; overflow-y: auto; flex: 1 1 auto }
.s-modal-body table { table-layout: auto }
.s-modal-panel { display: none }
.s-modal-panel.active { display: block }

/* Settings sections */
.settings-section {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.settings-section h3 { font-size: 1rem; margin-bottom: .25rem }
.settings-section .section-desc { font-size: .82rem; color: var(--text-muted); margin-bottom: .85rem }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .75rem;
}
.settings-sub {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: .85rem 1rem; margin-top: .75rem;
}
.settings-sub > h4 {
  margin-bottom: .5rem; font-size: .85rem;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px;
}
.settings-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; padding: .5rem 0;
}
.settings-toggle-row .lbl-main  { font-size: .92rem; font-weight: 500 }
.settings-toggle-row .lbl-hint  { font-size: .78rem; color: var(--text-muted); margin-top: .1rem }

/* ---- §10.11 iOS-Switch ------------------------------------ */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0 }
.switch input { opacity: 0; width: 0; height: 0 }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 24px; transition: background .15s;
}
.switch .slider:before {
  content: ''; position: absolute;
  height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--primary) }
.switch input:checked + .slider:before { transform: translateX(18px) }

/* Smaller switch variant used in compact table rows (Users tab) */
.switch-sm { width: 36px; height: 20px; }
.switch-sm .slider:before { height: 14px; width: 14px; left: 3px; top: 3px; }
.switch-sm input:checked + .slider:before { transform: translateX(16px); }

/* ---- §10.11b Settings modal form inputs ------------------- */
#settings-modal-content input[type=text],
#settings-modal-content input[type=password],
#settings-modal-content input[type=email],
#settings-modal-content input[type=number],
#settings-modal-content select {
  width: 100%; padding: .42rem .7rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--input-bg); color: var(--text);
  font-size: .88rem; font-family: inherit;
}
#settings-modal-content input[type=text]:focus,
#settings-modal-content input[type=password]:focus,
#settings-modal-content input[type=email]:focus,
#settings-modal-content input[type=number]:focus,
#settings-modal-content select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,.12);
  background: var(--input-focus-bg);
}

/* ---- §10.12 KPI-Cards ------------------------------------- */
.kpi-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .2rem 0 .6rem }
.kpi-card {
  flex: 1 1 130px; min-width: 120px;
  padding: .45rem .6rem; background: var(--card);
  border-radius: 6px; border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.kpi-card .kpi-label {
  font-size: .66rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em; line-height: 1.1;
}
.kpi-card .kpi-value { font-size: 1rem; font-weight: 700; margin-top: 2px; line-height: 1.15 }
.kpi-card .kpi-sub   { font-size: .66rem; color: var(--text-muted); margin-top: 1px }

/* ---- §10.13 Badges / Pills -------------------------------- */
.pill { font-size: .7rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; display: inline-block }
.einvoice-badge {
  display: inline-block;
  margin-left: .4rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  background: rgba(168,85,247,.14);
  color: #7e22ce;
  border: 1px solid rgba(168,85,247,.3);
  vertical-align: middle;
  white-space: nowrap;
}
[data-theme="dark"] .einvoice-badge { color: #d8b4fe; background: rgba(168,85,247,.18); border-color: rgba(168,85,247,.4) }

.logo-backdrop {
  display: inline-block;
  border-radius: 8px;
  padding: .6rem 1rem;
  transition: background .2s;
}
.logo-backdrop--dark {
  background: #1e3a5f;
}
.paymethod-badge {
  display: inline-block;
  margin-left: 0;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .01em;
  vertical-align: middle;
  white-space: nowrap;
  border: 1px solid transparent;
}
.paymethod-badge--fixed { width: 90px; text-align: center; }
.paymethod-dd { background: rgba(245,158,11,.14);  color: #b45309; border-color: rgba(245,158,11,.3) }
.paymethod-bt { background: rgba(59,130,246,.12);  color: #1d4ed8; border-color: rgba(59,130,246,.3) }
[data-theme="dark"] .paymethod-dd { color: #fbbf24; background: rgba(245,158,11,.18); border-color: rgba(245,158,11,.4) }
[data-theme="dark"] .paymethod-bt { color: #93c5fd; background: rgba(59,130,246,.18); border-color: rgba(59,130,246,.4) }

/* ---- Manual upload (modal drop-zone + full-page overlay) -------- */
.upload-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem 1.25rem;
  margin: .5rem 1.25rem 0;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  outline: none;
}
.upload-drop:hover,
.upload-drop:focus { border-color: var(--primary, #2563eb); color: var(--text); }
.upload-drop.is-over {
  border-color: var(--primary, #2563eb);
  background: rgba(37,99,235,.07);
  color: var(--text);
}
.upload-drop-title { font-size: 1rem; font-weight: 600; color: var(--text) }
.upload-drop-sub   { font-size: .8rem; margin-top: .15rem }

.upload-list {
  margin: 1rem 1.25rem 0;
  display: flex; flex-direction: column; gap: .35rem;
  max-height: 260px; overflow-y: auto;
}
.upload-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem .75rem;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: .85rem;
  transition: background .2s, border-color .2s;
}
.upload-row.is-success { border-color: rgba(22,163,74,.45); background: rgba(22,163,74,.06) }
.upload-row.is-error   { border-color: rgba(220,38,38,.45); background: rgba(220,38,38,.06) }
.upload-spinner {
  display: inline-block;
  width: .85rem; height: .85rem;
  border: 2px solid var(--border);
  border-top-color: var(--primary, #2563eb);
  border-radius: 50%;
  animation: uploadSpin .7s linear infinite;
  vertical-align: middle;
}
@keyframes uploadSpin { to { transform: rotate(360deg) } }
.upload-row-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .78rem;
}
.upload-row-state { display: inline-flex; gap: .5rem; align-items: center; color: var(--text-muted); font-size: .78rem }
.upload-ok  { color: var(--success, #16a34a); font-weight: 600 }
.upload-err { color: var(--danger,  #dc2626); font-weight: 600 }
.upload-link { color: var(--primary, #2563eb); text-decoration: none; font-size: .76rem }
.upload-link:hover { text-decoration: underline }

/* Full-page drag overlay */
.drop-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 5000;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  animation: dropFadeIn .15s ease-out;
}
.drop-overlay[hidden] { display: none }
.drop-overlay-inner {
  background: linear-gradient(135deg, rgba(37,99,235,.95), rgba(124,58,237,.95));
  color: #fff;
  border: 3px dashed rgba(255,255,255,.55);
  border-radius: 22px;
  padding: 3rem 4rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  animation: dropZoomIn .2s cubic-bezier(.34,1.56,.64,1);
}
@keyframes dropFadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes dropZoomIn { from { transform: scale(.85); opacity: 0 } to { transform: scale(1); opacity: 1 } }
@media (max-width: 640px) {
  .drop-overlay-inner { padding: 2rem 1.5rem; border-radius: 16px }
  .drop-overlay-inner div { font-size: 1.15rem !important }
}
.pill-ok   { background: rgba(22,163,74,.12);  color: var(--success) }
.pill-warn { background: rgba(234,179,8,.12);  color: #ca8a04 }
.pill-err  { background: rgba(220,38,38,.12);  color: var(--danger) }
.pill-info { background: rgba(37,99,235,.12);  color: var(--primary) }
.pill-muted{ background: var(--border-light);  color: var(--text-muted) }

/* ---- §10.16 Mobile ---------------------------------------- */
@media (max-width: 640px) {
  .container { padding: 1rem .85rem }
  header.app-header {
    padding: .35rem .75rem;
    padding-top: env(safe-area-inset-top, 0px);
    padding-left:  calc(.75rem + env(safe-area-inset-left,  0px));
    padding-right: calc(.75rem + env(safe-area-inset-right, 0px));
    gap: .4rem;
  }
  .hdr-btn { width: 32px; height: 32px }
  .hdr-title { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
  .hdr-left { gap: .5rem; min-width: 0; flex: 1 }
  .hdr-right { gap: .25rem }
  .s-modal-overlay { padding: 0 }
  .s-modal { border-radius: 0; max-height: 100vh; max-width: none }
}

/* ---- Toast ------------------------------------------------- */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  padding: .75rem 2rem .75rem 1.25rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,.15);
  z-index: 2000; pointer-events: auto;
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  font-size: .9rem; max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0) }
.toast-success { border-left: 3px solid var(--success) }
.toast-error   { border-left: 3px solid var(--danger)  }
.toast-info    { border-left: 3px solid var(--primary) }
.toast-close {
  position: absolute; top: .4rem; right: .5rem;
  background: none; border: none; cursor: pointer;
  font-size: 1.05rem; line-height: 1; padding: .1rem .25rem;
  color: var(--text-muted); border-radius: 4px;
}
.toast-close:hover { background: var(--btn-secondary-bg); color: var(--text); }

/* ---- Comment arrive animation ----------------------------- */
@keyframes comment-arrive {
  0%   { background:rgba(37,99,235,.18); box-shadow:0 0 0 3px rgba(37,99,235,.35); transform:translateY(-4px); opacity:.6; }
  30%  { background:rgba(37,99,235,.12); box-shadow:0 0 0 5px rgba(37,99,235,.18); transform:translateY(0);    opacity:1; }
  100% { background:transparent;         box-shadow:none;                           transform:translateY(0);    opacity:1; }
}
.comment-new {
  animation: comment-arrive 1.8s cubic-bezier(.22,.68,0,1.2) forwards;
  border-radius: 8px;
}

/* ---- Login card ------------------------------------------- */
.login-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  padding: 2rem;
}
.login-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 2.5rem 2rem;
  width: 100%; max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.1);
}
.login-card h1 {
  font-size: 1.4rem; font-weight: 700; margin-bottom: .25rem;
}
.login-card .login-sub { font-size: .85rem; color: var(--text-muted); margin-bottom: 1.75rem }
.login-card .field + .field { margin-top: .85rem }
.login-card .btn { width: 100%; margin-top: 1.25rem; justify-content: center }
.login-logo {
  width: 48px; height: 48px; border-radius: 10px;
  background: linear-gradient(135deg, #1e40af, #2563eb);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1.25rem;
}
.login-logo svg { width: 28px; height: 28px; fill: #fff }

/* ---- Misc -------------------------------------------------- */
.page-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem }
.empty-state {
  text-align: center; padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state svg { width: 56px; height: 56px; opacity: .3; margin-bottom: 1rem; fill: currentColor }
.empty-state h3 { font-size: 1rem; margin-bottom: .4rem; color: var(--text) }
.empty-state p  { font-size: .85rem }

/* ---- Color picker ------------------------------------------ */
input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  padding: 2px;
  border: 1px solid var(--border-light);
  border-radius: 5px;
  cursor: pointer;
  background: var(--card);
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0 }
input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}
input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 3px;
}
@media (hover: hover) {
  input[type="color"]:hover { border-color: var(--border) }
}

/* Health indicator dots */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px }
.dot-ok  { background: var(--success) }
.dot-err { background: var(--danger)  }
.dot-unk { background: var(--text-muted) }
