/* ═══════════════════════════════════════════════════════════════
   Fatura — Design System
   Mobile-first, sidebar layout
═══════════════════════════════════════════════════════════════ */

:root {
  /* Brand */
  --brand:         #1E5A41;
  --brand-dark:    #163D2C;
  --brand-light:   #2A7A5A;
  --brand-soft:    #E2EDE6;

  /* Neutrals */
  --bg:     #F0F2EB;
  --paper:  #FFFFFF;
  --ink:    #1A2218;
  --muted:  #5C6A5E;
  --line:   #D6DAD0;
  --line-strong: #C4CAC0;

  /* Feedback */
  --danger: #A33B2E;
  --ok:     #1E5A41;
  --warn:   #8A6D1F;

  /* Type */
  --mono:    "IBM Plex Mono", ui-monospace, monospace;
  --display: "Sora", system-ui, sans-serif;
  --body:    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Sidebar */
  --sb-w:          230px;
  --sb-bg:         #18302A;
  --sb-hover:      rgba(255,255,255,.07);
  --sb-active:     rgba(255,255,255,.13);
  --sb-text:       rgba(255,255,255,.68);
  --sb-text-on:    #fff;
  --sb-border:     rgba(255,255,255,.1);

  /* Layout */
  --topbar-h:      56px;
  --radius:        10px;
  --radius-lg:     14px;
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
}
h1, h2, h3 {
  font-family: var(--display);
  letter-spacing: -.01em;
  margin: 0 0 8px;
}
h1 { font-size: 1.4rem; }
h2 { font-size: 1rem;   }
a  { color: var(--brand); text-decoration: none; }


/* ══════════════════════════════════════════════════════════════
   APP SHELL — flex container for sidebar + content
══════════════════════════════════════════════════════════════ */

/* Stretch body so the shell can fill the viewport */
html { height: 100%; }
body { min-height: 100%; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════════ */

.sidebar {
  /* Desktop: sticky flex child — no position:fixed needed */
  width: var(--sb-w);
  flex-shrink: 0;
  background: var(--sb-bg);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  scrollbar-width: none;
  /* transition only for mobile drawer */
  transition: transform .28s cubic-bezier(.4,0,.2,1),
              box-shadow .28s cubic-bezier(.4,0,.2,1);
}
.sidebar::-webkit-scrollbar { display: none; }

/* Brand header */
.sb-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sb-brand-link {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  letter-spacing: -.01em;
}
.sb-close {
  display: none;
  width: 30px; height: 30px;
  background: none; border: none;
  color: rgba(255,255,255,.5);
  font-size: 1rem; cursor: pointer;
  border-radius: 6px; line-height: 1;
  align-items: center; justify-content: center;
}
.sb-close:hover { background: rgba(255,255,255,.1); color: #fff; }

/* Nav area */
.sb-nav {
  flex: 1;
  min-height: 0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sb-nav::-webkit-scrollbar { display: none; }
.sb-section {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  padding: 14px 10px 4px;
}
.sb-divider {
  border: none;
  border-top: 1px solid var(--sb-border);
  margin: 6px 0;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--sb-text);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .1s, color .1s;
  border: none; background: none;
  font-family: var(--body);
  width: 100%; text-align: left;
  line-height: 1.3;
}
.sb-item:hover { background: var(--sb-hover); color: #fff; }
.sb-item.on    {
  background: var(--sb-active);
  color: var(--sb-text-on);
  font-weight: 600;
}
.sb-icon {
  font-size: .95rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  opacity: .75;
}
.sb-item.on .sb-icon,
.sb-item:hover .sb-icon { opacity: 1; }
.sb-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e8a317;
  color: #1a2218;
  font-size: .68rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  flex-shrink: 0;
}
.sb-badge[hidden] { display: none !important; }
.sb-item.on .sb-badge {
  background: #f0c14b;
}

/* Footer: user card */
.sb-footer {
  padding: 8px;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 10px;
}
.sb-avatar {
  width: 32px; height: 32px;
  background: var(--brand-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 700;
  font-size: .9rem; color: #fff; flex-shrink: 0;
}
.sb-user-name {
  font-size: .82rem; font-weight: 600;
  color: rgba(255,255,255,.85);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 150px;
}
.sb-user-role {
  font-size: .68rem;
  color: rgba(255,255,255,.4);
  margin-top: 1px;
}
.sb-logout {
  color: rgba(255,255,255,.45) !important;
  font-size: .84rem !important;
}
.sb-logout:hover { color: rgba(255,255,255,.75) !important; }
.sb-credit {
  text-align: center;
  font-size: .66rem;
  letter-spacing: .02em;
  color: rgba(255,255,255,.32);
  padding: 8px 6px 4px;
}
.sb-credit strong {
  color: rgba(255,255,255,.6);
  font-weight: 600;
}
.auth-credit {
  text-align: center;
  margin-top: 18px;
  font-size: .72rem;
  letter-spacing: .02em;
  color: var(--muted, #94a3b8);
}
.auth-credit strong { font-weight: 700; }

/* Overlay (mobile drawer backdrop) */
.sb-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 250;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.sb-overlay.open { display: block; }


/* ══════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
══════════════════════════════════════════════════════════════ */

.main-content {
  flex: 1;
  min-width: 0;        /* prevent flex overflow */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top bar ──────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
}
.topbar-hamburger {
  display: none;
  background: none; border: none;
  font-size: 1.25rem; cursor: pointer;
  padding: 6px 8px; color: var(--ink);
  border-radius: 8px; line-height: 1; flex-shrink: 0;
}
.topbar-hamburger:hover { background: var(--brand-soft); }
.topbar-back {
  display: none;
  align-items: center;
  gap: 1px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 6px 6px 2px;
  margin-right: -4px;
  color: var(--brand);
  border-radius: 8px;
  flex-shrink: 0;
  font-family: var(--display);
  font-weight: 600;
  line-height: 1;
}
.topbar-back.is-visible { display: flex; }
.topbar-back:hover { background: var(--brand-soft); }
.topbar-back-chevron {
  font-size: 1.5rem;
  line-height: 1;
  margin-top: -2px;
}
.topbar-back-label {
  font-size: .82rem;
  max-width: 84px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-title {
  font-family: var(--display); font-weight: 700;
  font-size: .98rem; color: var(--ink);
  display: none; /* mobile only */
  white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; flex: 1;
}
.topbar-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}

/* ── Page content wrap ────────────────────────────────────────── */
.wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 24px 24px 80px;
  width: 100%;
}
.muted   { color: var(--muted); font-size: .88rem; }
.mono    { font-family: var(--mono); font-variant-numeric: tabular-nums; }


/* ── Search bar ───────────────────────────────────────────────── */
.search-wrap { position: relative; flex: 1; max-width: 400px; }
.search-wrap input {
  width: 100%; padding: 8px 12px 8px 34px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: .9rem; background: var(--bg);
}
.search-wrap::before {
  content: "🔍"; position: absolute;
  left: 9px; top: 50%; transform: translateY(-50%);
  font-size: .82rem; pointer-events: none;
}
.search-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.12);
  max-height: 420px; overflow-y: auto; z-index: 200; display: none;
}
.search-dropdown.open { display: block; }
@media(max-width: 768px) {
  .search-dropdown {
    position: fixed;
    top: 60px;
    left: 8px;
    right: 8px;
    max-height: calc(100vh - 70px);
    z-index: 250;
  }
}
.s-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.s-item:last-child { border: none; }
.s-item:hover { background: var(--brand-soft); }
.s-dot  { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.s-label { font-size: .9rem; font-weight: 600; }
.s-sub   { font-size: .78rem; color: var(--muted); }
.s-none  { padding: 16px; text-align: center; color: var(--muted); font-size: .88rem; }


/* ══════════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font-size: .92rem; cursor: pointer;
  font-family: var(--body); min-height: 38px; text-align: center;
  transition: background .12s, border-color .12s, transform .1s;
  -webkit-appearance: none; white-space: nowrap;
}
.btn:hover  { border-color: var(--brand); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost  { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line); }
.btn-danger:disabled:hover { border-color: var(--danger); }
.btn-sm  { padding: 5px 10px; font-size: .83rem; min-height: 32px; }
.btn-lg  { padding: 12px 22px; font-size: 1rem; min-height: 46px; }
.inline  { display: inline; }
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* FAB — floating action button */
.fab {
  display: none;
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: 20px;
  width: 56px; height: 56px;
  background: var(--brand); color: #fff;
  border-radius: 50%; font-size: 1.75rem; font-weight: 300;
  align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(30,90,65,.45);
  z-index: 90; text-decoration: none;
  border: none; cursor: pointer; font-family: var(--body);
  transition: transform .15s, box-shadow .15s;
}
.fab:active { transform: scale(.93); box-shadow: 0 2px 10px rgba(30,90,65,.3); }


/* ══════════════════════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════════════════════ */

input, select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--body); font-size: 15px;
  background: var(--paper); color: var(--ink);
  -webkit-appearance: none;
  transition: border-color .12s, outline .12s;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand);
}
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field { margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }

