/* ═══════════════════════════════════════════════════════════════════
   FATURA-KS 2026 — DESIGN SYSTEM (single source of truth)
   ───────────────────────────────────────────────────────────────────
   Replaces & absorbs: design-system.css (old tokens), redesign-2026.css
   (dashboard skin) and emil-polish.css (motion). Load this LAST so it
   is authoritative over any legacy inline <style> blocks.

   Sections:
     1. Tokens            — colours, type, spacing, radius, shadow, motion
     2. Base / reset
     3. Buttons           — .btn + .btn-sm/md/lg + 5 variants (fixed heights)
     4. Cards
     5. Inputs / fields
     6. Badges
     7. Tables (generic)
     8. Utilities
     9. Dashboard skin    — appended below (sidebar / topbar / KPI / lists)
    10. Motion / polish    — appended below
   ═══════════════════════════════════════════════════════════════════ */

/* ── 1. TOKENS ─────────────────────────────────────────────────────────
   Light Skeuomorphic — see pricing-plans-light-skeuomorphic-DESIGN.md.
   Token NAMES are unchanged from the previous system (hundreds of var()
   references across dashboard.html / admin.html depend on these names) —
   only the VALUES were retuned, plus a few additive tokens for the new
   surface/typography language (--surface-2, --font-mono, --sh-inset).
   ──────────────────────────────────────────────────────────────────── */
:root,
[data-theme="modern-light"] {
  /* Surfaces & ink */
  --bg:            #f3f5f8;  /* reference: background */
  --surface:       #ffffff;  /* reference: secondary / card inner */
  --surface-soft:  #f8fafc;  /* light hover tint between surface and surface-2 */
  --surface-2:     #e2e8f0;  /* reference: surface — recessed/inset panel tone */
  --text:          #111827;  /* reference: text-primary */
  --muted:         #4b5563;  /* reference: text-secondary */
  --subtle:        #6b7280;  /* tertiary text, one step lighter than muted */

  /* Hairlines */
  --border:        #e5e7eb;  /* reference: border */
  --border-soft:   #eef0f3;
  --border-strong: #d1d5db;

  /* Brand — blue */
  --brand:         #3b82f6;  /* reference: primary / accent */
  --brand-dark:    #2563eb;  /* hover/active depth */
  --brand-light:   #eff6ff;  /* tint background for active/selected */

  /* Semantic */
  --ok:       #15803d;  --ok-bg:   #ecfdf5;  --ok-bd:   rgba(21,128,61,.18);
  --warn:     #b45309;  --warn-bg: #fffbeb;  --warn-bd: rgba(180,83,9,.18);
  --bad:      #dc2626;  --bad-bg:  #fef2f2;  --bad-bd:  rgba(220,38,38,.18);
  --neutral:  #4b5563;  --neutral-bg: #f1f5f9; --neutral-bd: rgba(75,85,99,.16);
  --success:  #15803d;
  --danger:   #dc2626;
  --accent:   #b45309;

  /* Sidebar (white rail, blue accent) */
  --sidebar-bg:          #ffffff;
  --sidebar-text:        #111827;
  --sidebar-muted:       #4b5563;
  --sidebar-hover:       #f3f5f8;
  --sidebar-active-bg:   rgba(59,130,246,.10);
  --sidebar-active-text: #2563eb;
  --sidebar-border:      #e5e7eb;

  /* Typography — Inter for UI, JetBrains Mono for labels/badges/metadata */
  --font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  /* Spacing scale — 8px base (matches reference base/gap/card-padding: 8 / 16 / 24) */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;

  /* Radius — light skeuomorphic: precise 8px corners (reference: card 8 / control 8 / pill 9999) */
  --r-sm: 8px; --r-md: 10px; --r-lg: 14px; --r-xl: 18px;
  --radius: 8px;

  /* Control radii (buttons / inputs) */
  --r-btn-sm: 8px; --r-btn-md: 8px; --r-btn-lg: 8px;
  --r-pill: 9999px;

  /* Control heights */
  --h-sm: 36px; --h-md: 44px; --h-lg: 52px;

  /* Shadows — soft, realistic skeuomorphic depth (ambient + tight contact shadow) */
  --sh-card:   0 1px 2px rgba(17,24,39,.05), 0 2px 8px rgba(17,24,39,.05);
  --sh-hover:  0 10px 24px rgba(17,24,39,.09), 0 2px 6px rgba(17,24,39,.05);
  --sh-pop:    0 24px 60px rgba(17,24,39,.16), 0 8px 20px rgba(17,24,39,.08);
  --sh-inset:  inset 0 1px 2px rgba(17,24,39,.05);

  /* Layout */
  --sw: 248px;
  --sb-gap: 14px;
  --topbar: 72px;

  /* Motion */
  --ease-ui:     cubic-bezier(0.23, 1, 0.32, 1);
  --ease-pop:    cubic-bezier(0.16, 1, 0.3,  1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ── 2. BASE / RESET ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── 3. BUTTONS ────────────────────────────────────────────────────────
   One scale. Default size = md (44px). Add .btn-sm / .btn-lg to resize.
   Variants: .btn-primary .btn-secondary .btn-ghost .btn-success .btn-danger
   Every button shares: height, padding, radius, font, icon gap, focus ring.
   ──────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--h-md);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--r-btn-md);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color 160ms var(--ease-ui),
    border-color 160ms var(--ease-ui),
    box-shadow 160ms var(--ease-ui),
    color 120ms ease,
    transform 130ms var(--ease-ui);
}
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled, .btn[disabled], .btn[aria-disabled="true"] {
  opacity: .5; cursor: not-allowed; transform: none !important; box-shadow: none;
}
.btn-block { width: 100%; }

