/*
 * ERP UI theme (from scratch)
 * Style language: Windows 12-inspired enterprise glass UI
 */

:root {
  --ui-font: "Segoe UI Variable Text", "Segoe UI", "Noto Sans", system-ui, -apple-system, sans-serif;
  --ui-mono: "Cascadia Mono", "JetBrains Mono", "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --ui-bg: #eaf1fb;
  --ui-bg-accent: #d9e7fb;
  --ui-surface: rgba(255, 255, 255, 0.82);
  --ui-surface-solid: #ffffff;
  --ui-surface-2: rgba(246, 251, 255, 0.9);
  --ui-border: #cfdcf2;
  --ui-border-strong: #b8c9e6;
  --ui-text: #1d2a3d;
  --ui-muted: #607496;

  --ui-accent: #1b84ff;
  --ui-accent-hover: #1476e8;
  --ui-accent-press: #0f63c5;

  --ui-danger: #c83243;
  --ui-danger-hover: #ae2737;

  --ui-success-bg: #e9faef;
  --ui-success-text: #1f6a39;
  --ui-success-border: #b7e8c8;

  --ui-warning-bg: #fff8e8;
  --ui-warning-text: #7e5b12;
  --ui-warning-border: #f0ddb0;

  --ui-info-bg: #edf5ff;
  --ui-info-text: #0c4c93;
  --ui-info-border: #bfd9fb;

  --ui-row: #ffffff;
  --ui-row-alt: #f7faff;
  --ui-row-hover: #edf4ff;
  --ui-row-selected: #dcecff;
  --ui-head: #edf4ff;

  --ui-radius-sm: 10px;
  --ui-radius-md: 14px;
  --ui-radius-lg: 18px;

  --ui-shadow-sm: 0 2px 10px rgba(14, 35, 73, 0.09);
  --ui-shadow-md: 0 12px 32px rgba(14, 35, 73, 0.14);

  --table-head-size: 15px;
  --table-head-line: 1.25;
  --table-head-weight: 600;
}

html[data-theme="dark"],
html[data-bs-theme="dark"],
body.theme-dark {
  --ui-bg: #121722;
  --ui-bg-accent: #1a2436;
  --ui-surface: rgba(31, 39, 56, 0.76);
  --ui-surface-solid: #212a3b;
  --ui-surface-2: rgba(37, 47, 68, 0.82);
  --ui-border: #3b4c69;
  --ui-border-strong: #4e6286;
  --ui-text: #eaf1ff;
  --ui-muted: #afc0df;

  --ui-accent: #3f9cff;
  --ui-accent-hover: #2f8fed;
  --ui-accent-press: #2678cd;

  --ui-danger: #da5a6a;
  --ui-danger-hover: #cb4a5b;

  --ui-success-bg: #1d3a2b;
  --ui-success-text: #a7e9c0;
  --ui-success-border: #39664f;

  --ui-warning-bg: #3c321f;
  --ui-warning-text: #ffd590;
  --ui-warning-border: #6e5836;

  --ui-info-bg: #1e3650;
  --ui-info-text: #a0cdfa;
  --ui-info-border: #3a5f86;

  --ui-row: #212a3b;
  --ui-row-alt: #24314a;
  --ui-row-hover: #2b3d5b;
  --ui-row-selected: #375381;
  --ui-head: #2a3956;

  --ui-shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.34);
  --ui-shadow-md: 0 14px 36px rgba(0, 0, 0, 0.42);
}

/* ── Dark-mode overrides for Tailwind slate utilities ─────────────────────
   Tailwind generates concrete hex values — they don't follow CSS variables.
   We remap the full slate scale here so every slate-* class adapts to dark.
   ──────────────────────────────────────────────────────────────────────── */
html[data-theme="dark"] .bg-slate-50,
html[data-theme="dark"] .\!bg-slate-50,
html[data-bs-theme="dark"] .bg-slate-50,
html[data-bs-theme="dark"] .\!bg-slate-50,
body.theme-dark .bg-slate-50,
body.theme-dark .\!bg-slate-50 {
  background-color: var(--ui-surface-solid) !important;
}
html[data-theme="dark"] .bg-slate-100,
html[data-theme="dark"] .\!bg-slate-100,
html[data-bs-theme="dark"] .bg-slate-100,
html[data-bs-theme="dark"] .\!bg-slate-100,
body.theme-dark .bg-slate-100,
body.theme-dark .\!bg-slate-100 {
  background-color: var(--ui-row-alt) !important;
}
html[data-theme="dark"] .bg-slate-200,
html[data-theme="dark"] .\!bg-slate-200,
html[data-bs-theme="dark"] .bg-slate-200,
html[data-bs-theme="dark"] .\!bg-slate-200,
body.theme-dark .bg-slate-200,
body.theme-dark .\!bg-slate-200 {
  background-color: var(--ui-row-hover) !important;
}