/* Compact invoice document fields */
.invoice-doc-card {
  padding: 14px 16px 16px;
}
.invoice-doc-card h2 {
  margin-bottom: 10px;
  font-size: .95rem;
}
.invoice-doc-grid {
  gap: 8px;
}
.invoice-doc-grid + .invoice-doc-grid {
  margin-top: 8px;
}
.invoice-doc-card .field {
  margin: 0;
  padding: 8px 9px;
  border: 1px solid rgba(214,218,208,.72);
  border-radius: 9px;
  background: #FBFCF8;
}
.invoice-doc-card label {
  margin-bottom: 4px;
  font-size: .6rem;
  line-height: 1.1;
  letter-spacing: .045em;
  text-transform: uppercase;
  color: #6C796E;
}
.invoice-doc-card input,
.invoice-doc-card select {
  height: 32px;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: .82rem;
  background: #fff;
}
.invoice-doc-card input::placeholder {
  color: #8D988F;
}


/* ══════════════════════════════════════════════════════════════
   CARDS & PAGE
══════════════════════════════════════════════════════════════ */

.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 { margin: 0; }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .92rem; border: 1px solid; }
.flash-success { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.flash-error   { background: #F7E8E5; border-color: var(--danger); color: var(--danger); }


/* ══════════════════════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════════════════════ */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); padding: 8px 12px;
  border-bottom: 2px solid var(--line); font-weight: 700; white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
.row-link { cursor: pointer; }
.row-link:hover td { background: #F5F7F2; }


/* ══════════════════════════════════════════════════════════════
   INVOICE DETAIL ITEMS TABLE (desktop)
══════════════════════════════════════════════════════════════ */
@media (min-width: 641px) {
  .items-table {
    --items-row-bg: #FFFFFF;
    --items-row-alt: #FBFCF8;
    --items-row-hover: #F3F7EF;
  }

  .table-scroll:has(.items-table) {
    padding: 2px 2px 4px;
  }

  .items-table {
    width: 100%;
    min-width: 820px;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0 5px;
    font-size: .8rem;
    background: transparent;
  }

  .items-table th {
    padding: 0 10px 6px;
    font-size: .62rem;
    letter-spacing: .045em;
    line-height: 1.1;
    color: #6C796E;
    background: transparent;
    border: none;
  }

  .items-table td {
    padding: 8px 10px;
    line-height: 1.25;
    vertical-align: middle;
    border-top: 1px solid rgba(214,218,208,.72);
    border-bottom: 1px solid rgba(214,218,208,.72);
    background: var(--items-row-bg);
  }

  .items-table tbody tr:nth-child(even):not(.items-gjithsej) td {
    background: var(--items-row-alt);
  }

  .items-table tbody tr:hover:not(.items-gjithsej) td {
    background: var(--items-row-hover);
  }

  .items-table tbody tr:not(.items-gjithsej) td:first-child {
    border-left: 1px solid rgba(214,218,208,.72);
    border-radius: 9px 0 0 9px;
  }

  .items-table tbody tr:not(.items-gjithsej) td:last-child {
    border-right: 1px solid rgba(214,218,208,.72);
    border-radius: 0 9px 9px 0;
  }

  .items-table .it-kodi,
  .items-table .it-njesi {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .items-table th,
  .items-table .num {
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
  }

  .items-table .it-desc {
    white-space: normal;
    overflow-wrap: anywhere;
    font-weight: 600;
    color: var(--ink);
  }

  .items-table .it-kodi,
  .items-table .it-njesi {
    color: var(--muted);
  }

  .items-table .it-vlera {
    color: var(--brand);
    font-weight: 800;
  }

  .items-table .it-nr {
    color: var(--muted);
    font-weight: 700;
  }

  .items-table th:nth-child(1), .items-table .it-nr    { width: 5%; }
  .items-table th:nth-child(2), .items-table .it-kodi  { width: 8%; }
  .items-table th:nth-child(3), .items-table .it-desc  { width: 30%; }
  .items-table th:nth-child(4), .items-table .it-sasia { width: 7%; }
  .items-table th:nth-child(5), .items-table .it-njesi { width: 6%; }
  .items-table th:nth-child(6), .items-table .it-cmim  { width: 10%; }
  .items-table th:nth-child(7), .items-table .it-vpa   { width: 11%; }
  .items-table th:nth-child(8), .items-table .it-tvsh  { width: 9%; }
  .items-table th:nth-child(9), .items-table .it-vlera { width: 14%; }

  .items-table .items-gjithsej td {
    padding: 9px;
    background: var(--brand-soft) !important;
    border-top: 1px solid #BFD3C5;
    border-bottom: 1px solid #BFD3C5;
    color: var(--brand-dark);
    font-weight: 800;
  }

  .items-table .items-gjithsej td:first-child {
    border-left: 1px solid #BFD3C5;
    border-radius: 9px 0 0 9px;
  }

  .items-table .items-gjithsej td:last-child {
    border-right: 1px solid #BFD3C5;
    border-radius: 0 9px 9px 0;
  }
}


/* ══════════════════════════════════════════════════════════════
   STATUS & CATEGORY CHIPS
══════════════════════════════════════════════════════════════ */

.status-badge {
  display: inline-block; font-size: .75rem; padding: 3px 10px;
  border-radius: 999px; font-weight: 600; white-space: nowrap;
}
.status-draft   { background: #F3EBD7; color: #8A6D1F; }
.status-derguar { background: var(--brand-soft); color: var(--brand); }

.cat-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.cat-tag { display: inline-flex; align-items: center; font-size: .83rem; color: var(--muted); }
.cat-actions { justify-content: flex-end; flex-wrap: nowrap; }
.cat-edit td { background: var(--brand-soft); }
.cat-edit-form {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
}
.qty-chip {
  display: inline-block; font-family: var(--mono); font-size: .8rem;
  background: var(--brand-soft); color: var(--brand); padding: 1px 7px;
  border-radius: 999px; white-space: nowrap;
}


/* ══════════════════════════════════════════════════════════════
   DASHBOARD STATS
══════════════════════════════════════════════════════════════ */

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px; margin-bottom: 20px;
}
.stat {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.stat .v { font-family: var(--mono); font-size: 1.55rem; font-weight: 500; line-height: 1.1; }
.stat .l { font-size: .78rem; color: var(--muted); margin-top: 4px; }

.bar-row {
  display: grid; grid-template-columns: 160px 1fr 110px;
  gap: 10px; align-items: center; padding: 5px 0; font-size: .88rem;
}
.bar-track { background: var(--bg); border-radius: 5px; height: 14px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 5px; min-width: 2px; }


/* ══════════════════════════════════════════════════════════════
   SCAN ZONE
══════════════════════════════════════════════════════════════ */

.scan-zone {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-lg); padding: 28px 22px;
  text-align: center; background: #FAFBF8;
  transition: border-color .15s, background .15s;
}
.scan-zone.drag { border-color: var(--brand); background: var(--brand-soft); }
.scan-zone-icon { font-size: 2.6rem; display: block; margin-bottom: 10px; line-height: 1; }
.scan-zone h3   { font-family: var(--display); font-size: 1.1rem; margin: 0 0 5px; }
.scan-zone-desc { font-size: .86rem; }
.scan-status    { font-size: .9rem; margin-top: 12px; min-height: 20px; }
.spinner {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .8s linear infinite;
  vertical-align: -3px; margin-right: 5px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scan Loading Overlay ─────────────────────────────────────────────────── */
.scan-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0; /* fallback for browsers without inset */
  inset: 0;
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(26, 34, 24, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden;
  transition: opacity .25s, visibility .25s;
  will-change: opacity;
}
.scan-overlay.active { opacity: 1; visibility: visible; }

.scan-modal {
  background: var(--paper);
  border-radius: 24px;
  padding: 40px 36px 32px;
  width: min(420px, 90vw);
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,.28);
  transform: translateY(12px) scale(.97);
  transition: transform .28s cubic-bezier(.22,1,.36,1);
}
.scan-overlay.active .scan-modal {
  transform: translateY(0) scale(1);
}

/* Document + scan-line animation */
.scan-doc-wrap {
  position: relative;
  display: inline-block;
  width: 80px; height: 100px;
  margin-bottom: 24px;
}
.scan-doc {
  width: 80px; height: 100px;
  background: var(--brand-soft);
  border-radius: 10px;
  border: 2px solid var(--brand-light);
  position: relative;
  overflow: hidden;
}
.scan-doc::before {
  content: '';
  position: absolute; top: 14px; left: 14px; right: 14px; height: 3px;
  background: var(--line); border-radius: 2px;
  box-shadow: 0 9px 0 var(--line), 0 18px 0 var(--line), 0 27px 0 var(--line), 0 36px 0 var(--line), 0 45px 0 var(--line);
}
.scan-line {
  position: absolute; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--brand), var(--brand-light), var(--brand), transparent);
  border-radius: 2px;
  box-shadow: 0 0 10px var(--brand), 0 0 20px rgba(30,90,65,.4);
  animation: scanLine 1.6s ease-in-out infinite;
  top: 0;
}
@keyframes scanLine {
  0%   { top: 0; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.scan-modal-title {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 6px;
}
.scan-modal-sub {
  font-size: .85rem;
  color: var(--muted);
  margin: 0 0 24px;
}

/* Step list */
.scan-steps {
  list-style: none;
  margin: 0; padding: 0;
  text-align: left;
  display: flex; flex-direction: column; gap: 10px;
}
.scan-step {
  display: flex; align-items: center; gap: 12px;
  font-size: .88rem; color: var(--muted);
  transition: color .3s;
}
.scan-step.active { color: var(--ink); font-weight: 600; }
.scan-step.done   { color: var(--ok); }

.step-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
  flex-shrink: 0;
  transition: all .3s;
  background: var(--bg);
}
.scan-step.active .step-icon {
  border-color: var(--brand);
  background: var(--brand-soft);
  animation: stepPulse 1.2s ease-in-out infinite;
}
.scan-step.done .step-icon {
  border-color: var(--ok);
  background: var(--brand-soft);
  font-size: .85rem;
}
@keyframes stepPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(30,90,65,.35); }
  50%      { box-shadow: 0 0 0 6px rgba(30,90,65,0); }
}