/* Sizes */
.btn-sm { height: var(--h-sm); padding: 0 14px; border-radius: var(--r-btn-sm); font-size: 13px; gap: 6px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-md { height: var(--h-md); padding: 0 18px; border-radius: var(--r-btn-md); font-size: 14px; gap: 8px; }
.btn-md svg { width: 18px; height: 18px; }
.btn-lg { height: var(--h-lg); padding: 0 24px; border-radius: var(--r-btn-lg); font-size: 15px; font-weight: 700; gap: 10px; }
.btn-lg svg { width: 20px; height: 20px; }

/* Variant: primary — subtle top-light gradient for a soft tactile (skeuomorphic) press feel */
.btn-primary {
  background: linear-gradient(180deg, #5b95f8 0%, var(--brand) 100%);
  color: #fff; border-color: var(--brand-dark);
  box-shadow: 0 1px 2px rgba(59,130,246,.30), inset 0 1px 0 rgba(255,255,255,.22);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #6aa0f9 0%, var(--brand-dark) 100%);
  border-color: var(--brand-dark);
  box-shadow: 0 4px 14px rgba(59,130,246,.30), inset 0 1px 0 rgba(255,255,255,.22);
}

/* Variant: secondary */
.btn-secondary {
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
  box-shadow: var(--sh-card);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-soft); border-color: #c7ccd4; }

/* Variant: ghost */
.btn-ghost {
  background: transparent; color: var(--muted); border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-soft); color: var(--text); }

/* Variant: success */
.btn-success {
  background: var(--ok); color: #fff; border-color: var(--ok);
  box-shadow: 0 1px 2px rgba(31,146,84,.28);
}
.btn-success:hover:not(:disabled) { background: #1a7d48; border-color: #1a7d48; box-shadow: 0 4px 14px rgba(31,146,84,.26); }

/* Variant: danger */
.btn-danger {
  background: var(--bad); color: #fff; border-color: var(--bad);
  box-shadow: 0 1px 2px rgba(214,69,69,.28);
}
.btn-danger:hover:not(:disabled) { background: #c23b3b; border-color: #c23b3b; box-shadow: 0 4px 14px rgba(214,69,69,.26); }

@media (prefers-reduced-motion: reduce) {
  .btn { transition: background-color 100ms ease, color 100ms ease; }
  .btn:active:not(:disabled) { transform: none; opacity: .85; }
}

/* ── 4. CARDS ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-card);
  padding: var(--space-6);
}
.card-pop { box-shadow: var(--sh-pop); }

/* ── 5. INPUTS / FIELDS ────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label {
  font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: -.01em;
}
.input,
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
  width: 100%;
  height: var(--h-md);
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-btn-md);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.field textarea { height: auto; min-height: 96px; padding: 12px 14px; line-height: 1.5; resize: vertical; }
.input::placeholder,
.field input::placeholder, .field textarea::placeholder { color: var(--subtle); }
.input:focus,
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.14);
}
.input.is-error, .field input.is-error {
  border-color: var(--bad); box-shadow: 0 0 0 3px rgba(214,69,69,.12);
}
.field-error { font-size: 12px; font-weight: 500; color: var(--bad); }

/* ── 6. BADGES ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  min-height: 26px; padding: 0 12px;
  border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: -.005em;
  border: 1px solid transparent;
}
.badge-green,  .badge-success { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-bd); }
.badge-yellow, .badge-warn    { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-bd); }
.badge-red,    .badge-danger  { background: var(--bad-bg);  color: var(--bad);  border-color: var(--bad-bd); }
.badge-gray,   .badge-neutral,
.badge-blue                   { background: var(--neutral-bg); color: var(--neutral); border-color: var(--neutral-bd); }

/* ── 7. TABLES (generic) ───────────────────────────────────────────── */
.table { width: 100%; border-collapse: separate; border-spacing: 0 10px; }
.table thead th {
  background: transparent; border: none;
  color: var(--subtle); font-size: 11px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  padding: 0 18px 2px; text-align: left;
}
.table tbody td {
  background: var(--surface);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 14px 18px; font-size: 13.5px; vertical-align: middle;
}
.table tbody td:first-child { border-left: 1px solid var(--border); border-radius: var(--r-btn-md) 0 0 var(--r-btn-md); }
.table tbody td:last-child  { border-right: 1px solid var(--border); border-radius: 0 var(--r-btn-md) var(--r-btn-md) 0; }
.table tbody tr:hover td { background: var(--surface-soft); border-color: var(--border-strong); }

/* ── 8. UTILITIES ──────────────────────────────────────────────────── */
.ds-stack { display: flex; flex-direction: column; }
.ds-row   { display: flex; align-items: center; }
.ds-gap-2 { gap: 8px; } .ds-gap-3 { gap: 12px; } .ds-gap-4 { gap: 16px; }
.ds-muted { color: var(--muted); } .ds-subtle { color: var(--subtle); }
.tabular  { font-variant-numeric: tabular-nums; }

/* ═══════════════════════════════════════════════════════════════════
   9. DASHBOARD SKIN + 10. MOTION  (appended automatically below)
   ═══════════════════════════════════════════════════════════════════ */



/* ═══════════════════════════════════════════════════════════════════
   3b. DASHBOARD BUTTON OVERRIDE
   The legacy inline <style> in dashboard.html redefines .btn-* up to ~10×
   (black primary, gradient success/danger). These scoped rules re-assert
   the single button system on the dashboard. Safe to delete the inline
   blocks later; until then this keeps every button on-brand & on-scale.
   ═══════════════════════════════════════════════════════════════════ */
[data-theme="modern-light"] .btn {
  height: var(--h-md); padding: 0 18px; border: 1px solid transparent;
  border-radius: var(--r-btn-md); font-family: var(--font);
  font-size: 14px; font-weight: 600; letter-spacing: -.01em; gap: 8px;
  background: var(--surface); color: var(--text);
}
[data-theme="modern-light"] .btn svg { width: 18px; height: 18px; }
[data-theme="modern-light"] .btn-sm { height: var(--h-sm); padding: 0 14px; border-radius: var(--r-btn-sm); font-size: 13px; gap: 6px; }
[data-theme="modern-light"] .btn-lg { height: var(--h-lg); padding: 0 24px; border-radius: var(--r-btn-lg); font-size: 15px; font-weight: 700; gap: 10px; }
[data-theme="modern-light"] .btn-primary   { background: linear-gradient(180deg, #5b95f8 0%, var(--brand) 100%); color: #fff; border-color: var(--brand-dark); box-shadow: 0 1px 2px rgba(59,130,246,.30), inset 0 1px 0 rgba(255,255,255,.22); }
[data-theme="modern-light"] .btn-primary:hover:not(:disabled)   { background: linear-gradient(180deg, #6aa0f9 0%, var(--brand-dark) 100%); border-color: var(--brand-dark); box-shadow: 0 4px 14px rgba(59,130,246,.30), inset 0 1px 0 rgba(255,255,255,.22); }
[data-theme="modern-light"] .btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
[data-theme="modern-light"] .btn-secondary:hover:not(:disabled) { background: var(--surface-soft); border-color: #c7ccd4; }
[data-theme="modern-light"] .btn-ghost     { background: transparent; color: var(--muted); border-color: transparent; }
[data-theme="modern-light"] .btn-ghost:hover:not(:disabled)     { background: var(--surface-soft); color: var(--text); }
[data-theme="modern-light"] .btn-success   { background: var(--ok); color: #fff; border-color: var(--ok); box-shadow: 0 1px 2px rgba(31,146,84,.28); }
[data-theme="modern-light"] .btn-success:hover:not(:disabled)   { background: #1a7d48; border-color: #1a7d48; }
[data-theme="modern-light"] .btn-danger    { background: var(--bad); color: #fff; border-color: var(--bad); box-shadow: 0 1px 2px rgba(214,69,69,.28); }
[data-theme="modern-light"] .btn-danger:hover:not(:disabled)    { background: #c23b3b; border-color: #c23b3b; }


/* ═══ 9. DASHBOARD SKIN (from redesign-2026, deduped) ═══════════════ */
/* ═══════════════════════════════════════════════════════════════════
   Fatura-KS 2026 — REDESIGN 2026 (Calm SaaS)
   Authoritative skin. Loaded LAST so it wins the cascade.
   Visual-only: no markup logic, no data, no workflow changes.
   Scope: shell (sidebar/topbar), Dashboard, Invoices, Statistik, Settings.
   ═══════════════════════════════════════════════════════════════════ */

/* (tokens removed — owned by section 1) */

/* ── 2. BASE ───────────────────────────────────────────────────── */
[data-theme="modern-light"] body,
body.pre-auth {
  background: var(--bg);
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
[data-theme="modern-light"] .gl-bg { background: var(--bg); }

[data-theme="modern-light"] .main {
  margin-left: calc(var(--sw) + var(--sb-gap) * 2);
  background: var(--bg);
}

/* Kill the leftover blue radial glow page wash for a calm flat field */
[data-theme="modern-light"] .stats-hero,
[data-theme="modern-light"] .stats-status,
[data-theme="modern-light"] .chart-card {
  background: var(--surface);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid var(--border);
  box-shadow: var(--sh-card);
}

/* ── 3. SIDEBAR — white, floating, rounded ──────────────────────── */
@media (min-width: 769px) {
  [data-theme="modern-light"] .sidebar {
    top: var(--sb-gap);
    left: var(--sb-gap);
    bottom: var(--sb-gap);
    width: var(--sw);
    height: auto;
    border-radius: var(--r-xl);
    border: 1px solid var(--sidebar-border);
    background: var(--sidebar-bg);
    box-shadow: 0 1px 4px rgba(17,18,22,.06), 0 4px 16px rgba(17,18,22,.06);
    overflow: hidden;
  }
}
[data-theme="modern-light"] .sidebar { color: var(--sidebar-text); }

/* Logo block — left aligned, compact */
[data-theme="modern-light"] .sidebar-logo {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--sidebar-border);
}
[data-theme="modern-light"] .sidebar-logo::before {
  display: none;
  content: "";
}
[data-theme="modern-light"] .sidebar-logo .brand-logo {
  background: transparent;
  max-height: 44px;
  max-width: 160px;
  margin: 0 auto;
  display: block;
}
[data-theme="modern-light"] .sidebar-logo h1 {
  color: var(--text);
  font-size: 15px; font-weight: 700; letter-spacing: -.01em;
  text-align: center;
}
[data-theme="modern-light"] .sidebar-logo p { color: var(--muted); text-align: center; }

/* New button (added at top of nav) — subtle top-light gradient, matches .btn-primary */
.sidebar-new-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  margin: 4px 0 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--brand-dark);
  background: linear-gradient(180deg, #5b95f8 0%, var(--brand) 100%);
  color: #fff;
  font-family: inherit;
  font-size: 14px; font-weight: 700; letter-spacing: -.01em;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .12s;
  box-shadow: 0 2px 8px rgba(59,130,246,.30), inset 0 1px 0 rgba(255,255,255,.22);
}
.sidebar-new-btn:hover { background: linear-gradient(180deg, #6aa0f9 0%, var(--brand-dark) 100%); border-color: var(--brand-dark); transform: translateY(-1px); }
.sidebar-new-btn:active { transform: translateY(0); }
.sidebar-new-btn svg { width: 18px; height: 18px; stroke-width: 2.4; }
.sidebar-new-btn span { white-space: nowrap; }

/* Nav — horizontal rows */
[data-theme="modern-light"] .sidebar-nav {
  flex-direction: column;
  padding: 4px 14px 14px;
  gap: 3px;
}
[data-theme="modern-light"] .nav-btn {
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 13px;
  min-height: 0;
  height: 44px;
  padding: 0 13px;
  border-radius: 12px;
  font-size: 14px; font-weight: 600; letter-spacing: -.01em;
  color: var(--sidebar-muted);
  text-align: left;
  line-height: 1;
}
[data-theme="modern-light"] .nav-btn span {
  white-space: nowrap;
  word-break: normal;
  font-weight: 600;
}
[data-theme="modern-light"] .nav-btn svg { width: 20px; height: 20px; opacity: .7; stroke-width: 1.9; }
/* :hover:not(.active) matches specificity of inline overrides (0,4,0) and wins by source order */
[data-theme="modern-light"] .nav-btn:hover,
[data-theme="modern-light"] .nav-btn:hover:not(.active) {
  background: #f3f6fb;
  color: #111827;
}
[data-theme="modern-light"] .nav-btn:hover svg,
[data-theme="modern-light"] .nav-btn:hover:not(.active) svg {
  opacity: 1;
  color: #2563eb;
}
[data-theme="modern-light"] .nav-btn.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 700;
}
[data-theme="modern-light"] .nav-btn.active svg { opacity: 1; color: var(--sidebar-active-text); }

/* Foot — Settings link + user profile */
[data-theme="modern-light"] .sidebar-foot {
  border-top: 1px solid var(--sidebar-border);
  padding: 12px 14px 16px;
}
.sidebar-foot-link {
  display: flex; align-items: center; gap: 13px;
  width: 100%;
  height: 44px;
  padding: 0 13px;
  margin-bottom: 8px;
  border: none; background: none;
  border-radius: 12px;
  color: var(--sidebar-muted);
  font-family: inherit; font-size: 14px; font-weight: 600; letter-spacing: -.01em;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}
.sidebar-foot-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.sidebar-foot-link svg { width: 20px; height: 20px; opacity: .85; stroke-width: 1.9; flex-shrink: 0; }

/* Hide standalone gear/restore icons (Settings now a labelled row) on desktop */
@media (min-width: 769px) {
  [data-theme="modern-light"] #usersBtn,
  [data-theme="modern-light"] #restoreBtn { display: none; }
  [data-theme="modern-light"] .sidebar-user-row {
    grid-template-columns: minmax(0,1fr) 44px;
    display: grid; gap: 8px; align-items: center;
  }
}

/* User chip — light (white sidebar) */
[data-theme="modern-light"] .user-chip {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  box-shadow: none;
  border-radius: 13px;
  min-height: 48px;
}
[data-theme="modern-light"] .user-chip:hover { background: var(--surface); border-color: var(--border-strong); }
[data-theme="modern-light"] .avatar { background: var(--brand); color: #fff; width: 30px; height: 30px; border-radius: 9px; }
[data-theme="modern-light"] .user-info .name { color: var(--text); font-size: 13.5px; }
[data-theme="modern-light"] .user-info .role { display: block; color: var(--muted); font-size: 11px; }
[data-theme="modern-light"] #logoutBtn,
[data-theme="modern-light"] .suf-btn {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  box-shadow: none;
}
[data-theme="modern-light"] #logoutBtn:hover,
[data-theme="modern-light"] .suf-btn:hover { background: var(--surface); border-color: var(--border-strong); color: var(--text); }

/* ── 4. TOPBAR ─────────────────────────────────────────────────── */
[data-theme="modern-light"] .topbar {
  background: rgba(244,245,247,.78);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: none;
  box-shadow: none;
  height: var(--topbar);
  padding: 0 34px;
}
[data-theme="modern-light"] .topbar-info h2 {
  font-size: 24px; font-weight: 800; letter-spacing: -.035em; color: var(--text);
}
[data-theme="modern-light"] .topbar-info p { font-size: 13.5px; color: var(--muted); margin-top: 2px; }

/* ── 5. PAGE / LAYOUT ──────────────────────────────────────────── */
[data-theme="modern-light"] .page { padding: 16px 34px 40px; }
[data-theme="modern-light"] .sec-hdr { margin-bottom: 14px; }
[data-theme="modern-light"] .sec-hdr h3 { font-size: 18px; font-weight: 800; letter-spacing: -.025em; }

/* ── 6. KPI / STAT CARDS ───────────────────────────────────────── */
[data-theme="modern-light"] .stats {
  gap: 16px;
  margin-bottom: 22px;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
}
[data-theme="modern-light"] .stat {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px 60px;
  box-shadow: var(--sh-card);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: box-shadow .2s, transform .18s, border-color .2s;
}
[data-theme="modern-light"] .stat::before { display: none; } /* remove old left accent bar */
[data-theme="modern-light"] .stat:hover {
  box-shadow: var(--sh-hover);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}
/* decorative sparklines — each card has a distinct shape */
[data-theme="modern-light"] .stat::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 42px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  opacity: .85;
  pointer-events: none;
}
/* Total invoices — steady upward accumulation */
[data-theme="modern-light"] #statCardTotal::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='42' viewBox='0 0 240 42' preserveAspectRatio='none'%3E%3Cpath d='M0 38 L30 36 L60 34 L90 30 L120 26 L150 20 L180 15 L210 10 L240 6' fill='none' stroke='%23c8ccd4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* This month — spiky activity pattern */
[data-theme="modern-light"] #statCardMonth::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='42' viewBox='0 0 240 42' preserveAspectRatio='none'%3E%3Cpath d='M0 30 L20 28 L40 18 L60 32 L80 20 L100 34 L120 12 L140 28 L160 16 L180 30 L200 10 L220 22 L240 14' fill='none' stroke='%23a8d5b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* Total amount — stepped revenue growth */
[data-theme="modern-light"] #statCardAmt::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='42' viewBox='0 0 240 42' preserveAspectRatio='none'%3E%3Cpath d='M0 36 L40 34 L40 28 L80 26 L80 20 L120 18 L120 14 L160 12 L160 8 L200 6 L240 4' fill='none' stroke='%23e8c87a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* Debt — high then declining (debt being paid down) */
[data-theme="modern-light"] #statCardDebt::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='42' viewBox='0 0 240 42' preserveAspectRatio='none'%3E%3Cpath d='M0 8 L30 10 L60 14 L90 12 L120 18 L150 22 L180 26 L210 30 L240 34' fill='none' stroke='%23f0a0a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
[data-theme="modern-light"] .stat .stat-hdr { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
[data-theme="modern-light"] .stat .stat-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
[data-theme="modern-light"] .stat .stat-icon svg { width: 17px; height: 17px; }
[data-theme="modern-light"] .stat-icon-blue  { background: var(--neutral-bg); color: var(--neutral); }
[data-theme="modern-light"] .stat-icon-green { background: var(--ok-bg);  color: var(--ok); }
[data-theme="modern-light"] .stat-icon-amber { background: var(--warn-bg); color: var(--warn); }
[data-theme="modern-light"] .stat-icon-red   { background: var(--bad-bg);  color: var(--bad); }
[data-theme="modern-light"] .stat .lbl {
  font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: -.01em;
  color: var(--muted);
}
[data-theme="modern-light"] .stat .val {
  font-size: 34px; font-weight: 800; letter-spacing: -.04em; margin-top: 0;
  color: var(--text); line-height: 1.05;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
[data-theme="modern-light"] .stat .sub { font-size: 12.5px; color: var(--subtle); margin-top: 6px; font-weight: 500; }

/* ── 7. STATISTIK VIEW ─────────────────────────────────────────── */
[data-theme="modern-light"] .stats-hero {
  border-radius: var(--r-lg);
  padding: 24px 26px;
}
[data-theme="modern-light"] .stats-eyebrow,
[data-theme="modern-light"] .chart-eyebrow {
  color: var(--muted); letter-spacing: .1em; font-size: 11px;
}
[data-theme="modern-light"] .stats-hero h3 { font-size: 26px; letter-spacing: -.035em; }
[data-theme="modern-light"] .stats-kpi-card { border-radius: var(--r-lg); padding: 18px 18px 14px; }
[data-theme="modern-light"] .stats-kpi-card::after { display: none; }
[data-theme="modern-light"] .stats-kpi-card { padding-bottom: 16px; }
[data-theme="modern-light"] .chart-card { border-radius: var(--r-lg); padding: 22px; }
[data-theme="modern-light"] .chart-head h3 { font-size: 17px; font-weight: 800; letter-spacing: -.03em; }
[data-theme="modern-light"] .legend-chip {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text);
}
[data-theme="modern-light"] .stats-refresh-btn,
[data-theme="modern-light"] .stats-control .search-inp { border-radius: 12px; }

/* ── 8. INVOICE LIST → card rows ───────────────────────────────── */
[data-theme="modern-light"] .tbl-wrap {
  background: transparent;
  border: none;
  box-shadow: none;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 0;
  padding-bottom: 4px;
}
/* thin, subtle scrollbar for wide tables (offers/warehouse on small desktops) */
[data-theme="modern-light"] .tbl-wrap::-webkit-scrollbar { height: 8px; }
[data-theme="modern-light"] .tbl-wrap::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
[data-theme="modern-light"] .tbl-wrap::-webkit-scrollbar-track { background: transparent; }
[data-theme="modern-light"] #invTable,
[data-theme="modern-light"] #incomeTable {
  border-collapse: separate;
  border-spacing: 0 10px;
}
[data-theme="modern-light"] #invTable thead th,
[data-theme="modern-light"] #incomeTable thead th {
  background: transparent;
  border: none;
  color: var(--subtle);
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 0 18px 2px;
}
[data-theme="modern-light"] #invTable tbody td,
[data-theme="modern-light"] #incomeTable tbody td {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  font-size: 13.5px;
  vertical-align: middle;
}
[data-theme="modern-light"] #invTable tbody td:first-child,
[data-theme="modern-light"] #incomeTable tbody td:first-child {
  border-left: 1px solid var(--border);
  border-radius: var(--r-md) 0 0 var(--r-md);
}
[data-theme="modern-light"] #invTable tbody td:last-child,
[data-theme="modern-light"] #incomeTable tbody td:last-child {
  border-right: 1px solid var(--border);
  border-radius: 0 var(--r-md) var(--r-md) 0;
}
[data-theme="modern-light"] #invTable tbody tr,
[data-theme="modern-light"] #incomeTable tbody tr {
  transition: transform .15s, box-shadow .15s;
}
[data-theme="modern-light"] #invTable tbody tr:hover td,
[data-theme="modern-light"] #incomeTable tbody tr:hover td {
  background: #fff;
  border-color: var(--border-strong);
}
[data-theme="modern-light"] #invTable tbody tr:hover {
  box-shadow: var(--sh-hover);
}
[data-theme="modern-light"] #invTable tbody tr:last-child td,
[data-theme="modern-light"] #incomeTable tbody tr:last-child td { border-bottom: 1px solid var(--border); }

/* client cell: avatar + two-line */
.inv-client { display: flex; align-items: center; gap: 13px; }
.inv-avatar {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px; font-weight: 700; letter-spacing: -.01em;
}
.invoice-client-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: inherit; text-align: left;
}
.invoice-client-btn .inv-cname { font-size: 14.5px; font-weight: 700; color: var(--text); letter-spacing: -.015em; }
.invoice-client-btn .inv-cnum  { font-size: 12.5px; color: var(--subtle); font-weight: 500; }
.invoice-client-btn:hover .inv-cname { color: var(--text); }

/* drop the now-redundant Nr. column on the invoice list; shift rounding to client cell */
[data-theme="modern-light"] #invTable thead th:first-child,
[data-theme="modern-light"] #invTable tbody td:first-child { display: none; }
@media (min-width: 769px) {
  [data-theme="modern-light"] #invTable tbody td:nth-child(2) {
    border-left: 1px solid var(--border);
    border-radius: var(--r-md) 0 0 var(--r-md);
  }
  [data-theme="modern-light"] #invTable tbody tr:hover td:nth-child(2) { border-color: var(--border-strong); }
}
[data-theme="modern-light"] .invoice-date-cell  { white-space: nowrap; color: var(--muted); }
[data-theme="modern-light"] .invoice-total-cell { white-space: nowrap; font-weight: 700; color: var(--text); font-size: 14.5px; }
[data-theme="modern-light"] .invoice-debt-cell  { white-space: nowrap; font-weight: 600; }

/* status pills */
[data-theme="modern-light"] .badge {
  min-width: 0;
  min-height: 26px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: -.005em;
}
[data-theme="modern-light"] .badge-green  { background: var(--ok-bg);   color: var(--ok);   border: 1px solid var(--ok-bd); }
[data-theme="modern-light"] .badge-yellow { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-bd); }
[data-theme="modern-light"] .badge-red    { background: var(--bad-bg);  color: var(--bad);  border: 1px solid var(--bad-bd); }
[data-theme="modern-light"] .badge-gray   { background: var(--neutral-bg); color: var(--neutral); border: 1px solid var(--neutral-bd); }
[data-theme="modern-light"] .badge-blue   { background: var(--neutral-bg); color: var(--neutral); border: 1px solid var(--neutral-bd); }

/* icon action buttons */
[data-theme="modern-light"] .act-btns { gap: 4px; }
[data-theme="modern-light"] .ic-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}
[data-theme="modern-light"] .ic-btn:hover { background: var(--surface-soft); border-color: var(--border); color: var(--text); }
[data-theme="modern-light"] .ic-btn.del:hover { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-bd); }
[data-theme="modern-light"] .ic-btn svg { width: 16px; height: 16px; }

