/* ==========================================================================
   x.ERP v4 — 5-zonska ljuska, Gornja traka, Lijevi pod-meni, Statusna traka,
   Početna (3×3 Launcher) i Mobilna/Tablet optimizacija (web/shell.css)
   Usklađeno sa:
   - 09-antigravity-handoff-ux-reorganizacija-i-mobilno.md (Poglavlja 4, 5, 6, 8)
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body.x-v4-active {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: var(--x-bg-page, #F2F6FA);
  color: var(--x-text-main, #00203F);
  font-family: var(--x-font-sans, "Archivo", sans-serif);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   1. 5-ZONSKA MREŽA LJUSKE (.x-shell) — Poglavlje 4.1
   ========================================================================== */
.x-shell {
  display: grid;
  height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
  grid-template-columns: var(--nav-w, 240px) minmax(0, 1fr) var(--ai-w, 48px);
  grid-template-rows: 56px minmax(0, 1fr) 32px;
  grid-template-areas:
    "top top top"
    "nav main ai"
    "status status status";
  background: var(--x-bg-page, #F2F6FA);
  color: var(--x-text-main, #00203F);
}

.x-top {
  grid-area: top;
  z-index: 50;
}

.x-nav {
  grid-area: nav;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 35;
}

.x-main {
  grid-area: main;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  min-height: 0;
  position: relative;
  background: var(--x-bg-page, #F2F6FA);
}

.x-ai {
  grid-area: ai;
  overflow: hidden;
  position: relative;
  z-index: 40;
  background: var(--x-bg-surface, #FFFFFF);
  border-left: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
}

.x-status {
  grid-area: status;
  z-index: 45;
}

.x-bottomnav {
  display: none;
}

.x-shell.nav-collapsed {
  --nav-w: 64px;
}

.x-shell.nav-hidden {
  --nav-w: 0px;
}

.x-shell.nav-hidden .x-nav {
  border-right: none;
  visibility: hidden;
  pointer-events: none;
}

.x-shell.ai-open {
  --ai-w: 380px;
}

/* Sakrij stare duple navigacione trake kada je x-shell aktivan (B5, F1, F5) */
body.x-v4-active #xerpGlobalTopHeader,
body.x-v4-active #mainTabs,
body.x-v4-active #mobileBottomNav,
body.x-v4-active #xm3ResponsiveBottomDock,
body.x-v4-active .xm3-bottom-dock,
body.x-v4-active #xlTenantSelect {
  display: none !important;
}

/* Poništi stare margin-right pomake sa .main-container jer CSS Grid kolona ai već gura .x-main */
body.x-v4-active .main-container {
  margin: 0 !important;
  padding: 0 !important;
  max-width: none !important;
  width: 100% !important;
  min-width: 0 !important;
}

/* ==========================================================================
   2. GORNJA TRAKA (.x-top, 56px) — Poglavlje 4.2 (D6)
   ========================================================================== */
.x-top {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: var(--x-bg-surface, #FFFFFF);
  border-bottom: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
  min-width: 0;
}

.x-top-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.x-top-launcher-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--x-radius-ctrl, 4px);
  border: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
  background: var(--x-bg-elevated, #EDF1F5);
  color: var(--x-text-main, #00203F);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.x-top-launcher-btn:hover {
  border-color: var(--x-primary, #FC6735);
  background: var(--x-chip-active-bg, rgba(252, 103, 53, 0.10));
}

.x-top-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 0 4px;
  height: 36px;
  text-decoration: none;
  color: var(--x-text-main, #00203F);
  font-weight: 900;
  font-size: 16px;
  letter-spacing: -0.02em;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: var(--x-radius-ctrl, 4px);
}

.x-top-brand img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.x-top-brand .x-dot {
  color: var(--x-primary, #FC6735);
}

/* 9 područja u gornjoj traci */
.x-top-areas {
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: 56px;
  min-width: 0;
  overflow: hidden;
}

.x-area-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  height: 56px;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--x-text-main, #00203F);
  font-family: var(--x-font-sans);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.x-area-tab:hover:not([aria-disabled="true"]) {
  background: var(--x-bg-elevated, #EDF1F5);
}

.x-area-tab.is-active {
  border-bottom-color: var(--x-primary, #FC6735);
  background: var(--x-chip-active-bg, rgba(252, 103, 53, 0.10));
  color: var(--x-text-main, #00203F);
}

.x-area-tab .x-area-no {
  font-family: var(--x-font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--x-accent-ink, #B3400F);
}

.x-area-tab[aria-disabled="true"],
.x-area-tab.is-soon {
  color: var(--x-muted, rgba(0, 32, 63, 0.38));
  cursor: not-allowed;
}

.x-area-tab[aria-disabled="true"] .x-area-no,
.x-area-tab.is-soon .x-area-no {
  color: var(--x-muted, rgba(0, 32, 63, 0.38));
}

.x-soon-pill {
  font-family: var(--x-font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: var(--x-radius-ctrl, 4px);
  background: var(--x-bg-elevated, #EDF1F5);
  color: var(--x-text-mono, rgba(0, 32, 63, 0.62));
}

/* Sredina: Komandna paleta / Pretraga (/ · Ctrl+K) */
.x-top-search-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  min-width: 170px;
  max-width: 240px;
  border-radius: var(--x-radius-ctrl, 4px);
  border: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
  background: var(--x-bg-elevated, #EDF1F5);
  color: var(--x-text-body, rgba(0, 32, 63, 0.72));
  font-family: var(--x-font-sans);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 1;
}

.x-top-search-btn:hover {
  border-color: var(--x-primary, #FC6735);
}

.x-top-search-kbd {
  font-family: var(--x-font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--x-bg-surface, #FFFFFF);
  border: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
  color: var(--x-text-mono, rgba(0, 32, 63, 0.62));
}

/* Desno: Identitet firme, PJ, period, alati i profil */
.x-top-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.x-top-context-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 9px;
  border-radius: var(--x-radius-ctrl, 4px);
  border: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
  background: var(--x-bg-elevated, #EDF1F5);
  color: var(--x-text-main, #00203F);
  font-family: var(--x-font-mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.x-top-context-pill .x-firm-code {
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--x-chip-active-bg, rgba(252, 103, 53, 0.10));
  border: 1px solid var(--x-primary, #FC6735);
  color: var(--x-accent-ink, #B3400F);
  font-weight: 700;
}

.x-top-pj-select {
  height: 34px;
  padding: 0 6px;
  border-radius: var(--x-radius-ctrl, 4px);
  border: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
  background: var(--x-bg-surface, #FFFFFF);
  color: var(--x-text-main, #00203F);
  font-family: var(--x-font-mono);
  font-size: 12px;
  font-weight: 600;
}

.x-top-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 34px;
  height: 34px;
  padding: 0 7px;
  border-radius: var(--x-radius-ctrl, 4px);
  border: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
  background: var(--x-bg-surface, #FFFFFF);
  color: var(--x-text-main, #00203F);
  font-family: var(--x-font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.x-top-icon-btn:hover {
  border-color: var(--x-primary, #FC6735);
  background: var(--x-chip-active-bg, rgba(252, 103, 53, 0.10));
}

.x-top-icon-btn svg {
  stroke: var(--x-icon-body, #666666);
  flex-shrink: 0;
}

.x-top-notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--x-primary, #FC6735);
}

.x-top-avatar-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 8px;
  border-radius: var(--x-radius-ctrl, 4px);
  border: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
  background: var(--x-bg-elevated, #EDF1F5);
  color: var(--x-text-main, #00203F);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.x-avatar-health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--x-status-ok, #25C55E);
  flex-shrink: 0;
}

/* Mobilni aktivni naziv područja u zaglavlju (skriven na >= 1024px) */
.x-top-mobile-area-btn {
  display: none;
}

/* Dropdown meni "Više ▾" u gornjoj traci */
.x-top-more-wrap {
  position: relative;
}

.x-top-more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: var(--x-bg-surface, #FFFFFF);
  border: 1px solid var(--x-border-strong, rgba(0, 32, 63, 0.20));
  border-radius: var(--x-radius-card, 12px);
  box-shadow: var(--x-shadow);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 200;
}

.x-top-more-wrap.is-open .x-top-more-menu {
  display: flex;
}

.x-top-more-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: var(--x-radius-ctrl, 4px);
  border: none;
  background: transparent;
  color: var(--x-text-main, #00203F);
  font-family: var(--x-font-sans);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

.x-top-more-item:hover {
  background: var(--x-bg-elevated, #EDF1F5);
}

/* Na 1024–1279px: kompaktni tabovi područja bez horizontalnog skrola! (Poglavlje 4.2) */
@media (min-width: 1024px) and (max-width: 1420px) {
  .x-area-tab {
    padding: 0 6px;
    gap: 3px;
    font-size: 12px;
  }
  .x-area-tab .x-soon-pill,
  .x-area-tab .x-area-no {
    display: none;
  }
  .x-top-search-btn {
    min-width: 40px;
    max-width: 130px;
    padding: 0 8px;
  }
  .x-top-search-btn .x-top-search-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .x-top-icon-btn .x-btn-txt {
    display: none;
  }
}

@media (min-width: 1024px) and (max-width: 1180px) {
  .x-top-search-btn {
    min-width: 36px;
    max-width: 36px;
    justify-content: center;
    padding: 0;
  }
  .x-top-search-btn .x-top-search-label,
  .x-top-search-btn .x-top-search-kbd {
    display: none;
  }
  .x-top-context-pill .x-ctx-extra {
    display: none;
  }
}

/* ==========================================================================
   3. LIJEVI POD-MENI (.x-nav, 240px / 64px) — Poglavlje 4.1 (D13)
   ========================================================================== */
.x-nav {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--x-bg-surface, #FFFFFF);
  border-right: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
  user-select: none;
}

.x-nav-top {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.x-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
}

.x-nav-area-meta {
  min-width: 0;
  overflow: hidden;
}

.x-nav-area-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 800;
  color: var(--x-text-main, #00203F);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.x-nav-area-no {
  font-family: var(--x-font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--x-accent-ink, #B3400F);
}

.x-nav-area-desc {
  font-size: 12px;
  color: var(--x-text-body, rgba(0, 32, 63, 0.72));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.x-nav-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--x-radius-ctrl, 4px);
  border: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
  background: var(--x-bg-elevated, #EDF1F5);
  color: var(--x-text-main, #00203F);
  cursor: pointer;
  flex-shrink: 0;
}

.x-nav-collapse-btn:hover {
  border-color: var(--x-primary, #FC6735);
}

.x-nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
}

.x-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  min-height: 44px;
  border-radius: var(--x-radius-ctrl, 4px);
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--x-text-main, #00203F);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
  min-width: 0;
}

.x-nav-item:hover:not([aria-disabled="true"]) {
  background: var(--x-bg-elevated, #EDF1F5);
}

.x-nav-item.is-active {
  border-left-color: var(--x-primary, #FC6735);
  background: var(--x-chip-active-bg, rgba(252, 103, 53, 0.10));
}

.x-nav-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--x-icon-body, #666666);
}

.x-nav-item.is-active .x-nav-item-icon {
  color: var(--x-accent-ink, #B3400F);
}

.x-nav-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.x-nav-item-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--x-text-main, #00203F);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.x-nav-item-desc {
  font-size: 12px;
  color: var(--x-text-body, rgba(0, 32, 63, 0.72));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.x-nav-soon-group {
  margin-top: 8px;
  padding: 8px;
  border-top: 1px dashed var(--x-border, rgba(0, 32, 63, 0.12));
}

.x-nav-soon-label {
  font-family: var(--x-font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--x-muted, rgba(0, 32, 63, 0.38));
  padding: 0 8px 4px;
}

.x-nav-item[aria-disabled="true"],
.x-nav-item.is-soon {
  color: var(--x-muted, rgba(0, 32, 63, 0.38));
  cursor: not-allowed;
}

.x-nav-item[aria-disabled="true"] .x-nav-item-name,
.x-nav-item[aria-disabled="true"] .x-nav-item-desc {
  color: var(--x-muted, rgba(0, 32, 63, 0.38));
}

.x-nav-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border-top: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
}

.x-nav-settings-link {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: var(--x-radius-ctrl, 4px);
  color: var(--x-text-body, rgba(0, 32, 63, 0.72));
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.x-nav-settings-link:hover {
  background: var(--x-bg-elevated, #EDF1F5);
  color: var(--x-text-main, #00203F);
}

/* Sklopljeni lijevi meni (64px — samo ikone) */
.x-shell.nav-collapsed .x-nav-area-meta,
.x-shell.nav-collapsed .x-nav-item-text,
.x-shell.nav-collapsed .x-nav-soon-label,
.x-shell.nav-collapsed .x-nav-settings-link span {
  display: none;
}

.x-shell.nav-collapsed .x-nav-header {
  justify-content: center;
  padding: 12px 6px;
}

.x-shell.nav-collapsed .x-nav-item,
.x-shell.nav-collapsed .x-nav-settings-link {
  justify-content: center;
  padding: 8px 0;
}

/* ==========================================================================
   4. LJEPLJIVI NASLOV STRANICE (.x-page-header) — Poglavlje 4.1 & 4.4
   ========================================================================== */
.x-page {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  min-height: 100%;
}

.x-page-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--x-bg-surface, #FFFFFF);
  border-bottom: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
  padding: 10px 20px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.x-page-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 8px;
}

.x-page-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.x-page-icon-tile {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.x-page-icon-tile svg {
  width: 36px;
  height: 36px;
}

.x-page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--x-font-mono);
  font-size: 12px;
  color: var(--x-text-mono, rgba(0, 32, 63, 0.62));
}

.x-page-breadcrumb a {
  color: var(--x-accent-ink, #B3400F);
  text-decoration: none;
  font-weight: 600;
}

.x-page-h1 {
  margin: 2px 0 0;
  font-size: 19px;
  font-weight: 800;
  color: var(--x-text-main, #00203F);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.x-page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Prekidač Lista / Karta u naslovu stranice (Poglavlje 3.4, D11) */
.x-view-switch {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: var(--x-radius-ctrl, 4px);
  background: var(--x-bg-elevated, #EDF1F5);
  border: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
}

.x-view-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 10px;
  border: 1.5px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--x-text-body, rgba(0, 32, 63, 0.72));
  font-family: var(--x-font-sans);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.x-view-switch-btn.is-active {
  background: var(--x-chip-active-bg, rgba(252, 103, 53, 0.10));
  border-color: var(--x-primary, #FC6735);
  color: var(--x-text-main, #00203F);
}

/* Pod-tabovi stranice ispod naslova */
.x-page-subtabs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.x-page-subtabs::-webkit-scrollbar {
  display: none;
}

.x-page-subtab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: none;
  border-bottom: 2.5px solid transparent;
  background: transparent;
  color: var(--x-text-body, rgba(0, 32, 63, 0.72));
  font-family: var(--x-font-sans);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.x-page-subtab:hover {
  color: var(--x-text-main, #00203F);
  background: var(--x-bg-elevated, #EDF1F5);
}

.x-page-subtab.is-active {
  border-bottom-color: var(--x-primary, #FC6735);
  color: var(--x-text-main, #00203F);
  background: var(--x-chip-active-bg, rgba(252, 103, 53, 0.10));
}

.x-page-body {
  flex: 1 1 auto;
  padding: 16px 20px 28px;
  min-width: 0;
  width: 100%;
}

/* ==========================================================================
   5. DESNA TRAKA xAssistant (.x-ai, 48px / 380px) — Poglavlje 4.1 (D7, B6)
   ========================================================================== */
.x-ai #xg-stack {
  position: absolute !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100% !important;
  z-index: 2 !important;
  border-left: none !important;
  box-shadow: none !important;
}

.x-ai #xg-panel {
  position: absolute !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  z-index: 3 !important;
  border-left: none !important;
  box-shadow: none !important;
}

.x-shell:not(.ai-open) .x-ai #xg-panel {
  transform: translateX(102%) !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.x-shell.ai-open .x-ai #xg-panel {
  transform: translateX(0) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.x-shell.ai-open .x-ai #xg-stack {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Fallback ako #xg-stack nije ubačen */
.x-ai-fallback-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  gap: 10px;
  height: 100%;
  border-top: 3px solid var(--x-primary, #FC6735);
}

/* ==========================================================================
   6. STATUSNA TRAKA (.x-status, 32px) — Poglavlje 4.5 (D5)
   ========================================================================== */
.x-status {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--x-bg-surface, #FFFFFF);
  border-top: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
  font-family: var(--x-font-mono);
  font-size: 12px;
  color: var(--x-text-body, rgba(0, 32, 63, 0.72));
  gap: 8px;
  overflow: hidden;
}

.x-status-sec {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: var(--x-radius-ctrl, 4px);
  border: none;
  background: transparent;
  color: var(--x-text-main, #00203F);
  font-family: var(--x-font-mono);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  min-width: 0;
}

.x-status-sec:hover {
  background: var(--x-bg-elevated, #EDF1F5);
}

.x-status-sep {
  width: 1px;
  height: 16px;
  background: var(--x-border, rgba(0, 32, 63, 0.12));
  flex-shrink: 0;
}

.x-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--x-status-ok, #25C55E);
  flex-shrink: 0;
}

.x-status-dot.is-err {
  background: var(--x-status-err, #CC2929);
}

.x-status-dot.is-warn {
  background: var(--x-status-warn, #D97706);
}

.x-status-cancel-btn {
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--x-border-strong, rgba(0, 32, 63, 0.20));
  background: var(--x-bg-elevated, #EDF1F5);
  color: var(--x-text-main, #00203F);
  font-family: var(--x-font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ==========================================================================
   7. POČETNA — 3×3 LAUNCHER PODRUČJA (#/) — Poglavlje 4.6 & UX-F3
   Kompaktna visina tako da na 1440×900 stane u <= 1 ekran (<= 900px bez skrola),
   a na 390×844 u <= 2 ekrana!
   ========================================================================== */
.x-home-launcher {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 20px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.x-home-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.x-home-greeting h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--x-text-main, #00203F);
  letter-spacing: -0.02em;
}

.x-home-greeting p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--x-text-body, rgba(0, 32, 63, 0.72));
}

.x-home-search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 14px;
  min-width: 280px;
  border-radius: var(--x-radius-ctrl, 4px);
  border: 1px solid var(--x-border-strong, rgba(0, 32, 63, 0.20));
  background: var(--x-bg-surface, #FFFFFF);
  color: var(--x-text-body, rgba(0, 32, 63, 0.72));
  font-size: 13px;
  cursor: pointer;
}

.x-home-search-trigger:hover {
  border-color: var(--x-primary, #FC6735);
}

.x-home-grid-9 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.x-area-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--x-radius-card, 12px);
  background: var(--x-bg-surface, #FFFFFF);
  border: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
  border-top: 3px solid var(--x-primary, #FC6735);
  box-shadow: var(--x-shadow);
  color: var(--x-text-main, #00203F);
  min-width: 0;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.x-area-card:hover:not(.is-soon) {
  border-color: var(--x-primary, #FC6735);
}

.x-area-card.is-soon {
  border-top-color: var(--x-border-strong, rgba(0, 32, 63, 0.20));
  background: var(--x-bg-elevated, #EDF1F5);
  color: var(--x-muted, rgba(0, 32, 63, 0.38));
}

.x-area-card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.x-area-card-tile {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--x-tile-bg, #F2F6FA);
  border: 1px solid var(--x-tile-border, rgba(0, 32, 63, 0.14));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.x-area-card-tile svg {
  width: 40px;
  height: 40px;
}

.x-area-card.is-soon .x-area-card-tile {
  filter: grayscale(1);
  opacity: 0.55;
}

.x-area-card-titles {
  flex: 1;
  min-width: 0;
}

.x-area-card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.x-area-card-no {
  font-family: var(--x-font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--x-accent-ink, #B3400F);
}

.x-area-card.is-soon .x-area-card-no {
  color: var(--x-muted, rgba(0, 32, 63, 0.38));
}

.x-area-card-name {
  margin: 1px 0 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--x-text-main, #00203F);
  text-decoration: none;
  display: inline-block;
}

.x-area-card.is-soon .x-area-card-name {
  color: var(--x-muted, rgba(0, 32, 63, 0.38));
}

.x-area-card-desc {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--x-text-body, rgba(0, 32, 63, 0.72));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.x-area-card-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--x-bg-page, #F2F6FA);
  border: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
}

.x-area-stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.x-area-stat-val {
  font-family: var(--x-font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--x-text-main, #00203F);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.x-area-stat-lbl {
  font-size: 12px;
  color: var(--x-text-mono, rgba(0, 32, 63, 0.62));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.x-area-card-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.x-area-page-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--x-radius-ctrl, 4px);
  border: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
  background: var(--x-bg-elevated, #EDF1F5);
  color: var(--x-text-main, #00203F);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.x-area-page-chip:hover {
  border-color: var(--x-primary, #FC6735);
  background: var(--x-chip-active-bg, rgba(252, 103, 53, 0.10));
}

/* ==========================================================================
   8. MOBILNO (<= 767px) I TABLET (768–1023px) — Poglavlje 5
   ========================================================================== */
.x-mobile-subnav {
  display: none;
}

@media (max-width: 1023px) {
  .x-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 56px minmax(0, 1fr) calc(64px + env(safe-area-inset-bottom, 0px));
    grid-template-areas:
      "top"
      "main"
      "bottomnav";
  }

  .x-nav,
  .x-ai,
  .x-status {
    display: none !important;
  }

  /* 5.1 Mobilno zaglavlje 56px u 1 redu */
  .x-top {
    padding: 0 8px;
    gap: 6px;
  }

  .x-top-areas,
  .x-top-context-pill,
  .x-top-pj-select,
  .x-top-icon-btn.x-hide-mobile,
  .x-top-more-wrap {
    display: none !important;
  }

  .x-top-launcher-btn,
  .x-top-icon-btn,
  .x-top-avatar-btn,
  .x-top-search-btn {
    min-width: 44px !important;
    min-height: 44px !important;
    height: 44px !important;
  }

  .x-top-search-btn {
    width: 44px !important;
    max-width: 44px !important;
    padding: 0 !important;
    justify-content: center !important;
    flex: 0 0 44px !important;
  }

  .x-top-search-btn .x-top-search-label,
  .x-top-search-btn .x-top-search-kbd {
    display: none !important;
  }

  .x-top-mobile-area-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 10px;
    border-radius: var(--x-radius-ctrl, 4px);
    border: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
    background: var(--x-bg-elevated, #EDF1F5);
    color: var(--x-text-main, #00203F);
    font-family: var(--x-font-sans);
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* 5.3 Horizontalni ljepljivi red pod-stranica područja odmah ispod zaglavlja */
  .x-mobile-subnav {
    display: flex;
    align-items: center;
    gap: 4px;
    position: sticky;
    top: 0;
    z-index: 32;
    background: var(--x-bg-surface, #FFFFFF);
    border-bottom: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
    padding: 4px 10px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .x-mobile-subnav::-webkit-scrollbar {
    display: none;
  }

  .x-mobile-subnav-tab {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 44px;
    padding: 0 12px;
    border: none;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--x-text-body, rgba(0, 32, 63, 0.72));
    font-family: var(--x-font-sans);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    flex-shrink: 0;
  }

  .x-mobile-subnav-tab.is-active {
    border-bottom-color: var(--x-primary, #FC6735);
    color: var(--x-text-main, #00203F);
    background: var(--x-chip-active-bg, rgba(252, 103, 53, 0.10));
  }

  .x-mobile-subnav-tab[aria-disabled="true"] {
    color: var(--x-muted, rgba(0, 32, 63, 0.38));
    cursor: not-allowed;
  }

  /* 5.2 Donja navigacija (.x-bottomnav, 64px + safe-area) sa tačno 5 stavki */
  .x-bottomnav {
    grid-area: bottomnav;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding: 0 4px env(safe-area-inset-bottom, 0px);
    background: var(--x-bg-surface, #FFFFFF);
    border-top: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
    z-index: 60;
  }

  .x-main {
    padding-bottom: 68px;
  }

  .x-bnav-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 52px;
    min-width: 44px;
    padding: 4px 2px;
    border: none;
    background: transparent;
    color: var(--x-text-body, rgba(0, 32, 63, 0.72));
    font-family: var(--x-font-sans);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
  }

  .x-bnav-item.is-active {
    color: var(--x-accent-ink, #B3400F);
  }

  .x-bnav-item.is-primary-capture {
    background: var(--x-btn-fill, #E3541F);
    color: #FFFFFF;
    border-radius: 10px;
    margin: 4px;
    min-height: 48px;
  }

  .x-bnav-item.is-primary-capture svg {
    stroke: #FFFFFF;
  }

  .x-bnav-badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 22px);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--x-primary, #FC6735);
    color: #FFFFFF;
    font-family: var(--x-font-mono);
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Dodirne mete >= 44px i inputi >= 16px na mobilnom (Poglavlje 5.3 & 8 #4) */
  .x-shell button,
  .x-shell a.x-area-page-chip,
  .x-shell select,
  .x-shell input[type="button"],
  .x-shell input[type="submit"],
  .x-shell [role="button"],
  .x-shell [role="tab"] {
    min-height: 44px;
    min-width: 44px;
  }

  .x-shell input[type="text"],
  .x-shell input[type="number"],
  .x-shell input[type="search"],
  .x-shell input[type="email"],
  .x-shell input[type="tel"],
  .x-shell input[type="password"],
  .x-shell select,
  .x-shell textarea {
    font-size: 16px !important;
    min-height: 44px;
  }

  .x-page-header {
    position: relative;
    padding: 10px 12px 0;
  }

  .x-page-body {
    padding: 12px 12px 24px;
  }

  .x-home-grid-9 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .x-home-launcher {
    padding: 10px 12px;
    gap: 8px;
  }

  .x-home-search-trigger {
    min-width: 0;
    width: 100%;
  }

  /* Kompaktne kartice na 390×844 da stanu u <= 2 ekrana (<= 1688px) */
  .x-home-grid-9 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .x-area-card {
    padding: 10px;
    gap: 6px;
  }

  .x-area-card-tile {
    width: 34px;
    height: 34px;
  }

  .x-area-card-tile svg {
    width: 30px;
    height: 30px;
  }

  .x-area-card-name {
    font-size: 14px;
  }

  .x-area-card-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 4px 6px;
  }

  .x-area-card-stats .x-area-stat:nth-child(3) {
    display: none;
  }

  .x-area-card-links {
    display: none;
  }
}

/* ==========================================================================
   9. MOBILNI KORACI U x.Workbench (Tab 02) — Poglavlje 5.4 (B8)
   ========================================================================== */
.x-wb-mobile-steps {
  display: none;
}

.x-wb-sticky-lock-bar {
  display: none;
}

@media (max-width: 767px) {
  .x-wb-mobile-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 6px 10px;
    background: var(--x-bg-surface, #FFFFFF);
    border-bottom: 1px solid var(--x-border, rgba(0, 32, 63, 0.12));
    position: sticky;
    top: 52px;
    z-index: 28;
  }

  .x-wb-step-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 8px;
    border-radius: var(--x-radius-ctrl, 4px);
    border: 1.5px solid var(--x-border, rgba(0, 32, 63, 0.12));
    background: var(--x-bg-elevated, #EDF1F5);
    color: var(--x-text-main, #00203F);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
  }

  .x-wb-step-btn.is-active {
    background: var(--x-chip-active-bg, rgba(252, 103, 53, 0.10));
    border-color: var(--x-primary, #FC6735);
    color: var(--x-text-main, #00203F);
  }

  #tab-review[data-wb-step="1"] .split-col-pdf,
  #tab-review[data-wb-step="1"] .split-col-form {
    display: none !important;
  }

  #tab-review[data-wb-step="2"] .split-col-queue,
  #tab-review[data-wb-step="2"] .split-col-form {
    display: none !important;
  }

  #tab-review[data-wb-step="3"] .split-col-queue,
  #tab-review[data-wb-step="3"] .split-col-pdf {
    display: none !important;
  }

  .x-wb-sticky-lock-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    position: sticky;
    bottom: 0;
    z-index: 29;
    padding: 8px 12px;
    background: var(--x-bg-surface, #FFFFFF);
    border-top: 2px solid var(--x-primary, #FC6735);
    box-shadow: 0 -4px 12px rgba(0, 32, 63, 0.08);
  }
}
