/* ═══════════════════════════════════════════════════════════════
   AIERP — structure and layout
   Bootstrap skeleton + AIERP structure. Colours/fonts/backgrounds/borders live
   in default-theme.css (loaded after this file, so it can override anything here).
   Bootstrap provides: grid, utility classes, JS components.
   This file provides: layout, dimensions, animations, responsive behaviour.
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   1. DESIGN TOKENS — structural only (colours/fonts are in default-theme.css)
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* ── Layout dimensions ── */
  --aierp-sidebar-w: 260px;
  --aierp-sidebar-collapsed: 64px;
  --aierp-header-h: 56px;
  --aierp-footer-h: 32px;
  --aierp-ai-panel-w: 380px;

  /* ── Border radius ── */
  --aierp-radius-sm: 6px;
  --aierp-radius: 10px;
  --aierp-radius-lg: 14px;
  --aierp-radius-xl: 20px;

  /* ── Motion ── */
  --aierp-ease-out-expo: cubic-bezier(.16, 1, .3, 1);
  --aierp-ease-out-back: cubic-bezier(.34, 1.56, .64, 1);
  --aierp-duration-fast: 140ms;
  --aierp-duration: 220ms;
  --aierp-duration-slow: 380ms;
}



/* ═══════════════════════════════════════════════════════════════
   2. BOOTSTRAP STRUCTURE — component-level overrides
   Padding/dimensions/transitions of Bootstrap components. The --bs-* variable
   level (colours) lives in default-theme.css section 2.
   ═══════════════════════════════════════════════════════════════ */


/* ── Body ── */
body {
  font-family: var(--aierp-font);
  font-size: var(--aierp-font-size);
  background: var(--aierp-bg);
  color: var(--aierp-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  min-height: 100vh;
}

/* ── Links ── */
a {
  color: var(--aierp-accent-light);
  transition: color var(--aierp-duration-fast) var(--aierp-ease-out-expo);
}
a:hover {
  color: var(--aierp-accent-light);
  opacity: 0.8;
}

/* ── Bootstrap Cards ── */
.card {
  background: var(--aierp-surface);
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-lg);
}
.card-header {
  background: var(--aierp-surface-elevated);
  border-bottom: 1px solid var(--aierp-border);
  color: var(--aierp-text);
}
.card-footer {
  background: var(--aierp-surface-elevated);
  border-top: 1px solid var(--aierp-border);
}

/* ── Bootstrap Tables ── */
.table {
  --bs-table-color: var(--aierp-text);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--aierp-border);
  --bs-table-hover-bg: rgb(var(--aierp-accent-rgb) / .025);
  --bs-table-hover-color: var(--aierp-text);
  --bs-table-striped-bg: rgb(var(--aierp-white-rgb) / .01);
  --bs-table-striped-color: var(--aierp-text);
  color: var(--aierp-text);
}
.table > thead {
  background: var(--aierp-surface-elevated);
}
.table > thead > tr > th {
  border-bottom: 1px solid var(--aierp-border);
  color: var(--aierp-text-tertiary);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  padding: 12px 14px;
}
.table > tbody > tr > td {
  border-bottom: 1px solid var(--aierp-border);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--aierp-text-table);
}
.table > tbody > tr:hover > td {
  background: rgb(var(--aierp-accent-rgb) / .025);
}
.table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-bg-type: var(--aierp-bg-alt);
  background-color: rgb(var(--aierp-white-rgb) / .015);
  color: var(--aierp-text-table);
}
.table.data-table tbody tr:nth-child(even) td {
  background: rgb(var(--aierp-white-rgb) / .008);
}

/* ── Bootstrap Forms ── */
.form-control,
.form-select {
  background: var(--aierp-surface);
  border: 1px solid var(--aierp-border);
  color: var(--aierp-text);
  font-size: 12.5px;
  font-family: var(--aierp-font);
  border-radius: var(--aierp-radius-sm);
  padding: 8px 12px;
  transition: all var(--aierp-duration-fast) var(--aierp-ease-out-expo);
}
/* A <select> is a click-to-choose control everywhere in the app, not just
   text entry — never had an explicit cursor before (relied on the
   browser's own default, which is `default`, not `pointer`), same gap on
   every module's dropdown, not only kursna lista's. `:not([disabled])`
   leaves the UA's own not-allowed cursor alone for a disabled select. */
.form-select:not([disabled]) {
  cursor: pointer;
}
.form-control:focus,
.form-select:focus {
  background: var(--aierp-surface);
  border-color: var(--aierp-border-focus);
  box-shadow: 0 0 0 3px rgb(var(--aierp-accent-rgb) / .06);
  color: var(--aierp-text);
}
.form-control::placeholder {
  color: var(--aierp-text-tertiary);
}
.form-label {
  color: var(--aierp-text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 4px;
}
.form-check-input {
  width: 1.5em;
  height: 1.5em;
}
.form-check-input:checked {
  background-color: var(--aierp-accent);
  border-color: var(--aierp-accent);
}
.form-check-input:focus {
  border-color: var(--aierp-accent);
  box-shadow: 0 0 0 3px rgb(var(--aierp-accent-rgb) / .15);
}

/* ── Number input — dark arrows ── */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  filter: invert(0.85);
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* ── Bootstrap Buttons ── */
.btn {
  font-size: 12.5px;
  font-weight: 500;
  font-family: var(--aierp-font);
  letter-spacing: -0.01em;
  border-radius: var(--aierp-radius-sm);
  padding: 8px 16px;
  transition: all var(--aierp-duration-fast) var(--aierp-ease-out-expo);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  position: relative;
}
.btn:hover {
  background: var(--aierp-surface-elevated);
  border-color: var(--aierp-border-strong);
}
.btn:active {
  transform: scale(.97);
}
.btn-primary {
  background: linear-gradient(135deg, var(--aierp-accent), var(--aierp-accent-deep));
  border-color: transparent;
  box-shadow: 0 4px 16px var(--aierp-accent-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--aierp-accent-light), var(--aierp-accent));
  border-color: transparent;
  box-shadow: 0 6px 24px var(--aierp-accent-glow);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0) scale(.98);
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--aierp-text-secondary);
}
.btn-ghost:hover {
  background: rgb(var(--aierp-white-rgb) / .03);
  color: var(--aierp-text);
}
.btn-outline-secondary {
  color: var(--aierp-text-secondary);
  border-color: var(--aierp-border);
}
.btn-outline-secondary:hover {
  background: rgb(var(--aierp-white-rgb) / .03);
  color: var(--aierp-text);
  border-color: var(--aierp-border-strong);
}
.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ── Bootstrap Navs ── */
.nav-tabs {
  border-bottom: 1px solid var(--aierp-border);
}
.nav-tabs .nav-link {
  color: var(--aierp-text-tertiary);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
}
.nav-tabs .nav-link:hover {
  color: var(--aierp-text-secondary);
  border-bottom-color: transparent;
}
.nav-tabs .nav-link.active {
  color: var(--aierp-white);
  background: transparent;
  border-bottom-color: var(--aierp-accent);
  font-weight: 600;
}

/* ── Pagination Bar ── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  font-size: 12px;
  color: var(--aierp-text-tertiary);
  gap: 12px;
}
.pagination-info {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.pagination-info strong {
  color: var(--aierp-text);
  font-weight: 600;
}
.pagination-pages {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
}
.pagination-pages button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-sm);
  background: var(--aierp-surface);
  cursor: pointer;
  font-size: 12px;
  color: var(--aierp-text);
  transition: all var(--aierp-duration-fast);
  font-family: var(--aierp-font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  padding: 0;
}
.pagination-pages button:hover:not(:disabled):not(.active):not(.ellipsis) {
  background: var(--aierp-surface-elevated);
  border-color: var(--aierp-border-strong);
}
.pagination-pages button.active {
  background: var(--aierp-accent);
  border-color: var(--aierp-accent);
  color: var(--aierp-white);
  box-shadow: 0 2px 10px var(--aierp-accent-glow);
  cursor: default;
}
.pagination-pages button.ellipsis {
  border-color: transparent;
  background: transparent;
  color: var(--aierp-text-tertiary);
  cursor: default;
}
/* A format the current selection cannot use (ExportService::XLSX_MAX_ROWS)
   greys out with its label — the bare radio alone reads as a rendering
   glitch rather than an unavailable choice. */
.form-check:has(.form-check-input:disabled) {
  opacity: .45;
  cursor: default;
}
.pagination-pages button:disabled:not(.ellipsis) {
  opacity: .35;
  cursor: default;
}
.pagination-size select {
  padding: 5px 10px;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-sm);
  background: var(--aierp-surface);
  color: var(--aierp-text);
  font-size: 12px;
  font-family: var(--aierp-font);
  cursor: pointer;
}
/* ── Bootstrap Dropdown ── */
.dropdown-menu {
  background: var(--aierp-surface-overlay);
  border: 1px solid var(--aierp-border-strong);
  border-radius: var(--aierp-radius);
  box-shadow: 0 20px 60px rgb(var(--aierp-black-rgb) / .5);
  padding: 6px;
}
.dropdown-item {
  color: var(--aierp-text-secondary);
  font-size: 12.5px;
  border-radius: var(--aierp-radius-sm);
  padding: 7px 12px;
  transition: all var(--aierp-duration-fast);
}
.dropdown-item:hover {
  background: rgb(var(--aierp-white-rgb) / .04);
  color: var(--aierp-text);
}
.dropdown-divider {
  border-color: var(--aierp-border);
}
a.sort-link {
  text-decoration: none;
}

/* ── Bootstrap Custom ── */
.text-muted {
  color: rgb(var(--aierp-muted-rgb) / 0.79) !important;
}

/* ── AIERP Custom Modal (bez Bootstrap zavisnosti) ── */
.aierp-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
}
@media (max-width: 900px) {
  .aierp-modal {
    left: var(--aierp-sidebar-collapsed);
  }
}
.aierp-modal-viewport {
  left: 0;
}
.aierp-modal.show {
  display: flex;
  overflow-y: auto;
}
.aierp-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(var(--aierp-black-rgb) / .6);
  backdrop-filter: blur(4px);
}
.aierp-modal-dialog {
  position: relative;
  z-index: 1;
  width: 440px;
  max-width: calc(100vw - 48px);
  margin: auto;
  animation: aierpModalIn .22s cubic-bezier(.16,1,.3,1);
}
.aierp-modal-dialog.aierp-modal-lg {
  width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.aierp-modal-dialog.aierp-modal-lg > .aierp-modal-content {
  display: block;
  max-height: 90vh;
  overflow-y: scroll;
}
.aierp-modal-dialog.aierp-modal-lg .aierp-modal-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.flex-1 { flex: 1; }
@keyframes aierpModalIn {
  from { opacity: 0; transform: scale(.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.aierp-modal-content {
  background: var(--aierp-surface-overlay);
  border: 1px solid var(--aierp-border-strong);
  border-radius: var(--aierp-radius-lg);
  box-shadow: 0 20px 60px rgb(var(--aierp-black-rgb) / .6);
  overflow: hidden;
}
.aierp-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--aierp-border);
}
.aierp-modal-header h5 {
  font-size: 15px;
  font-weight: 700;
  color: var(--aierp-text);
  margin: 0;
}
.aierp-modal-close {
  background: none;
  border: none;
  color: var(--aierp-text-tertiary);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color var(--aierp-duration-fast);
}
.aierp-modal-close:hover { color: var(--aierp-text); }
.aierp-modal-body {
  padding: 20px;
  font-size: 13px;
  color: var(--aierp-text-secondary);
  line-height: 1.6;
}
.aierp-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--aierp-border);
}

/* ── Bootstrap Badges ── */
.badge {
  font-weight: 600;
  letter-spacing: 0.2px;
  font-size: 10.5px;
}

/* ── Bootstrap Alerts ── */
.alert {
  border-radius: var(--aierp-radius);
  font-size: 13px;
}
.alert-success {
  background: var(--aierp-green-bg);
  border: 1px solid rgb(var(--aierp-green-rgb) / .2);
  color: var(--aierp-green);
}
.alert-warning {
  background: var(--aierp-amber-bg);
  border: 1px solid rgb(var(--aierp-amber-rgb) / .2);
  color: var(--aierp-amber);
}

/* ── Settings lock notice (irreversible-choice warning above a create form) ── */
.settings-lock-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.settings-lock-notice svg { flex-shrink: 0; margin-top: 1px; }
.settings-lock-notice strong { display: block; margin-bottom: 4px; }
.settings-lock-notice ul { margin: 0 0 6px; padding-left: 18px; }
.settings-lock-notice span { color: var(--aierp-text-secondary); }
.settings-lock-notice a { margin-left: 6px; font-weight: 600; }

/* ── Bootstrap Tooltips ── */
.tooltip .tooltip-inner {
  background: var(--aierp-surface-overlay);
  border: 1px solid var(--aierp-border-strong);
  color: var(--aierp-text);
  font-size: 11.5px;
  border-radius: var(--aierp-radius-sm);
}
.bs-tooltip-top .tooltip-arrow::before { border-top-color: var(--aierp-border-strong); }
.bs-tooltip-bottom .tooltip-arrow::before { border-bottom-color: var(--aierp-border-strong); }

/* ── Bootstrap Popovers ── */
.popover {
  background: var(--aierp-surface-overlay);
  border: 1px solid var(--aierp-border-strong);
  border-radius: var(--aierp-radius);
  box-shadow: 0 16px 48px rgb(var(--aierp-black-rgb) / .5);
}
.popover-header {
  background: var(--aierp-surface-elevated);
  border-bottom: 1px solid var(--aierp-border);
  color: var(--aierp-text);
}
.popover-body {
  color: var(--aierp-text-secondary);
}

/* ── Bootstrap List Group ── */
.list-group-item {
  background: var(--aierp-surface);
  border: 1px solid var(--aierp-border);
  color: var(--aierp-text);
}

/* ── Bootstrap Breadcrumb ── */
.breadcrumb-item + .breadcrumb-item::before {
  color: var(--aierp-text-tertiary);
}
.breadcrumb-item a {
  color: var(--aierp-text-tertiary);
  text-decoration: none;
}
.breadcrumb-item.active {
  color: var(--aierp-text);
}

/* ═══════════════════════════════════════════════════════════════
   3. LAYOUT — Glavna struktura stranice
   ═══════════════════════════════════════════════════════════════ */

/* ── App wrapper ── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Auth layout (login, no sidebar) ── */
.auth-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  position: relative;
  z-index: 1;
}
.auth-card {
  width: 100%;
  max-width: 460px;
}
.auth-logo {
  height: 48px;
}
.auth-footer-note {
  font-size: 12px;
  color: var(--aierp-text-tertiary);
}

/* Checkbox row — ensure visible in dark theme */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.check-row .form-check-input {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--aierp-accent);
  background-color: var(--aierp-bg);
  border-color: var(--aierp-border);
}
.check-row .form-check-input:checked {
  background-color: var(--aierp-accent);
  border-color: var(--aierp-accent);
}
.check-row label {
  font-size: 13px;
  color: var(--aierp-text-secondary);
  cursor: pointer;
  user-select: none;
}

/* ── Ambient orbs (pozadinski efekti) ── */
.ambient-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: .06;
  animation: orbFloat 18s ease-in-out infinite;
}
.ambient-orb--1 {
  width: 640px;
  height: 640px;
  background: radial-gradient(circle, var(--aierp-accent-light), transparent 70%);
  top: -15%;
  left: -8%;
  animation-delay: 0s;
}
.ambient-orb--2 {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, var(--aierp-accent-secondary), transparent 70%);
  bottom: -20%;
  right: -10%;
  animation-delay: -9s;
}
.ambient-orb--3 {
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, var(--aierp-blue), transparent 70%);
  top: 50%;
  left: 45%;
  animation-delay: -4s;
  opacity: .03;
}
@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(40px, -30px) scale(1.08); }
  50% { transform: translate(-20px, 20px) scale(.95); }
  75% { transform: translate(-35px, -15px) scale(1.04); }
}