/* pager */
[data-theme="modern-light"] .pager { margin-top: 6px; }
[data-theme="modern-light"] .pager button {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
}
[data-theme="modern-light"] .pager button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
[data-theme="modern-light"] .pager button:hover:not(:disabled):not(.active) { border-color: var(--border-strong); color: var(--text); }

/* (button rules removed — owned by section 3) */

[data-theme="modern-light"] .search-inp {
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  backdrop-filter: none;
  font-size: 13.5px;
  box-shadow: var(--sh-card);
}
[data-theme="modern-light"] .search-inp:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  background: var(--surface);
}

/* ── 10. MODALS / SETTINGS ─────────────────────────────────────── */
[data-theme="modern-light"] .modal {
  background: var(--surface);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-pop);
}

/* ── 11. RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 768px) {
  [data-theme="modern-light"] .main { margin-left: 0; }
  [data-theme="modern-light"] .sidebar {
    border-radius: 0 var(--r-xl) var(--r-xl) 0;
    width: min(86vw, 320px);
  }
  [data-theme="modern-light"] .page { padding: 14px 16px 36px; }
  [data-theme="modern-light"] .topbar { padding: 0 16px; height: 60px; }
  [data-theme="modern-light"] .topbar-info h2 { font-size: 19px; }
  [data-theme="modern-light"] .stat { padding: 16px 16px 50px; }
  [data-theme="modern-light"] .stat .val { font-size: 26px; }
  [data-theme="modern-light"] .stat::after { height: 34px; }
  [data-theme="modern-light"] .stats { grid-template-columns: 1fr 1fr; gap: 12px; }

  /* invoice list → stacked cards (flex so cells never overlap) */
  [data-theme="modern-light"] #invTable { border-spacing: 0 10px; }
  [data-theme="modern-light"] #invTable thead { display: none; }
  [data-theme="modern-light"] #invTable,
  [data-theme="modern-light"] #invTable tbody,
  [data-theme="modern-light"] #invTable tr { display: block; width: 100%; }
  [data-theme="modern-light"] #invTable tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--sh-card);
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
  }
  [data-theme="modern-light"] #invTable td {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    font-size: 13px;
  }
  [data-theme="modern-light"] #invTable td:first-child { display: none; }              /* Nr */
  [data-theme="modern-light"] #invTable td.invoice-client-cell { flex: 1 1 100%; }      /* client on its own row */
  [data-theme="modern-light"] #invTable td.invoice-status-cell { margin-left: auto; }   /* push status right */
  [data-theme="modern-light"] #invTable td.invoice-actions-cell { flex: 1 1 100%; justify-content: flex-end; }
  [data-theme="modern-light"] #invTable td.invoice-date-cell::before  { content: "Data"; color: var(--subtle); font-weight: 600; }
  [data-theme="modern-light"] #invTable td.invoice-total-cell::before { content: "Total"; color: var(--subtle); font-weight: 600; }
  [data-theme="modern-light"] #invTable td.invoice-debt-cell::before  { content: "Borxh"; color: var(--subtle); font-weight: 600; }
}