html[data-theme="dark"] .hover\:bg-slate-50:hover,
html[data-bs-theme="dark"] .hover\:bg-slate-50:hover,
body.theme-dark .hover\:bg-slate-50:hover {
  background-color: var(--ui-row-hover) !important;
}
html[data-theme="dark"] .hover\:bg-slate-100:hover,
html[data-bs-theme="dark"] .hover\:bg-slate-100:hover,
body.theme-dark .hover\:bg-slate-100:hover {
  background-color: var(--ui-row-selected) !important;
}

html[data-theme="dark"] .text-slate-900,
html[data-bs-theme="dark"] .text-slate-900,
body.theme-dark .text-slate-900 {
  color: var(--ui-text) !important;
}
html[data-theme="dark"] .text-slate-800,
html[data-bs-theme="dark"] .text-slate-800,
body.theme-dark .text-slate-800 {
  color: #dde8ff !important;
}
html[data-theme="dark"] .text-slate-700,
html[data-bs-theme="dark"] .text-slate-700,
body.theme-dark .text-slate-700 {
  color: #c4d4ee !important;
}
html[data-theme="dark"] .text-slate-600,
html[data-bs-theme="dark"] .text-slate-600,
body.theme-dark .text-slate-600 {
  color: var(--ui-muted) !important;
}
html[data-theme="dark"] .text-slate-500,
html[data-bs-theme="dark"] .text-slate-500,
body.theme-dark .text-slate-500 {
  color: #8fa4c0 !important;
}
html[data-theme="dark"] .text-slate-400,
html[data-bs-theme="dark"] .text-slate-400,
body.theme-dark .text-slate-400 {
  color: #7a94b8 !important;
}

html[data-theme="dark"] .hover\:text-slate-700:hover,
html[data-bs-theme="dark"] .hover\:text-slate-700:hover,
body.theme-dark .hover\:text-slate-700:hover {
  color: var(--ui-text) !important;
}