/* ── Grain overlay ── */
.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: .018;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Sidebar ── */
.app-sidebar {
  width: var(--aierp-sidebar-w);
  min-width: var(--aierp-sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--aierp-surface) 0%, var(--aierp-bg-alt) 100%);
  border-right: 1px solid var(--aierp-border);
  transition: width var(--aierp-duration-slow) var(--aierp-ease-out-expo),
              min-width var(--aierp-duration-slow) var(--aierp-ease-out-expo);
  overflow-y: auto;
  overflow-x: hidden;
}
.app-sidebar.no-transition {
  transition: none !important;
}
.app-sidebar.collapsed {
  width: var(--aierp-sidebar-collapsed);
  min-width: var(--aierp-sidebar-collapsed);
}
.app-sidebar.collapsed .sidebar-brand-text,
.app-sidebar.collapsed .sidebar-tenant,
.app-sidebar.collapsed .sidebar-nav-label,
.app-sidebar.collapsed .sidebar-nav-chevron,
.app-sidebar.collapsed .sidebar-nav-badge,
.app-sidebar.collapsed .sidebar-nav-children { display: none !important; }
.app-sidebar.collapsed .sidebar-search input,
.app-sidebar.collapsed .sidebar-user-info { display: none; }
.app-sidebar.collapsed .sidebar-nav-trigger {
  justify-content: center;
  padding: 10px 8px;
}
.app-sidebar.collapsed .sidebar-brand {
  padding: 16px 14px;
  justify-content: center;
}

/* Sidebar brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 20px 16px;
  flex-shrink: 0;
}
.sidebar-brand-logo {
  width: 50px;
  height: 12px;
  border-radius: var(--aierp-radius-sm);
  flex-shrink: 0;
}
.sidebar-brand-text h1 {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -.4px;
  background: linear-gradient(135deg, var(--aierp-accent-light), var(--aierp-accent-lighter));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
  margin: 0;
}
.sidebar-tenant {
  font-size: 9.5px;
  color: var(--aierp-text-tertiary);
  font-weight: 500;
  letter-spacing: .1px;
}

/* Sidebar search */
.collapsed .sidebar-search {
  visibility: hidden;
}
.sidebar-search {
  position: relative;
  padding: 0 16px;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.sidebar-search input {
  width: 84%;
  padding: 7px 10px 7px 30px;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-sm);
  background: var(--aierp-bg-alt);
  color: var(--aierp-text);
  font-size: 11.5px;
  font-family: var(--aierp-font);
  transition: all var(--aierp-duration-fast) var(--aierp-ease-out-expo);
}
.sidebar-search input:focus {
  outline: none;
  border-color: var(--aierp-border-focus);
  box-shadow: 0 0 0 3px rgb(var(--aierp-accent-rgb) / .06);
}
.sidebar-search input::placeholder {
  color: var(--aierp-text-tertiary);
}
.sidebar-search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--aierp-text-tertiary);
  pointer-events: none;
  font-size: 12px;
}

/* Sidebar navigation */

.collapsed .sidebar-nav {
  margin-top: 30px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--aierp-text-tertiary) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--aierp-text-tertiary);
  border-radius: 10px;
}
.sidebar-nav-section {
  margin-bottom: 0;
}
.sidebar-nav-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 12px;
  margin: 1px 0;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--aierp-text-tertiary);
  background: none;
  border: none;
  border-radius: var(--aierp-radius-sm);
  cursor: pointer;
  font-family: var(--aierp-font);
  transition: all var(--aierp-duration-fast) var(--aierp-ease-out-expo);
  text-align: left;
}
.sidebar-nav-trigger:hover {
  color: var(--aierp-text-secondary);
  background: rgb(var(--aierp-white-rgb) / .02);
}
.sidebar-nav-trigger svg {
  width: 14px;
  height: 14px;
  opacity: .45;
  flex-shrink: 0;
}
.sidebar-nav-trigger:hover svg { opacity: .7; }
.sidebar-nav-section.active .sidebar-nav-trigger {
  color: var(--aierp-white);
  background: rgb(var(--aierp-accent-rgb) / .1);
}
.sidebar-nav-section.active .sidebar-nav-trigger svg {
  opacity: .9;
  color: var(--aierp-accent-light);
}
.sidebar-nav-chevron {
  margin-left: auto;
  font-size: 8px;
  transition: transform var(--aierp-duration) var(--aierp-ease-out-expo);
  opacity: .4;
}
.sidebar-nav-section.open .sidebar-nav-chevron {
  transform: rotate(90deg);
  opacity: .7;
}
.sidebar-nav-section.open .sidebar-nav-trigger {
    background: var(--aierp-nav-open-bg);
}
.collapsed .sidebar-nav-section.open .sidebar-nav-trigger {
    background: var(--aierp-nav-open-bg-collapsed);
}
.sidebar-nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-nav-badge {
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 100px;
  background: rgb(var(--aierp-white-rgb) / .05);
  color: var(--aierp-text-tertiary);
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: .2px;
}
.sidebar-nav-children {
  max-height: 0;
  padding: 0;
  overflow: hidden;
  transition: max-height var(--aierp-duration-fast) var(--aierp-ease-out-expo),
              padding var(--aierp-duration-fast) var(--aierp-ease-out-expo);
}
.sidebar-nav-section.open .sidebar-nav-children {
  /* Close to the tallest group's real height — the max-height animation is
     smooth only there, not with an oversized cap. */
  max-height: 290px;
  padding: 2px 0 6px;
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px 6px 34px;
  font-size: 12.5px;
  color: var(--aierp-text-secondary);
  border-radius: var(--aierp-radius-sm);
  cursor: pointer;
  transition: all var(--aierp-duration-fast) var(--aierp-ease-out-expo);
  position: relative;
  text-decoration: none;
  white-space: nowrap;
}
.sidebar-nav-item:hover {
  color: var(--aierp-text);
  background: rgb(var(--aierp-white-rgb) / .025);
}
.sidebar-nav-item.active {
  color: var(--aierp-white);
  background: rgb(var(--aierp-accent-rgb) / .1);
  font-weight: 600;
}
.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 5px;
  bottom: 5px;
  width: 3px;
  background: linear-gradient(180deg, var(--aierp-accent), var(--aierp-accent-light));
  border-radius: 0 4px 4px 0;
}
/* display:flex beats [hidden], so without this the menu search hides nothing. */
.sidebar-nav-item[hidden] {
  display: none;
}
.sidebar-nav-empty {
  padding: 10px 16px;
  font-size: 12.5px;
  color: var(--aierp-text-tertiary);
}

/* A module with no screen — visible only where aierp.sidebar.show_unfinished
   allows it. The colour is composed from an existing token, none added. */
.sidebar-nav-item.unfinished,
.sidebar-nav-dropdown-item.unfinished {
  color: rgb(var(--aierp-red-rgb) / .55);
  cursor: default;
}
.sidebar-nav-item.unfinished:hover,
.sidebar-nav-dropdown-item.unfinished:hover {
  color: rgb(var(--aierp-red-rgb) / .75);
  background: rgb(var(--aierp-red-rgb) / .06);
}
.sidebar-nav-item .nav-item-badge {
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 100px;
  background: var(--aierp-accent);
  color: var(--aierp-white);
  margin-left: auto;
  font-weight: 700;
}

/* ── Sidebar collapsed dropdown (hover na ikonici) ── */
.sidebar-nav-dropdown {
  display: none;
  position: fixed;
  left: calc(var(--aierp-sidebar-collapsed) - 12px);
  z-index: 100;
  min-width: 200px;
  padding: 6px;
  background: var(--aierp-surface-overlay);
  border: 1px solid var(--aierp-border-strong);
  border-radius: var(--aierp-radius);
  box-shadow: 0 16px 48px rgb(var(--aierp-black-rgb) / .5);
}
.app-sidebar.collapsed .sidebar-nav-section:hover .sidebar-nav-dropdown {
  display: block;
}
.app-sidebar:not(.collapsed) .sidebar-nav-dropdown { display: none !important; }
.sidebar-nav-dropdown-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--aierp-text-tertiary);
  padding: 6px 10px 8px;
  border-bottom: 1px solid var(--aierp-border);
  margin-bottom: 4px;
}
.sidebar-nav-dropdown-item {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--aierp-text-secondary);
  border-radius: var(--aierp-radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--aierp-duration-fast);
  white-space: nowrap;
}
.sidebar-nav-dropdown-item:hover,
.sidebar-nav-dropdown-item.active {
  color: var(--aierp-white);
  background: rgb(var(--aierp-accent-rgb) / .1);
}
.app-sidebar:not(.collapsed) .sidebar-nav-dropdown { display: none !important; }

/* Sidebar footer (user info) */
.sidebar-footer {
  border-top: 1px solid var(--aierp-border);
  padding: 12px 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--aierp-accent-secondary), var(--aierp-accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--aierp-bg-alt);
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--aierp-text);
  line-height: 1.1;
}
.collapsed .sidebar-toggle {
  top: 54px;
}
.sidebar-user-role { font-size: 10px; color: var(--aierp-text-tertiary); }
.sidebar-toggle {
  position: absolute;
  top: 68px;
  right: 18px;
  width: 26px;
  height: 26px;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-sm);
  background: var(--aierp-surface);
  color: var(--aierp-text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all var(--aierp-duration-fast);
  z-index: 31;
}
.sidebar-toggle:hover {
  background: var(--aierp-surface-overlay);
  color: var(--aierp-text);
  border-color: var(--aierp-border-strong);
}
.user-info-btn { display:block }
.collapsed .user-info-btn { display:none }

/* ── Main content area ── */
.app-main {
  margin-left: var(--aierp-sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 2;
  transition: margin-left var(--aierp-duration-slow) var(--aierp-ease-out-expo);
  min-width: 0;
}
.app-main.no-transition {
  transition: none !important;
}
.app-main.sidebar-collapsed {
  margin-left: var(--aierp-sidebar-collapsed);
}

/* Has right panel (AI sidebar) */
.app-main.has-right-panel {
  margin-right: var(--aierp-ai-panel-w);
  transition: margin-left var(--aierp-duration-slow) var(--aierp-ease-out-expo),
              margin-right var(--aierp-duration-slow) var(--aierp-ease-out-expo);
}
.app-main.right-panel-collapsed {
  margin-right: 0;
}

/* ── Header ── */
.app-header {
  height: var(--aierp-header-h);
  background: rgb(var(--aierp-surface-rgb) / .82);
  border-bottom: 1px solid var(--aierp-border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(20px) saturate(140%);
}
.app-header .header-breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
}
.app-header .header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ── Content area ── */
.app-content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1560px;
  /* max-width: 1760px; */
  width: 100%;
  margin: 0 auto;
}

/* ── Footer ── */
.app-footer {
  height: var(--aierp-footer-h);
  border-top: 1px solid var(--aierp-border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  font-size: 10.5px;
  color: var(--aierp-text-tertiary);
  gap: 14px;
  background: rgb(var(--aierp-surface-rgb) / .6);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}
.app-footer .footer-tenant {
  margin-left: auto;
  color: var(--aierp-text-secondary);
}
.app-footer .footer-locale {
  color: var(--aierp-text-tertiary);
  flex-shrink: 0;
}
.app-footer .footer-status {
  color: var(--aierp-green);
}
.app-footer .status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--aierp-green);
  animation: statusPulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
/* States Aierp.initSystemStatus() sets from /health. While the answer is
   unknown the dot stops pulsing — a pulse that means nothing is worse than a
   still dot. */
.app-footer .status-dot.is-unknown,
.app-footer .status-dot.is-down { animation: none; }
.app-footer .status-dot.is-down { background: var(--aierp-red); }
.app-footer .status-dot.is-unknown { background: var(--aierp-text-tertiary); }
.app-footer .footer-status.is-down { color: var(--aierp-red); }
.app-footer .footer-status.is-unknown { color: var(--aierp-text-tertiary); }
@keyframes statusPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgb(var(--aierp-green-rgb) / .4); }
  50% { box-shadow: 0 0 0 6px rgb(var(--aierp-green-rgb) / 0); }
}

/* ═══════════════════════════════════════════════════════════════
   4. CUSTOM COMPONENTS
   ═══════════════════════════════════════════════════════════════ */

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}
.stat-card {
  position: relative;
  background: var(--aierp-surface);
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-lg);
  padding: 18px 20px 10px;
  overflow: hidden;
  transition: all var(--aierp-duration) var(--aierp-ease-out-expo);
  cursor: default;
}
/* A card that filters the list — it has to look clickable. */
.stat-card--clickable { cursor: pointer; }
.stat-card--clickable:hover {
  border-color: var(--aierp-border-strong);
  transform: translateY(-1px);
}
.stat-card--clickable:focus-visible {
  outline: 2px solid var(--aierp-accent);
  outline-offset: 2px;
}
.stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--aierp-duration);
  background: radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgb(var(--aierp-accent-rgb) / .04), transparent 60%);
}
.stat-card:hover {
  border-color: var(--aierp-border-strong);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgb(var(--aierp-black-rgb) / .3);
}
.stat-card:hover::after { opacity: 1; }
.stat-icon {
  float: left;
  margin: 0 10px 0 0;
  width: 40px;
  height: 40px;
  border-radius: var(--aierp-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-bottom: 12px;
}
.stat-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--aierp-text-tertiary);
  margin-bottom: 5px;
}
.stat-value {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.6px;
  line-height: 1;
  margin-bottom: 4px;    
  float: left;
  padding: 0 10px 0 0px;
  width: 72%;
}
.stat-meta {
  font-size: 11px;
  color: var(--aierp-text-tertiary);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 0 0 0;
  float: left;
}
.stat-trend-up { color: var(--aierp-green); font-weight: 600; }
.stat-trend-down { color: var(--aierp-red); font-weight: 600; }

/* ── Stat card editor ── */
.stats-row { display: flex; align-items: stretch; gap: 10px; margin-bottom: 26px; }
.stats-row .stats-grid { flex: 1; min-width: 0; margin-bottom: 0; }
.stats-picker-btn {
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  background: var(--aierp-surface);
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-lg);
  color: var(--aierp-text-secondary);
  cursor: pointer;
  transition: all var(--aierp-duration) var(--aierp-ease-out-expo);
}
.stats-picker-btn:hover { border-color: var(--aierp-border-strong); color: var(--aierp-text); background: var(--aierp-surface-overlay); }
.stats-picker-btn:focus-visible { outline: 2px solid var(--aierp-accent); outline-offset: 2px; }
.stats-grid:empty { display: none; }
@media (min-width: 1301px) {
  /* 5-6 cards: 3 cols instead of the base 4 — only above the breakpoint that already drops to 2/1 col. */
  .stats-grid[data-count="5"], .stats-grid[data-count="6"] { grid-template-columns: repeat(3, 1fr); }
}
/* Sidebar-aware, same technique as .cmd-bar's left offset: a collapsed
   sidebar frees --aierp-sidebar-w minus --aierp-sidebar-collapsed (196px)
   of real width that the plain max-width queries above can't see (they
   only measure the raw viewport). Below 900px the sidebar is forced
   collapsed anyway (.app-main { margin-left: var(--aierp-sidebar-collapsed) }),
   so there's nothing to compensate for down there. */
@media (min-width: 1101px) and (max-width: 1300px) {
  .app-sidebar.collapsed ~ .app-main .stats-grid,
  .app-main.sidebar-collapsed .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .app-sidebar.collapsed ~ .app-main .stats-grid[data-count="5"],
  .app-main.sidebar-collapsed .stats-grid[data-count="5"],
  .app-sidebar.collapsed ~ .app-main .stats-grid[data-count="6"],
  .app-main.sidebar-collapsed .stats-grid[data-count="6"] { grid-template-columns: repeat(3, 1fr); }
}
/* Kolone prate ŠIRINU SAMOG POPUP-A (container query), ne viewport — na
   uskom viewport-u sa zatvorenim/uskim sidebar-om popup i dalje ima dosta
   prostora, dok isti viewport sa otvorenim/širokim sidebar-om ostavlja
   popup-u manje mesta iako se viewport nije promenio. #statCardPicker's
   .aierp-modal-dialog je container; 420px prag = tačno "širina popup-a
   manja od 421px → 1 red". */