/* ══════════════════════════════════════════════════════════════
   FINANCE ITEM GRID (desktop)
══════════════════════════════════════════════════════════════ */

.fin-grid {
  display: grid;
  grid-template-columns: 55px 50px 90px 80px 1fr 50px 70px 60px 80px 90px 80px 90px 36px;
  min-width: 800px;
  gap: 5px; align-items: center; margin-bottom: 5px;
}
.fin-head span {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 700; padding: 3px 2px;
}
.fin-grid input, .fin-grid select { padding: 7px; font-size: .86rem; }
.fin-grid input.mono  { font-family: var(--mono); }
.fin-grid > div       { padding: 0; }
.fin-grid > div input { width: 100%; padding: 7px; font-size: .86rem; box-sizing: border-box; }


/* ══════════════════════════════════════════════════════════════
   MISC COMPONENTS
══════════════════════════════════════════════════════════════ */

.del-item { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 4px; min-height: 0; }
.del-item:hover { color: var(--danger); }
.fld-tax[readonly] { background: var(--bg); color: var(--muted); cursor: default; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.auth-wrap { max-width: 400px; margin: 8vh auto 0; }
.auth-logo { font-family: var(--display); font-weight: 700; font-size: 1.4rem; text-align: center; margin-bottom: 18px; display:flex; flex-direction:column; align-items:center; gap:10px; }
.auth-logo-img { width:56px; height:56px; border-radius:14px; object-fit:cover; box-shadow:0 2px 10px rgba(0,0,0,.12); }
.sb-brand-icon { width:28px; height:28px; border-radius:7px; object-fit:cover; vertical-align:middle; margin-right:6px; }
.branding-preview-row { display:flex; gap:16px; align-items:flex-start; flex-wrap:wrap; }
.branding-preview { width:96px; height:96px; border-radius:22px; object-fit:cover; border:1px solid var(--line); background:var(--bg-subtle,#f4f6f2); flex-shrink:0; }
.receipt-img { max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius); }

/* Catalog autocomplete */
.sup-field { position: relative; }
.cat-drop {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.1); z-index: 50; display: none;
  max-height: 260px; overflow-y: auto;
}
.cat-drop.open { display: block; }
.cat-item {
  display: flex; flex-direction: column; padding: 10px 12px;
  cursor: pointer; border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--ink);
}
.cat-item:last-child { border-bottom: none; }
.cat-item:hover, .cat-item:focus { background: var(--brand-soft); outline: none; }
.cat-item-name { font-size: .88rem; font-weight: 600; }
.cat-item-meta { font-size: .75rem; color: var(--muted); margin-top: 1px; }
.matched-badge { font-size: .72rem; color: var(--brand); padding: 1px 0 4px 2px; grid-column: 1/-1; }