/* ═══════════════════════════════════════════════════════════════════
   PHASE 2 — remaining views (Clients, Products, Expenses, Quotes,
   Inventory, Templates, Statistik, Admin) + generic list-card tables
   ═══════════════════════════════════════════════════════════════════ */

/* generic row-lead (avatar + title) used by client / offer rows */
.row-lead { display: flex; align-items: center; gap: 13px; min-width: 0; }
.row-avatar {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px; font-weight: 700; letter-spacing: -.01em;
}
.row-lead-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-lead .row-title { font-size: 14.5px; font-weight: 700; color: var(--text); letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-lead .row-sub   { font-size: 12.5px; color: var(--subtle); font-weight: 500; }
[data-theme="modern-light"] .cell-amount { font-weight: 700; color: var(--text); white-space: nowrap; }

/* ── A. Desktop card-rows for the rest of the list tables ──────── */
[data-theme="modern-light"] #clientsTable,
[data-theme="modern-light"] #articlesTable,
[data-theme="modern-light"] #offersTable,
[data-theme="modern-light"] #warehouseTable,
[data-theme="modern-light"] #warehouseMovesTable,
[data-theme="modern-light"] #shabSavedTable {
  border-collapse: separate;
  border-spacing: 0 10px;
}
[data-theme="modern-light"] #clientsTable thead th,
[data-theme="modern-light"] #articlesTable thead th,
[data-theme="modern-light"] #offersTable thead th,
[data-theme="modern-light"] #warehouseTable thead th,
[data-theme="modern-light"] #warehouseMovesTable thead th,
[data-theme="modern-light"] #shabSavedTable thead th {
  background: transparent; border: none;
  color: var(--subtle); font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 0 18px 2px;
}
[data-theme="modern-light"] #clientsTable tbody td,
[data-theme="modern-light"] #articlesTable tbody td,
[data-theme="modern-light"] #offersTable tbody td,
[data-theme="modern-light"] #warehouseTable tbody td,
[data-theme="modern-light"] #warehouseMovesTable tbody td,
[data-theme="modern-light"] #shabSavedTable tbody td {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 13px 18px;
  font-size: 13.5px;
  vertical-align: middle;
}
[data-theme="modern-light"] #clientsTable tbody td:first-child,
[data-theme="modern-light"] #articlesTable tbody td:first-child,
[data-theme="modern-light"] #offersTable tbody td:first-child,
[data-theme="modern-light"] #warehouseTable tbody td:first-child,
[data-theme="modern-light"] #warehouseMovesTable tbody td:first-child,
[data-theme="modern-light"] #shabSavedTable tbody td:first-child {
  border-left: 1px solid var(--border);
  border-radius: var(--r-md) 0 0 var(--r-md);
}
[data-theme="modern-light"] #clientsTable tbody td:last-child,
[data-theme="modern-light"] #articlesTable tbody td:last-child,
[data-theme="modern-light"] #offersTable tbody td:last-child,
[data-theme="modern-light"] #warehouseTable tbody td:last-child,
[data-theme="modern-light"] #warehouseMovesTable tbody td:last-child,
[data-theme="modern-light"] #shabSavedTable tbody td:last-child {
  border-right: 1px solid var(--border);
  border-radius: 0 var(--r-md) var(--r-md) 0;
}
[data-theme="modern-light"] #clientsTable tbody tr:hover,
[data-theme="modern-light"] #articlesTable tbody tr:hover,
[data-theme="modern-light"] #offersTable tbody tr:hover,
[data-theme="modern-light"] #warehouseTable tbody tr:hover,
[data-theme="modern-light"] #shabSavedTable tbody tr:hover { box-shadow: var(--sh-hover); }
[data-theme="modern-light"] #clientsTable tbody tr:hover td,
[data-theme="modern-light"] #articlesTable tbody tr:hover td,
[data-theme="modern-light"] #offersTable tbody tr:hover td,
[data-theme="modern-light"] #warehouseTable tbody tr:hover td,
[data-theme="modern-light"] #shabSavedTable tbody tr:hover td { border-color: var(--border-strong); }