#statCardPicker .aierp-modal-dialog { container-type: inline-size; }
.stat-card-picker-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@container (max-width: 420px) {
  .stat-card-picker-grid { grid-template-columns: 1fr; }
}
.stat-card-tile { cursor: pointer; border-radius: var(--aierp-radius-lg); padding: 3px; border: 2px solid transparent; transition: border-color var(--aierp-duration); }
.stat-card-tile > .stat-card { pointer-events: none; margin: 0; }
.stat-card-tile--selected { border-color: var(--aierp-accent); }
.stat-card-tile--disabled { opacity: .4; cursor: not-allowed; }
.stat-card-picker-spacer { flex: 1; }

/* ── Page Toolbar ── */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-toolbar h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.5px;
  margin: 0;
}
.page-toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Skeleton Loader ── */
.skeleton-table,
.skeleton-stats,
.skeleton-card,
.skeleton-text {
  width: 100%;
}
.skeleton-row {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--aierp-border);
}
.skeleton-header { border-bottom-width: 2px; padding-bottom: 10px; }
.skeleton-cell {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 0 6px;
}
.skeleton-bar {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--aierp-surface) 25%, var(--aierp-surface-elevated) 50%, var(--aierp-surface) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.6s ease-in-out infinite;
}
.skeleton-bar--sm { height: 24px; border-radius: 6px; }
.skeleton-bar--stat-icon { width: 30px; height: 30px; border-radius: 8px; margin-bottom: 10px; }
.skeleton-bar--stat-label { width: 60%; height: 10px; margin-bottom: 6px; }
.skeleton-bar--stat-value { width: 40%; height: 18px; }
.skeleton-bar--card-title { width: 30%; height: 14px; margin-bottom: 16px; }
.skeleton-bar--field-label { width: 40%; height: 9px; margin-bottom: 6px; }
.skeleton-bar--field-input { width: 100%; height: 34px; }
.skeleton-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.skeleton-stat-card {
  padding: 16px;
  background: var(--aierp-surface);
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius);
}
.skeleton-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 18px;
}
.skeleton-field {
  display: flex;
  flex-direction: column;
}
.skeleton-text .skeleton-bar {
  margin-bottom: 10px;
  height: 14px;
}
@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Page Tabs ── */
.page-tabs {
  /* display: flex; */
  gap: 2px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--aierp-border);
  padding-bottom: 0;
}
.page-tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--aierp-text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--aierp-duration-fast);
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.page-tab:hover { color: var(--aierp-text-secondary); }
.page-tab.active {
  color: var(--aierp-white);
  border-bottom-color: var(--aierp-accent);
  font-weight: 600;
}
.page-tab .tab-count {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 100px;
  background: rgb(var(--aierp-white-rgb) / .06);
  font-weight: 600;
}

/* ── In-page Tabs (detail sekcije) ── */
.aierp-tabs-nav {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--aierp-border);
}
.aierp-tab-btn {
  padding: 9px 16px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--aierp-text-tertiary);
  cursor: pointer;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-sm) var(--aierp-radius-sm) 0 0;
  background: var(--aierp-surface);
  color: var(--aierp-text-tertiary);
  transition: all var(--aierp-duration-fast);
  white-space: nowrap;
  font-family: var(--aierp-font);
}
.aierp-tab-btn:hover { color: var(--aierp-text); }
.aierp-tab-btn.active {
  color: var(--aierp-white);
  border-bottom-color: var(--aierp-accent);
  font-weight: 600;
}
.aierp-tab-panel {
  display: none;
  min-width: 0;
}
.aierp-tab-panel:first-child { display: block; }
.aierp-tab-panel .section-card {
  overflow: hidden;
}

/* ── Wizard (višekoračni proces) ── */
.wizard-steps {
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--aierp-surface);
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-lg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.wizard-step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  position: relative;
}
.wizard-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  border: 2px solid var(--aierp-border-strong);
  color: var(--aierp-text-tertiary);
  background: var(--aierp-bg-alt);
  transition: all var(--aierp-duration);
}
.wizard-step-item.completed .wizard-step-num {
  border-color: var(--aierp-green);
  background: var(--aierp-green);
  color: var(--aierp-text-inverse);
}
.wizard-step-item.active .wizard-step-num {
  border-color: var(--aierp-accent-light);
  background: var(--aierp-accent);
  color: var(--aierp-white);
  box-shadow: 0 0 12px var(--aierp-accent-glow);
}
.wizard-step-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--aierp-text-tertiary);
  white-space: nowrap;
  transition: color var(--aierp-duration);
}
.wizard-step-item.completed .wizard-step-label { color: var(--aierp-green); }
.wizard-step-item.active .wizard-step-label { color: var(--aierp-white); }
.wizard-step-line {
  flex: 1;
  height: 2px;
  background: var(--aierp-border);
  margin: auto 8px;
  min-width: 16px;
  transition: background var(--aierp-duration);
}
.wizard-step-line.done { background: var(--aierp-green); }
.wizard-content {
  margin-bottom: 16px;
}
.wizard-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-top: 1px solid var(--aierp-border);
}
.wizard-counter {
  font-size: 12px;
  color: var(--aierp-text-tertiary);
  font-weight: 500;
}
.wizard-step-panel { display: none; }
.wizard-step-panel.active { display: block; padding:20px; }
.wizard-step-panel h6 { 
  padding: 20px;
  margin: 10px auto; 
  color: var(--aierp-text-muted-alt);
  }

/* ── Wizard inside modal — more compact, centered, no background card ── */
.wizard-steps-modal {
  justify-content: center;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--aierp-border);
  border-radius: 0;
  padding: 16px 24px 20px;
  margin-bottom: 0;
}
.wizard-steps-modal .wizard-step-item { flex: 0 0 auto; }

.aierp-wizard .form-control { font-size: 16px; }
@media (max-width: 900px) {
  .aierp-wizard .form-control { font-size: 16px; }
}

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar .form-control,
.filter-bar .form-select {
  min-width: 140px;
  width: auto;
}
.filter-bar input[type="search"] {
  width: 460px;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--aierp-border);
  background: var(--aierp-surface);
  color: var(--aierp-text-secondary);
  cursor: pointer;
  transition: all var(--aierp-duration-fast);
}
.filter-chip:hover {
  border-color: var(--aierp-border-strong);
  color: var(--aierp-text);
}
.filter-chip.active {
  background: rgb(var(--aierp-accent-rgb) / .1);
  border-color: var(--aierp-accent);
  color: var(--aierp-accent-light);
}
.filter-chip .chip-close {
  font-size: 14px;
  opacity: .4;
  cursor: pointer;
}
.filter-chip .chip-close:hover { opacity: 1; }
.filter-results {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--aierp-text-tertiary);
  white-space: nowrap;
}

/* ── Date Range (od-do filter) ── */
.date-range {
  display: flex;
  align-items: center;
  gap: 0;
}
.date-range-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--aierp-text-tertiary);
  margin-right: 8px;
  white-space: nowrap;
}
.date-range-inputs {
  display: flex;
  align-items: center;
  gap: 0;
}
.date-range-inputs .form-control {
  width: auto;
  min-width: 130px;
}
.date-range-sep {
  padding: 0 6px;
  color: var(--aierp-text-tertiary);
  font-size: 12px;
}

/* ── Dual Date Input (native picker + dd.MM.yyyy display) ── */
.aierp-date-wrap {
  position: relative;
}
.aierp-date-input {
  cursor: pointer;
  /* calendar icon on the right */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 32px;
}
/* A readonly date field must not look clickable — aierp.js also skips
   openCalendar() for it, this just keeps the cursor/icon honest about that. */
.aierp-date-input[readonly] {
  cursor: default;
  background-image: none;
  padding-right: 12px;
}

/* No existing [readonly] treatment anywhere else — x-form-input's readonly
   prop had no styled precedent before the kursna lista platform-row view. */
.form-control[readonly] {
  cursor: default;
  background-color: var(--aierp-bg-alt);
}

/* ── Date Picker Calendar ── */
.aierp-calendar {
  display: none;
  position: fixed;
  z-index: 9999;
  background: var(--aierp-surface);
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius);
  padding: 10px 12px 12px;
  min-width: 260px;
  box-shadow: 0 8px 24px rgb(var(--aierp-black-rgb) / .4);
  font-size: 12px;
  user-select: none;
}
.aierp-calendar.open { display: block; }
.aierp-calendar-header {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}
.aierp-calendar-header button {
  background: none;
  border: 1px solid var(--aierp-border);
  color: var(--aierp-text-secondary);
  width: 26px; height: 26px;
  border-radius: var(--aierp-radius-sm);
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--aierp-duration-fast);
}
.aierp-calendar-header button:hover { background: var(--aierp-surface-overlay); color: var(--aierp-text); }
.cal-month-sel,
.cal-year-sel {
  background: var(--aierp-bg-alt);
  color: var(--aierp-text);
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-sm);
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--aierp-font);
}
.cal-month-sel { flex: 1; }
.cal-year-sel { width: 70px; }
.cal-month-sel:focus,
.cal-year-sel:focus { outline: none; border-color: var(--aierp-border-focus); }
.aierp-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  color: var(--aierp-text-tertiary);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.aierp-calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.aierp-calendar-day {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--aierp-radius-sm);
  cursor: pointer;
  color: var(--aierp-text-secondary);
  font-variant-numeric: tabular-nums;
  transition: all var(--aierp-duration-fast);
  font-size: 11.5px;
}
.aierp-calendar-day:hover { background: var(--aierp-surface-overlay); color: var(--aierp-text); }
.aierp-calendar-day.other { color: var(--aierp-text-tertiary); opacity: .4; }
.aierp-calendar-day.today { border: 1px solid var(--aierp-border-strong); }
.aierp-calendar-day.selected { background: var(--aierp-accent); color: var(--aierp-white); font-weight: 700; }

/* ── Bulk Actions Bar ── */
.bulk-close { cursor: pointer; opacity: .7; font-size: 16px; transition: opacity var(--aierp-duration-fast); }
.bulk-close:hover { opacity: 1; }


/* ── Data Table (enhanced Bootstrap table) ── */
.data-table-container {
  background: var(--aierp-surface);
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-lg);
  overflow: clip;
}
.data-table-wrapper {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--aierp-text-tertiary) transparent;
}
.table.data-table {
  margin-bottom: 0;
}
.table.data-table thead th {
  background: var(--aierp-surface-elevated);
  position: sticky;
  top: 0;
  z-index: 2;
  user-select: none;
}
.table.data-table thead th.sortable {
  cursor: pointer;
  transition: color var(--aierp-duration-fast);
}
.table.data-table thead th.sortable:hover {
  color: var(--aierp-text-secondary);
}
.table.data-table thead th.sortable .sort-icon {
  display: inline-block;
  margin-left: 3px;
  font-size: 9px;
  opacity: .4;
  transition: opacity var(--aierp-duration-fast);
}
.table.data-table thead th.sortable:hover .sort-icon { opacity: .8; }
.table.data-table thead th.sortable.sorted .sort-icon {
  opacity: 1;
  color: var(--aierp-accent-light);
}
.table.data-table thead th.col-check { width: 40px; text-align: center; padding: 0; }
.table.data-table tbody tr.row-muted td { color: var(--aierp-text-tertiary); }
.table.data-table thead th.col-actions { width: 44px; }

.table.data-table tbody tr { transition: all var(--aierp-duration-fast); position: relative; }
.table.data-table tbody tr.selected td { background: rgb(var(--aierp-accent-rgb) / .06); }
.table.data-table tbody tr:last-child td { border-bottom: none; }
.table.data-table tfoot td {
  background: var(--aierp-surface-elevated);
  border-top: 2px solid var(--aierp-border-strong);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.import-mapping-row.is-ignored { opacity: .6; }
.map-ignored {
  font-size: 12px;
  font-style: italic;
  color: var(--aierp-text-secondary);
}

.data-table-summary-label {
  color: var(--aierp-text-secondary);
  font-size: 10.5px;
  text-transform: uppercase;
}
.data-table-summary-value { 
    min-width: 120px;
    display: block; 
}

.table.data-table .cell-num {
  font-weight: 700;
  color: var(--aierp-accent-light);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.2px;
}
.table.data-table .cell-money {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.table.data-table .cell-total {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.table.data-table .cell-check { text-align: center; padding: 0; }
.cell-check-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 38px;
  cursor: pointer;
  margin: 0;
  min-width: 32px;
}
.table.data-table .cell-check .form-check-input {
  width: 15px;
  height: 15px;
  cursor: pointer;
  margin: 0;
}
.table.data-table .cell-actions { text-align: center; }

/* ── Row focus (while the popup is open) ── */
.table.data-table tbody tr.row-focused {
  outline: 1px solid var(--aierp-border-focus);
  outline-offset: -1px;
  background: rgb(var(--aierp-accent-rgb) / .015);
  transition: background var(--aierp-duration-slow) var(--aierp-ease-out-expo);
}
.table.data-table .cell-link {
  color: var(--aierp-text);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--aierp-duration-fast);
}
.table.data-table .cell-link:hover { color: var(--aierp-accent-light); }
.table.data-table tbody tr { }

.cell-truncate-text { display: inline; white-space: pre-line; }
.cell-truncate-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 3px;
  padding: 0;
  border: none;
  background: none;
  color: var(--aierp-text-tertiary);
  cursor: pointer;
  vertical-align: -3px;
  transition: color var(--aierp-duration-fast);
}
.cell-truncate-toggle svg { width: 12px; height: 12px; transition: transform var(--aierp-duration-fast); }
.cell-truncate-toggle:hover { color: var(--aierp-accent-light); }
.cell-truncate-toggle.expanded svg { transform: rotate(180deg); }

/* Row action trigger */
.row-action-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--aierp-radius-sm);
  color: var(--aierp-text-tertiary);
  cursor: pointer;
  transition: all var(--aierp-duration-fast);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -1px;
  border: none;
  background: transparent;
}
.row-action-trigger:hover {
  color: var(--aierp-text);
  background: rgb(var(--aierp-white-rgb) / .04);
}
/* Direct row action shown next to the ⋯ trigger (drill-down into a
   document's lines) — same 28×28 target, icon instead of the ellipsis. */
.row-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--aierp-radius-sm);
  color: var(--aierp-text-tertiary);
  cursor: pointer;
  transition: all var(--aierp-duration-fast);
  border: none;
  background: transparent;
}
.row-action-btn:hover {
  color: var(--aierp-text);
  background: rgb(var(--aierp-white-rgb) / .04);
}

/* ── Status Badges ── */
.aierp-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
}
.aierp-badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Row Popup Menu ── */
.row-popup-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--aierp-surface-overlay);
  border: 1px solid var(--aierp-border-strong);
  border-radius: var(--aierp-radius);
  box-shadow: 0 20px 60px rgb(var(--aierp-black-rgb) / .5), 0 0 0 1px rgb(var(--aierp-white-rgb) / .03);
  z-index: 99;
  min-width: 200px;
  padding: 6px;
  display: none;
  animation: popupIn var(--aierp-duration-fast) var(--aierp-ease-out-back);
  transform-origin: top right;
}
.row-popup-menu.show { display: block; }
@keyframes popupIn {
  from { opacity: 0; transform: scale(.92) translateY(-6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.popup-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--aierp-text-secondary);
  border-radius: var(--aierp-radius-sm);
  cursor: pointer;
  transition: all var(--aierp-duration-fast);
  white-space: nowrap;
}
.popup-menu-item:hover {
  background: rgb(var(--aierp-white-rgb) / .04);
  color: var(--aierp-text);
}
.popup-menu-item svg {
  width: 15px;
  height: 15px;
  opacity: .5;
  flex-shrink: 0;
}
.popup-menu-item.danger { color: var(--aierp-red); }
.popup-menu-item.danger:hover { background: var(--aierp-red-bg); }
/* A row action that submits its own <form> (full-page POST, e.g. "Kloniraj")
   instead of the AJAX Aierp.toggleActive()/confirmAndDelete() pattern —
   resets default <button> chrome so it matches the plain <div> items. */
.popup-menu-form { margin: 0; }
.popup-menu-form .popup-menu-item {
  width: 100%;
  background: none;
  border: none;
  font: inherit;
}
.popup-menu-form:hover {
  background: rgb(var(--aierp-white-rgb) / .04);
  color: var(--aierp-text);
  border-radius: 6px;
}
.popup-menu-divider {
  height: 1px;
  background: var(--aierp-border);
  margin: 4px 8px;
}
.popup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 49;
  display: none;
}
.popup-backdrop.show { display: block; }

