:root {
  /* Invenza-style blue admin · ZETA еФактуре */
  --bg0: #f3f6fb;
  --bg1: #eef3f9;
  --ink: #152238;
  --muted: #6b7a90;
  --panel: #ffffff;
  --line: #e3eaf3;
  --blue: #1e5bb8;
  --blue-mid: #2f6fd6;
  --blue-soft: #5b8def;
  --blue-deep: #143f86;
  --navy: #0b1f3a;
  --navy-mid: #143056;
  --ok: #1b7a4a;
  --err: #c0352b;
  --warn: #b86a12;
  --shadow: 0 10px 30px rgba(11, 31, 58, 0.06);
  --shadow-blue: 0 12px 28px rgba(30, 91, 184, 0.22);
  --radius: 14px;
  --radius-lg: 18px;
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --font-ui: Manrope, "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html {
  overflow-x: clip;
  max-width: 100%;
}
body {
  font-family: var(--font);
  color: var(--ink);
  overflow-x: clip;
  max-width: 100%;
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(30, 91, 184, 0.07), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(47, 111, 214, 0.06), transparent 50%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

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

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 100%;
  overflow-x: clip;
}
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 80;
  background: rgba(11, 31, 58, .45);
  backdrop-filter: blur(2px);
  border: 0; padding: 0; cursor: pointer;
}
.sidebar {
  padding: 1.15rem .9rem 1.1rem;
  padding-top: max(1.15rem, env(safe-area-inset-top));
  padding-bottom: max(1.1rem, env(safe-area-inset-bottom));
  border-right: 1px solid var(--line);
  background: #fff;
  display: flex; flex-direction: column; gap: 1rem;
  min-height: 0;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
}
.sidebar-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem;
  flex-shrink: 0;
}
.sidebar-head .brand { flex: 1; min-width: 0; }
.sidebar .brand-logo { height: 34px; max-width: 120px; }
.nav-close {
  display: none;
  width: 40px; height: 40px; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font-size: 1.45rem; line-height: 1; color: var(--muted); cursor: pointer;
}
.nav-burger {
  display: none;
  flex-direction: column; justify-content: center; gap: 5px;
  width: 42px; height: 42px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  cursor: pointer; flex-shrink: 0;
}
.nav-burger span {
  display: block; height: 2px; width: 100%;
  background: var(--navy); border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}