/* the embedded "expenses/warehouse KPIs" reuse .stats — already styled.
   warehouse KPI cards have no icon; keep sparkline + spacing tidy */
[data-theme="modern-light"] #viewWarehouse .stat,
[data-theme="modern-light"] #viewIncome .stat { min-height: 0; }

/* status text in offers when it is plain (fallback) */
[data-theme="modern-light"] .offer-status { font-weight: 700; }

/* ── B. Empty states ───────────────────────────────────────────── */
[data-theme="modern-light"] .empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  padding: 56px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  color: var(--muted);
  text-align: center;
}
[data-theme="modern-light"] .empty svg {
  width: 40px; height: 40px;
  color: var(--subtle);
  padding: 12px;
  background: var(--surface-soft);
  border-radius: 14px;
  box-sizing: content-box;
}
[data-theme="modern-light"] .empty p { font-size: 14px; font-weight: 600; color: var(--muted); }
[data-theme="modern-light"] .loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 40px; color: var(--muted); font-size: 14px; font-weight: 600;
}

/* ── C. Statistik view — softer, consistent ────────────────────── */
[data-theme="modern-light"] .stats-kpis { gap: 14px; }
[data-theme="modern-light"] .chart-scroll { border-radius: 14px; background: var(--surface-soft); padding: 6px; }
[data-theme="modern-light"] .chart-foot strong { color: var(--text); }
[data-theme="modern-light"] .stats-status { border-radius: var(--r-lg); }
[data-theme="modern-light"] .stats-loading .spin,
[data-theme="modern-light"] .loading .spin {
  border-color: var(--border-strong);
  border-top-color: var(--text);
}

/* ── D. Admin / user-management panel ──────────────────────────── */
[data-theme="modern-light"] #mUsers .modal,
[data-theme="modern-light"] #mUserPerms .modal { max-width: 720px; }
[data-theme="modern-light"] #mUsers h3,
[data-theme="modern-light"] #mUserPerms h3 { font-size: 20px; font-weight: 800; letter-spacing: -.03em; }
[data-theme="modern-light"] #usersBody td {
  background: var(--surface-soft);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
[data-theme="modern-light"] #mUsers table { border-collapse: separate; border-spacing: 0 8px; }
[data-theme="modern-light"] #usersBody td:first-child { border-left: 1px solid var(--border); border-radius: 12px 0 0 12px; }
[data-theme="modern-light"] #usersBody td:last-child { border-right: 1px solid var(--border); border-radius: 0 12px 12px 0; }