/* ── Column Visibility Dropdown ── */
/* max-height + scroll: a module with many columns used to render a list
   taller than the viewport, and the browser simply clipped the bottom
   entries with no way to reach them. */
.col-vis-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--aierp-surface-overlay);
  border: 1px solid var(--aierp-border-strong);
  border-radius: var(--aierp-radius);
  box-shadow: 0 20px 60px rgb(var(--aierp-black-rgb) / .5);
  z-index: 99;
  min-width: 200px;
  padding: 6px;
  display: none;
  max-height: min(55vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.col-vis-menu.show { display: block; }
.col-vis-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--aierp-text-secondary);
  border-radius: var(--aierp-radius-sm);
  cursor: pointer;
  transition: all var(--aierp-duration-fast);
  white-space: nowrap;
  margin: 0;
  font-weight: 400;
}
.col-vis-option:hover {
  background: rgb(var(--aierp-white-rgb) / .04);
  color: var(--aierp-text);
}
.col-vis-option input[type="checkbox"] {
  accent-color: var(--aierp-accent);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--aierp-text-tertiary);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: .3;
}
.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--aierp-text-secondary);
  margin-bottom: 6px;
}
.empty-state p { font-size: 13px; margin-bottom: 20px; }
.empty-state-search-note {
  font-size: 12px;
  color: var(--aierp-text-tertiary);
  max-width: 620px;
  margin: -8px auto 20px;
  line-height: 1.6;
}
.empty-state-search-fields { color: var(--aierp-text-secondary); font-weight: 500; }

/* ── Command Bar ── */
.cmd-bar {
  position: fixed;
  bottom: 20px;
  left: calc(var(--aierp-sidebar-w) + (100vw - var(--aierp-sidebar-w)) / 2);
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--aierp-surface-overlay);
  border: 1px solid var(--aierp-border-strong);
  border-radius: 100px;
  box-shadow: 0 12px 40px rgb(var(--aierp-black-rgb) / .5), 0 0 0 1px rgb(var(--aierp-white-rgb) / .02);
  backdrop-filter: blur(20px);
  transition: left var(--aierp-duration-slow) var(--aierp-ease-out-expo), background var(--aierp-duration-fast), border-color var(--aierp-duration-fast);
}
.cmd-bar-normal { display: flex; align-items: center; gap: 6px; }
.cmd-bar-bulk  { display: none;  align-items: center; gap: 6px; }
.cmd-bar.bulk {
  background: rgb(var(--aierp-accent-rgb) / 15%);
  border-color: rgb(var(--aierp-accent-rgb) / 30%);
}
.cmd-bar.bulk .cmd-bar-normal { display: none; }
.cmd-bar.bulk .cmd-bar-bulk  { display: flex; }
.cmd-bar.bulk .cmd-item { color: var(--aierp-accent); }
.cmd-bar.bulk .bulk-close { color: var(--aierp-text-secondary); }
.cmd-bar.bulk .bulk-close:hover { color: var(--aierp-text); background: rgb(var(--aierp-white-rgb) / .06); }
.bulk-count { font-size: 12px; font-weight: 600; color: var(--aierp-accent); white-space: nowrap; padding: 0 4px; }
.app-sidebar.collapsed ~ .app-main .cmd-bar,
.app-main.sidebar-collapsed .cmd-bar {
  left: calc(var(--aierp-sidebar-collapsed) + (100vw - var(--aierp-sidebar-collapsed)) / 2);
}
@media (min-width: 1101px) {
  body.ai-panel-open .cmd-bar {
    left: calc(var(--aierp-sidebar-w) + (100vw - var(--aierp-sidebar-w) - var(--aierp-ai-panel-w)) / 2);
  }
  body.ai-panel-open .app-sidebar.collapsed ~ .app-main .cmd-bar,
  body.ai-panel-open .app-main.sidebar-collapsed .cmd-bar {
    left: calc(var(--aierp-sidebar-collapsed) + (100vw - var(--aierp-sidebar-collapsed) - var(--aierp-ai-panel-w)) / 2);
  }
}
.cmd-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  color: var(--aierp-text-secondary);
  cursor: pointer;
  transition: all var(--aierp-duration-fast);
  white-space: nowrap;
  border: none;
  background: transparent;
  font-family: var(--aierp-font);
}
.cmd-item:hover {
  background: rgb(var(--aierp-white-rgb) / .04);
  color: var(--aierp-text);
}
.cmd-item .cmd-key {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgb(var(--aierp-white-rgb) / .06);
  color: var(--aierp-text-tertiary);
  font-family: var(--aierp-font);
  font-weight: 600;
}
.cmd-divider {
  width: 1px;
  height: 18px;
  background: var(--aierp-border);
  margin: 0 4px;
}

/* ── Toast Notifications ── */
.toast-container-aierp {
  position: fixed;
  top: 20px;
  right: 20px;
  max-width: calc(100vw - 40px);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast-aierp {
  padding: 12px 18px;
  border-radius: var(--aierp-radius);
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(20px);
  animation: toastIn var(--aierp-duration) var(--aierp-ease-out-back);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 30px rgb(var(--aierp-black-rgb) / .4);
  max-width: 380px;
}

/* Inline actions inside a toast (undo, dismiss) — the toast owns its colour,
   so both inherit it with currentColor instead of picking their own. */
.toast-aierp-action,
.toast-aierp-close {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: currentColor;
  cursor: pointer;
  font: inherit;
}
.toast-aierp-action {
  margin-left: auto;
  padding: 2px 8px;
  border: 1px solid currentColor;
  border-radius: var(--aierp-radius-sm);
  font-weight: 600;
}
.toast-aierp-close {
  margin-left: auto;
  width: 20px;
  height: 20px;
  line-height: 1;
  font-size: 16px;
  opacity: .6;
}
.toast-aierp-action + .toast-aierp-close { margin-left: 0; }
.toast-aierp-close:hover { opacity: 1; }
.toast-aierp-success {
  background: rgb(var(--aierp-green-rgb) / .12);
  border: 1px solid rgb(var(--aierp-green-rgb) / .2);
  color: var(--aierp-green);
}
.toast-aierp-error {
  background: rgb(var(--aierp-red-rgb) / .12);
  border: 1px solid rgb(var(--aierp-red-rgb) / .2);
  color: var(--aierp-red);
}
.toast-aierp-warning {
  background: rgb(var(--aierp-amber-rgb) / .12);
  border: 1px solid rgb(var(--aierp-amber-rgb) / .2);
  color: var(--aierp-amber);
}
.toast-aierp-info {
  background: rgb(var(--aierp-blue-rgb) / .12);
  border: 1px solid rgb(var(--aierp-blue-rgb) / .2);
  color: var(--aierp-blue);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* ── FAB (Floating Action Button) ── */
.fab-aierp {
  position: fixed;
  bottom: 80px;
  right: 28px;
  z-index: 99;
  display: inline-flex;
  align-items: center;
  gap: 0px;
  padding: 12px 12px 12px 12px;
  background: linear-gradient(135deg, var(--aierp-accent), var(--aierp-accent-deep));
  color: var(--aierp-white);
  border-radius: 100px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .2px;
  box-shadow: 0 8px 32px var(--aierp-accent-glow), 0 0 0 4px rgb(var(--aierp-accent-rgb) / .08);
  transition: all var(--aierp-duration) var(--aierp-ease-out-expo);
  animation: fabPulse 3s ease-in-out infinite;
  border: none;
  cursor: grab;
  font-family: var(--aierp-font);
  user-select: none;
}
.fab-aierp:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 14px 44px rgb(var(--aierp-accent-rgb) / .5), 0 0 0 8px rgb(var(--aierp-accent-rgb) / .1);
  color: var(--aierp-white);
}
.fab-aierp svg {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 0 6px rgb(var(--aierp-white-rgb) / .3));
}
@keyframes fabPulse {
  0%, 100% { box-shadow: 0 8px 32px var(--aierp-accent-glow), 0 0 0 4px rgb(var(--aierp-accent-rgb) / .08); }
  50% { box-shadow: 0 8px 32px rgb(var(--aierp-accent-rgb) / .45), 0 0 0 14px rgb(var(--aierp-accent-rgb) / 0); }
}


/* ── Header buttons (notifications + gear) ── */
.header-notif-btn,
.header-gear-btn {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--aierp-border);
  background: var(--aierp-surface);
  color: var(--aierp-text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--aierp-duration-fast);
  font-size: 14px;
}
.header-notif-btn:hover,
.header-gear-btn:hover {
  color: var(--aierp-text);
  border-color: var(--aierp-border-strong);
  background: var(--aierp-surface-elevated);
}
.header-notif-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--aierp-red);
  border: 1px solid var(--aierp-bg);
}
/* Per-row unread indicator (notifications table) — same visual weight as
   header-notif-dot, just inline instead of absolutely positioned. */
.notif-unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--aierp-blue);
  flex-shrink: 0;
}
/* v. Notification::dotState() */
.notif-unread-dot.notif-dot-red {
  background: var(--aierp-red);
}

/* ── Notification bell dropdown (same show-toggle pattern as .header-user-dropdown) ── */
.header-notif-menu {
  position: relative;
  display: flex;
  align-items: center;
}
.header-notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--aierp-surface-elevated);
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius);
  box-shadow: 0 12px 32px rgb(var(--aierp-black-rgb) / 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all var(--aierp-duration-fast);
  z-index: 1100;
  overflow: hidden;
}
.header-notif-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.notif-dropdown-header {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--aierp-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--aierp-border);
}
.notif-dropdown-empty {
  padding: 24px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--aierp-text-tertiary);
}
.notif-dropdown-list {
  max-height: 360px;
  overflow-y: auto;
}
.notif-dropdown-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
  border-bottom: 1px solid var(--aierp-border);
  transition: background var(--aierp-duration-fast);
}
.notif-dropdown-item:last-child {
  border-bottom: none;
}
.notif-dropdown-item:hover {
  background: var(--aierp-surface);
}
.notif-dropdown-item .notif-unread-dot {
  margin-top: 5px;
}
.notif-dropdown-item-spacer {
  display: inline-block;
  width: 8px;
  flex-shrink: 0;
}
.notif-dropdown-item-body {
  min-width: 0;
}
.notif-dropdown-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--aierp-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-dropdown-item.unread .notif-dropdown-item-title {
  font-weight: 600;
  color: var(--aierp-text);
}
.notif-dropdown-item-snippet {
  font-size: 12px;
  color: var(--aierp-text-tertiary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-dropdown-item-time {
  font-size: 11px;
  color: var(--aierp-text-tertiary);
  margin-top: 4px;
}
.notif-dropdown-footer {
  display: block;
  padding: 10px 14px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--aierp-accent);
  text-decoration: none;
  border-top: 1px solid var(--aierp-border);
  transition: background var(--aierp-duration-fast);
}
.notif-dropdown-footer:hover {
  background: var(--aierp-surface);
}

/* ── Notification detail (<x-detail-modal> body content, Faza 0.8b) ── */
.notif-detail-badges {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.notif-detail-body {
  margin: 0 0 16px;
  white-space: pre-wrap;
  color: var(--aierp-text);
}
.notif-detail-error {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: var(--aierp-radius-sm);
  background: rgb(var(--aierp-red-rgb) / 0.08);
  color: var(--aierp-red);
  font-size: 12px;
}
.notif-detail-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0;
}
.notif-detail-meta dt {
  color: var(--aierp-text-tertiary);
  font-size: 12px;
}
.notif-detail-meta dd {
  margin: 0;
  color: var(--aierp-text-secondary);
  font-size: 12px;
}
.notif-detail-action {
  margin-top: 16px;
}

/* ── Header user menu (avatar + dropdown) ── */
.header-user-menu {
  position: relative;
  margin-left: 6px;
}
.header-avatar-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--aierp-border);
  background: var(--aierp-accent);
  color: var(--aierp-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all var(--aierp-duration-fast);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.5px;
}
.header-avatar-btn:hover {
  opacity: 0.9;
  box-shadow: 0 0 0 3px rgb(var(--aierp-accent-rgb) / 0.25);
}
.header-avatar-initials {
  line-height: 1;
  user-select: none;
}

/* Dropdown */
.header-user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--aierp-surface-elevated);
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius);
  box-shadow: 0 12px 32px rgb(var(--aierp-black-rgb) / 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all var(--aierp-duration-fast);
  z-index: 1100;
  padding: 6px 0;
}
.header-user-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.dropdown-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}
.dropdown-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--aierp-accent);
  color: var(--aierp-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.dropdown-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--aierp-text);
  line-height: 1.2;
}
.dropdown-user-email {
  font-size: 11px;
  color: var(--aierp-text-tertiary);
  line-height: 1.2;
}
.dropdown-divider {
  height: 1px;
  background: var(--aierp-border);
  margin: 4px 0;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--aierp-text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--aierp-duration-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.dropdown-item:hover {
  background: var(--aierp-surface);
  color: var(--aierp-text);
}
.dropdown-item-form {
  margin: 0;
}
.dropdown-item-logout {
  color: var(--aierp-red) !important;
}
.dropdown-item-logout:hover {
  background: rgb(var(--aierp-red-rgb) / 0.08) !important;
}

/* ── Theme row: the label toggles dark/light, the stepper picks the light tone.
   The row is a <div> so the stepper buttons are not nested inside a button. ── */
.dropdown-item.theme-item {
  gap: 0;
  padding: 0 10px 0 0;
  justify-content: space-between;
}
.dropdown-item.theme-item:hover {
  background: none;
}
.theme-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 7px 14px;
  border: none;
  background: none;
  color: inherit;
  font-family: var(--aierp-font);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background var(--aierp-duration-fast);
}
.theme-item-main:hover {
  background: var(--aierp-surface);
  color: var(--aierp-text);
}
.theme-tone {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
/* Tones exist only for the light theme — the dark one is a single palette. */
html:not([data-theme="light"]) .theme-tone {
  display: none;
}
.theme-tone-btn {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-sm);
  background: none;
  color: var(--aierp-text-secondary);
  font-family: var(--aierp-font);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: all var(--aierp-duration-fast);
}
.theme-tone-btn:hover:not(:disabled) {
  background: var(--aierp-surface-overlay);
  border-color: var(--aierp-border-strong);
  color: var(--aierp-text);
}
.theme-tone-btn:disabled {
  opacity: .35;
  cursor: default;
}
.theme-tone-value {
  min-width: 14px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--aierp-text-tertiary);
}

/* ── Button extensions ── */
.btn-aierp-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--aierp-text-secondary);
}
.btn-aierp-ghost:hover {
  background: rgb(var(--aierp-white-rgb) / .03);
  color: var(--aierp-text);
}
.btn-aierp-icon {
  padding: 8px;
  width: 34px;
  height: 34px;
  justify-content: center;
}
.btn .kbd-shortcut {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  font-size: 10px;
  border-radius: 4px;
  border: 1px solid var(--aierp-border-strong);
  color: var(--aierp-text-tertiary);
  font-family: var(--aierp-font);
  background: rgb(var(--aierp-black-rgb) / .2);
}

/* ═══════════════════════════════════════════════════════════════
   5. AI PANEL — Desni sidebar asistent
   ═══════════════════════════════════════════════════════════════ */