html[data-theme="dark"] .border-slate-100,
html[data-bs-theme="dark"] .border-slate-100,
body.theme-dark .border-slate-100 {
  border-color: #2d3d57 !important;
}
html[data-theme="dark"] .border-slate-200,
html[data-bs-theme="dark"] .border-slate-200,
body.theme-dark .border-slate-200 {
  border-color: var(--ui-border) !important;
}
html[data-theme="dark"] .border-slate-300,
html[data-bs-theme="dark"] .border-slate-300,
body.theme-dark .border-slate-300 {
  border-color: var(--ui-border-strong) !important;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body,
.app-shell,
.main-column,
main {
  background:
    radial-gradient(900px 480px at -15% -15%, color-mix(in srgb, var(--ui-accent) 14%, transparent), transparent 62%),
    radial-gradient(980px 540px at 110% -35%, color-mix(in srgb, var(--ui-bg-accent) 58%, transparent), transparent 70%),
    var(--ui-bg) !important;
  color: var(--ui-text) !important;
  font-family: var(--ui-font);
}

/* Desktop app shell layout: sidebar + main column side-by-side */
.app-shell {
  display: flex;
  min-height: calc(100vh - 3.5rem);
}

.main-column {
  min-width: 0;
}

a {
  color: color-mix(in srgb, var(--ui-accent) 84%, #ffffff 16%);
}

a:hover {
  color: var(--ui-accent-hover);
}

.text-muted,
.text-slate-400,
.text-slate-500,
.text-slate-600,
.text-slate-700 {
  color: var(--ui-muted) !important;
}

.max-w-\[1400px\] {
  max-width: 100% !important;
  width: 100% !important;
}

/* Global filter sizing: align filter sections with table width */
form[method="get"] .card {
  width: 100% !important;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  position: static !important;
}

/* Global surface system */
.app-navbar,
.app-sidebar,
.app-footer,
.card,
.card-header,
.card-body,
.card-footer,
.bg-white,
.\!bg-white,
.bg-slate-50,
.\!bg-slate-50,
.bg-slate-100,
.\!bg-slate-100,
.dropdown-menu,
.modal-content,
.offcanvas,
.overflow-x-auto,
.overflow-auto,
.table-responsive,
.erp-table-shell,
.erp-filter-one-row,
.table-controls-toolbar {
  background: var(--ui-surface) !important;
  color: var(--ui-text) !important;
  border: 1px solid var(--ui-border) !important;
  border-radius: var(--ui-radius-lg) !important;
  box-shadow: var(--ui-shadow-sm) !important;
  backdrop-filter: blur(12px) saturate(1.04);
  -webkit-backdrop-filter: blur(12px) saturate(1.04);
}

.card-header,
.border-b.border-slate-100,
.border-b.border-slate-200 {
  background: linear-gradient(180deg, var(--ui-surface-2) 0%, color-mix(in srgb, var(--ui-surface-solid) 80%, var(--ui-surface-2)) 100%) !important;
}

/* Prevent double frame artifacts: keep one outer card radius/border only */
.card > .card-body {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  border-radius: inherit !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html[data-theme="dark"] .\!bg-slate-50,
html[data-theme="dark"] .\!bg-white,
html[data-bs-theme="dark"] .\!bg-slate-50,
html[data-bs-theme="dark"] .\!bg-white,
body.theme-dark .\!bg-slate-50,
body.theme-dark .\!bg-white {
  background: var(--ui-surface) !important;
  color: var(--ui-text) !important;
  border-color: var(--ui-border) !important;
}

/* Filter containers (kontejneri filtera): identical to Finance .erp-filter-shell in dark mode.
   Targets any card wrapping a GET filter form, regardless of its bg utility
   (!bg-slate-50, !bg-slate-100, !bg-sky-100, bg-white, ...). */
html[data-theme="dark"] .card:has(form[method="get"]),
html[data-bs-theme="dark"] .card:has(form[method="get"]),
body.theme-dark .card:has(form[method="get"]) {
  background: color-mix(in srgb, var(--ui-surface-solid) 90%, #0a111f 10%) !important;
  border: 1px solid color-mix(in srgb, var(--ui-border-strong) 78%, #1d2d46 22%) !important;
  box-shadow: 0 14px 34px rgba(2, 8, 20, 0.42) !important;
}

html[data-theme="dark"] .card:has(form[method="get"]) > .card-body,
html[data-theme="dark"] .card:has(form[method="get"]) > .p-4,
html[data-bs-theme="dark"] .card:has(form[method="get"]) > .card-body,
html[data-bs-theme="dark"] .card:has(form[method="get"]) > .p-4,
body.theme-dark .card:has(form[method="get"]) > .card-body,
body.theme-dark .card:has(form[method="get"]) > .p-4 {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

/* Navigation */
.app-navbar {
  border-bottom-color: var(--ui-border-strong) !important;
  box-shadow: var(--ui-shadow-md) !important;
}

.app-sidebar {
  border-right-color: var(--ui-border-strong) !important;
}

.navbar-home-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 1rem 0 0.5rem;
  color: var(--ui-text) !important;
  text-decoration: none;
}

.navbar-home-brand__icon {
  flex: 0 0 auto;
}

.navbar-home-brand__text {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.navbar-home-brand:hover {
  opacity: 0.92;
}

.navbar-group-tabs {
  flex: 1 1 0 !important;
  min-width: 0 !important;
}

.navbar-group-tabs .nav-group-tab {
  flex: 1 1 0 !important;
  justify-content: center !important;
  text-align: center !important;
  min-width: 0 !important;
}

.nav-group-tab .module-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.65rem;
  font-size: 1.6rem;
  flex-shrink: 0;
  background: transparent !important;
}

.nav-group-tab .module-link-text {
  display: inline-flex;
}

.module-link-icon--finance { color: #1d4ed8 !important; }
.module-link-icon--crm { color: #0c4a6e !important; }
.module-link-icon--procurement { color: #15803d !important; }
.module-link-icon--wms { color: #7c3aed !important; }
.module-link-icon--tms { color: #b45309 !important; }
.module-link-icon--manufacturing { color: #be123c !important; }
.module-link-icon--hrm { color: #4338ca !important; }
.module-link-icon--fsm { color: #4d7c0f !important; }
.module-link-icon--reports { color: #d97706 !important; }
.module-link-icon--platform { color: #0f172a !important; }

.app-footer {
  padding-block: calc(var(--spacing) * 1.5) !important;
}

#sidebar-accordion .nav-link,
.app-sidebar .nav-link,
.nav-group-tab {
  color: var(--ui-text) !important;
  border-radius: var(--ui-radius-sm) !important;
  transition: background-color 60ms ease, color 60ms ease;
}

/* Top-bar main menu tabs: slightly smaller, tighter font */
.nav-group-tab {
  font-size: 0.78rem !important;
  letter-spacing: 0.01em;
}

#sidebar-accordion .nav-link:hover,
.app-sidebar .nav-link:hover,
.nav-group-tab:hover {
  background: color-mix(in srgb, var(--ui-accent) 10%, var(--ui-surface-solid)) !important;
}

#sidebar-accordion .nav-link.active,
.app-sidebar .nav-link.active,
.nav-group-tab.active {
  background: color-mix(in srgb, var(--ui-accent) 24%, var(--ui-surface-solid)) !important;
  color: var(--ui-text) !important;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ui-accent) 45%, var(--ui-border));
}

/* Report links in sidebar — warm yellow tint to distinguish from operational links */
#sidebar-accordion .sidebar-subnav--reports .nav-link,
.app-sidebar .sidebar-subnav--reports .nav-link,
#sidebar-accordion .nav-report-item .nav-link,
.app-sidebar .nav-report-item .nav-link {
  background: var(--ui-warning-bg) !important;
  border: 1px solid var(--ui-warning-border) !important;
}

#sidebar-accordion .sidebar-subnav--reports .nav-link:hover,
.app-sidebar .sidebar-subnav--reports .nav-link:hover,
#sidebar-accordion .nav-report-item .nav-link:hover,
.app-sidebar .nav-report-item .nav-link:hover {
  background: color-mix(in srgb, #ffc107 22%, var(--ui-warning-bg)) !important;
  border-color: color-mix(in srgb, #ffc107 40%, var(--ui-warning-border)) !important;
}

#sidebar-accordion .sidebar-subnav--reports .nav-link.active,
.app-sidebar .sidebar-subnav--reports .nav-link.active,
#sidebar-accordion .nav-report-item .nav-link.active,
.app-sidebar .nav-report-item .nav-link.active {
  background: color-mix(in srgb, #ffc107 35%, var(--ui-warning-bg)) !important;
  border-color: color-mix(in srgb, #ffc107 55%, var(--ui-warning-border)) !important;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #ffc107 50%, var(--ui-warning-border)) !important;
}

/* Electron top line tuning (menu, search, user + window controls) */
html.electron .app-navbar {
  font-size: 14px !important;
  -webkit-app-region: drag;
}

html.electron .app-navbar a,
html.electron .app-navbar button,
html.electron .app-navbar input,
html.electron .app-navbar [role="button"],
html.electron .app-navbar .nav-group-tab,
html.electron .app-navbar .navbar-home-brand,
html.electron .app-navbar .omni-search-trigger,
html.electron .app-navbar #userDropdown,
html.electron .app-navbar .win-ctrl,
html.electron .app-navbar .dropdown-menu,
html.electron .electron-nav-btns {
  -webkit-app-region: no-drag;
}

html.electron .app-navbar .nav-group-tab,
html.electron .app-navbar .omni-search-trigger,
html.electron .app-navbar #userDropdown,
html.electron .app-navbar .navbar-home-brand,
html.electron .app-navbar .btn {
  font-size: 0.78rem !important;
}

html.electron .app-navbar .nav-group-tab {
  padding-left: 0.5rem !important;
  padding-right: 0.5rem !important;
}

html.electron .app-navbar .omni-search-trigger i,
html.electron .app-navbar #userDropdown i,
html.electron .app-navbar .nav-group-tab i {
  font-size: 14px !important;
}

html.electron .app-navbar .nav-group-tab .module-link-icon {
  width: 2.6rem !important;
  height: 2.6rem !important;
  font-size: 1.6rem !important;
}

html.electron .electron-window-controls,
html.electron .electron-standalone-controls {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.25rem !important;
}

html.electron .electron-window-controls .win-ctrl,
html.electron .electron-standalone-controls .win-ctrl,
html.electron .app-navbar .win-ctrl {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
  margin: 0 !important;
  color: var(--ui-text) !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  outline: none !important;
}

html.electron .electron-window-controls .win-ctrl:hover,
html.electron .electron-window-controls .win-ctrl:focus,
html.electron .electron-window-controls .win-ctrl:active,
html.electron .electron-standalone-controls .win-ctrl:hover,
html.electron .electron-standalone-controls .win-ctrl:focus,
html.electron .electron-standalone-controls .win-ctrl:active,
html.electron .app-navbar .win-ctrl:hover,
html.electron .app-navbar .win-ctrl:focus,
html.electron .app-navbar .win-ctrl:active {
  background: color-mix(in srgb, var(--ui-surface-solid) 94%, var(--ui-surface)) !important;
}

/* Reusable filter and toolbar strips */
.erp-filter-one-row,
.table-controls-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  margin-bottom: 0.6rem !important;
  padding: 0.55rem 0.68rem !important;
}

.erp-filter-one-row > * {
  flex: 0 0 auto;
}

.erp-filter-actions,
.table-controls-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  white-space: nowrap;
}

/* Finance filter shells: avoid double-framed card-body in dark mode */
.erp-filter-shell > .card-body,
.erp-filter-shell > .p-4 {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .erp-filter-shell,
html[data-bs-theme="dark"] .erp-filter-shell,
body.theme-dark .erp-filter-shell {
  background: color-mix(in srgb, var(--ui-surface-solid) 90%, #0a111f 10%) !important;
  border-color: color-mix(in srgb, var(--ui-border-strong) 78%, #1d2d46 22%) !important;
  box-shadow: 0 14px 34px rgba(2, 8, 20, 0.42) !important;
}

html[data-theme="dark"] .erp-filter-shell .form-label,
html[data-bs-theme="dark"] .erp-filter-shell .form-label,
body.theme-dark .erp-filter-shell .form-label {
  color: color-mix(in srgb, var(--ui-text) 86%, var(--ui-accent) 14%) !important;
}

/* Filter section inputs: lighter background in dark mode for better contrast */
html[data-theme="dark"] .erp-filter-one-row .form-control,
html[data-theme="dark"] .erp-filter-one-row .form-select,
html[data-theme="dark"] .erp-filter-one-row input:not([type="hidden"]),
html[data-theme="dark"] .erp-filter-one-row select,
html[data-theme="dark"] .erp-filter-shell .form-control,
html[data-theme="dark"] .erp-filter-shell .form-select,
html[data-theme="dark"] .erp-filter-shell input:not([type="hidden"]),
html[data-theme="dark"] .erp-filter-shell select,
html[data-theme="dark"] form[method="get"] .form-control,
html[data-theme="dark"] form[method="get"] .form-select,
html[data-theme="dark"] form[method="get"] input:not([type="hidden"]):not([type="submit"]),
html[data-theme="dark"] form[method="get"] select,
html[data-bs-theme="dark"] .erp-filter-one-row .form-control,
html[data-bs-theme="dark"] .erp-filter-one-row .form-select,
html[data-bs-theme="dark"] .erp-filter-one-row input:not([type="hidden"]),
html[data-bs-theme="dark"] .erp-filter-one-row select,
html[data-bs-theme="dark"] .erp-filter-shell .form-control,
html[data-bs-theme="dark"] .erp-filter-shell .form-select,
html[data-bs-theme="dark"] .erp-filter-shell input:not([type="hidden"]),
html[data-bs-theme="dark"] .erp-filter-shell select,
html[data-bs-theme="dark"] form[method="get"] .form-control,
html[data-bs-theme="dark"] form[method="get"] .form-select,
html[data-bs-theme="dark"] form[method="get"] input:not([type="hidden"]):not([type="submit"]),
html[data-bs-theme="dark"] form[method="get"] select,
body.theme-dark .erp-filter-one-row .form-control,
body.theme-dark .erp-filter-one-row .form-select,
body.theme-dark .erp-filter-one-row input:not([type="hidden"]),
body.theme-dark .erp-filter-one-row select,
body.theme-dark .erp-filter-shell .form-control,
body.theme-dark .erp-filter-shell .form-select,
body.theme-dark .erp-filter-shell input:not([type="hidden"]),
body.theme-dark .erp-filter-shell select,
body.theme-dark form[method="get"] .form-control,
body.theme-dark form[method="get"] .form-select,
body.theme-dark form[method="get"] input:not([type="hidden"]):not([type="submit"]),
body.theme-dark form[method="get"] select {
  background: var(--ui-row-hover) !important;
  border: 1px solid var(--ui-border-strong) !important;
  color: var(--ui-text) !important;
}

/* Buttons */
.btn,
button,
[role="button"] {
  border: 1px solid var(--ui-border-strong) !important;
  border-radius: var(--ui-radius-sm) !important;
  background: linear-gradient(180deg, color-mix(in srgb, var(--ui-surface-solid) 92%, #ffffff) 0%, var(--ui-surface-2) 100%) !important;
  color: var(--ui-text) !important;
  box-shadow: var(--ui-shadow-sm) !important;
  font-weight: 600 !important;
  transition: background-color 60ms ease, border-color 60ms ease, color 60ms ease, transform 60ms ease;
}

.btn:hover,
button:hover,
[role="button"]:hover {
  background: color-mix(in srgb, var(--ui-accent) 12%, var(--ui-surface-solid)) !important;
  border-color: color-mix(in srgb, var(--ui-border-strong) 65%, var(--ui-accent) 35%) !important;
  color: color-mix(in srgb, var(--ui-text) 85%, var(--ui-accent) 15%) !important;
}

.btn:active,
button:active,
[role="button"]:active {
  transform: translateY(0.5px);
}

.btn-primary,
.btn-nav-active {
  background: linear-gradient(180deg, color-mix(in srgb, var(--ui-accent) 78%, #ffffff 22%) 0%, var(--ui-accent) 100%) !important;
  border-color: var(--ui-accent) !important;
  color: #ffffff !important;
}

.btn-primary:hover,
.btn-nav-active:hover {
  background: var(--ui-accent-hover) !important;
  border-color: var(--ui-accent-hover) !important;
  color: #ffffff !important;
}

.btn-primary:active,
.btn-nav-active:active {
  background: var(--ui-accent-press) !important;
  border-color: var(--ui-accent-press) !important;
  color: #ffffff !important;
}

.btn-danger,
.btn-outline-danger {
  border-color: var(--ui-danger) !important;
  color: var(--ui-danger) !important;
}

.btn-danger {
  background: var(--ui-danger) !important;
  color: #ffffff !important;
}

.btn-danger:hover {
  background: var(--ui-danger-hover) !important;
  border-color: var(--ui-danger-hover) !important;
  color: #ffffff !important;
}

/* Forms */
.form-control,
.form-select,
.input-group-text,
input,
select,
textarea {
  background: color-mix(in srgb, var(--ui-surface-solid) 88%, var(--ui-surface-2)) !important;
  border: 1px solid var(--ui-border-strong) !important;
  color: var(--ui-text) !important;
  border-radius: var(--ui-radius-sm) !important;
  box-shadow: inset 0 1px 2px rgba(15, 33, 66, 0.08) !important;
}

/* Numeric/date consistency */
input[type="number"],
input[inputmode="numeric"],
input[inputmode="decimal"] {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  font-family: var(--ui-mono) !important;
  width: 100px !important;
}

/* Amount inputs: override with width for 12 digits */
input.erp-amount-input,
input[data-amount="true"],
input[data-amount-field="true"],
input[inputmode="decimal"].erp-amount-input {
  width: 160px !important;
}

/* Date inputs: minimal width */
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="time"],
time,
.erp-mono-value,
.erp-amount {
  font-family: var(--ui-mono) !important;
  font-variant-numeric: tabular-nums;
}

input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="time"] {
  width: auto !important;
}

/* Calendar icon for date inputs */
input[type="date"],
input[type="datetime-local"],
input[type="month"] {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  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='%23607496' stroke-width='2'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='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") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.5rem center !important;
  background-size: 1.2rem auto !important;
  padding-right: 2.2rem !important;
}

/* Remove default calendar icon from webkit browsers */
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  background: transparent;
}

input[type="date"]::-webkit-outer-spin-button,
input[type="date"]::-webkit-inner-spin-button {
  display: none;
}

/* Calendar icon for flatpickr inputs */
input.flatpickr-input {
  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='%23607496' stroke-width='2'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='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") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.5rem center !important;
  background-size: 1.2rem auto !important;
  padding-right: 2.2rem !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  width: fit-content !important;
  min-width: 110px !important;
  max-width: 130px !important;
}

/* Hide native browser calendar for alt input */
input.flatpickr-input::-webkit-calendar-picker-indicator {
  display: none !important;
}

input.flatpickr-input::-webkit-outer-spin-button,
input.flatpickr-input::-webkit-inner-spin-button {
  display: none !important;
}

.erp-amount {
  white-space: nowrap;
}

.form-control::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--ui-muted) !important;
}

/* Product autocomplete - full width filter, no horizontal scroll */
#stock_levels_filter_form {
  width: 100% !important;
}

#stock_levels_filter_form .card {
  width: 100% !important;
  overflow-x: visible !important;
}

#stock_levels_filter_form .card-body {
  overflow-x: visible !important;
}

input.pac-text[data-purpose="stock-filter"] {
  width: 100% !important;
}

.pac-wrapper[data-purpose="stock-filter"] input.pac-text {
  width: 100% !important;
}

/* Remove buttons - square icon only */
.remove-nested-field,
.remove-line,
.remove-line-item,
.remove-claim-line {
  width: 40px !important;
  height: 40px !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0;
  line-height: 1 !important;
  font-size: 0 !important;
}

.remove-nested-field i,
.remove-nested-field .bi,
.remove-line i,
.remove-line .bi,
.remove-line-item i,
.remove-line-item .bi,
.remove-claim-line i,
.remove-claim-line .bi {
  font-size: 1.1rem !important;
  margin: 0 !important;
}

.form-control:focus,
.form-select:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--ui-accent) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-accent) 28%, transparent) !important;
  outline: none;
}

/* Select dropdown carrots */
.form-select,
select {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23607496' d='M6 9L1 4h10z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.75rem center !important;
  background-size: 1rem auto !important;
  padding-right: 2.5rem !important;
}

/* Tables: globally identical */
table,
.table,
table.min-w-full,
.min-w-full.divide-y,
.min-w-full.text-sm {
  width: 100%;
  border-collapse: separate !important;
  border-spacing: 0;
  margin-bottom: 0;
  color: var(--ui-text) !important;
  background: transparent !important;
}

table thead th,
.table thead th,
.table-light,
.min-w-full.divide-y > thead > tr > th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, var(--ui-head) 0%, color-mix(in srgb, var(--ui-surface-solid) 80%, var(--ui-head)) 100%) !important;
  border-top: 0 !important;
  border-bottom: 1px solid var(--ui-border-strong) !important;
  color: var(--ui-text) !important;
  text-shadow: none !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0.66rem 0.82rem !important;
}

table thead th + th,
.table thead th + th,
.min-w-full.divide-y > thead > tr > th + th {
  box-shadow: inset 1px 0 0 var(--ui-border);
}

table td,
table th,
.table td,
.table th,
.min-w-full tbody td,
.min-w-full tbody th {
  padding: 0.62rem 0.82rem !important;
  border-top: 0 !important;
  border-bottom: 1px solid var(--ui-border) !important;
  vertical-align: middle;
  background: transparent !important;
}

table tbody tr td,
.table tbody tr td,
.min-w-full tbody tr td {
  background: var(--ui-row) !important;
}

table tbody tr:nth-child(even) td,
.table tbody tr:nth-child(even) td,
.min-w-full tbody tr:nth-child(even) td {
  background: var(--ui-row-alt) !important;
}

table tbody tr:hover td,
.table tbody tr:hover td,
.table-hover tbody tr:hover td,
.min-w-full tbody tr:hover td {
  background: var(--ui-row-hover) !important;
}

table tbody tr.is-selected td,
table tbody tr[aria-selected="true"] td,
.table tbody tr.is-selected td,
.table tbody tr[aria-selected="true"] td,
.min-w-full tbody tr.is-selected td,
.min-w-full tbody tr[aria-selected="true"] td {
  background: var(--ui-row-selected) !important;
  box-shadow: inset 3px 0 0 var(--ui-accent);
}

/* Absolute global lock for header typography */
table thead th,
table thead th *,
.table thead th,
.table thead th *,
.table-light,
.table-light *,
.min-w-full.divide-y > thead > tr > th,
.min-w-full.divide-y > thead > tr > th * {
  font-size: var(--table-head-size) !important;
  line-height: var(--table-head-line) !important;
  font-weight: var(--table-head-weight) !important;
  font-family: var(--ui-font) !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}

table thead th a,
table thead th a *,
.table thead th a,
.table thead th a *,
.min-w-full.divide-y > thead > tr > th a,
.min-w-full.divide-y > thead > tr > th a * {
  font-size: var(--table-head-size) !important;
  line-height: var(--table-head-line) !important;
  font-weight: var(--table-head-weight) !important;
  font-family: var(--ui-font) !important;
  letter-spacing: 0 !important;
}

/* Pagination */
.pagy a,
.pagy span,
nav[aria-label="pagination"] a,
nav[aria-label="pagination"] span {
  border-radius: var(--ui-radius-sm) !important;
  border: 1px solid var(--ui-border) !important;
  background: var(--ui-surface) !important;
  color: var(--ui-text) !important;
  box-shadow: var(--ui-shadow-sm) !important;
}

.pagy .current,
nav[aria-label="pagination"] [aria-current="page"] {
  background: var(--ui-accent) !important;
  border-color: var(--ui-accent) !important;
  color: #ffffff !important;
}

/* Status badges */
.badge,
.status-pill {
  border-radius: 999px !important;
  font-weight: 600 !important;
  border: 1px solid transparent;
}

.badge.bg-success,
.status-success {
  background: var(--ui-success-bg) !important;
  color: var(--ui-success-text) !important;
  border-color: var(--ui-success-border) !important;
}

.badge.bg-warning,
.status-warning {
  background: var(--ui-warning-bg) !important;
  color: var(--ui-warning-text) !important;
  border-color: var(--ui-warning-border) !important;
}

.badge.bg-info,
.status-info,
.status-primary {
  background: var(--ui-info-bg) !important;
  color: var(--ui-info-text) !important;
  border-color: var(--ui-info-border) !important;
}

.badge.bg-danger,
.status-danger,
.status-error {
  background: color-mix(in srgb, var(--ui-danger) 20%, var(--ui-surface-solid)) !important;
  color: var(--ui-danger) !important;
  border-color: color-mix(in srgb, var(--ui-danger) 48%, transparent) !important;
}

/* Utility essentials */
.win-ctrl.is-hidden {
  display: none;
}

.col-checkbox.col-checkbox-fixed {
  width: 2rem;
}

.no-scrollbar-width {
  scrollbar-width: none;
}

.no-scrollbar-width::-webkit-scrollbar {
  display: none;
}

.app-flash-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#flash_messages {
  position: absolute;
  right: 0.75rem;
  left: auto;
  bottom: 20px;
  z-index: 1100;
  width: min(26rem, calc(100vw - 1.5rem));
  pointer-events: none;
}

.app-shell #flash_messages,
.auth-main #flash_messages {
  position: absolute !important;
  bottom: 20px !important;
}

#flash_messages .app-flash-container {
  align-items: flex-end;
}

#flash_messages .toast-item {
  width: 100%;
  pointer-events: auto;
}

.toast-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.8rem 0.9rem;
  overflow: hidden;
  border-radius: var(--ui-radius-md) !important;
  border: 1px solid var(--ui-border) !important;
  border-left-width: 4px !important;
  background: var(--ui-surface) !important;
  color: var(--ui-text) !important;
  box-shadow: var(--ui-shadow-md, 0 14px 34px rgba(2, 8, 20, 0.22));
}

/* Accent stripe per kind */
.toast-item--success { border-left-color: #16a34a !important; }
.toast-item--warning { border-left-color: #f59e0b !important; }
.toast-item--danger  { border-left-color: #dc2626 !important; }
.toast-item--info,
.toast-item--notice  { border-left-color: var(--ui-accent) !important; }

.toast-icon {
  flex: 0 0 auto;
  margin-top: 0.05rem;
  font-size: 1.15rem;
  line-height: 1.3;
}
.toast-item--success .toast-icon { color: #16a34a; }
.toast-item--warning .toast-icon { color: #f59e0b; }
.toast-item--danger  .toast-icon { color: #dc2626; }
.toast-item--info    .toast-icon,
.toast-item--notice  .toast-icon { color: var(--ui-accent); }

.toast-body {
  flex: 1 1 auto;
  min-width: 0;
}
.toast-title {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.25;
  margin-bottom: 0.1rem;
}
.toast-message {
  font-size: 0.85rem;
  line-height: 1.35;
  color: color-mix(in srgb, var(--ui-text) 78%, transparent);
  overflow-wrap: anywhere;
}

.toast-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0 !important;
  border: 0 !important;
  border-radius: var(--ui-radius-sm) !important;
  background: transparent !important;
  color: color-mix(in srgb, var(--ui-text) 60%, transparent) !important;
  box-shadow: none !important;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background-color 60ms ease, color 60ms ease;
}
.toast-close:hover {
  background: color-mix(in srgb, var(--ui-text) 10%, transparent) !important;
  color: var(--ui-text) !important;
}

.toast-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  transform-origin: left center;
  background: currentColor;
  opacity: 0.5;
}
.toast-item--success .toast-progress { color: #16a34a; }
.toast-item--warning .toast-progress { color: #f59e0b; }
.toast-item--danger  .toast-progress { color: #dc2626; }
.toast-item--info    .toast-progress,
.toast-item--notice  .toast-progress { color: var(--ui-accent); }

.erp-win11-alert-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(6px);
}

.erp-win11-alert-backdrop.is-open {
  display: flex;
}

.erp-win11-alert {
  width: min(28rem, calc(100vw - 2rem));
  border: 1px solid color-mix(in srgb, var(--ui-border) 70%, #ffffff 30%);
  border-radius: 14px;
  background: color-mix(in srgb, var(--ui-surface) 92%, #ffffff 8%);
  color: var(--ui-text);
  box-shadow: 0 26px 54px rgba(15, 23, 42, 0.28);
  transform: translateY(8px) scale(0.985);
  opacity: 0;
  animation: erpWin11DialogIn 160ms ease-out forwards;
}

.erp-win11-alert__header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem 0.65rem;
}

.erp-win11-alert__icon {
  color: #2563eb;
  font-size: 1.05rem;
}

.erp-win11-alert__icon--confirm {
  color: #f59e0b;
}

.erp-win11-alert__title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
}

.erp-win11-alert__message {
  padding: 0 1rem 0.8rem;
  font-size: 0.95rem;
  line-height: 1.35;
}

.erp-win11-alert__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.8rem 1rem 1rem;
}

.erp-win11-alert__button {
  border: 1px solid color-mix(in srgb, var(--ui-border) 82%, #ffffff 18%);
  border-radius: 999px;
  padding: 0.4rem 0.95rem;
  background: color-mix(in srgb, var(--ui-surface) 94%, #ffffff 6%);
  color: var(--ui-text);
  font-weight: 600;
  transition: background 60ms ease, border-color 60ms ease, transform 60ms ease;
}

.erp-win11-alert__button:hover {
  background: color-mix(in srgb, var(--ui-surface) 86%, #dbeafe 14%);
}

.erp-win11-alert__button--primary {
  border-color: #2563eb;
  background: linear-gradient(180deg, #4f8fff 0%, #2f6ee6 100%);
  color: #ffffff;
}

.erp-win11-alert__button--primary:hover {
  background: linear-gradient(180deg, #5a98ff 0%, #3475f0 100%);
}

.erp-win11-alert__button:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

@keyframes erpWin11DialogIn {
  from {
    transform: translateY(8px) scale(0.985);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .erp-filter-one-row,
  .table-controls-toolbar {
    padding: 0.45rem 0.5rem !important;
    gap: 0.4rem;
  }

  table td,
  .table td,
  .min-w-full tbody td {
    font-size: 0.83rem;
    padding: 0.52rem 0.58rem !important;
  }

  table thead th,
  .table thead th,
  .min-w-full.divide-y > thead > tr > th,
  table thead th *,
  .table thead th *,
  .min-w-full.divide-y > thead > tr > th * {
    font-size: 14px !important;
    line-height: 1.2 !important;
  }
}