/* permission toggle chips/cards inside perms modal — soft */
[data-theme="modern-light"] #mUserPerms label {
  border-radius: 12px;
}

/* inputs inside modals — consistent rounded soft */
[data-theme="modern-light"] .modal input[type="text"],
[data-theme="modern-light"] .modal input[type="password"],
[data-theme="modern-light"] .modal input[type="email"],
[data-theme="modern-light"] .modal input[type="number"],
[data-theme="modern-light"] .modal input[type="date"],
[data-theme="modern-light"] .modal input[type="month"],
[data-theme="modern-light"] .modal select,
[data-theme="modern-light"] .modal textarea {
  border-radius: 11px;
  border: 1px solid var(--border-strong);
}
[data-theme="modern-light"] .modal input:focus,
[data-theme="modern-light"] .modal select:focus,
[data-theme="modern-light"] .modal textarea:focus {
  border-color: #4b5563;
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}

/* ── E. Mobile — stack the rest of the list tables as cards ─────── */
@media (max-width: 768px) {
  [data-theme="modern-light"] #clientsTable,
  [data-theme="modern-light"] #articlesTable,
  [data-theme="modern-light"] #incomeTable,
  [data-theme="modern-light"] #offersTable,
  [data-theme="modern-light"] #warehouseTable,
  [data-theme="modern-light"] #warehouseMovesTable,
  [data-theme="modern-light"] #shabSavedTable { border-spacing: 0 10px; }

  [data-theme="modern-light"] #clientsTable thead,
  [data-theme="modern-light"] #articlesTable thead,
  [data-theme="modern-light"] #incomeTable thead,
  [data-theme="modern-light"] #offersTable thead,
  [data-theme="modern-light"] #warehouseTable thead,
  [data-theme="modern-light"] #warehouseMovesTable thead,
  [data-theme="modern-light"] #shabSavedTable thead { display: none; }

  [data-theme="modern-light"] #clientsTable, [data-theme="modern-light"] #clientsTable tbody, [data-theme="modern-light"] #clientsTable tr,
  [data-theme="modern-light"] #articlesTable, [data-theme="modern-light"] #articlesTable tbody, [data-theme="modern-light"] #articlesTable tr,
  [data-theme="modern-light"] #incomeTable, [data-theme="modern-light"] #incomeTable tbody, [data-theme="modern-light"] #incomeTable tr,
  [data-theme="modern-light"] #offersTable, [data-theme="modern-light"] #offersTable tbody, [data-theme="modern-light"] #offersTable tr,
  [data-theme="modern-light"] #warehouseTable, [data-theme="modern-light"] #warehouseTable tbody, [data-theme="modern-light"] #warehouseTable tr,
  [data-theme="modern-light"] #warehouseMovesTable, [data-theme="modern-light"] #warehouseMovesTable tbody, [data-theme="modern-light"] #warehouseMovesTable tr,
  [data-theme="modern-light"] #shabSavedTable, [data-theme="modern-light"] #shabSavedTable tbody, [data-theme="modern-light"] #shabSavedTable tr { display: block; width: 100%; }

  [data-theme="modern-light"] #clientsTable tr,
  [data-theme="modern-light"] #articlesTable tr,
  [data-theme="modern-light"] #incomeTable tr,
  [data-theme="modern-light"] #offersTable tr,
  [data-theme="modern-light"] #warehouseTable tr,
  [data-theme="modern-light"] #warehouseMovesTable tr,
  [data-theme="modern-light"] #shabSavedTable tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--sh-card);
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  }
  [data-theme="modern-light"] #clientsTable td,
  [data-theme="modern-light"] #articlesTable td,
  [data-theme="modern-light"] #incomeTable td,
  [data-theme="modern-light"] #offersTable td,
  [data-theme="modern-light"] #warehouseTable td,
  [data-theme="modern-light"] #warehouseMovesTable td,
  [data-theme="modern-light"] #shabSavedTable td {
    display: inline-flex; align-items: center; gap: 6px;
    background: transparent !important; border: none !important; border-radius: 0 !important; padding: 0 !important;
    font-size: 13px; color: var(--muted);
  }
  /* primary cell (full width, prominent) per table */
  [data-theme="modern-light"] #clientsTable td:nth-child(1),
  [data-theme="modern-light"] #articlesTable td:nth-child(1),
  [data-theme="modern-light"] #warehouseTable td:nth-child(1),
  [data-theme="modern-light"] #incomeTable td:nth-child(2),
  [data-theme="modern-light"] #offersTable td:nth-child(2),
  [data-theme="modern-light"] #warehouseMovesTable td:nth-child(2),
  [data-theme="modern-light"] #shabSavedTable td:nth-child(3) {
    flex: 1 1 100%; color: var(--text); font-weight: 700; font-size: 14px;
  }
  /* actions cell → full-width, right aligned */
  [data-theme="modern-light"] #clientsTable td:last-child,
  [data-theme="modern-light"] #articlesTable td:last-child,
  [data-theme="modern-light"] #incomeTable td:last-child,
  [data-theme="modern-light"] #offersTable td:last-child,
  [data-theme="modern-light"] #warehouseTable td:last-child,
  [data-theme="modern-light"] #shabSavedTable td:last-child {
    flex: 1 1 100%; justify-content: flex-end; margin-top: 2px;
  }
  /* keep amounts / badges prominent on mobile */
  [data-theme="modern-light"] #incomeTable td:nth-child(3),
  [data-theme="modern-light"] #articlesTable td:nth-child(4),
  [data-theme="modern-light"] #offersTable td:nth-child(6) { margin-left: auto; color: var(--text); font-weight: 700; }
  [data-theme="modern-light"] #offersTable td:nth-child(7) { margin-left: auto; }

  /* declutter very wide warehouse table on phones */
  [data-theme="modern-light"] #warehouseTable td:nth-child(6) { display: none; }   /* Lokacioni */

  /* admin users table → stacked */
  [data-theme="modern-light"] #mUsers table thead { display: none; }
  [data-theme="modern-light"] #mUsers table, [data-theme="modern-light"] #mUsers tbody, [data-theme="modern-light"] #mUsers tr { display: block; width: 100%; }
  [data-theme="modern-light"] #usersBody tr { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin-bottom: 8px; padding: 12px 14px; border-radius: 12px; }
  [data-theme="modern-light"] #usersBody td { display: inline-flex; padding: 0 !important; border: none !important; background: transparent !important; }
  [data-theme="modern-light"] #usersBody td:first-child { flex: 1 1 100%; font-weight: 700; color: var(--text); }
}

/* ═══════════════════════════════════════════════════════════════════
   FINAL QA PASS — overflow safety, alignment, touch, wrapping, Help
   ═══════════════════════════════════════════════════════════════════ */

/* rows sit inside an overflow-x container now → swap lift-shadow on hover
   for a border emphasis so nothing gets vertically clipped */
[data-theme="modern-light"] #invTable tbody tr:hover,
[data-theme="modern-light"] #incomeTable tbody tr:hover,
[data-theme="modern-light"] #clientsTable tbody tr:hover,
[data-theme="modern-light"] #articlesTable tbody tr:hover,
[data-theme="modern-light"] #offersTable tbody tr:hover,
[data-theme="modern-light"] #warehouseTable tbody tr:hover,
[data-theme="modern-light"] #shabSavedTable tbody tr:hover { box-shadow: none; }
[data-theme="modern-light"] #invTable tbody tr:hover td,
[data-theme="modern-light"] #incomeTable tbody tr:hover td,
[data-theme="modern-light"] #clientsTable tbody tr:hover td,
[data-theme="modern-light"] #articlesTable tbody tr:hover td,
[data-theme="modern-light"] #offersTable tbody tr:hover td,
[data-theme="modern-light"] #warehouseTable tbody tr:hover td,
[data-theme="modern-light"] #shabSavedTable tbody tr:hover td {
  background: var(--surface-soft);
  border-color: var(--border-strong);
}