.ai-panel {
  width: var(--aierp-ai-panel-w);
  min-width: var(--aierp-ai-panel-w);
  background: linear-gradient(180deg, var(--aierp-surface) 0%, var(--aierp-bg-alt) 100%);
  border-left: 1px solid var(--aierp-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  transition: transform var(--aierp-duration-slow) var(--aierp-ease-out-expo),
              opacity var(--aierp-duration-slow) var(--aierp-ease-out-expo);
}
.ai-panel.collapsed {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.ai-panel-resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -5px;
  z-index: 1;
  width: 10px;
  cursor: col-resize;
  touch-action: none;
}
.ai-panel-resize-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 4px;
  width: 2px;
  height: 48px;
  border-radius: var(--aierp-radius-sm);
  background: var(--aierp-border-strong);
  transform: translateY(-50%);
  transition: background var(--aierp-duration-fast);
}
.ai-panel-resize-handle:hover::after,
.ai-panel-resize-handle:focus-visible::after { background: var(--aierp-accent); }
.ai-panel.is-resizing,
.app-main.ai-panel-resizing { transition: none; }
body.ai-panel-resizing { cursor: col-resize; user-select: none; }
body.ai-panel-resizing .cmd-bar { transition: none; }

.ai-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--aierp-border);
  flex-shrink: 0;
}
.ai-panel-logo {
  width: 30px;
  height: 30px;
  border-radius: var(--aierp-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ai-panel-logo img {
  width: 28px;
  height: 28px;
  border-radius: 5px;
}
.ai-panel-title {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--aierp-text);
}
.ai-panel-subtitle {
  font-size: 10px;
  color: var(--aierp-text-tertiary);
  margin-top: 1px;
}
.ai-panel-actions {
  margin-left: auto;
  display: flex;
  gap: 3px;
}
.ai-panel-actions button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--aierp-border);
  background: transparent;
  color: var(--aierp-text-tertiary);
  border-radius: var(--aierp-radius-sm);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--aierp-duration-fast);
  font-family: var(--aierp-font);
}
.ai-panel-actions button:hover {
  background: var(--aierp-surface-overlay);
  color: var(--aierp-text);
  border-color: var(--aierp-border-strong);
}
.ai-panel-actions button:disabled,
.ai-session-drawer button:disabled,
.ai-session-drawer input:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.ai-session-drawer {
  display: flex;
  flex: 0 1 42%;
  min-height: 150px;
  flex-direction: column;
  border-bottom: 1px solid var(--aierp-border);
  background: var(--aierp-surface-elevated);
}
.ai-session-drawer-head {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--aierp-border);
  font-size: 11px;
  color: var(--aierp-text);
}
.ai-session-drawer-head span {
  margin-left: auto;
  font-size: 10px;
  color: var(--aierp-text-tertiary);
}
.ai-session-list {
  min-height: 0;
  overflow-y: auto;
}
.ai-session-item {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--aierp-border);
}
.ai-session-item.is-current {
  box-shadow: inset 2px 0 0 var(--aierp-accent);
}
.ai-session-open {
  min-width: 0;
  flex: 1;
  padding: 9px 10px 9px 16px;
  border: 0;
  background: transparent;
  color: var(--aierp-text);
  text-align: left;
  cursor: pointer;
  font-family: var(--aierp-font);
}
.ai-session-open:hover,
.ai-session-rename:hover,
.ai-session-rename-form button:hover,
.ai-session-more:hover {
  background: rgb(var(--aierp-white-rgb) / .05);
}
.ai-session-title,
.ai-session-date {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-session-title {
  font-size: 11px;
  font-weight: 600;
}
.ai-session-date {
  margin-top: 2px;
  font-size: 9.5px;
  color: var(--aierp-text-tertiary);
}
.ai-session-rename,
.ai-session-rename-form button {
  width: 34px;
  flex: 0 0 34px;
  border: 0;
  background: transparent;
  color: var(--aierp-text-tertiary);
  cursor: pointer;
}
.ai-session-rename-form {
  display: flex;
  min-width: 0;
  flex: 1;
  padding-left: 10px;
}
.ai-session-rename-form input {
  min-width: 0;
  flex: 1;
  margin: 6px 0;
  padding: 5px 8px;
  border: 1px solid var(--aierp-border-strong);
  border-radius: var(--aierp-radius-sm);
  outline: none;
  background: var(--aierp-surface);
  color: var(--aierp-text);
  font: 11px var(--aierp-font);
}
.ai-session-rename-form input:focus {
  border-color: var(--aierp-accent);
}
.ai-session-more {
  flex: 0 0 auto;
  padding: 7px;
  border: 0;
  border-top: 1px solid var(--aierp-border);
  background: transparent;
  color: var(--aierp-accent-light);
  font: 10.5px var(--aierp-font);
  cursor: pointer;
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--aierp-text-tertiary) transparent;
}
.ai-messages::-webkit-scrollbar { width: 3px; }
.ai-messages::-webkit-scrollbar-thumb {
  background: var(--aierp-text-tertiary);
  border-radius: 10px;
}

.ai-msg {
  display: flex;
  gap: 10px;
  font-size: 12.5px;
  line-height: 1.5;
}
.ai-msg.ai-user { flex-direction: row-reverse; }
.ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
}
.ai-msg-avatar.ai-avatar-theme {
  background: transparent;
  color: var(--aierp-white);
  box-shadow: none;
  padding: 0;
}
.ai-msg-avatar.ai-avatar-theme img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: block;
}
.ai-msg-avatar.user-avatar-theme {
  background: var(--aierp-surface-overlay);
  color: var(--aierp-text-secondary);
  border: 1px solid var(--aierp-border);
}
.ai-msg-bubble {
  padding: 10px 14px;
  border-radius: var(--aierp-radius);
  max-width: 88%;
}
.ai-user .ai-msg-bubble {
  background: linear-gradient(135deg, var(--aierp-accent), var(--aierp-accent-deep));
  color: var(--aierp-white);
  border-bottom-right-radius: var(--aierp-radius-sm);
  box-shadow: 0 4px 12px var(--aierp-accent-glow);
}
.ai-bot .ai-msg-bubble {
  background: var(--aierp-surface-elevated);
  border: 1px solid var(--aierp-border);
  border-bottom-left-radius: var(--aierp-radius-sm);
}
.ai-msg-bubble .ai-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
  opacity: .7;
}
.ai-thinking {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}
.ai-thinking span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--aierp-text-tertiary);
  animation: aiDotPulse 1.4s infinite;
}
.ai-thinking span:nth-child(2) { animation-delay: .2s; }
.ai-thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes aiDotPulse {
  0%, 80%, 100% { opacity: .3; transform: scale(.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

.ai-prompts {
  padding: 0 16px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ai-prompts button {
  padding: 5px 11px;
  font-size: 10.5px;
  font-weight: 500;
  border: 1px solid var(--aierp-border);
  border-radius: 100px;
  background: transparent;
  color: var(--aierp-text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--aierp-duration-fast);
  font-family: var(--aierp-font);
}
.ai-prompts button:hover {
  border-color: var(--aierp-accent);
  color: var(--aierp-accent-light);
  background: rgb(var(--aierp-accent-rgb) / .06);
}

/* Executed-call line — sits ABOVE the answer it explains, indented to the
   bubble's text column so the two read as one unit. Deliberately quieter than
   an answer: it is a check, not content. */
.ai-tool-line {
  margin: 2px 0 -2px 34px;
  padding: 5px 10px;
  border-left: 2px solid var(--aierp-accent);
  border-radius: 0 var(--aierp-radius-sm) var(--aierp-radius-sm) 0;
  background: rgb(var(--aierp-accent-rgb) / .06);
  color: var(--aierp-text-secondary);
  font-size: 11px;
  line-height: 1.45;
}

/* Prepared form draft — a call to action, so it is the one thing in the
   transcript allowed to look like a control rather than like text. Indented to
   the same column as the executed-call line, because both belong to the answer
   above them. */
.ai-form-draft {
  margin: 6px 0 2px 34px;
  padding: 10px;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-sm);
  background: var(--aierp-surface-overlay);
}

.ai-form-draft-btn {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: var(--aierp-radius-sm);
  background: var(--aierp-accent);
  color: var(--aierp-white);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--aierp-duration-fast) ease;
}

.ai-form-draft-btn:hover { filter: brightness(1.08); }

.ai-form-draft-meta {
  margin-top: 6px;
  color: var(--aierp-text-tertiary);
  font-size: 10.5px;
}

.ai-form-draft-warning {
  margin-top: 4px;
  padding-left: 8px;
  border-left: 2px solid var(--aierp-amber);
  color: var(--aierp-text-secondary);
  font-size: 10.5px;
  line-height: 1.4;
}

/* „Prikaži na ekranu" — part of the executed-call line, so it inherits its
   size and only the colour marks it as a control. */
.ai-tool-screen-link {
  color: var(--aierp-accent);
  text-decoration: underline;
  white-space: nowrap;
}

/* The call to action and its way out on one row — the button takes the space
   it needs, the way out stays a quiet text control beside it. */
.ai-form-draft-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-form-draft-actions > form,
.ai-form-draft-actions > .ai-form-draft-btn { flex: 1; }

.ai-form-draft-discard {
  flex: none;
  padding: 0;
  border: none;
  background: none;
  color: var(--aierp-text-tertiary);
  font-size: 10.5px;
  text-decoration: underline;
  cursor: pointer;
}

.ai-form-draft-discard:hover { color: var(--aierp-text-secondary); }

/* Rendered model answer (App\Support\Ai\AiAnswerMarkdown) — same classes in
   the chat bubble and in the conversation-history detail popup, so the answer
   reads identically wherever it is shown. */
.ai-md-table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 11.5px;
}
.ai-md-table th,
.ai-md-table td {
  padding: 4px 8px;
  border: 1px solid var(--aierp-border);
  text-align: left;
  white-space: nowrap;
}
.ai-md-table th {
  background: var(--aierp-surface-overlay);
  font-weight: 600;
}
.ai-md-list {
  margin: 6px 0;
  padding-left: 18px;
}
.ai-md-list li { margin: 2px 0; }
.ai-md-code {
  margin: 6px 0;
  padding: 8px 10px;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-sm);
  background: var(--aierp-surface-overlay);
  overflow-x: auto;
  font-size: 11px;
}
.ai-md-heading { margin: 8px 0 4px; }
.ai-msg-bubble code,
.notif-detail code {
  padding: 1px 4px;
  border-radius: var(--aierp-radius-sm);
  background: var(--aierp-surface-overlay);
  font-size: .92em;
}
.ai-msg-bubble p { margin: 0 0 6px; }
.ai-msg-bubble p:last-child,
.ai-msg-bubble .ai-md-table:last-child,
.ai-msg-bubble .ai-md-list:last-child { margin-bottom: 0; }

/* Rating one answer. Sits inside the bubble, quiet until hovered — a control
   the user may use, never one the answer is about. */
.ai-feedback {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.ai-feedback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: var(--aierp-radius-sm);
  background: transparent;
  color: var(--aierp-text-tertiary);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--aierp-duration-fast), color var(--aierp-duration-fast);
}

.ai-feedback-btn:hover { background: var(--aierp-surface-hover); color: var(--aierp-text-secondary); }
.ai-feedback-btn.is-active { color: var(--aierp-accent); }

.ai-feedback-note-row {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

.ai-feedback-note {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-sm);
  background: var(--aierp-surface);
  color: var(--aierp-text-primary);
  font-size: 11.5px;
}

.ai-feedback-note.is-withdrawn {
  border-color: var(--aierp-red);
  color: var(--aierp-red);
}

.ai-feedback-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  padding: 0;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-sm);
  background: transparent;
  color: var(--aierp-text-tertiary);
  cursor: pointer;
}

.ai-feedback-action:hover {
  background: var(--aierp-surface-hover);
  color: var(--aierp-text-secondary);
}

/* Availability of the assistant itself — never a readiness signal (D57). */
.ai-status {
  margin-right: auto;
  font-size: 10.5px;
  color: var(--aierp-text-tertiary);
  white-space: nowrap;
}

.ai-status.is-down { color: var(--aierp-red); }

/* While an answer streams the send button becomes a stop button: the tokens
   keep being spent, so cancelling is the useful control at that moment. */
.ai-send-btn.is-stopping { background: var(--aierp-red); }
.ai-send-btn.is-stopping svg { display: none; }

.ai-send-btn.is-stopping::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: currentColor;
}

/* The assistant said something went wrong — must not look like an answer. */
.ai-msg-error .ai-msg-bubble {
  border-color: var(--aierp-red);
  background: rgb(var(--aierp-red-rgb) / .08);
}

.ai-privacy-note {
  margin: 0 0 8px;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--aierp-text-tertiary);
}

.ai-input-area {
  padding: 14px 16px;
  border-top: 1px solid var(--aierp-border);
  flex-shrink: 0;
}
.ai-input-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.ai-input-wrap textarea {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius);
  font-size: 12.5px;
  font-family: var(--aierp-font);
  background: var(--aierp-surface);
  color: var(--aierp-text);
  resize: none;
  min-height: 40px;
  max-height: 80px;
  transition: all var(--aierp-duration-fast) var(--aierp-ease-out-expo);
  line-height: 1.4;
}
.ai-input-wrap textarea:focus {
  outline: none;
  border-color: var(--aierp-border-focus);
  box-shadow: 0 0 0 3px rgb(var(--aierp-accent-rgb) / .06);
}
.ai-input-wrap textarea::placeholder { color: var(--aierp-text-tertiary); }
.ai-send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--aierp-radius);
  background: linear-gradient(135deg, var(--aierp-accent), var(--aierp-accent-deep));
  color: var(--aierp-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--aierp-duration-fast) var(--aierp-ease-out-expo);
  flex-shrink: 0;
  box-shadow: 0 4px 14px var(--aierp-accent-glow);
}
.ai-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--aierp-accent-glow);
}
.ai-send-btn:active { transform: scale(.95); }
.ai-send-btn svg { width: 16px; height: 16px; }

/* ═══════════════════════════════════════════════════════════════
   6. UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════ */




.font-tabular { font-variant-numeric: tabular-nums; }
.cursor-pointer { cursor: pointer; }

/* Scrollbar styling */
.aierp-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: var(--aierp-text-tertiary) transparent;
}
.aierp-scrollbar::-webkit-scrollbar { width: 4px; }
.aierp-scrollbar::-webkit-scrollbar-thumb {
  background: var(--aierp-text-tertiary);
  border-radius: 10px;
}

/* ═══════════════════════════════════════════════════════════════
   7. EDIT PAGE COMPONENTS
   Specifični stilovi za edit/stranice unosa podataka
   ═══════════════════════════════════════════════════════════════ */

/* ── Progress Steps (stepper) ── */
.progress-track {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
  padding: 4px;
  background: var(--aierp-surface);
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-xl);
  position: relative;
  overflow: hidden;
}
.progress-step {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--aierp-text-tertiary);
  position: relative;
  z-index: 1;
  cursor: default;
  transition: all var(--aierp-duration) var(--aierp-ease-out-expo);
  border-radius: var(--aierp-radius-lg);
  white-space: nowrap;
}
.progress-step.completed { color: var(--aierp-green); }
.progress-step.active {
  color: var(--aierp-white);
  background: rgb(var(--aierp-accent-rgb) / .12);
  box-shadow: 0 0 0 1px rgb(var(--aierp-accent-rgb) / .15);
}
.progress-step .step-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
  border: 2px solid var(--aierp-text-tertiary);
  transition: all var(--aierp-duration);
}
.progress-step.completed .step-icon {
  border-color: var(--aierp-green);
  background: var(--aierp-green);
  color: var(--aierp-text-inverse);
}
.progress-step.active .step-icon {
  border-color: var(--aierp-accent-light);
  background: var(--aierp-accent);
  color: var(--aierp-white);
  box-shadow: 0 0 12px var(--aierp-accent-glow);
}
.progress-connector {
  width: 20px;
  height: 2px;
  background: var(--aierp-border);
  flex-shrink: 0;
  z-index: 0;
}
.progress-connector.done { background: var(--aierp-green); }