/* Filter grid */
.filter-grid { display: grid; grid-template-columns: repeat(4,1fr) auto; gap: 10px; align-items: end; }


/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (≤ 1024px)
═══════════════════════════════════════════════════════════════ */
@media(max-width: 1024px) {
  :root { --sb-w: 200px; }
  .wrap { padding: 20px 20px 60px; }
  .sb-item { font-size: .85rem; gap: 9px; }
}


/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤ 768px): Drawer layout
═══════════════════════════════════════════════════════════════ */
@media(max-width: 768px) {
  :root { --sb-w: 272px; }

  body { font-size: 16px; }

  /* Sidebar → slide-out drawer (position:fixed restores for mobile) */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    height: auto;
    z-index: 300;
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 40px rgba(0,0,0,.3);
  }
  .sb-close { display: flex; }
  .sb-footer {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  /* Content: takes full width (sidebar is out of flow when fixed) */
  .main-content { min-height: 100vh; }

  /* Topbar: hamburger + search visible, hide title on mobile */
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar-hamburger { display: flex; }
  .topbar-back.is-visible { display: flex; }
  .topbar-back-label { display: none; }
  .topbar-title     { display: none; }  /* Hide title to make room for search */
  .search-wrap { 
    display: flex;
    flex: 1;
    max-width: none;
  }
  .search-wrap input {
    font-size: 0.88rem;
    padding: 7px 10px 7px 30px;
  }
  .topbar-right .btn { 
    padding: 6px 10px;
    font-size: 0.85rem;
  }

  /* Wrap */
  .wrap { padding: 14px 14px calc(88px + env(safe-area-inset-bottom)); }

  /* FAB visible */
  .fab { display: flex; }

  /* Page head */
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-head > a.btn,
  .page-head > .action-bar { width: 100%; }
  .page-head .btn     { flex: 1; justify-content: center; }
  .page-head h1       { font-size: 1.25rem; }

  /* Touch targets */
  .btn     { min-height: 44px; }
  .btn-sm  { min-height: 38px; }
  .btn-lg  { min-height: 52px; }
  .action-bar .btn { flex: 1; }

  /* Cards */
  .card { padding: 14px 14px; border-radius: var(--radius-lg); }

  /* Stats */
  .stats { grid-template-columns: repeat(3,1fr); gap: 8px; }
  .stat  { padding: 12px 12px; }
  .stat .v { font-size: 1.25rem; }
  .stat .l { font-size: .72rem; }

  /* Bar chart */
  .bar-row { grid-template-columns: 100px 1fr 70px; font-size: .8rem; }

  /* Filter grid */
  .filter-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .filter-grid > div:last-child { grid-column: 1/-1; }

  /* Forms */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .invoice-doc-card { padding: 12px; }
  .invoice-doc-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px;
  }
  .invoice-doc-grid + .invoice-doc-grid { margin-top: 6px; }
  .invoice-doc-grid-3 .sup-field {
    grid-column: 1 / -1;
    order: -1;
  }
  .invoice-doc-grid-4 .sup-field {
    grid-column: 1 / -1;
    order: -1;
  }
  .invoice-doc-card .field { padding: 6px 7px; }
  .invoice-doc-card label { margin-bottom: 3px; font-size: .58rem; }
  .invoice-doc-card input,
  .invoice-doc-card select {
    height: 30px;
    padding: 4px 7px;
    font-size: .8rem;
  }
}