/* amounts: tabular figures everywhere for a clean right edge */
[data-theme="modern-light"] .cell-amount,
[data-theme="modern-light"] .invoice-total-cell,
[data-theme="modern-light"] .invoice-debt-cell,
[data-theme="modern-light"] .stat .val,
[data-theme="modern-light"] .stats-kpi-card .val { font-variant-numeric: tabular-nums; }

/* unify the two avatar variants exactly */
[data-theme="modern-light"] .inv-avatar,
[data-theme="modern-light"] .row-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-soft); border: 1px solid var(--border);
  color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: -.01em;
}

/* neutral / non-interactive Help entry (no route, no feature) */
.sidebar-foot-link--muted { opacity: .5; cursor: default; }
.sidebar-foot-link--muted:hover { background: none; color: var(--sidebar-muted); }

/* ── Mobile final polish (375 / 390 / 430 / tablet) ────────────── */
@media (max-width: 768px) {
  /* long names break cleanly instead of being clipped with ellipsis */
  [data-theme="modern-light"] .row-lead .row-title,
  [data-theme="modern-light"] .invoice-client-btn .inv-cname {
    white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.25;
  }
  [data-theme="modern-light"] .invoice-client-btn { align-items: flex-start; }
  /* larger touch targets for icon actions */
  [data-theme="modern-light"] .ic-btn { width: 40px; height: 40px; }
  [data-theme="modern-light"] .act-btns { gap: 6px; }
  /* amounts/prices wrap safely */
  [data-theme="modern-light"] .cell-amount,
  [data-theme="modern-light"] .invoice-total-cell,
  [data-theme="modern-light"] .invoice-debt-cell { white-space: normal; }
  /* keep the search/filter row from forcing overflow */
  [data-theme="modern-light"] .sec-hdr > div { width: 100%; }
  [data-theme="modern-light"] .sec-hdr .search-inp { flex: 1 1 100%; min-width: 0; }
  /* modals never exceed the viewport */
  [data-theme="modern-light"] .modal { width: calc(100vw - 24px); max-width: calc(100vw - 24px); }
}

/* very small phones (≤390) — single-column KPIs read better */
@media (max-width: 400px) {
  [data-theme="modern-light"] .stats { grid-template-columns: 1fr; }
  [data-theme="modern-light"] .stat .val { font-size: 28px; }
}

/* ── Search right-alignment — push search to trailing edge on all list pages ── */
@media (min-width: 769px) {
  /* Direct search input child of sec-hdr */
  [data-theme="modern-light"] .sec-hdr > .search-inp {
    margin-left: auto;
  }
  /* Wrapper div containing a search input (clients, articles, etc.) */
  [data-theme="modern-light"] .sec-hdr > div:has(> .search-inp) {
    margin-left: auto;
  }
  /* Fallback: any last div child in sec-hdr that has no h3 sibling */
  @supports not selector(:has(*)) {
    [data-theme="modern-light"] .sec-hdr > input.search-inp {
      order: 99;
      margin-left: auto;
    }
    [data-theme="modern-light"] .sec-hdr > div:last-child {
      order: 99;
      margin-left: auto;
    }
  }
}


/* ═══ 10. MOTION / POLISH (from emil-polish, deduped) ═══════════════ */
/* ═══════════════════════════════════════════════════════════════════
   Fatura-KS 2026 — Emil-style UI Polish
   Loaded LAST. Visual-only: no markup/logic/data changes.
   Principles: scale(0.97) press, ease-out custom curve, <300ms,
   @media(hover:hover) guard, prefers-reduced-motion support.
   ═══════════════════════════════════════════════════════════════════ */

/* (easing tokens removed — owned by section 1) */

/* ── 1. DASHBOARD STAT CARDS ─────────────────────────────────── */

/* No lift on hover — stat cards are seen constantly; keep it calm */
[data-theme="modern-light"] .stat {
  transition:
    box-shadow   180ms var(--ease-ui),
    border-color 180ms ease;
}

/* Reset any translateY from base theme */
[data-theme="modern-light"] .stat:hover { transform: none; }

@media (hover: hover) and (pointer: fine) {
  [data-theme="modern-light"] .stat:hover {
    box-shadow: var(--sh-hover);
    border-color: var(--border-strong);
  }
}

/* Inline-style override for liquid-glass stat (dashboard inline block) */
.stat {
  transition:
    box-shadow   180ms var(--ease-ui),
    border-color 180ms ease !important;
}

.stat:hover { transform: none !important; }

/* ── 2. BUTTONS — pressed state + better easing ──────────────── */

/* Base .btn: use custom curve, add active press */
.btn {
  transition:
    transform  160ms var(--ease-ui),
    box-shadow 160ms var(--ease-ui),
    background 160ms ease,
    color      120ms ease !important;
}

.btn:active {
  transform: scale(0.97) !important;
  box-shadow: none !important;
}

/* Primary: keep hover lift, add press sink */
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { transform: translateY(-1px); }
}
.btn-primary:active { transform: scale(0.97) !important; }

/* Ghost / secondary */
.btn-ghost:active,
.btn-secondary:active { transform: scale(0.97) !important; }

/* Success */
.btn-success:active { transform: scale(0.97) !important; }
@media (hover: hover) and (pointer: fine) {
  .btn-success:hover { transform: translateY(-1px); }
}

/* Danger */
.btn-danger:active { transform: scale(0.97) !important; }

/* Sidebar new-invoice button */
.sidebar-new-btn {
  transition:
    background    160ms var(--ease-ui),
    border-color  160ms ease,
    transform     160ms var(--ease-ui) !important;
}
.sidebar-new-btn:active {
  transform: scale(0.97) !important;
}
@media (hover: hover) and (pointer: fine) {
  .sidebar-new-btn:hover { transform: translateY(-1px) !important; }
}

/* Icon buttons in table rows */
[data-theme="modern-light"] .ic-btn {
  transition:
    background   140ms ease,
    border-color 140ms ease,
    color        120ms ease,
    transform    120ms var(--ease-ui);
}
[data-theme="modern-light"] .ic-btn:active {
  transform: scale(0.93);
}

/* Pager buttons */
[data-theme="modern-light"] .pager button {
  transition:
    background   140ms ease,
    border-color 140ms ease,
    color        120ms ease,
    transform    120ms var(--ease-ui);
}
[data-theme="modern-light"] .pager button:active {
  transform: scale(0.94);
}

/* ── 3. SIDEBAR NAVIGATION ───────────────────────────────────── */

/* Nav buttons: custom easing, no-blue active, press state */
[data-theme="modern-light"] .nav-btn {
  transition:
    background   150ms var(--ease-ui),
    color        120ms ease,
    transform    120ms var(--ease-ui);
}

[data-theme="modern-light"] .nav-btn:active {
  transform: scale(0.97);
}

/* Active state uses blue accent */
[data-theme="modern-light"] .nav-btn.active {
  box-shadow: none;
}

/* Settings / help foot links */
.sidebar-foot-link {
  transition:
    background   150ms var(--ease-ui),
    color        120ms ease,
    transform    120ms var(--ease-ui) !important;
}
.sidebar-foot-link:active {
  transform: scale(0.97) !important;
}

/* Logout / suffix buttons */
[data-theme="modern-light"] #logoutBtn,
[data-theme="modern-light"] .suf-btn {
  transition:
    background   150ms ease,
    border-color 150ms ease,
    color        120ms ease,
    transform    120ms var(--ease-ui);
}
[data-theme="modern-light"] #logoutBtn:active,
[data-theme="modern-light"] .suf-btn:active {
  transform: scale(0.96);
}

/* User chip */
[data-theme="modern-light"] .user-chip {
  transition:
    background   150ms ease,
    border-color 150ms ease,
    transform    120ms var(--ease-ui);
}
[data-theme="modern-light"] .user-chip:active {
  transform: scale(0.97);
}

/* ── 4. MODALS — smoother entry, proper scale origin ─────────── */

/* Overlay: keyframe fade-in (display:none → block can't use transitions) */
.overlay.show {
  animation: emilOverlayIn 180ms ease-out both;
}