/* ── Page Header (edit mode) ── */
.page-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-top-left h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.6px;
  line-height: 1.1;
  margin: 0;
}
.page-top-left .doc-meta {
  font-size: 13px;
  color: var(--aierp-text-tertiary);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.doc-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 600;
  border: 1px solid var(--aierp-border);
  background: rgb(var(--aierp-white-rgb) / .03);
  color: var(--aierp-text-tertiary);
}
.doc-badge .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--aierp-text-tertiary); }
.page-top-right { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Doc facts ──
   Read-only values a document earns for itself (legal number, lifecycle
   statuses) — shown inside a section-card next to the editable fields, but
   deliberately not rendered as inputs: nothing here is ever submitted. */
.doc-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 24px;
  margin: 0;
}
.doc-facts dt {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--aierp-text-tertiary);
  margin-bottom: 3px;
}
.doc-facts dd {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--aierp-text);
}
/* Inside a modal there is no neighbouring form to line up with, so the
   facts breathe across the full dialog width instead of a rigid 3-up. */
.doc-facts--wide {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 14px;
}

/* ── Document lines (drill-down sa liste dokumenata, <x-document-lines>) ──
   Ulazi klizanjem zdesna, tako da se čita kao ULAZAK U dokument, a ne kao
   nova strana; povratak je browser-ov „nazad", pa tab/sort/filter liste
   ostaju netaknuti. */
.doc-lines {
  animation: drill-enter var(--aierp-duration) var(--aierp-ease-out-expo);
}
@keyframes drill-enter {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .doc-lines { animation: none; }
}
.doc-lines-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 0 14px;
  margin-bottom: 4px;
  background: var(--aierp-bg);
}
.doc-lines-back {
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1;
}
.doc-lines-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.doc-lines-title h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}
.doc-lines-subtitle {
  font-size: 12px;
  color: var(--aierp-text-secondary);
}
.doc-lines-badges {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.doc-lines-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  margin-bottom: 14px;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-lg);
  overflow: hidden;
}
.doc-lines-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
  background: var(--aierp-surface);
}
.doc-lines-stat-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--aierp-text-tertiary);
}
.doc-lines-stat-value {
  font-size: 15px;
  font-weight: 700;
}
.doc-lines-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

@media (max-width: 900px) {
  .doc-lines-head { position: static; }
  .doc-lines-badges { width: 100%; }
}

/* ── Readiness bar ──
   Read-only verdict of the same validator the posting Action runs, so the
   user reads what is missing instead of finding out by clicking. Colours
   are in default-theme.css (readiness-bar--ready / --blocked). */
.readiness-bar {
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-lg);
  padding: 12px 16px;
  margin-bottom: 14px;
}
.readiness-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
}
.readiness-head svg { flex-shrink: 0; }
.readiness-title { flex: 1; min-width: 0; }
.readiness-count {
  flex-shrink: 0;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .3px;
  opacity: .75;
}
.readiness-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}
.readiness-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  font-size: 12.5px;
  padding-left: 26px;
}
.readiness-item-label { font-weight: 600; }
.readiness-item-hint { color: var(--aierp-text-secondary); }

/* Advisory checks sit below a separator so a green (ready) bar still reads
   as ready — the warning is a remark, not a blocker. Colour in
   default-theme.css. */
.readiness-list--advisory {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--aierp-border);
}

@media (max-width: 480px) {
  .readiness-bar { padding: 10px 12px; }
  .readiness-item { padding-left: 0; }
  .readiness-count { display: none; }
}

/* ── Busy overlay ──
   Shown while an action that must not be interrupted is running. It covers
   the page on purpose: the second click on „Proknjiži" is the thing being
   prevented, not just the uncertainty. Colours in default-theme.css. */
.busy-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.busy-overlay.show { display: flex; }
.busy-overlay-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 26px 34px;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-lg);
  max-width: min(420px, calc(100vw - 32px));
  text-align: center;
}
.busy-overlay-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--aierp-border);
  border-top-color: var(--aierp-accent-light);
  border-radius: 50%;
  animation: spin-static .6s linear infinite;
}
.busy-overlay-message { font-size: 13.5px; font-weight: 600; }
.busy-overlay-hint { font-size: 11.5px; }

/* Stuck state — the work outlived the timeout, so the overlay stops claiming
   to know what is happening and hands control back. The spinner and the
   „don't leave" line go; the way out arrives. */
.busy-overlay-stuck-hint,
.busy-overlay-release { display: none; }
.busy-overlay.is-stuck .busy-overlay-spinner,
.busy-overlay.is-stuck .busy-overlay-hint:not(.busy-overlay-stuck-hint) { display: none; }
.busy-overlay.is-stuck .busy-overlay-stuck-hint { display: block; }
.busy-overlay.is-stuck .busy-overlay-release { display: inline-block; }

/* ── Document history (tab „Istorija") ──
   One entry per act; a save that touched twenty lines is one row with a
   count, not twenty. Colours in default-theme.css. */
.doc-history { display: flex; flex-direction: column; gap: 10px; }
.doc-history-item { padding: 10px 12px; border: 1px solid var(--aierp-border); border-radius: var(--aierp-radius-sm); }
.doc-history-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
.doc-history-user { font-weight: 600; }
.doc-history-time, .doc-history-lines { color: var(--aierp-text-tertiary); }
.doc-history-time { margin-left: auto; white-space: nowrap; }
.doc-history-changes { margin-top: 8px; width: 100%; font-size: 12px; border-collapse: collapse; }
.doc-history-changes td { padding: 2px 8px 2px 0; vertical-align: top; }
.doc-history-field { font-weight: 600; white-space: nowrap; }
.doc-history-from { color: var(--aierp-text-tertiary); text-decoration: line-through; }
.doc-history-arrow { color: var(--aierp-text-tertiary); }
.doc-history-to { word-break: break-word; }
@media (max-width: 600px) {
  .doc-history-time { margin-left: 0; }
}

/* ── Document total (sticky bar) ──
   The one figure a user checks constantly, on the only element visible from
   every tab. Two states — a live estimate while the document is a draft,
   and the binding amount once it is posted. Colours in default-theme.css. */
.document-total {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 12px;
  border-left: 1px solid var(--aierp-border);
  line-height: 1.25;
}
.document-total-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.document-total-value {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.document-total-approx { font-weight: 500; }

@media (max-width: 480px) {
  .document-total {
    padding-left: 8px;
    padding-right: 0;
  }
  .document-total-value { font-size: 13px; }
}

/* ── Scope legend ──
   What each RBAC scope excludes, next to the role dropdowns. Whoever
   assigns a role is not whoever later notices the consequence, so the
   consequence is stated where the choice is made. */
.scope-legend {
  display: grid;
  gap: 6px;
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-md);
  background: var(--aierp-surface-overlay);
  font-size: 12px;
}
.scope-legend-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}
.scope-legend dt {
  flex-shrink: 0;
  min-width: 160px;
  font-weight: 600;
  color: var(--aierp-text);
}
.scope-legend dd {
  flex: 1;
  min-width: 220px;
  margin: 0;
  color: var(--aierp-text-secondary);
}

@media (max-width: 900px) {
  .scope-legend dt { min-width: 0; }
}

/* ── Setting lock badge ──
   Marks a field that is set once and then frozen. Two states (open /
   locked) so an irreversible choice reads differently BEFORE it is made,
   not only after. Colours in default-theme.css. */
.setting-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: var(--aierp-radius-sm);
  border: 1px solid transparent;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
  vertical-align: middle;
}
.setting-lock-badge svg { flex-shrink: 0; }

@media (max-width: 480px) {
  .setting-lock-badge {
    margin-left: 0;
    margin-top: 4px;
  }
}

/* ── Section Card ── */
.section-card {
  background: var(--aierp-surface);
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-lg);
  margin-bottom: 14px;
  overflow: hidden;
  transition: border-color var(--aierp-duration);
}
.section-card:focus-within {
  border-color: var(--aierp-border-focus);
  box-shadow: 0 0 0 4px rgb(var(--aierp-accent-rgb) / .04);
}
.section-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  background: var(--aierp-surface-elevated);
  border-bottom: 1px solid var(--aierp-border);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .2px;
  color: var(--aierp-text);
}
.section-card-header svg { width: 15px; height: 15px; color: var(--aierp-accent-light); flex-shrink: 0; }
.section-card-header .section-badge {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--aierp-text-tertiary);
}
.section-card-body { padding: 18px 20px; }

/* ── Form Grid ── */
.form-grid { display: grid; gap: 14px 22px; }
/* Consecutive grids used to touch edge-to-edge — the row-gap only applies
   INSIDE one grid, so a field in the next grid looked glued to the one above. */
.form-grid + .form-grid { margin-top: 14px; }
.form-grid--2 { grid-template-columns: 1fr 1fr; }
.form-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid--4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--aierp-text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.form-group label .required { color: var(--aierp-accent-light); }
.form-group .form-control,
.form-group .form-select { padding: 9px 12px; font-size: 13px; background: var(--aierp-bg-alt); width: 100%; }
.form-group .form-control:focus,
.form-group .form-select:focus { background: var(--aierp-surface-overlay); }
.form-group .form-control:read-only { background: rgb(var(--aierp-white-rgb) / .015); color: var(--aierp-text-secondary); cursor: not-allowed; }
.form-group .form-select:disabled { background: rgb(var(--aierp-white-rgb) / .015); color: var(--aierp-text-secondary); cursor: not-allowed; }
.form-group .hint { font-size: 10.5px; color: var(--aierp-text-tertiary); margin-top: 1px; }
.form-group.is-valid .form-control { border-color: var(--aierp-green); }
.form-group.is-invalid .form-control { border-color: var(--aierp-red); box-shadow: 0 0 0 3px rgb(var(--aierp-red-rgb) / .06); }
.form-group.is-invalid .error-msg { font-size: 10.5px; color: var(--aierp-red); margin-top: 1px; font-weight: 500; }

/* ── Checkbox Row ── */
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.check-row .form-check-input { width: 15px; height: 15px; cursor: pointer; }
.check-row label {
  font-size: 12.5px;
  color: var(--aierp-text-secondary);
  cursor: pointer;
  text-transform: none;
  font-weight: 400;
  letter-spacing: 0;
}

/* ── Radio Group ── */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.radio-group--inline {
  flex-direction: row;
  gap: 16px;
}
.radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--aierp-text-secondary);
  cursor: pointer;
  padding: 4px 0;
  transition: color var(--aierp-duration-fast);
}
.radio-item:hover { color: var(--aierp-text); }
.radio-item input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.radio-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--aierp-border-strong);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--aierp-duration-fast);
  flex-shrink: 0;
}
.radio-dot::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--aierp-accent);
  transform: scale(0);
  transition: transform var(--aierp-duration-fast) var(--aierp-ease-out-back);
}
.radio-item input:checked + .radio-dot {
  border-color: var(--aierp-accent);
  box-shadow: 0 0 0 3px var(--aierp-accent-glow);
}
.radio-item input:checked + .radio-dot::after {
  transform: scale(1);
}
.radio-item input:focus-visible + .radio-dot {
  outline: 2px solid var(--aierp-accent);
  outline-offset: 2px;
}

/* ── Switch (toggle) ── */
.switch-row {
  padding: 2px 0;
}
/* Inside a form-grid a switch has no label line above it, so it would sit
   at the top of its cell — level with the NEIGHBOUR's label instead of the
   neighbour's input. Reserve the label's height so controls line up. */
/* Inside a form-grid a switch has no label line above it, so it would sit
   at the top of its cell — level with the NEIGHBOUR's label instead of the
   neighbour's input. The reserved top padding is that label line; padding
   rather than bottom-alignment because a hint of a different length would
   otherwise push its own switch out of line with the one beside it. */
.form-grid > .switch-row {
  align-self: start;
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.form-grid > .switch-row .switch-wrap {
  min-height: 36px;
}
/* A hint sits under the whole control, indented past the track so it reads
   as belonging to the label rather than to the toggle. */
.switch-row .hint {
    display: block;
    margin-top: 2px;
    padding-left: 0px;
    font-size: 10.5px;
    color: var(--aierp-text-tertiary);
}
.switch-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--aierp-text-secondary);
  transition: color var(--aierp-duration-fast);
  user-select: none;
}
.switch-wrap:hover { color: var(--aierp-text); }
/* A locked toggle must not look clickable — the value is frozen by a
   business rule, not merely unavailable right now. */
.switch-wrap:has(.switch-input:disabled) {
  cursor: not-allowed;
  opacity: .65;
}
.switch-wrap:has(.switch-input:disabled):hover { color: var(--aierp-text-secondary); }
.switch-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-track {
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: var(--aierp-border-strong);
  position: relative;
  transition: background var(--aierp-duration-fast);
  flex-shrink: 0;
}
.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--aierp-white);
  transition: transform var(--aierp-duration-fast) var(--aierp-ease-out-expo);
  box-shadow: 0 1px 4px rgb(var(--aierp-black-rgb) / .3);
}
.switch-input:checked + .switch-track {
  background: var(--aierp-accent);
}
.switch-input:checked + .switch-track .switch-thumb {
  transform: translateX(16px);
}
.switch-input:focus-visible + .switch-track {
  outline: 2px solid var(--aierp-accent);
  outline-offset: 2px;
}
.switch-label {
  font-weight: 500;
}

/* ── Search Input (ajax dropdown) ── */
.form-group[data-search] {
  position: relative;
}
.search-input-wrap {
  position: relative;
}
.search-spinner {
  display: none;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border: 2px solid var(--aierp-border);
  border-top-color: var(--aierp-accent-light);
  border-radius: 50%;
  animation: spin .5s linear infinite;
}
.search-spinner.searching { display: block; }
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }
@keyframes spin-static { to { transform: rotate(360deg); } }
.search-dropdown {
  display: none;
  position: absolute;
  z-index: 100;
  margin-top: 0;
  background: var(--aierp-surface-overlay);
  border: 1px solid var(--aierp-border-strong);
  border-radius: var(--aierp-radius-sm);
  box-shadow: 0 20px 60px rgb(var(--aierp-black-rgb) / .5), 0 0 0 1px rgb(var(--aierp-white-rgb) / .03);
  max-height: 240px;
  overflow-y: auto;
}
.search-dropdown.show { display: block; }
.search-dropdown-item {
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--aierp-text-secondary);
  cursor: pointer;
  transition: all var(--aierp-duration-fast);
}
.search-dropdown-item:hover,
.search-dropdown-item.active {
  background: rgb(var(--aierp-accent-rgb) / .1);
  color: var(--aierp-text);
}
.search-dropdown-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--aierp-text-tertiary);
}

/* ── Tooltip (JS-portal u body) ── */
[data-tooltip] {
  position: relative;
}
.aierp-tooltip-fly {
  position: fixed;
  z-index: 9999;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--aierp-white);
  background: var(--aierp-surface-deep);
  border: 1px solid var(--aierp-border-strong);
  border-radius: var(--aierp-radius-sm);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 8px 24px rgb(var(--aierp-black-rgb) / .5);
  opacity: 0;
  transition: opacity .12s;
}
.aierp-tooltip-fly.show { opacity: 1; }

/* ── Lines editor (unos stavki dokumenta, <x-lines-editor>) ──
   Replaces the demo-only .lines-table: same visual language, but built around
   a search box that inserts rows and a totals block that recomputes live. */
.lines-editor { display: flex; flex-direction: column; }
.lines-search { position: relative; padding: 12px 14px; border-bottom: 1px solid var(--aierp-border); }
.lines-search-input { width: 100%; }
.lines-results {
  position: absolute;
  left: 14px;
  right: 14px;
  top: calc(100% - 4px);
  z-index: 30;
  max-height: 296px;            /* ~8 rows, then it scrolls */
  overflow-y: auto;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-sm);
  background: var(--aierp-surface-elevated);
  box-shadow: 0 12px 32px rgb(var(--aierp-black-rgb) / .45);
}
.lines-result {
  display: grid;
  grid-template-columns: auto 90px 1fr 46px 92px 54px auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  font-size: 12.5px;
  cursor: pointer;
  border-bottom: 1px solid var(--aierp-border);
}
.lines-result:last-child { border-bottom: none; }
.lines-result.is-active { background: rgb(var(--aierp-accent-rgb) / .10); }
.lines-result-code { font-weight: 600; color: var(--aierp-text-secondary); }
.lines-result-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lines-result-dup { margin-left: 6px; font-style: normal; font-size: 11px; color: var(--aierp-amber); }
.lines-result-unit, .lines-result-tax { color: var(--aierp-text-tertiary); font-size: 11.5px; }
.lines-result-price { text-align: right; font-variant-numeric: tabular-nums; }
.lines-result-discount { display: block; font-style: normal; font-size: 10.5px; color: var(--aierp-green); }
.lines-result-stock { font-size: 11.5px; white-space: nowrap; }
.lines-result-stock--ok { color: var(--aierp-green); }
.lines-result-stock--out { color: var(--aierp-red); }
.lines-result-stock--none { color: var(--aierp-text-tertiary); }
.lines-result-empty, .lines-result-more {
  padding: 10px;
  font-size: 12px;
  text-align: center;
  color: var(--aierp-text-tertiary);
}
.lines-result-more { border-top: 1px solid var(--aierp-border); }