.topbar-left {
  display: flex; align-items: center; gap: .65rem; min-width: 0; flex: 1;
}
.topbar-left h1,
.topbar-title {
  margin: 0;
  min-width: 0;
}
.cta-short { display: none; }
.brand {
  display: flex; gap: .7rem; align-items: center;
  color: inherit; text-decoration: none; font-family: var(--font-ui); min-width: 0;
}
.brand:hover { text-decoration: none; opacity: .92; }
.brand-logo {
  height: 38px; width: auto; max-width: 140px;
  object-fit: contain; object-position: left center; display: block; flex-shrink: 0;
}
.brand-logo-sm { height: 28px; max-width: 110px; }
.brand-logo-lg { height: 52px; max-width: 220px; }
.brand-logo-panel { height: 44px; max-width: 200px; margin-bottom: 1rem; }
.brand-text {
  display: flex; flex-direction: column; gap: .1rem; min-width: 0;
  padding-left: .65rem; border-left: 1px solid var(--line);
}
.brand-text strong {
  display: block; font-size: .92rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15;
}
.brand-text small {
  color: var(--muted); font-weight: 700; font-size: .66rem;
  letter-spacing: .06em; text-transform: uppercase;
}
.brand-dark .brand-text { border-left-color: rgba(255,255,255,.2); }
.brand-dark .brand-text strong { color: #fff; }
.brand-dark .brand-text small { color: rgba(255,255,255,.65); }
.login-product {
  margin: 1rem 0 0; font-size: .8rem; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase; color: #a8b8ff;
  font-family: var(--font-ui);
}
.portal-foot-brand { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

.side-nav {
  display: flex; flex-direction: column; gap: .25rem; font-family: var(--font-ui);
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: .35rem;
}
.side-nav a {
  display: flex; align-items: center; gap: .7rem;
  padding: .62rem .8rem; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 650; font-size: .92rem;
  transition: background .15s ease, color .15s ease;
  flex-shrink: 0;
}
.side-nav a:hover {
  background: rgba(30, 91, 184, 0.07); color: var(--ink); text-decoration: none;
}
.side-nav a.active {
  background: rgba(30, 91, 184, 0.12);
  color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}
.nav-ico { width: 1.15rem; opacity: .7; text-align: center; }

/* УЈП hub — исти бои како главниот sidebar (бело + плаво, без розево/црно) */
.ujp-hub {
  display: grid;
  grid-template-columns: minmax(220px, 270px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.ujp-hub-nav {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .75rem .55rem 1rem;
  position: sticky;
  top: .75rem;
  max-height: calc(100vh - 5.5rem);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: .22rem;
  font-family: var(--font-ui);
}
.ujp-hub-group {
  margin: .75rem .5rem .25rem;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ujp-hub-group:first-child { margin-top: .1rem; }
.ujp-hub-link {
  display: flex;
  align-items: center;
  padding: .58rem .75rem;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 650;
  line-height: 1.25;
  transition: background .15s ease, color .15s ease;
}
.ujp-hub-link:hover {
  background: rgba(30, 91, 184, 0.07);
  color: var(--ink);
  text-decoration: none;
}
.ujp-hub-link.active {
  background: rgba(30, 91, 184, 0.12);
  color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}
.ujp-hub-link.ujp-hub-sub {
  padding-left: 1.2rem;
  font-size: .84rem;
  font-weight: 600;
}
.ujp-hub-link.ujp-hub-accent {
  background: var(--blue);
  color: #fff !important;
  margin: .4rem .15rem .2rem;
  font-weight: 800;
  box-shadow: var(--shadow-blue);
  justify-content: center;
}
.ujp-hub-link.ujp-hub-accent:hover,
.ujp-hub-link.ujp-hub-accent.active {
  background: var(--blue-mid);
  color: #fff !important;
  box-shadow: var(--shadow-blue);
}
.ujp-hub-main { min-width: 0; }
.ujp-ref-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.ujp-ref-toolbar h2 {
  margin: 0;
  font-size: 1.05rem;
  font-family: var(--font);
  font-weight: 800;
  color: var(--ink);
}
.ujp-ref-search {
  max-width: 220px;
}
@media (max-width: 960px) {
  .ujp-hub {
    grid-template-columns: 1fr;
  }
  .ujp-hub-nav {
    position: static;
    max-height: none;
    flex-direction: row;
    flex-wrap: wrap;
    gap: .25rem;
    padding: .55rem;
  }
  .ujp-hub-group {
    flex: 1 0 100%;
    margin: .35rem .2rem 0;
  }
  .ujp-hub-link {
    flex: 1 1 auto;
  }
}
.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  padding-top: .75rem;
  border-top: 1px solid var(--line);
  background: #fff;
}
.user-chip {
  font-size: .85rem; color: var(--muted); font-weight: 600;
  padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: #fff;
}
.link-quiet { font-size: .85rem; color: var(--muted); font-weight: 600; }
.page-body { animation: rise .35s ease both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.main {
  padding: 1.25rem 1.45rem 2.2rem;
  padding-bottom: max(2.2rem, env(safe-area-inset-bottom));
  background: var(--bg0);
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
}
.page-body {
  min-width: 0;
  max-width: 100%;
}
.chart-box {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.chart-box canvas {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
}
.chart-box-md {
  max-height: 240px;
}
.dash-product-select {
  min-height: 4.25rem !important;
  max-height: 5.5rem;
  width: 100%;
}

/* Промет по артикл — jasniji, veci grafikon */
.dash-grid-promet {
  grid-template-columns: minmax(0, 1.75fr) minmax(220px, 0.85fr);
  align-items: stretch;
}
.panel-promet {
  border-color: rgba(30, 91, 184, 0.18);
  box-shadow: 0 12px 32px rgba(30, 91, 184, 0.08);
  background:
    linear-gradient(180deg, rgba(30, 91, 184, 0.04), transparent 42%),
    #fff;
}
.panel-promet .panel-head {
  align-items: baseline;
  gap: .65rem;
  flex-wrap: wrap;
}
.panel-promet .panel-head h2 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -.02em;
}
.panel-promet .panel-head .hint {
  margin: 0;
  font-size: .82rem;
  font-weight: 650;
  color: var(--blue);
}
.chart-box-promet {
  height: min(340px, 48vh);
  min-height: 260px;
  padding: .35rem .15rem .15rem;
}
.panel-promet-table {
  margin-bottom: 1rem;
}
.panel-promet-table .table-wrap {
  max-height: min(420px, 55vh);
  overflow: auto;
}
.panel-promet-table .data thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6f9fd;
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: .75rem; margin-bottom: 1.1rem; flex-wrap: nowrap;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: .85rem 1.1rem; box-shadow: var(--shadow);
}
.topbar h1,
.topbar-title {
  margin: 0; font-family: var(--font-ui);
  font-weight: 800; font-size: clamp(1.25rem, 2vw, 1.55rem);
  letter-spacing: -.02em; line-height: 1.25; color: var(--navy);
}
.topbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.dash-welcome {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  align-items: end; margin-bottom: 1.1rem;
}
.dash-welcome h2 {
  margin: 0; font-size: clamp(1.35rem, 2.2vw, 1.75rem); font-weight: 800;
  letter-spacing: -.02em; color: var(--navy); font-family: var(--font-ui);
}
.dash-welcome p { margin: .35rem 0 0; color: var(--muted); max-width: 48ch; }
.dash-welcome-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.kpi-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1rem; margin-bottom: 1rem;
}
.kpi-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.05rem 1.1rem; box-shadow: var(--shadow);
}
.kpi-card.kpi-blue {
  background: linear-gradient(145deg, #1e5bb8, #2f6fd6);
  border-color: transparent; color: #fff;
}
.kpi-card.kpi-blue span, .kpi-card.kpi-blue small { color: rgba(255,255,255,.78); }
.kpi-card.kpi-blue strong { color: #fff; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.kpi-top span { font-size: .82rem; font-weight: 650; color: var(--muted); }
.kpi-card strong {
  display: block; margin-top: .45rem; font-size: 1.45rem; font-weight: 800;
  letter-spacing: -.03em; font-family: var(--font-ui);
}
.kpi-card small { display: block; margin-top: .35rem; color: var(--muted); font-size: .78rem; }
.kpi-up { color: #1b7a4a; font-style: normal; font-weight: 800; }
.kpi-down { color: #c0352b; font-style: normal; font-weight: 800; }
.kpi-warn { color: #b86a12; font-style: normal; font-weight: 800; }
.kpi-blue .kpi-up, .kpi-blue .kpi-down, .kpi-blue .kpi-warn { color: #fff; }

.overview-mini {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); gap: .75rem; margin-bottom: 1rem;
}
.mini-stat {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: .75rem .9rem; box-shadow: var(--shadow);
  min-width: 0;
}
.mini-stat span { display: block; color: var(--muted); font-size: .78rem; font-weight: 650; }
.mini-stat strong {
  font-size: 1.2rem; color: var(--navy); font-family: var(--font-ui);
  overflow-wrap: anywhere; word-break: break-word;
}

.dash-grid {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; margin-bottom: 1rem;
}
.dash-span-2 { grid-column: 1 / 2; }
.breakdown { display: grid; gap: .7rem; }
.breakdown > div {
  display: flex; justify-content: space-between; gap: .75rem;
  padding: .7rem .8rem; border-radius: 10px; background: #f6f9fd; border: 1px solid var(--line);
}
.breakdown span { color: var(--muted); font-size: .82rem; font-weight: 650; }
.breakdown strong { font-size: .95rem; color: var(--navy); }
.quick-links { display: grid; gap: .45rem; margin-top: 1rem; }
.quick-links a { font-weight: 700; font-size: .9rem; }

.grid-stats {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1rem; margin-bottom: 1.25rem;
}
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.15rem; box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.stat .value {
  font-size: 1.65rem; font-weight: 800; margin-top: .25rem;
  letter-spacing: -.03em; color: var(--ink);
}
.stat .meta { color: var(--muted); font-size: .8rem; margin-top: .35rem; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.15rem 1.25rem; margin-bottom: 1.1rem;
  min-width: 0;
  max-width: 100%;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: .8rem; margin-bottom: .9rem; flex-wrap: wrap;
}
.panel-head h2 {
  margin: 0; font-size: 1.05rem; font-weight: 800; letter-spacing: -.02em;
}

.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -.15rem;
  padding-bottom: .15rem;
  max-width: 100%;
}
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 0; }
@media (min-width: 981px) {
  table.data:not(.table-stack) { min-width: min(100%, 520px); }
}
table.data th, table.data td {
  padding: .7rem .55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top;
}
table.data th {
  color: var(--muted); font-weight: 700; font-size: .75rem;
  text-transform: uppercase; letter-spacing: .05em; font-family: var(--font-ui);
}
table.data tr:hover td { background: rgba(30, 91, 184, 0.03); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.badge {
  display: inline-flex; align-items: center; padding: .2rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700; border: 1px solid var(--line);
}
.badge-ok { background: rgba(31,122,76,.1); color: var(--ok); border-color: transparent; }
.badge-warn { background: rgba(181,71,8,.1); color: var(--warn); border-color: transparent; }
.badge-err { background: rgba(180,35,24,.1); color: var(--err); border-color: transparent; }
.badge-info { background: rgba(30, 91, 184,.1); color: var(--blue-deep); border-color: transparent; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 12px; padding: .7rem 1.15rem; font: inherit; font-weight: 700;
  font-size: .875rem; cursor: pointer; text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  font-family: var(--font);
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn-primary {
  background: var(--blue);
  color: #fff; border-color: transparent;
  box-shadow: var(--shadow-blue);
}
.btn-primary:hover {
  background: var(--blue-mid);
  box-shadow: 0 14px 32px rgba(30, 91, 184, 0.35);
}
.btn-danger {
  background: rgba(180, 35, 24, 0.08);
  border-color: rgba(180, 35, 24, 0.28);
  color: var(--err, #b42318);
}
.btn-danger:hover {
  background: rgba(180, 35, 24, 0.14);
}
.btn-amber {
  background: linear-gradient(135deg, var(--blue-deep), var(--blue));
  color: #fff; border-color: transparent;
}
.btn-ghost { background: transparent; }
.btn-outline-light {
  background: transparent; color: #fff;
  border: 1px solid rgba(255,255,255,.35);
}
.btn-outline-light:hover { background: rgba(255,255,255,.08); }
.btn-sm { padding: .4rem .7rem; font-size: .82rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: .55rem; flex-wrap: wrap; }

form.stack { display: grid; gap: .85rem; }
form.stack.two { grid-template-columns: 1fr 1fr; }
label { display: grid; gap: .35rem; font-size: .88rem; color: var(--muted); font-weight: 600; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: .7rem .8rem; font: inherit; color: var(--ink); background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: rgba(30, 91, 184, 0.45);
  box-shadow: 0 0 0 3px rgba(30, 91, 184, 0.12);
}
textarea { min-height: 110px; resize: vertical; }
.hint { color: var(--muted); font-size: .82rem; }

.flash {
  padding: .85rem 1rem; border-radius: 12px; margin-bottom: 1rem;
  border: 1px solid var(--line); background: #fff; font-weight: 600;
}
.flash-ok, .flash-success { background: rgba(31,122,76,.08); color: var(--ok); border-color: transparent; }
.flash-error, .flash-err { background: rgba(180,35,24,.08); color: var(--err); border-color: transparent; }
.flash-info { background: rgba(30, 91, 184,.08); color: var(--blue-deep); border-color: transparent; }

.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a, .tabs button {
  border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: .45rem .9rem; font: inherit; cursor: pointer;
  color: var(--muted); font-weight: 700; font-size: .88rem; text-decoration: none;
}
.tabs a.active, .tabs button.active {
  background: linear-gradient(135deg, var(--blue), var(--blue-soft));
  color: #fff; border-color: transparent;
}

.hero-actions {
  display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 1rem;
}
.action-tile {
  display: block; padding: 1.2rem; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  color: inherit; text-decoration: none; transition: transform .2s ease, border-color .2s ease;
}
.action-tile:hover {
  transform: translateY(-3px); text-decoration: none;
  border-color: rgba(30, 91, 184, 0.25);
}
.action-tile strong {
  display: block; font-size: 1.1rem; font-weight: 800;
  margin-bottom: .35rem; letter-spacing: -.02em;
}
.action-tile span { color: var(--muted); font-size: .9rem; }

/* Auth */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-hero {
  width: min(980px, 100%);
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 1.5rem; align-items: stretch;
}
.login-brand {
  padding: 2.2rem; border-radius: var(--radius-lg); color: #fff;
  background:
    linear-gradient(160deg, #0a0e1c 0%, #151c38 42%, #121830 100%),
    radial-gradient(500px 240px at 90% 10%, rgba(30, 91, 184, 0.35), transparent 60%);
  display: flex; flex-direction: column; justify-content: end; min-height: 420px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.login-brand h1 {
  font-size: clamp(2rem, 4vw, 2.85rem); margin: 1rem 0 .4rem;
  font-weight: 800; letter-spacing: -.03em; line-height: 1.1;
}
.login-brand p { margin: 0; max-width: 32ch; opacity: .88; line-height: 1.5; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 1.6rem; box-shadow: var(--shadow); display: grid; gap: .9rem; align-content: center;
}
.login-card h2 { margin: 0; font-weight: 800; letter-spacing: -.02em; }

.line-rows { display: grid; gap: .55rem; }
.line-rows-head {
  display: grid; grid-template-columns: 2fr 0.7fr 0.9fr 0.7fr auto; gap: .45rem;
  padding: 0 .15rem; margin-bottom: .15rem;
  font-size: .72rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; font-family: var(--font-ui);
}
.line-row {
  display: grid; grid-template-columns: 2fr 0.7fr 0.9fr 0.7fr auto; gap: .45rem;
  align-items: end;
}
.line-rows-head.has-discount,
.line-rows.has-discount .line-row {
  grid-template-columns: 2fr 0.5fr 0.7fr 0.5fr 0.5fr 0.85fr auto;
}
/* Hidden product id ne sme da zauzima CSS grid ćeliju (lomi mobilni layout). */
.line-row > input[type="hidden"] { display: none !important; }
.line-row .line-field input,
.line-row .line-field select,
.line-row .line-field .line-total {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.line-field { display: grid; gap: .25rem; margin: 0; min-width: 0; }
.line-field-lab {
  display: none; font-size: .72rem; font-weight: 700; color: var(--muted);
}
.line-total {
  display: flex; align-items: center; min-height: 2.55rem;
  padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 8px;
  background: #f7fafc; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--ink); font-size: .9rem;
}
.lines-totals {
  display: flex; flex-wrap: wrap; gap: .75rem 1.25rem;
  margin-top: .65rem; padding: .75rem .9rem;
  border: 1px solid var(--line); border-radius: 10px; background: #f7fafc;
}
.lines-totals > div { display: grid; gap: .15rem; min-width: 7rem; }
.lines-totals span { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.lines-totals strong { font-size: 1rem; font-variant-numeric: tabular-nums; }
.line-remove {
  min-width: 2.2rem; padding: .55rem .4rem; color: var(--err);
  border-color: rgba(180, 35, 24, 0.25);
}
@media (max-width: 980px) {
  .line-rows-head { display: none !important; }
  .line-row,
  .line-rows.has-discount .line-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-items: stretch;
    gap: .65rem .55rem;
    padding: .75rem .7rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
  }
  .line-field-lab {
    display: block !important;
    margin-bottom: .1rem;
    color: var(--muted);
  }
  /* Eksplicitne klase — ne oslanjaj se na :has() / :first-child (WebView) */
  .line-row .line-field-name,
  .line-row .line-field-total,
  .line-row .line-field:first-of-type,
  .line-row .line-remove {
    grid-column: 1 / -1;
  }
  .line-row .line-field-qty,
  .line-row .line-field-price,
  .line-row .line-field-disc,
  .line-row .line-field-vat {
    grid-column: auto;
    min-width: 0;
    visibility: visible;
    opacity: 1;
  }
  .line-row .line-field-qty input,
  .line-row .line-field-price input,
  .line-row .line-field input[name="line_qty[]"],
  .line-row .line-field input[name="line_price[]"],
  .line-row input[name="line_qty[]"],
  .line-row input[name="line_price[]"] {
    display: block !important;
    width: 100% !important;
    min-width: 0;
    min-height: 2.65rem;
    font-size: 16px; /* iOS — bez zoom-a; čitljive vrednosti */
    font-weight: 600;
    color: var(--ink) !important;
    background: #fff !important;
    opacity: 1 !important;
    -moz-appearance: textfield;
    appearance: auto;
  }
  .line-row input[name="line_qty[]"]::-webkit-outer-spin-button,
  .line-row input[name="line_qty[]"]::-webkit-inner-spin-button,
  .line-row input[name="line_price[]"]::-webkit-outer-spin-button,
  .line-row input[name="line_price[]"]::-webkit-inner-spin-button {
    opacity: 1;
    height: 2rem;
  }
  .line-row .line-field input[type="number"] {
    font-size: 16px;
    min-height: 2.65rem;
  }
  .line-row .line-remove {
    justify-self: stretch;
    min-height: 2.4rem;
  }
}
@media (max-width: 420px) {
  .line-row,
  .line-rows.has-discount .line-row {
    grid-template-columns: 1fr !important;
  }
  .line-row .line-field-name,
  .line-row .line-field-qty,
  .line-row .line-field-price,
  .line-row .line-field-disc,
  .line-row .line-field-vat,
  .line-row .line-field-total,
  .line-row .line-field:first-of-type,
  .line-row .line-remove {
    grid-column: 1 / -1;
  }
}
.brand-links { margin-top: 1.5rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.brand-links a { color: rgba(255,255,255,.85); font-weight: 600; font-size: .9rem; }

/* Portal — ZETA hero stil */
.portal-body {
  min-height: 100vh; padding: 0 0 2.5rem;
  background: #ffffff;
}
.portal-top {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; padding: .85rem 1.5rem;
  background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 20;
  min-height: 76px;
}
.portal-wrap { padding: 1.4rem 1.5rem 0; max-width: 1120px; margin: 0 auto; }
.portal-hero {
  display: grid; grid-template-columns: 1.25fr .75fr; gap: 1.2rem;
  align-items: stretch; margin-bottom: 1.25rem;
}
.portal-hero-copy {
  padding: clamp(1.8rem, 4vw, 3rem); border-radius: var(--radius-lg); color: #fff;
  background: linear-gradient(160deg, #0a0e1c 0%, #151c38 42%, #101628 100%);
  box-shadow: var(--shadow); min-height: 440px;
  display: flex; flex-direction: column; justify-content: end;
  position: relative; overflow: hidden;
}
.portal-hero-copy::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(600px 280px at 85% 0%, rgba(30, 91, 184, 0.4), transparent 55%);
}
.portal-hero-copy > * { position: relative; z-index: 1; }
.portal-hero-copy .eyebrow {
  display: inline-flex; align-items: center; gap: .45rem;
  width: fit-content;
  text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; font-weight: 700;
  margin: 0 0 .85rem; padding: .45rem .9rem; border-radius: 999px;
  border: 1px solid rgba(47, 111, 214, 0.45);
  background: rgba(12, 16, 32, 0.45); color: #a8b8ff;
  font-family: var(--font-ui);
}
.portal-hero-copy h1 {
  margin: 0 0 .75rem; font-weight: 800;
  font-size: clamp(2.2rem, 4.5vw, 3.4rem); letter-spacing: -.035em; line-height: 1.08;
}
.portal-hero-copy .lead {
  margin: 0 0 1.4rem; max-width: 38ch; opacity: .9; line-height: 1.55; font-size: 1.02rem;
}
.portal-hero-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 1.5rem; box-shadow: var(--shadow);
}
.portal-hero-panel h2 {
  margin: 0 0 1rem; font-weight: 800; letter-spacing: -.02em; font-size: 1.15rem;
}
.portal-hero-panel ol { margin: 0; padding-left: 1.15rem; color: var(--muted); line-height: 1.75; font-weight: 500; }
.portal-features {
  display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 1rem;
}
.portal-features article {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem; box-shadow: var(--shadow);
  transition: border-color .2s ease, transform .2s ease;
}
.portal-features article:hover {
  border-color: rgba(30, 91, 184, 0.22); transform: translateY(-2px);
}
.portal-features strong {
  display: block; font-size: 1.05rem; font-weight: 800;
  margin-bottom: .35rem; letter-spacing: -.02em;
}
.portal-features span { color: var(--muted); font-size: .92rem; line-height: 1.45; }

.portal-foot {
  margin-top: 2rem; padding: 1.25rem 0 0; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  color: var(--muted); font-size: .85rem; font-weight: 600;
}
.portal-foot a { color: var(--blue-deep); font-weight: 700; }

.dash-banner {
  background: rgba(30, 91, 184, 0.1);
  border: 1px solid rgba(30, 91, 184, 0.25);
  color: var(--blue-deep);
  padding: .75rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-size: .92rem;
}
.dash-filter-row {
  display: flex; flex-wrap: wrap; gap: .85rem; align-items: end;
  min-width: 0;
  max-width: 100%;
}
.dash-filter-row label {
  display: grid; gap: .3rem; font-size: .82rem; color: var(--muted); font-weight: 600;
  min-width: 0; flex: 1 1 140px;
}
.dash-filter-row select,
.dash-filter-row input {
  max-width: 100%;
  min-width: 0;
}
.dash-filter-row select[multiple] { min-width: 0; width: 100%; min-height: 88px; }
.dash-filter-grow { flex: 1 1 100%; min-width: 0; }
.dash-charts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem;
}
.compare-periods {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}
.compare-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .85rem 1rem;
  background: rgba(30, 91, 184, 0.03);
}
.compare-title {
  font-size: .75rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); margin-bottom: .65rem;
}
@media (max-width: 980px) {
  .compare-periods { grid-template-columns: 1fr; }
}
.kpo-share-box {
  margin-top: 1rem; padding: 1rem;
  border: 1px dashed var(--line); border-radius: 12px; background: rgba(30, 91, 184,.04);
}
.kpo-link {
  display: block; margin-top: .5rem; padding: .65rem .75rem;
  background: #0c1020; color: #eef2ff; border-radius: 8px;
  font-size: .82rem; overflow-x: auto; white-space: nowrap;
}
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }

.check-inline {
  display: flex !important; flex-direction: row !important; align-items: center; gap: .5rem;
  font-size: .9rem; color: var(--muted);
}
.check-inline input { width: auto; }

.pos-shell { margin-bottom: 1rem; }
.pos-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: .75rem;
  align-items: end;
  margin-bottom: 1rem;
  padding: 1rem 1.15rem;
}
.pos-toolbar .pos-wh-form label {
  display: grid;
  gap: .3rem;
  font-size: .82rem;
  color: var(--muted);
  font-weight: 600;
}
.pos-toolbar .pos-search {
  max-width: none;
  width: 100%;
  align-self: end;
}
.pos-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 0;
}
.pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .65rem;
  max-height: 520px;
  overflow: auto;
  padding: .15rem;
}
.pos-paybar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-top: .35rem;
}
.pos-paybar-total {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  min-width: 0;
}
.pos-paybar-total span {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.pos-paybar-total strong {
  font-size: 1.2rem;
  color: var(--navy);
  overflow-wrap: anywhere;
}
.pos-paybar .btn-primary {
  flex: 0 0 auto;
  min-width: 8.5rem;
  min-height: 48px;
  font-size: 1.05rem;
}
.pos-day-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
  gap: .55rem;
  margin-top: .75rem;
}
.pos-day-filters { margin-top: .35rem; }
.pos-day-actions .export-btns { flex-wrap: wrap; }
.pos-item {
  display: flex; flex-direction: column; gap: .25rem; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: .75rem .7rem; cursor: pointer; font: inherit; color: inherit;
  min-height: 96px;
}
.pos-item:hover:not(:disabled) { border-color: var(--accent, #1e5bb8); box-shadow: 0 0 0 2px rgba(30,91,184,.12); }
.pos-item strong { font-size: .9rem; line-height: 1.25; }
.pos-item span { font-weight: 700; color: #1e5bb8; }
.pos-item small { color: var(--muted); font-size: .75rem; }
.pos-item.is-empty, .pos-item:disabled { opacity: .45; cursor: not-allowed; }
.pos-totals {
  display: grid; gap: .35rem; margin-top: .85rem;
  padding: .75rem; border-radius: 10px; background: rgba(30,91,184,.05);
}
.pos-totals div { display: flex; justify-content: space-between; gap: .75rem; }
.pos-totals strong { font-size: 1.05rem; }
.pos-fiscal-check {
  padding: .55rem .7rem;
  border: 1px solid rgba(30, 91, 184, .25);
  border-radius: 8px;
  background: rgba(30, 91, 184, .06);
}
.pos-fiscal-check small { display: block; margin-left: 1.35rem; margin-top: .15rem; }
.pos-search {
  max-width: 220px;
  width: 100%;
}
.pos-fiscal-details,
.pos-recent-details {
  padding-top: .85rem;
}
.pos-fiscal-summary {
  cursor: pointer;
  font-weight: 800;
  font-size: .95rem;
  color: var(--navy);
  list-style: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.pos-fiscal-summary::-webkit-details-marker { display: none; }
.pos-fiscal-summary::before {
  content: '▸';
  display: inline-block;
  transition: transform .15s ease;
  color: var(--muted);
}
details[open] > .pos-fiscal-summary::before {
  transform: rotate(90deg);
}
.pos-qty-ctrl {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.pos-qty-val { min-width: 1.25rem; text-align: center; font-weight: 700; }
.pos-checkout { margin-top: 1rem; }
.pos-tot-main strong { font-size: 1.15rem; color: var(--navy); }
.export-btns { flex-wrap: wrap; gap: .35rem; }
.export-btns a { white-space: nowrap; }

.stock-wh-card { transition: border-color .15s, box-shadow .15s; cursor: pointer; }
.stock-wh-card:hover, .stock-wh-card.is-active {
  border-color: var(--accent, #1e5bb8);
  box-shadow: 0 0 0 2px rgba(30,91,184,.12);
}
.stock-zero-row td { opacity: .55; }
.stock-matrix th, .stock-matrix td { white-space: nowrap; }
table.data tfoot th {
  border-top: 2px solid var(--line);
  padding-top: .75rem;
  background: #f6f9fd;
}

@media (max-width: 1100px) {
  .overview-mini { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar-backdrop {
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  body.nav-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  body.nav-open { overflow: hidden; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(300px, 88vw);
    z-index: 90;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: 12px 0 40px rgba(11, 31, 58, .18);
    transform: translateX(-105%);
    transition: transform .28s cubic-bezier(.22, 1, .36, 1);
    overflow: hidden;
    max-height: 100dvh;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .nav-burger { display: flex; }
  .nav-close { display: inline-flex; align-items: center; justify-content: center; }
  .side-nav {
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    gap: .2rem;
  }
  .side-foot {
    flex-shrink: 0;
    background: #fff;
  }
  .side-nav a {
    padding: .72rem .85rem;
    font-size: .95rem;
    min-height: 44px;
  }
  .side-nav a.active {
    box-shadow: inset 3px 0 0 var(--blue);
  }
  .main {
    padding: .85rem .85rem 1.6rem;
    padding-left: max(.85rem, env(safe-area-inset-left));
    padding-right: max(.85rem, env(safe-area-inset-right));
    overflow-x: clip;
  }
  .topbar {
    position: sticky;
    top: max(0px, env(safe-area-inset-top));
    z-index: 40;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "burger actions"
      "title title";
    align-items: center;
    padding: .65rem .75rem;
    margin-bottom: .85rem;
    gap: .45rem .55rem;
    min-width: 0;
  }
  .topbar-left {
    display: contents;
  }
  .topbar-left .nav-burger {
    grid-area: burger;
    justify-self: start;
  }
  .topbar-left h1,
  .topbar-title {
    grid-area: title;
    font-size: 1.05rem;
    line-height: 1.3;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: normal;
    overflow-wrap: break-word;
    max-width: 100%;
  }
  .topbar-actions {
    grid-area: actions;
    justify-self: end;
    flex-wrap: nowrap;
    gap: .35rem;
  }
  .kpi-card { min-width: 0; }
  .kpi-card strong {
    font-size: clamp(1rem, 4.2vw, 1.2rem);
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .overview-mini {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .hint { overflow-wrap: anywhere; word-break: break-word; }
  #revExpSummary { font-size: .8rem; }
  .cta-full { display: none; }
  .cta-short { display: inline; }
  .panel {
    padding: .95rem .9rem;
    margin-bottom: .85rem;
    border-radius: 12px;
  }
  .panel-head { gap: .55rem; margin-bottom: .7rem; }
  .panel-head h2 { font-size: .98rem; }
  .btn { min-height: 40px; padding: .55rem .8rem; }
  .btn-sm { min-height: 36px; }
  .btn-row { gap: .4rem; }
  .export-btns a { font-size: .8rem; }
  .dash-welcome { margin-bottom: .85rem; }
  .dash-welcome h2 { font-size: 1.2rem; }
  .dash-welcome p { font-size: .9rem; }
  .kpi-grid, .grid-stats { gap: .65rem; }
  .kpi-card strong { font-size: 1.2rem; }
  .stat .value { font-size: 1.35rem; }
  .dash-filter-row {
    flex-direction: column;
    align-items: stretch;
  }
  .dash-filter-row label,
  .dash-filter-row select,
  .dash-filter-row input,
  .dash-filter-row button {
    width: 100%;
  }
  .dash-filter-row select[multiple] { min-width: 0; width: 100%; }
  .table-wrap {
    margin: 0;
    padding: 0;
    overflow: visible;
  }
  table.data.no-stack,
  table.data.stock-matrix {
    font-size: .85rem;
    min-width: 560px;
  }
  table.data.no-stack th,
  table.data.no-stack td,
  table.data.stock-matrix th,
  table.data.stock-matrix td {
    padding: .55rem .4rem;
  }
  .table-wrap:has(table.data.no-stack),
  .table-wrap:has(table.data.stock-matrix) {
    overflow-x: auto;
    margin: 0 -.4rem;
    padding: 0 .15rem .25rem;
  }

  /* List tables → cards on mobile (sales, purchases, products, partners, …) */
  .table-wrap-stack,
  .table-wrap:has(table.data.table-stack) {
    overflow: visible;
    margin: 0;
    padding: 0;
  }
  table.data.table-stack {
    min-width: 0;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .88rem;
  }
  table.data.table-stack thead {
    display: none;
  }
  table.data.table-stack tbody {
    display: grid;
    gap: .65rem;
  }
  table.data.table-stack tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .35rem .55rem;
    padding: .75rem .8rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
  }
  table.data.table-stack tr:hover td {
    background: transparent;
  }
  table.data.table-stack td {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: .15rem 0;
    border: 0;
    min-width: 0;
    word-break: break-word;
    font-size: .88rem;
  }
  table.data.table-stack td::before {
    content: attr(data-label);
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    font-family: var(--font-ui);
  }
  table.data.table-stack td[data-label=""] {
    grid-column: 1 / -1;
    text-align: center;
  }
  table.data.table-stack td[data-label=""]::before {
    display: none;
  }
  /* Primary field (број / име) across full card width */
  table.data.table-stack td.stack-primary {
    grid-column: 1 / -1;
    font-weight: 800;
    font-size: .95rem;
    color: var(--navy);
  }
  table.data.table-stack td.stack-primary::before {
    color: var(--muted);
    font-weight: 800;
  }
  table.data.table-stack td[data-label="Документ"],
  table.data.table-stack td[data-label="Партнер"],
  table.data.table-stack td[data-label="Клиент"],
  table.data.table-stack td[data-label="Добавувач"],
  table.data.table-stack td[data-label="Назив"],
  table.data.table-stack td[data-label="Име"],
  table.data.table-stack td[data-label="Салдо"] {
    grid-column: 1 / -1;
  }
  table.data.table-stack td.num {
    text-align: left !important;
    font-weight: 700;
  }
  table.data.table-stack td[data-label="Салдо"],
  table.data.table-stack td[data-label="Бруто"] {
    padding-top: .35rem;
  }
  table.data.table-stack td[data-label="Салдо"] {
    margin-top: .15rem;
    border-top: 1px dashed var(--line);
    font-size: .95rem;
    color: var(--navy);
  }
  table.data.table-stack td.btn-row,
  table.data.table-stack td.stack-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    padding-top: .55rem;
    margin-top: .2rem;
    border-top: 1px dashed var(--line);
  }
  table.data.table-stack td.btn-row::before,
  table.data.table-stack td.stack-actions::before {
    display: none;
  }
  table.data.table-stack td.btn-row .btn,
  table.data.table-stack td.stack-actions .btn {
    flex: 1 1 auto;
    min-width: calc(50% - .3rem);
    text-align: center;
    justify-content: center;
  }
  .login-body { padding: 1rem; align-items: start; padding-top: max(1rem, env(safe-area-inset-top)); }
  .login-brand {
    min-height: 0;
    padding: 1.35rem 1.25rem;
    justify-content: flex-start;
  }
  .login-brand h1 { font-size: 1.65rem; margin: .65rem 0 .35rem; }
  .login-brand p { font-size: .92rem; max-width: none; }
  .login-card { padding: 1.2rem; }
  .portal-top { padding: .75rem 1rem; min-height: 64px; }
  .portal-wrap { padding: 1rem 1rem 0; }
  .grid-stats, .hero-actions, .login-hero, form.stack.two, .portal-hero, .portal-features, .dash-charts,
  .kpi-grid, .overview-mini, .dash-grid, .dash-grid-promet, .compare-periods, .pos-layout {
    grid-template-columns: 1fr;
  }
  .chart-box-promet {
    height: 260px;
    min-height: 220px;
  }
  .dash-span-2 { grid-column: auto; }
  /* line-row mobilni layout je u bloku iznad (~980px) — ne override-uj ovde */
  .portal-hero-copy { min-height: 320px; padding: 1.4rem; }
  .portal-hero-copy h1 { font-size: 1.85rem; }

  /* POS mobile: one page scroll — no nested scroll areas */
  body.page-pos .main {
    padding-bottom: calc(4.75rem + env(safe-area-inset-bottom));
  }
  body.page-pos .page-body {
    padding-bottom: 0;
  }
  body.page-pos .pos-fiscal-details,
  body.page-pos .pos-recent-details {
    margin-bottom: .55rem;
    padding: .7rem .8rem;
    order: 3;
  }
  body.page-pos .pos-shell {
    display: flex;
    flex-direction: column;
    gap: .55rem;
    margin-bottom: .55rem;
  }
  body.page-pos .pos-toolbar {
    grid-template-columns: 1fr;
    gap: .55rem;
    padding: .7rem .75rem;
    margin-bottom: 0;
  }
  body.page-pos .pos-layout {
    display: flex;
    flex-direction: column;
    gap: .55rem;
    margin-bottom: 0;
  }
  body.page-pos .pos-catalog {
    order: 1;
    padding: .7rem .75rem;
    margin-bottom: 0;
    min-width: 0;
  }
  body.page-pos .pos-catalog .panel-head {
    margin-bottom: .55rem;
  }
  body.page-pos .pos-catalog-links .btn { min-height: 34px; }
  body.page-pos .pos-search {
    max-width: none;
    width: 100%;
    min-height: 40px;
  }
  body.page-pos .pos-grid {
    max-height: none;
    overflow: visible;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .45rem;
  }
  body.page-pos .pos-item {
    min-height: 0;
    min-width: 0;
    padding: .55rem .5rem;
    border-radius: 10px;
  }
  body.page-pos .pos-item strong {
    font-size: .78rem;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  body.page-pos .pos-item span { font-size: .85rem; }
  body.page-pos .pos-item small { font-size: .68rem; }
  body.page-pos .pos-cart {
    order: 2;
    position: static;
    max-height: none;
    overflow: visible;
    margin-bottom: 0;
    padding: .7rem .75rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    background: #fff;
  }
  body.page-pos .pos-cart-wrap {
    max-height: none;
    overflow: visible;
  }
  body.page-pos #cartTable.table-stack tbody {
    gap: .45rem;
  }
  body.page-pos #cartTable.table-stack tr.pos-cart-row {
    grid-template-columns: 1fr auto;
    gap: .25rem .5rem;
    padding: .55rem .6rem;
    border-radius: 10px;
  }
  body.page-pos #cartTable.table-stack td.stack-primary {
    grid-column: 1 / 2;
    font-size: .86rem;
  }
  body.page-pos #cartTable.table-stack td.pos-qty-cell {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
  }
  body.page-pos #cartTable.table-stack td.pos-qty-cell::before { display: none; }
  body.page-pos #cartTable.table-stack td[data-label="Цена"] {
    grid-column: 1;
    font-size: .78rem;
  }
  body.page-pos #cartTable.table-stack td[data-label="Износ"] {
    grid-column: 1;
    font-size: .86rem;
  }
  body.page-pos #cartTable.table-stack td.stack-actions {
    grid-column: 2;
    grid-row: 3;
    border-top: 0;
    margin: 0;
    padding: 0;
    justify-content: flex-end;
  }
  body.page-pos #cartTable.table-stack td.stack-actions .btn {
    flex: 0 0 auto;
    min-width: 36px;
  }
  body.page-pos .pos-totals {
    margin-top: .55rem;
    padding: .55rem .65rem;
    gap: .2rem;
  }
  body.page-pos .pos-tot-mini { font-size: .82rem; }
  body.page-pos .pos-checkout {
    margin-top: .65rem;
    gap: .55rem;
  }
  body.page-pos .pos-fiscal-check {
    font-size: .85rem;
    padding: .45rem .55rem;
  }
  /* Only sticky element: pay bar (total + Наплати) */
  body.page-pos .pos-paybar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    margin: 0;
    padding: .65rem .85rem calc(.65rem + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(11, 31, 58, .12);
  }
  body.page-pos .pos-paybar .btn-primary {
    flex: 1 1 auto;
    max-width: 11rem;
  }
}

@media (max-width: 560px) {
  .kpi-grid, .grid-stats { grid-template-columns: 1fr 1fr; }
  .overview-mini { grid-template-columns: 1fr 1fr; }
  .topbar-actions .btn-topbar-cta { padding: .5rem .65rem; font-size: .82rem; }
  .login-brand .brand-logo-lg { height: 40px; max-width: 160px; }
  body.page-pos .pos-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 400px) {
  .kpi-grid, .grid-stats, .overview-mini { grid-template-columns: 1fr; }
}

/* Landing iframe embed — scroll u .main (pouzdano pri navigaciji) */
html:has(body.is-embed) {
  height: 100%;
  overflow: hidden;
}
body.is-embed {
  height: 100%;
  max-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
body.is-embed .app-shell {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  grid-template-columns: 220px minmax(0, 1fr);
  overflow: hidden;
}
body.is-embed .sidebar {
  width: 220px;
  min-width: 220px;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}
body.is-embed .side-nav a {
  padding: .45rem .7rem;
  font-size: .88rem;
}
body.is-embed .side-foot {
  background: #fff;
}
body.is-embed .main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
body.is-embed .topbar {
  position: sticky;
  top: 0;
  z-index: 5;
}
body.is-embed .topbar h1 {
  font-size: 1.15rem;
}
body.is-embed .page-body {
  padding-bottom: 2.5rem;
}
@media (max-width: 980px) {
  body.is-embed .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
  body.is-embed .sidebar {
    width: 100%;
    min-width: 0;
    height: auto;
    max-height: none;
    overflow: visible;
  }
  body.is-embed.nav-open .sidebar {
    height: 100%;
    overflow-y: auto;
  }
  body.is-embed .main {
    min-width: 0;
    height: 100%;
  }
}

/* Language switcher MK | SQ */
.lang-switch{display:inline-flex;gap:.25rem;align-items:center}
.lang-btn{display:inline-flex;align-items:center;justify-content:center;min-width:2.1rem;padding:.28rem .45rem;border-radius:6px;font-size:.72rem;font-weight:700;letter-spacing:.04em;text-decoration:none;color:#5c6b7f;background:#eef2f8;border:1px solid transparent}
.lang-btn:hover{color:#1e5bb8;background:#e3ecfa}
.lang-btn.is-active{color:#fff;background:#1e5bb8;border-color:#1e5bb8}
.lang-switch-side{margin-bottom:.65rem}
.lang-switch-top{margin-right:.5rem}
.lang-switch-auth{margin-top:1rem}
.lang-switch-portal{margin-right:.35rem}
.topbar-actions{display:flex;align-items:center;gap:.35rem;flex-wrap:wrap}