@keyframes emilOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Modal backdrop */
.modal-bg.show {
  animation: emilBackdropIn 200ms ease-out both !important;
}

@keyframes emilBackdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Modal card: Emil-correct — start from scale(0.95) not scale(0.98) */
.modal-bg.show .modal,
.modal-bg.show .offer-modal,
.modal-bg.show .profile-modal {
  animation: emilModalIn 260ms var(--ease-pop) both !important;
}

@keyframes emilModalIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── 5. PDF PREVIEW TOOLBAR BUTTONS (tbtn) ───────────────────── */

.tbtn {
  transition:
    background   150ms var(--ease-ui),
    box-shadow   150ms var(--ease-ui),
    transform    130ms var(--ease-ui) !important;
}

.tbtn:active {
  transform: scale(0.96) !important;
  box-shadow: none !important;
}

@media (hover: hover) and (pointer: fine) {
  .tbtn-primary:hover { transform: translateY(-1px); }
}

/* ── 6. TOPBAR ACTION BUTTONS ────────────────────────────────── */

/* Hamburger / inline-icon buttons in topbar */
.hamburger {
  transition:
    background 130ms ease,
    transform  120ms var(--ease-ui);
}
.hamburger:active {
  transform: scale(0.92);
}

/* ── 7. INVOICE FORM — totals area + action footer buttons ───── */

/* Act-bar (save / cancel / print row) */
.act-bar .btn {
  transition:
    transform  160ms var(--ease-ui),
    box-shadow 160ms var(--ease-ui),
    background 160ms ease,
    color      120ms ease !important;
}
.act-bar .btn:active {
  transform: scale(0.97) !important;
}

/* Invoice total rows — subtle transition on value change */
.inv-tot-row,
.inv-total-row {
  transition: color 120ms ease;
}

/* ── 8. MOBILE NAV (bottom sheet / mbn) ─────────────────────── */

.mbn-sheet-backdrop.open {
  animation: emilOverlayIn 180ms ease both;
}

/* ── 9. VIEW TRANSITIONS ─────────────────────────────────────── */

/* Nav switching is a frequent action — no transform, no keyframe.
   Opacity-only fade via @starting-style fires when display toggles
   (display:none → visible). Degrades gracefully on older browsers. */
.view {
  transition: opacity 100ms ease-out;
}

@starting-style {
  .view {
    opacity: 0;
  }
}

/* ── 10. PREFERS-REDUCED-MOTION ──────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  /* keep opacity/color transitions, remove transforms & long durations */
  .btn,
  .btn-primary,
  .btn-ghost,
  .btn-secondary,
  .btn-success,
  .btn-danger,
  .sidebar-new-btn,
  .sidebar-foot-link,
  .ic-btn,
  .pager button,
  .nav-btn,
  .tbtn,
  .hamburger,
  .user-chip,
  #logoutBtn,
  .suf-btn {
    transition: background 100ms ease, color 100ms ease !important;
    transform: none !important;
  }

  .btn:active,
  .btn-primary:active,
  .btn-ghost:active,
  .btn-secondary:active,
  .btn-success:active,
  .btn-danger:active,
  .sidebar-new-btn:active,
  .sidebar-foot-link:active,
  .ic-btn:active,
  .pager button:active,
  .nav-btn:active,
  .tbtn:active,
  .hamburger:active,
  .user-chip:active,
  #logoutBtn:active,
  .suf-btn:active {
    transform: none !important;
    opacity: 0.85;
  }

  .stat,
  [data-theme="modern-light"] .stat {
    transition: box-shadow 100ms ease !important;
    transform: none !important;
  }

  /* Disable view transition animation (includes transform) */
  .view,
  .view.active {
    transition: none !important;
    animation: none !important;
  }

  /* Disable modal backdrop fade */
  .modal-bg.show {
    animation: none !important;
    opacity: 1 !important;
  }

  .modal-bg.show .modal,
  .modal-bg.show .offer-modal,
  .modal-bg.show .profile-modal {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ── FINAL AUTHORITATIVE SIDEBAR NAV COLORS ──────────────────────────
   The desktop sidebar is a light/white surface. Several older inline
   rules in dashboard.html (from a previous dark-sidebar design) set
   nav-item hover text to white — invisible on the white sidebar.
   This block is loaded last and is the single source of truth for the
   left-rail nav-item states. Scoped to `.sidebar` so the mobile bottom
   bar (.mobile-bottom-nav .mbn-btn) is unaffected.
   Menu items: Rechnungen, Statistik, Kunden, Artikel, Ausgaben, Lager,
   Angebote, Vorlage. */
.sidebar .nav-btn {
  color: var(--sidebar-muted) !important;          /* non-active: readable gray */
}
.sidebar .nav-btn svg {
  color: var(--sidebar-muted) !important;
  opacity: 1 !important;              /* icon never disappears */
}
.sidebar .nav-btn:hover:not(.active),
.sidebar .nav-btn:focus-visible:not(.active) {
  background: var(--sidebar-hover) !important;     /* subtle light hover surface */
  color: var(--text) !important;                   /* non-active hover: dark, readable */
}
.sidebar .nav-btn:hover:not(.active) svg,
.sidebar .nav-btn:focus-visible:not(.active) svg {
  color: var(--brand) !important;     /* hover icon: brand blue, visible */
  opacity: 1 !important;
}
.sidebar .nav-btn.active {
  background: var(--sidebar-active-bg) !important;   /* light blue background */
  color: var(--sidebar-active-text) !important;       /* active: blue text */
}
.sidebar .nav-btn.active svg {
  color: var(--sidebar-active-text) !important;       /* active: blue icon */
  opacity: 1 !important;
}

/* ═══════════════════════════════════════════════════════════════════
   11. LIGHT SKEUOMORPHIC FINISHING LAYER
   Visual-only additions on top of the redesign-2026 skin above:
   - JetBrains Mono for labels/badges/technical metadata (per design ref)
   - Slightly deeper, more tactile card/stat depth
   - Recessed (surface-2) tone for inset panels
   No markup, class names, IDs or JS hooks are touched by this block.
   ═══════════════════════════════════════════════════════════════════ */

/* Labels, badges, table headers & KPI captions → mono, per design ref */
.badge,
.table thead th,
[data-theme="modern-light"] #invTable thead th,
[data-theme="modern-light"] #incomeTable thead th,
[data-theme="modern-light"] #clientsTable thead th,
[data-theme="modern-light"] #articlesTable thead th,
[data-theme="modern-light"] #offersTable thead th,
[data-theme="modern-light"] #warehouseTable thead th,
[data-theme="modern-light"] #warehouseMovesTable thead th,
[data-theme="modern-light"] #shabSavedTable thead th,
[data-theme="modern-light"] #mUsers table thead th,
[data-theme="modern-light"] .stat .lbl,
[data-theme="modern-light"] .stats-eyebrow,
[data-theme="modern-light"] .chart-eyebrow {
  font-family: var(--font-mono);
  letter-spacing: .04em;
}
.badge {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
}

/* Cards & stat tiles — slightly richer, more "raised" depth */
[data-theme="modern-light"] .card,
.card {
  box-shadow: var(--sh-card);
}
[data-theme="modern-light"] .stat {
  box-shadow: var(--sh-card);
}

/* Recessed / inset surfaces (search fields at rest, chart scroller track) get
   the surface-2 tone for a subtle "well" depth typical of skeuomorphic UI */
[data-theme="modern-light"] .chart-scroll {
  background: var(--surface-2);
}
[data-theme="modern-light"] .legend-chip {
  background: var(--surface-2);
}

/* Secondary buttons — soft surface-2 fill reads as a clear, non-primary action */
[data-theme="modern-light"] .btn-secondary,
.btn-secondary {
  background: var(--surface-2);
}
[data-theme="modern-light"] .btn-secondary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
  background: #d7deea;
}

/* Focus rings — brand blue, consistent everywhere */
.btn:focus-visible,
.input:focus-visible,
[data-theme="modern-light"] .search-inp:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