.lines-table-wrapper {
  padding: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
/* The WRAPPER scrolls, never the <table> — same as .data-table-wrapper on
   the list screens. `display: block` on a table makes thead and tbody
   independent block boxes whose widths are computed from their own content,
   so the header stops lining up with the rows underneath it. `min-width`
   is what makes a narrow screen scroll instead of squeezing the columns. */
.lines-table { width: 100%; min-width: 720px; border-collapse: collapse; table-layout: fixed; }
.lines-table thead th {
  padding: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--aierp-text-tertiary);
  background: var(--aierp-bg-alt);
  border-bottom: 1px solid var(--aierp-border);
  text-align: left;
  white-space: nowrap;
}
.lines-table td { padding: 6px 10px; border-bottom: 1px solid var(--aierp-border); vertical-align: middle; }
.lines-table tr:last-child td { border-bottom: none; }
.lines-table .form-control,
.lines-table .form-select {
  padding: 6px 8px;
  border: 1px solid transparent;
  font-size: 13px;
  background: transparent;
  width: 100%;
}
.lines-table .form-control:focus,
.lines-table .form-select:focus { border-color: var(--aierp-border-focus); background: var(--aierp-bg-alt); }
/* table-layout: fixed reads the widths off the FIRST row, so every column
   has to declare one — including the article column, which takes whatever
   the fixed ones leave. */
.lines-col-article { width: auto; }
.lines-col-num { width: 40px; text-align: center; color: var(--aierp-text-tertiary); font-size: 11.5px; }
.lines-col-unit, .lines-col-stock { width: 74px; font-size: 12px; color: var(--aierp-text-tertiary); }
.lines-col-qty, .lines-col-discount { width: 92px; }
.lines-col-price { width: 116px; }
.lines-col-tax { width: 150px; }
.lines-col-amount { width: 124px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.lines-col-del { width: 36px; text-align: center; }
.lines-article-code { display: block; font-size: 11px; color: var(--aierp-text-tertiary); }
.lines-article-name { display: block; font-size: 13px; font-weight: 600; }
.lines-field-description { margin-top: 2px; font-size: 12px; }
.lines-row { cursor: default; }
.lines-row--dragging { opacity: .45; }
.lines-row--added { animation: linesRowAdded var(--aierp-duration-slow, 520ms) var(--ease-out-expo, ease-out); }
.lines-row--short-stock .lines-col-qty .form-control { border-color: var(--aierp-amber); }
@keyframes linesRowAdded {
  from { background: rgb(var(--aierp-accent-rgb) / .16); }
  to   { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .lines-row--added { animation: none; }
}
.lines-empty { padding: 22px; text-align: center; font-size: 12.5px; color: var(--aierp-text-tertiary); }
.summary-line--rate { display: flex; justify-content: space-between; gap: 24px; }
.lines-summary .summary-line { display: flex; justify-content: space-between; gap: 24px; }
.lines-warnings { margin-top: 8px; }
.lines-warning { font-size: 12px; color: var(--aierp-amber); }

/* Refused lines — the row keeps what was typed, the block above says why. */
.lines-errors {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--aierp-red);
  border-radius: var(--aierp-radius-sm);
  background: var(--aierp-red-bg);
  color: var(--aierp-red);
  font-size: 12px;
}
.lines-errors strong { display: block; margin-bottom: 4px; }
.lines-errors ul { margin: 0; padding-left: 18px; }
.lines-row--invalid .form-control.is-invalid { border-color: var(--aierp-red); }

.btn-del {
  width: 26px;
  height: 26px;
  border-radius: var(--aierp-radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--aierp-text-tertiary);
  cursor: pointer;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--aierp-duration-fast);
}
.btn-del:hover { color: var(--aierp-red); background: var(--aierp-red-bg); border-color: rgb(var(--aierp-red-rgb) / .15); }

/* Pull-lines-from-source strip above the line editor of a correction. */
.lines-pull-source {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--aierp-border);
}
.lines-pull-source .hint { flex: 1; min-width: 220px; }

/* ── Summary Block ── */
.summary-block {
  padding: 16px 20px;
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--aierp-border);
}
/* Label and amount are two separate spans on one line — `gap` is what keeps
   them from reading as one string. Right-packed rather than spread, so the
   amounts stay flush in a single column down the box. */
.summary-box { text-align: right; line-height: 2; }
.summary-line,
.summary-total {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 24px;
}
.summary-line { font-size: 12.5px; color: var(--aierp-text-tertiary); }
.summary-line strong { color: var(--aierp-text); font-weight: 600; }
.summary-total {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.6px;
  margin-top: 2px;
  background: linear-gradient(135deg, var(--aierp-white), var(--aierp-accent-lighter));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Sticky Bottom Bar ── */
.sticky-bar {
  position: sticky;
  bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  margin: 20px -4px -4px;
  background: rgb(var(--aierp-surface-rgb) / .9);
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-lg);
  backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 -8px 30px rgb(var(--aierp-black-rgb) / .3);
  flex-wrap: wrap;
  gap: 10px;
}
.sticky-bar-left { display: flex; gap: 8px; align-items: center; }
.sticky-bar-right { display: flex; gap: 8px; align-items: center; }
.sticky-bar .saved-indicator {
  font-size: 11px;
  color: var(--aierp-green);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ── Side Panel (aktivnost / AI sugestije) ── */
.side-panel {
  position: fixed;
  right: 0;
  top: 0;
  width: 320px;
  height: 100vh;
  background: var(--aierp-surface);
  border-left: 1px solid var(--aierp-border);
  z-index: 25;
  padding: 20px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform var(--aierp-duration-slow) var(--aierp-ease-out-expo);
}
.side-panel.open { transform: translateX(0); }
.side-panel-toggle {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 26;
  width: 28px;
  border: 1px solid var(--aierp-border);
  border-right: none;
  border-radius: var(--aierp-radius-sm) 0 0 var(--aierp-radius-sm);
  background: var(--aierp-surface);
  color: var(--aierp-text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all var(--aierp-duration-fast);
  writing-mode: vertical-rl;
  letter-spacing: 2px;
  font-weight: 700;
  font-family: var(--aierp-font);
  padding: 14px 0;
}
.side-panel-toggle:hover { color: var(--aierp-text); background: var(--aierp-surface-elevated); }
.side-panel h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--aierp-text-tertiary);
  margin-bottom: 14px;
}

/* ── Activity Feed ── */
.activity-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--aierp-border);
  font-size: 12px;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 3px;
  flex-shrink: 0;
}
.activity-dot.edit { background: var(--aierp-accent); }
.activity-dot.system { background: var(--aierp-text-tertiary); }
.activity-dot.warning { background: var(--aierp-amber); }
.activity-content { flex: 1; }
.activity-content .act-user { font-weight: 600; color: var(--aierp-text); }
.activity-content .act-action { color: var(--aierp-text-secondary); }
.act-action--amber { color: var(--aierp-amber) !important; }
.act-action--red { color: var(--aierp-red) !important; }
.act-action--green { color: var(--aierp-green) !important; }
.act-action--purple { color: var(--aierp-accent-light) !important; }
.activity-content .act-time { font-size: 10.5px; color: var(--aierp-text-tertiary); margin-top: 2px; }

/* ── AI Suggestion (u side panelu) ── */
.ai-suggestion {
  background: rgb(var(--aierp-accent-rgb) / .04);
  border: 1px solid rgb(var(--aierp-accent-rgb) / .1);
  border-radius: var(--aierp-radius);
  padding: 12px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--aierp-text-secondary);
  line-height: 1.5;
}
.ai-suggestion .ai-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--aierp-accent-light);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.ai-suggestion .ai-actions { display: flex; gap: 6px; margin-top: 8px; }
.ai-suggestion .ai-btn {
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgb(var(--aierp-accent-rgb) / .2);
  background: rgb(var(--aierp-accent-rgb) / .08);
  color: var(--aierp-accent-light);
  transition: all var(--aierp-duration-fast);
  font-family: var(--aierp-font);
}
.ai-suggestion .ai-btn:hover { background: rgb(var(--aierp-accent-rgb) / .15); }

/* ── Attachments ── */
.attachment-zone {
  border: 1px dashed var(--aierp-border);
  border-radius: var(--aierp-radius);
  padding: 24px;
  text-align: center;
  color: var(--aierp-text-tertiary);
  transition: all var(--aierp-duration-fast);
  cursor: pointer;
}
.attachment-zone.uploading {
  cursor: default;
  pointer-events: none;
  opacity: .85;
}
.attachment-zone-loading { display: flex; flex-direction: column; align-items: center; gap: 8px; }
/* Ista .search-spinner komponenta kao <x-form-search> — ovde samo repozicionirana
   iz apsolutnog (input corner) u statičan, centriran tok. Sopstveni keyframes
   (ne nasleđeni .search-spinner-ov `spin`) — taj ima translateY(-50%) ubačen
   u animaciju radi centriranja UNUTAR apsolutnog pozicioniranja, što bi ovde
   (position: static) izazvalo pomeranje gore-dole uz rotaciju. */
.attachment-zone-loading .search-spinner {
  display: block;
  position: static;
  transform: none;
  animation-name: spin-static;
  width: 20px;
  height: 20px;
}
.attachment-zone:hover,
.attachment-zone.dragover {
  border-color: var(--aierp-border-strong);
  color: var(--aierp-text-secondary);
  background: rgb(var(--aierp-white-rgb) / .01);
}
.attachment-zone.dragover {
  border-color: var(--aierp-accent);
  background: rgb(var(--aierp-accent-rgb) / .06);
}
.attachment-zone .att-icon { font-size: 28px; margin-bottom: 8px; opacity: .4; }
.attachment-zone.has-attachments { margin-top: 10px; }
.att-info { font-size: 10.5px; margin-top: 4px; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.attachment-chip {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-sm);
  font-size: 11.5px;
  background: var(--aierp-bg-alt);
  color: var(--aierp-text-secondary);
  max-width: 260px;
}
.attachment-chip-main { display: flex; align-items: center; gap: 6px; }
.attachment-chip-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.attachment-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip-desc {
  font-size: 10px;
  color: var(--aierp-text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip .att-edit,
.attachment-chip .att-remove {
  cursor: pointer;
  color: var(--aierp-text-tertiary);
  transition: color var(--aierp-duration-fast);
  flex-shrink: 0;
}
.attachment-chip .att-edit svg { width: 13px; height: 13px; display: block; }
.attachment-chip .att-edit:hover { color: var(--aierp-accent); }
.attachment-chip .att-remove { font-size: 14px; }
.attachment-chip .att-remove:hover { color: var(--aierp-red); }
.attachment-chip-edit { display: flex; flex-direction: column; gap: 6px; }
.attachment-chip-edit textarea { resize: vertical; min-height: 44px; }
.attachment-chip-edit-actions { display: flex; gap: 6px; justify-content: flex-end; }
.attachment-chip-thumb {
  width: 18px;
  height: 18px;
  object-fit: cover;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Image gallery (edit page) — first user: articles "Slike" section
   (module-generator.md §modul `articles`, U6). Generic aierp-* naming since
   any future module with its own image upload can reuse this, same as
   every other edit-page block. ── */
.aierp-image-gallery { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.aierp-image-item {
  width: 140px;
  border: 1px solid var(--aierp-border);
  border-radius: var(--aierp-radius-sm);
  padding: 8px;
  text-align: center;
  background: var(--aierp-bg-alt);
}
.aierp-image-thumb {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: var(--aierp-radius-sm);
  display: block;
  cursor: pointer;
}
.aierp-image-primary-badge {
  font-size: 11px;
  margin-top: 6px;
  color: var(--aierp-accent-light);
}
.aierp-image-item form { margin-top: 4px; }
.aierp-image-item .btn { font-size: 11px; width: 100%; }

/* ── List-page thumbnail cell (x-data-table 'thumbnail' column) — small,
   always shown regardless of the column picker (like the actions column),
   click opens x-image-lightbox. ── */
.aierp-list-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: var(--aierp-radius-sm);
  cursor: pointer;
  display: block;
}
.aierp-list-thumb-placeholder {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--aierp-border);
  border-radius: var(--aierp-radius-sm);
  color: var(--aierp-text-tertiary);
}
.data-table th[data-col-key="thumbnail"] {
  width: 48px;
}

/* ── Image lightbox (x-image-lightbox) — full-size preview on click,
   reuses .aierp-modal/.aierp-modal-backdrop mechanics with its own
   borderless, image-only content instead of .aierp-modal-dialog. ── */
.aierp-lightbox-content {
  position: relative;
  z-index: 1;
  margin: auto;
  max-width: min(90vw, 900px);
  max-height: 90vh;
  animation: aierpModalIn .22s cubic-bezier(.16,1,.3,1);
}
.aierp-lightbox-content img {
  display: block;
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--aierp-radius-lg);
  box-shadow: 0 20px 60px rgb(var(--aierp-black-rgb) / .6);
}
.aierp-lightbox-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--aierp-surface-overlay);
  color: var(--aierp-text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgb(var(--aierp-black-rgb) / .4);
}
.aierp-lightbox-close:hover { color: var(--aierp-red); }

/* ── Button extensions (edit page) ── */
.btn-success {
  background: linear-gradient(135deg, var(--aierp-green), var(--aierp-green-deep));
  border-color: transparent;
  color: var(--aierp-white);
  box-shadow: 0 4px 14px rgb(var(--aierp-green-rgb) / .2);
}
.btn-success:hover {
  box-shadow: 0 6px 20px rgb(var(--aierp-green-rgb) / .3);
  transform: translateY(-1px);
}
.btn-danger {
  color: var(--aierp-red);
  border-color: transparent;
  background: transparent;
}
.btn-danger:hover { background: var(--aierp-red-bg); }

/* Edit content — uža maks. širina */
.app-content--edit { max-width: 1100px; margin: 0 auto; }

/* Global scrollbar */
html { scrollbar-width: thin; scrollbar-color: var(--aierp-text-tertiary) transparent; }
html::-webkit-scrollbar { width: 4px; }
html::-webkit-scrollbar-thumb { background: var(--aierp-text-tertiary); border-radius: 10px; }

/* ═══════════════════════════════════════════════════════════════
   8. RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

/* ── Wide (≤1500px): narrower AI panel ── */
@media (max-width: 1500px) {
  :root { --aierp-ai-panel-w: 340px; }
  .app-content { padding: 24px 24px; }
}

@media (min-width: 1101px) {
  body.ai-panel-open .toast-container-aierp {
    right: calc(var(--aierp-ai-panel-w) + 60px);
    max-width: calc(100vw - var(--aierp-ai-panel-w) - 80px);
  }
}

/* ── Desktop (≤1300px): stats 2 cols, tighter spacing ── */
@media (max-width: 1300px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .skeleton-stats { grid-template-columns: 1fr 1fr; }
  .app-content { padding: 20px 20px; }
  .filter-bar { flex-wrap: wrap; }
  .page-toolbar { flex-wrap: wrap; }
  .page-top { flex-wrap: wrap; gap: 12px; }
  .page-top-right { width: 100%; justify-content: flex-start; }
}