@media(max-width: 400px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stats > .stat:last-child { grid-column: 1/-1; }
}


/* ═══════════════════════════════════════════════════════════════
   INVOICE LIST — selection, bulk bar, row actions
═══════════════════════════════════════════════════════════════ */

.inv-list-card { position: relative; }
.inv-list-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: .88rem;
  color: var(--muted);
}

.inv-bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--brand-soft);
  border-bottom: 1px solid #c8ddd2;
  flex-wrap: wrap;
}
.inv-bulk-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}
.inv-bulk-count {
  font-size: .84rem;
  font-weight: 700;
  color: var(--brand);
  white-space: nowrap;
}
.inv-bulk-total {
  font-size: .78rem;
  color: var(--muted);
}
.inv-bulk-total:not(:empty)::before { content: '· '; }
.inv-bulk-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.inv-bulk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 30px;
  padding: 0 10px;
  border: 1.5px solid #b8d4c4;
  border-radius: 7px;
  background: var(--paper);
  color: var(--brand);
  font-size: .78rem;
  font-weight: 600;
  font-family: var(--body);
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
  flex-shrink: 0;
}
.inv-bulk-btn:hover { background: #d4ebe0; }
.inv-bulk-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.inv-bulk-primary:hover { background: var(--brand-light); border-color: var(--brand-light); }
.inv-bulk-danger { color: var(--danger); border-color: #e8c5c0; }
.inv-bulk-danger:hover { background: #fae8e6; border-color: var(--danger); }
.inv-bulk-deselect {
  margin-left: auto;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--brand); cursor: pointer; border-radius: 7px;
  flex-shrink: 0;
  transition: background .1s;
}
.inv-bulk-deselect:hover { background: rgba(30,90,65,.12); }

.inv-cb {
  width: 16px; height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
  vertical-align: middle;
}
.inv-th-check, .inv-check { width: 40px; text-align: center; padding-left: 10px !important; padding-right: 6px !important; }
.inv-th-actions, .inv-actions { width: 1%; white-space: nowrap; text-align: right; padding-right: 8px !important; }

.inv-row.inv-row-selected td { background: #eaf3ee; }
.inv-row:hover .inv-row-actions { opacity: 1; }

.inv-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1px;
  opacity: 0;
  transition: opacity .12s;
}
.inv-act-btn {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: background .1s, color .1s;
}
.inv-act-btn:hover { background: var(--bg); color: var(--ink); }
.inv-act-send:hover { color: var(--brand); background: var(--brand-soft); }
.inv-act-del:hover { color: var(--danger); background: #fdf3f2; }
.inv-inline-form { display: inline-flex; }

.invoice-table { min-width: 680px; }

@media (max-width: 640px) {
  .inv-th-cat, .inv-cat { display: none; }
  .inv-th-actions, .inv-actions { display: none; }
  .inv-nrdok { display: block; font-size: .72rem !important; margin-top: 1px; }
}

/* ═══════════════════════════════════════════════════════════════
   INVOICE LIST CARDS (≤ 640px)
═══════════════════════════════════════════════════════════════ */
@media(max-width: 640px) {
  .invoice-table { min-width: 0 !important; }
  .invoice-table thead { display: none; }
  .invoice-table tbody tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    gap: 4px 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
  }
  .invoice-table tbody tr:active { background: var(--brand-soft); }
  .invoice-table td { border: none; padding: 0; vertical-align: middle; }

  .inv-check  { grid-column: 1; grid-row: 1 / 3; align-self: center; padding: 0 !important; }
  .inv-sup    { grid-column: 2; grid-row: 1; font-weight: 600; font-size: .92rem; align-self: center; }
  .inv-amt    { grid-column: 3; grid-row: 1; font-family: var(--mono); font-weight: 700; font-size: .88rem; text-align: right; align-self: center; }
  .inv-date   { grid-column: 2; grid-row: 2; font-size: .74rem; color: var(--muted); font-family: var(--mono); }
  .inv-status { grid-column: 3; grid-row: 2; justify-self: end; align-self: center; }
  .inv-cat    { display: none; }
}


/* ═══════════════════════════════════════════════════════════════
   FINANCE ITEM GRID — horizontal scroll on mobile
   .fin-grid has min-width:800px so it scrolls inside .table-scroll.
   Hide the header row on phones (too small to read at that size).
   Also hide the Kurs column (always empty) on mobile.
═══════════════════════════════════════════════════════════════ */
@media(max-width: 640px) {
  .fin-head { display: none; }
  .fin-col-kurs,
  .fld-kurs { display: none !important; }
  .fin-grid {
    grid-template-columns: 55px 90px 80px 1fr 50px 70px 60px 80px 90px 80px 90px 36px;
  }
}


/* ═══════════════════════════════════════════════════════════════
   ARTIKUJT TABLE — card layout on mobile (≤ 640px)
   invoice_detail.html: .items-table
   Each row becomes a compact card; header-level columns are hidden
   (Nrdok/Furnitor/Date/Magazina/Kurs already visible in page header).
═══════════════════════════════════════════════════════════════ */
@media(max-width: 640px) {
  .items-table { min-width: 0 !important; }
  .items-table thead { display: none; }

  /* each item row → card */
  .items-table tbody tr:not(.items-gjithsej) {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 3px 10px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
  }
  .items-table td {
    border: none; padding: 0;
    font-size: .78rem;
    display: inline-flex; align-items: baseline; gap: 3px;
  }
  .items-table td::before {
    content: attr(data-label);
    font-size: .6rem; text-transform: uppercase;
    color: var(--muted); font-weight: 700;
    letter-spacing: .04em; white-space: nowrap;
  }

  /* hide invoice-header columns — already shown in page title area */
  .items-table td.it-nrdok,
  .items-table td.it-magazina,
  .items-table td.it-kurs { display: none !important; }

  /* description: full width, bold, no label prefix */
  .items-table td.it-desc {
    width: calc(100% - 48px); font-weight: 600; font-size: .84rem;
    display: block; margin-bottom: 1px;
    order: -1;
  }
  .items-table td.it-desc::before { display: none; }

  .items-table td.it-nr {
    order: -2;
    min-width: 34px;
    justify-content: center;
    font-weight: 700;
    color: var(--brand);
  }

  /* Vlera: full width, right-aligned, bold + accent colour */
  .items-table td.it-vlera {
    width: 100%; justify-content: flex-end;
    font-weight: 700; font-size: .86rem; color: var(--brand);
    margin-top: 2px; border-top: 1px solid var(--line); padding-top: 3px;
  }

  /* GJITHSEJ row — compact summary */
  .items-gjithsej { display: flex !important; flex-wrap: wrap; gap: 3px 10px;
                    justify-content: flex-end; padding: 8px 10px; }
  .items-gjithsej td { display: none; border: none; padding: 0; font-size: .78rem; }
  .items-gjithsej td.gjith-vpa,
  .items-gjithsej td.gjith-tvsh,
  .items-gjithsej td.gjith-vlera {
    display: inline-flex; align-items: baseline; gap: 3px;
  }
  .items-gjithsej td.gjith-vpa::before    { content: "PaTvsh "; font-size: .6rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
  .items-gjithsej td.gjith-tvsh::before   { content: "Tvsh "; font-size: .6rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
  .items-gjithsej td.gjith-vlera::before  { content: "Gjithsej "; font-size: .6rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
  .items-gjithsej td.gjith-vlera { font-weight: 700; color: var(--brand); }
}


/* ═══════════════════════════════════════════════════════════════
   SCAN ZONE (mobile)
═══════════════════════════════════════════════════════════════ */
@media(max-width: 640px) {
  .scan-zone { padding: 30px 16px 22px; border-radius: 16px; }
  .scan-zone-icon { font-size: 3.2rem; }
  .scan-zone h3   { font-size: 1.2rem; }
  .btn-scan-primary {
    width: 100%; padding: 16px; font-size: 1.05rem;
    border-radius: 12px; margin-top: 14px; min-height: 58px; font-weight: 600;
  }
  .btn-scan-secondary {
    width: 100%; padding: 11px; font-size: .95rem;
    border-radius: 10px; margin-top: 8px; min-height: 46px;
  }
  .card.scan-card-done { padding: 8px 12px; }
  .scan-zone.is-scanned {
    padding: 0;
    text-align: left;
    border: 0;
    background: transparent;
  }
  .scan-zone.is-scanned .scan-zone-icon,
  .scan-zone.is-scanned h3,
  .scan-zone.is-scanned .scan-zone-desc,
  .scan-zone.is-scanned .btn-scan-primary,
  .scan-zone.is-scanned .btn-scan-secondary { display: none !important; }
  .scan-zone.is-scanned .scan-status {
    margin: 0;
    min-height: 0;
    font-weight: 600;
    color: var(--brand, #1e5a41);
  }
  .pay-choice-grid { display: none; }
  .pay-choice-select {
    display: block;
    width: 100%;
    min-height: 46px;
    border-radius: 10px;
    border: 1px solid var(--line, #dde5db);
    padding: 0 12px;
    font: inherit;
    font-weight: 600;
    background: #fff;
    color: inherit;
  }
  #payChoiceBox.is-missing .pay-choice-select { border-color: #b42318; }
}



/* ═══════════════════════════════════════════════════════════════
   PRODUCT DETAIL
═══════════════════════════════════════════════════════════════ */

.product-detail-page { padding-bottom: 24px; }
.product-detail-head { flex-direction: column; align-items: flex-start; gap: 8px; }
.product-detail-back {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: 100%;
}
.product-detail-head h1 {
  margin: 0; font-size: 1.35rem; line-height: 1.25; word-break: break-word;
}
.product-detail-card { padding: 0; overflow: hidden; }
.product-kv { display: flex; flex-direction: column; }
.product-kv-row {
  display: grid; grid-template-columns: 110px 1fr; gap: 10px 14px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: start;
}
.product-kv-row:last-child { border-bottom: none; }
.product-kv-row-full { grid-template-columns: 1fr; gap: 8px; }
.product-kv-label {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted);
}
.product-kv-value { font-size: .95rem; word-break: break-word; }
.product-alias-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.alias-tag {
  display: inline-block; font-size: .8rem; padding: 4px 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink);
}
.product-detail-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.product-detail-actions form.inline { display: inline-flex; flex: 1; min-width: 120px; }
.product-detail-actions .btn { flex: 1; min-width: 0; }
.product-detail-edit-card h2 { margin: 0 0 12px; font-size: 1rem; }

@media (max-width: 640px) {
  .product-detail-head h1 { font-size: 1.15rem; }
  .product-kv-row { grid-template-columns: 1fr; gap: 4px; padding: 11px 14px; }
  .product-detail-actions { flex-direction: column; }
  .product-detail-actions form.inline { width: 100%; }
  .product-detail-actions .btn { width: 100%; }
  .product-detail-actions-card {
    position: sticky; bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 5; box-shadow: 0 -4px 20px rgba(0,0,0,.08);
  }
}


/* ═══════════════════════════════════════════════════════════════
   iOS safe-area
═══════════════════════════════════════════════════════════════ */
@supports(padding: env(safe-area-inset-bottom)) {
  .fab { bottom: calc(24px + env(safe-area-inset-bottom)); }
}


/* ═══════════════════════════════════════════════════════════════
   TOTALS ROW — invoice form summary inputs
═══════════════════════════════════════════════════════════════ */

.totals-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.total-field {
  padding: 7px 8px;
  border: 1px solid rgba(214,218,208,.72);
  border-radius: 9px;
  background: #FBFCF8;
}
.total-field label {
  margin-bottom: 3px;
  font-size: .58rem;
  line-height: 1.1;
  letter-spacing: .045em;
  text-transform: uppercase;
  color: #6C796E;
}
.total-input {
  width: 108px;
  height: 32px;
  display: block;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: .82rem;
  text-align: right;
}
.total-input-readonly {
  background: var(--bg);
}
.total-input-main {
  width: 118px;
  font-size: .9rem;
  font-weight: 800;
  color: var(--brand);
  border-color: var(--brand);
}

@media (max-width: 640px) {
  .totals-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
    justify-content: stretch;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
  }
  .total-field {
    min-width: 0;
    padding: 6px;
  }
  .total-input,
  .total-input-main {
    width: 100%;
    height: 30px;
    font-size: .78rem;
  }
  .total-field label {
    font-size: .54rem;
  }
}


/* ═══════════════════════════════════════════════════════════════
   INVOICE FORM — "Shto artikull" button full width on mobile
═══════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  #invForm .btn[onclick="addItem()"] {
    max-width: 100% !important;
    width: 100%;
  }
}


/* ═══════════════════════════════════════════════════════════════
   INVOICE FORM — Notes textarea + save buttons full width
═══════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .field textarea {
    width: 100%;
    box-sizing: border-box;
  }
  .btn-lg {
    width: 100%;
  }
}


/* ═══════════════════════════════════════════════════════════════
   SCAN ZONE — tighter padding + block buttons on small phones
═══════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  .scan-zone { padding: 16px; }
  .btn-scan-primary,
  .btn-scan-secondary {
    width: 100%;
    display: block;
  }
}


/* ═══════════════════════════════════════════════════════════════
   ACTION BAR — full-width buttons on small phones
═══════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  .action-bar {
    flex-direction: column;
    gap: 8px;
  }
  .action-bar .btn {
    width: 100%;
    justify-content: center;
    flex: none;
  }
}


/* ═══════════════════════════════════════════════════════════════
   VERY SMALL SCREENS (≤420px) — extra card tightening
═══════════════════════════════════════════════════════════════ */

@media (max-width: 420px) {
  .card { padding: 12px 10px; }
}

.inv-dup-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  border-radius: 6px;
  vertical-align: middle;
  flex-shrink: 0;
  text-decoration: none;
  cursor: help;
}
a.inv-dup-icon { cursor: pointer; }
.inv-dup-icon.is-hard { color: #9f1239; background: #ffe4e6; }
.inv-dup-icon.is-soft { color: #b45309; background: #fef3c7; }
.inv-dup-icon svg { display: block; }
a.inv-dup-icon:hover { filter: brightness(0.95); }

.module-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #d5d5d0;
  background: #f6f6f4;
}
.module-row.is-on {
  background: #e8f5ee;
  border-color: #1e5a41;
}
.module-badge {
  display: inline-flex;
  align-items: center;
  margin-bottom: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  background: #6b6b66;
  color: #fff;
}
.module-row.is-on .module-badge { background: #1e5a41; }
.module-badge.is-off-badge { background: #6b6b66; }
.project-admin { margin-top: 18px; }
.project-add { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.project-add .field { flex: 1; min-width: 180px; margin: 0; }
.project-list { width: 100%; border-collapse: collapse; margin-top: 12px; }
.project-list td { padding: 8px 6px 8px 0; border-top: 1px solid var(--line, #dde5db); vertical-align: middle; }
.project-row-form { display: flex; gap: 8px; align-items: center; }
.project-row-form input { flex: 1; min-width: 0; }
.project-meta { white-space: nowrap; text-align: right; }
.project-meta .module-badge { margin: 0 0 0 8px; }
.project-toggle { width: 1%; white-space: nowrap; text-align: right; }
@media (max-width: 640px) {
  .project-list, .project-list tbody, .project-list tr, .project-list td { display: block; width: 100%; }
  .project-meta, .project-toggle { text-align: left; white-space: normal; }
  .project-list tr { padding: 8px 0; border-top: 1px solid var(--line, #dde5db); }
  .project-list td { border-top: none; padding: 4px 0; }
}
.proj-desc { max-width: 280px; color: var(--muted); font-size: .85rem; }
.proj-note { margin-top: 0; }
@media (max-width: 640px) {
  .proj-stats { grid-template-columns: 1fr 1fr !important; }
  .proj-stats > .stat:last-child { grid-column: auto !important; }
  .proj-note { font-size: .8rem; line-height: 1.35; }
  .proj-table, .proj-inv { min-width: 0 !important; }
  .proj-table thead, .proj-inv thead { display: none; }
  .proj-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line, #dde5db);
  }
  .proj-table td { border: none; padding: 0; }
  .proj-table .proj-name { flex: 1 0 100%; font-size: 1rem; font-weight: 700; order: 1; }
  .proj-table .proj-date { order: 2; }
  .proj-table .proj-count { order: 3; }
  .proj-table .proj-count::before,
  .proj-table .proj-status::before { content: "· "; }
  .proj-table .proj-count::after { content: " fatura"; }
  .proj-table .proj-status { order: 4; }
  .proj-table .proj-date,
  .proj-table .proj-count,
  .proj-table .proj-status { font-size: .78rem; color: var(--muted); }
  .proj-table .proj-desc {
    order: 5;
    flex: 1 0 100%;
    max-width: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .proj-table .proj-actions { order: 6; flex: 1 0 100%; margin-top: 6px; }
  .proj-table .proj-actions .action-bar { gap: 8px; }
  .proj-inv tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 6px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line, #dde5db);
  }
  .proj-inv tbody tr::before {
    content: "";
    order: 3;
    flex-basis: 100%;
    width: 0;
    height: 0;
  }
  .proj-inv td { display: block; border: none; padding: 0; }
  .proj-inv-sup { order: 1; flex: 1 1 auto; font-weight: 700; }
  .proj-inv-amt { order: 2; flex: 0 0 auto; font-weight: 700; text-align: right; }
  .proj-inv-date, .proj-inv-cat, .proj-inv-pay { order: 4; font-size: .75rem; color: var(--muted); }
  .proj-inv-cat::before, .proj-inv-pay::before { content: "· "; }
}
.inv-proj { display: block; margin-top: 2px; font-size: .72rem; font-weight: 700; color: #1e5a41; }
.inv-proj.is-empty { color: #9f1239; }
#projectChoiceBox.is-missing { outline: 2px solid #b42318; border-radius: 12px; }
#projectChoiceBox.is-missing select { border-color: #b42318; }
.module-title { display: block; }
.module-row .muted { margin: 4px 0 0; }
.module-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  flex: 0 0 220px;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--line, #dde5db);
  background: #fff;
}
.module-switch label { position: relative; margin: 0; }
.module-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.module-switch span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 8px;
  font-weight: 700;
  font-size: .88rem;
  color: #666;
  cursor: pointer;
}
.module-switch .is-off-opt input:checked + span { background: #6b6b66; color: #fff; }
.module-switch .is-on-opt input:checked + span { background: #1e5a41; color: #fff; }
.module-switch input:focus-visible + span { outline: 2px solid #1e5a41; outline-offset: 2px; }
@media (max-width: 640px) {
  .module-row { flex-direction: column; align-items: stretch; }
  .module-switch { flex-basis: auto; width: 100%; }
}
.pay-choice-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.pay-choice { position: relative; }
.pay-choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.pay-choice span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line, #dde5db);
  background: var(--paper, #fff);
  font-weight: 600;
  cursor: pointer;
}
.pay-choice input:checked + span {
  background: #1E5A41;
  color: #fff;
  border-color: #1E5A41;
}
.pay-choice input:focus-visible + span { outline: 2px solid #1E5A41; outline-offset: 2px; }
.pay-choice-select { display: none; }
#payChoiceBox.is-missing { outline: 2px solid #b42318; border-radius: 12px; }
.pay-required {
  font-size: .72rem;
  font-weight: 700;
  color: #9f1239;
  background: #ffe4e6;
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 6px;
  vertical-align: middle;
}
.pay-tag {
  display: inline-flex;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8f5ee;
  color: #1e5a41;
  font-size: .72rem;
  font-weight: 700;
  vertical-align: middle;
}
.ph-inv {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: help;
}
.ph-tip {
  position: fixed;
  z-index: 80;
  width: min(340px, calc(100vw - 16px));
  padding: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line, #dde5db);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,.14);
  font-size: .8rem;
  line-height: 1.35;
  pointer-events: none;
}
.ph-tip-head { padding: 10px 12px 8px; }
.ph-tip-name {
  margin-top: 2px;
  font-weight: 700;
  font-size: .95rem;
  line-height: 1.35;
  word-break: break-word;
}
.ph-tip-cols { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line, #eee); }
.ph-tip-cols.is-single { grid-template-columns: 1fr; }
.ph-tip-col { padding: 8px 12px 10px; min-width: 0; }
.ph-tip-col + .ph-tip-col { border-left: 1px solid var(--line, #eee); }
.ph-tip-k { color: var(--muted, #777); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.ph-tip-date { margin-top: 3px; font-weight: 600; }
.ph-tip-sup { color: var(--muted, #777); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-tip-price { margin-top: 6px; font-size: .95rem; font-weight: 700; }
.ph-tip-qty { color: var(--muted, #777); font-size: .75rem; }
.ph-tip-delta {
  margin: 0;
  padding: 8px 12px;
  font-weight: 700;
  background: #f6f6f4;
  border-top: 1px solid var(--line, #eee);
}
.ph-tip-delta.is-up { background: #fdecea; color: #9f1239; }
.ph-tip-delta.is-down { background: #e8f5ee; color: #1e5a41; }