/* ── Tablet landscape (≤1100px): AI panel hidden, data table scroll ── */
@media (max-width: 1100px) {
  .ai-panel { display: none; }
  .ai-panel:not(.collapsed) { display: flex; }
  .ai-panel-resize-handle { display: none; }
  body.ai-panel-open .toast-container-aierp {
    right: 60px;
    max-width: calc(100vw - 80px);
  }
  .app-main.has-right-panel { margin-right: 0; }
  .fab-aierp { right: 20px; bottom: 70px; }
  .data-table-wrapper { -webkit-overflow-scrolling: touch; }
  .progress-step { font-size: 11px; padding: 8px 10px; gap: 5px; }
  .progress-step .step-icon { width: 18px; height: 18px; font-size: 9px; }
}

/* ── Tablet portrait (≤900px): collapsed sidebar, 1-col grids ── */
@media (max-width: 900px) {
  .hide-on-mobile { display: none; }
  .stats-grid { grid-template-columns: 1fr; }
  .skeleton-stats { grid-template-columns: 1fr; }

  .app-main { margin-left: var(--aierp-sidebar-collapsed); }

  .app-content { padding: 16px; }
  .app-header { padding: 0 16px; }
  .app-footer { padding: 0 16px; font-size: 10px; gap: 10px; }

  /* .cmd-bar { display: none; } */
  .form-grid--2, .form-grid--3, .form-grid--4 { grid-template-columns: 1fr !important; }
  .doc-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sticky-bar { flex-direction: column; gap: 10px; }
  .sticky-bar-left, .sticky-bar-right { width: 100%; flex-wrap: wrap; }
  .side-panel { width: 260px; }

  .page-top { flex-direction: column; }
  .page-top-left h2 { font-size: 20px; }
  .page-top-right { width: 100%; }
  .page-top-right .btn { font-size: 12px; padding: 6px 12px; }

  .progress-track { display: flex !important; flex-direction: column !important; gap: 5px; padding: 8px; overflow: visible; }
  .progress-step { width: 100%; flex: auto !important; font-size: 10px; padding: 7px 10px; white-space: normal; border-radius: var(--aierp-radius-sm); }
  .progress-connector { width: 100% !important; height: 2px; }

  .filter-bar input[type="search"] { width: 100%; }
  .filter-bar .form-control,
  .filter-bar .form-select { min-width: 100px; font-size: 12px; }
  .date-range-label { display: none; }
  .date-range-inputs .form-control { min-width: 110px; font-size: 11px; }

  .data-table thead th,
  .data-table tbody td,
  .data-table tfoot td { padding: 8px 10px; font-size: 11.5px; }

  .lines-table thead th,
  .lines-table td { padding: 6px 8px; font-size: 11.5px; }
  .lines-table .form-control,
  .lines-table .form-select { font-size: 11.5px; padding: 5px 7px; }

  .summary-total { font-size: 18px; }

  .aierp-tabs-nav { flex-wrap: wrap; }
  .aierp-tab-btn { font-size: 11px; padding: 7px 10px; }

  .wizard-steps { padding: 12px 14px; }
  .wizard-step-num { width: 24px; height: 24px; font-size: 10px; }
  .wizard-step-label { font-size: 10px; }
  .wizard-step-line { margin: 0 4px; min-width: 8px; }
  .wizard-nav { flex-wrap: wrap; gap: 8px; }
  .wizard-nav .btn { font-size: 11px; padding: 6px 10px; }

  .section-card-header { padding: 10px 14px; font-size: 11px; }
  .section-card-body { padding: 14px 16px; }

  .pagination-bar { flex-wrap: wrap; gap: 8px; font-size: 11px; }
  .pagination-pages button { width: 28px; height: 28px; font-size: 11px; }

  .mobile-toggle-btn {
    display: flex; align-items: center; gap: 6px;
    width: 100%; padding: 8px 12px; margin-bottom: 8px;
    font-size: 11px; font-weight: 600;
    color: var(--aierp-text-tertiary);
    background: var(--aierp-surface);
    border: 1px solid var(--aierp-border);
    border-radius: var(--aierp-radius-sm);
    cursor: pointer; font-family: var(--aierp-font);
    transition: all var(--aierp-duration-fast);
  }
  .mobile-toggle-btn:hover { color: var(--aierp-text); border-color: var(--aierp-border-strong); }
  .mobile-toggle-btn .toggle-arrow { margin-left: auto; transition: transform var(--aierp-duration); font-size: 10px; }
  .mobile-toggle-btn.open .toggle-arrow { transform: rotate(180deg); }
  .mobile-collapsible.collapsed { display: none; }

  .btn { font-size: 11.5px; padding: 4px 8px; }
  .fab-aierp {
    padding: 10px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    justify-content: center;
    gap: 0;
  }
  .fab-aierp #aiFabLabel { display: none; }
  .fab-aierp img { width: 20px; height: 20px; margin: 0; }
  .cmd-bar.bulk .cmd-item { padding: 10px 3px; }
  .cmd-bar.bulk .cmd-divider { margin: 0 2px; }
  .table.data-table .cell-check .form-check-input { margin: 0 0 0 6px; }
  .table.data-table .col-check .form-check-input { margin: 0 0 0 6px; }
}

@media (min-width: 901px) {
  .mobile-toggle-btn { display: none; }
  .mobile-collapsible.collapsed { display: block !important; }
}

/* ── Phone (≤480px): sakrij copyright i locale u footeru ── */
@media (max-width: 480px) {
  .app-footer .footer-copyright { display: none; }
  .app-footer .footer-locale { display: none; }
  .wizard-steps { flex-wrap: wrap; gap: 4px; padding: 8px 10px; }
  .wizard-step-item { flex: 0 0 auto; }
  .wizard-step-line { display: none; }
  .wizard-step-num { width: 22px; height: 22px; font-size: 9px; }
  .wizard-step-label { font-size: 9px; }
  .header-user-dropdown { right: -8px; min-width: 200px; }
  /* fixed, not absolute — anchor-relative width/right overflowed off-screen */
  .header-notif-dropdown {
    position: fixed;
    top: var(--aierp-header-h);
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
  }
  .pagination-size { display: none; }
  .col-vis-option { padding: 4px 12px; }
  .page-tab { padding: 10px 10px; font-size: 11px; }
  .wizard-step-panel h6 { padding: 8px 4px; margin: 2px auto 10px; font-size: 12px; line-height: 1.5; }
  .cmd-bar { padding: 4px 8px; }
  .cmd-bar.bulk { padding: 0 8px; }
  .cmd-bar.bulk .cmd-item { padding: 12px 5px; max-width: 68px; display: block; line-height: normal; white-space: normal; font-size: 11px; }
}

/* ── Small mobile (≤320px): minimal, no overflow ── */
@media (max-width: 320px) {
  :root { --aierp-header-h: 44px; --aierp-footer-h: 28px; }

  html, body { overflow-x: hidden; }
  .app-wrapper { overflow-x: hidden; }

  .app-sidebar {
    width: var(--aierp-sidebar-collapsed) !important;
    min-width: var(--aierp-sidebar-collapsed) !important;
  }
  .app-main { margin-left: var(--aierp-sidebar-collapsed) !important; max-width: calc(100vw - var(--aierp-sidebar-collapsed)); overflow-x: hidden; }

  .app-content { padding: 8px; max-width: 100%; overflow-x: hidden; }
  .app-header { padding: 0 8px; gap: 4px; height: 44px; max-width: 100%; }
  .app-header .header-breadcrumb { font-size: 10px; gap: 3px; }
  .app-footer { font-size: 8px; gap: 4px; padding: 0 8px; height: 28px; max-width: 100%; }
  .app-footer .footer-copyright { display: none; }
  .app-footer .footer-locale { display: none; }

  .page-toolbar,
  .filter-bar,
  .pagination-bar,
  .data-table-container,
  .section-card { max-width: 100%; }

  .form-grid--2, .form-grid--3, .form-grid--4 { grid-template-columns: 1fr !important; }
  .doc-facts { grid-template-columns: 1fr; }

  .progress-step { font-size: 9px; padding: 6px 8px; }

  .page-toolbar { gap: 6px; }
  .page-toolbar h2 { font-size: 16px; }
  .page-toolbar-actions { flex-wrap: wrap; gap: 4px; }
  .page-toolbar-actions .btn { font-size: 10px; padding: 5px 8px; }
  .page-tabs { gap: 0; flex-wrap: wrap; }
  .page-tab { padding: 5px 7px; font-size: 10px; white-space: nowrap; }
  .page-tab .tab-count { font-size: 8px; padding: 1px 4px; margin-left: 3px; }
  .aierp-tabs-nav { flex-wrap: wrap; }
  .aierp-tab-btn { font-size: 10px; padding: 6px 10px; }

  .wizard-steps { gap: 3px; padding: 6px 8px; }
  .wizard-step-num { width: 20px; height: 20px; font-size: 8px; }
  .wizard-step-label { font-size: 8px; }

  .stat-card { padding: 10px 12px; }
  .stat-icon { width: 28px; height: 28px; font-size: 13px; margin-bottom: 8px; }
  .stat-label { font-size: 9px; }
  .stat-value { font-size: 18px; }
  .stat-meta { font-size: 9.5px; }

  .filter-bar { gap: 4px; }
  .filter-bar input[type="search"],
  .filter-bar .form-control,
  .filter-bar .form-select { width: 100%; font-size: 11px; padding: 6px 8px; }
  .filter-chip { font-size: 9.5px; padding: 3px 7px; }
  .date-range { flex-direction: column; align-items: flex-start; gap: 4px; }
  .date-range-inputs { width: 100%; }
  .date-range-inputs .form-control { width: 100%; min-width: 0; flex: 1; }

  .data-table thead th { font-size: 8px; padding: 5px 6px; letter-spacing: .3px; }
  .data-table tbody td,
  .data-table tfoot td { font-size: 10px; padding: 5px 6px; }
  .cell-num { font-size: 10px; }
  .row-action-trigger { width: 24px; height: 24px; font-size: 14px; }
  .aierp-badge { font-size: 9px; padding: 2px 6px; }

  .page-top-left h2 { font-size: 15px; }
  .doc-meta { font-size: 10px; gap: 4px; }
  .doc-badge { font-size: 9px; padding: 2px 7px; }
  .page-top-right .btn { font-size: 10.5px; padding: 5px 8px; }

  .section-card-header { padding: 8px 10px; font-size: 10px; gap: 6px; }
  .section-card-header svg { width: 12px; height: 12px; }
  .section-card-body { padding: 10px 12px; }

  .form-group label { font-size: 9px; }
  .form-group .form-control,
  .form-group .form-select { padding: 6px 8px; font-size: 11px; }
  .check-row label { font-size: 11px; }

  .lines-table { font-size: 10px; min-width: 620px; }
  .lines-table thead th { font-size: 8px; padding: 5px 4px; letter-spacing: .2px; white-space: nowrap; }
  .lines-table td { padding: 5px 4px; }
  .lines-table .form-control,
  .lines-table .form-select { font-size: 10px; padding: 4px 5px; }
  .btn-del { width: 22px; height: 22px; font-size: 13px; }
  .lines-add-row { font-size: 11px; padding: 8px 10px; }

  .summary-total { font-size: 14px; }
  .summary-line { font-size: 10.5px; }

  .sticky-bar { padding: 8px 10px; margin: 8px -2px -2px; gap: 6px; }
  .sticky-bar .btn { font-size: 10.5px; padding: 5px 8px; }
  .sticky-bar .saved-indicator { font-size: 9.5px; }

  .side-panel-toggle { width: 22px; font-size: 9px; padding: 10px 0; }
  .side-panel { width: 240px; }
  .side-panel h4 { font-size: 10px; margin-bottom: 10px; }

  .ai-panel { width: 80% !important; min-width: 80% !important; }
  .ai-panel .ai-input-wrap textarea { padding: 4px 12px; font-size: 11.5px; }

  .fab-aierp {
    right: 8px;
    bottom: 50px;
    padding: 8px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    justify-content: center;
    gap: 0;
    font-size: 0;
  }
  .fab-aierp #aiFabLabel { display: none; }
  .fab-aierp img { width: 16px; height: 16px; margin: 0; }

  .pagination-bar { font-size: 10px; flex-direction: column; gap: 6px; align-items: center; }
  .pagination-pages { gap: 2px; }
  .pagination-pages button { width: 26px; height: 26px; font-size: 9px; }
  .pagination-size { display: none; }
  .pagination-info { font-size: 10px; }
}

/* ═══════════════════════════════════════════════════════════════
   IMPORT / EXPORT
   ═══════════════════════════════════════════════════════════════ */

/* ── Dropzone ── */
.import-dropzone {
  border: 2px dashed var(--aierp-border-strong);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--aierp-duration-fast), background var(--aierp-duration-fast);
}
.import-dropzone:hover,
.import-dropzone.dragover {
  border-color: var(--aierp-accent);
  background: rgb(var(--aierp-accent-rgb) / .04);
}
.import-dropzone-icon { font-size: 40px; margin-bottom: 8px; }
.import-dropzone-filename { font-weight: 600; color: var(--aierp-accent); }

/* ── Mapping table ── */
.import-mapping-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.import-mapping-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  background: var(--aierp-surface);
  border-radius: 6px;
}
.import-mapping-row .file-col {
  flex: 1;
  font-size: 13px;
  color: var(--aierp-text-secondary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.import-mapping-row .map-arrow { color: var(--aierp-text-tertiary); }
.import-mapping-row select {
  flex: 1;
  min-width: 0;
}

/* ── Preview errors ── */
.import-preview-errors .preview-row {
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 12px;
}
.import-preview-errors .preview-row.valid {
  background: var(--aierp-green-soft-bg);
  border-left: 3px solid var(--aierp-green);
}
.import-preview-errors .preview-row.invalid {
  background: var(--aierp-red-soft-bg);
  border-left: 3px solid var(--aierp-red);
}
.import-preview-errors .preview-row.warned {
  background: rgb(var(--aierp-amber-rgb) / .12);
  border-left: 3px solid var(--aierp-amber);
}
.preview-row-num {
  font-weight: 600;
  margin-right: 8px;
  color: var(--aierp-text-tertiary);
}

/* ── Export modal form-check overrides ── */
.aierp-modal .form-check { margin: 2px 0; }
.aierp-modal .form-check-input { cursor: pointer; margin-right: 6px; }
.aierp-modal .form-check-input:checked { background-color: var(--aierp-accent); border-color: var(--aierp-accent); }

/* ══════════════════════════════════════════════════════════
   READ-ONLY RECORD — the actor may look, not change
   Set by App\Support\Rbac\FormLock through @section('readonly') as
   data-record-readonly on .app-content; fields are locked by
   Aierp.applyReadOnlyMode().
   ⚠️ The name deliberately differs from data-readonly, which lines-editor
   already uses for its own rows — and sets even when it is 0.
   ══════════════════════════════════════════════════════════ */

/* Everything that writes — Save, Delete, Post, Unlock, add line — disappears.
   CSS hides it so no button flashes before the script runs. */
[data-record-readonly] button[type="submit"],
[data-record-readonly] [onclick*="confirmSubmitForm"],
[data-record-readonly] [onclick*="confirmDeleteForm"],
[data-record-readonly] .btn-danger,
[data-record-readonly] .lines-editor-add,
[data-record-readonly] .line-remove-btn,
[data-record-readonly] .attachment-drop {
  display: none !important;
}

[data-record-readonly] .form-control[readonly],
[data-record-readonly] .form-control:disabled,
[data-record-readonly] select:disabled {
  background: var(--aierp-surface-overlay);
  cursor: default;
  opacity: 1;
}

/* Checkbox and radio stay readable — locked is not the same as switched off. */
[data-record-readonly] input[type="checkbox"]:disabled,
[data-record-readonly] input[type="radio"]:disabled,
[data-record-readonly] .form-switch input:disabled {
  opacity: .75;
  cursor: default;
}

.readonly-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 9px 14px;
  border: 1px solid var(--aierp-border);
  border-left: 3px solid var(--aierp-accent);
  border-radius: var(--aierp-radius-sm);
  background: var(--aierp-surface-overlay);
  color: var(--aierp-text-secondary);
  font-size: 12.5px;
}
