/* ==========================================================================
   DEUS DRONES — MILITARY-TECH DESIGN SYSTEM (STAGE 3 FRONTEND)
   ========================================================================== */

:root, [data-theme="dark"] {
  --bg-primary: #0a0d14;
  --bg-secondary: #121824;
  --bg-card: #182030;
  --bg-card-hover: #1f2a3e;
  --border-color: #2a364f;
  --border-focus: #3b82f6;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;

  /* Status Badges */
  --badge-spravnyi-bg: rgba(16, 185, 129, 0.15);
  --badge-spravnyi-text: #10b981;
  --badge-novyi-bg: rgba(59, 130, 246, 0.15);
  --badge-novyi-text: #60a5fa;
  --badge-remont-bg: rgba(245, 158, 11, 0.15);
  --badge-remont-text: #f59e0b;
  --badge-doukomplekt-bg: rgba(217, 119, 6, 0.15);
  --badge-doukomplekt-text: #fbbf24;
  --badge-donor-bg: rgba(239, 68, 68, 0.15);
  --badge-donor-text: #f87171;
  --badge-spysanyi-bg: rgba(100, 116, 139, 0.2);
  --badge-spysanyi-text: #94a3b8;

  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --border-color: #cbd5e1;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;

  /* Status Badges in Light Mode */
  --badge-spravnyi-bg: rgba(16, 185, 129, 0.18);
  --badge-spravnyi-text: #047857;
  --badge-novyi-bg: rgba(37, 99, 235, 0.15);
  --badge-novyi-text: #1d4ed8;
  --badge-remont-bg: rgba(217, 119, 6, 0.18);
  --badge-remont-text: #b45309;
  --badge-doukomplekt-bg: rgba(202, 138, 4, 0.18);
  --badge-doukomplekt-text: #854d0e;
  --badge-donor-bg: rgba(239, 68, 68, 0.18);
  --badge-donor-text: #b91c1c;
  --badge-spysanyi-bg: rgba(100, 116, 139, 0.22);
  --badge-spysanyi-text: #334155;

  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s ease, color 0.25s ease;
}

#app-view {
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
}

/* --- TOAST NOTIFICATIONS --- */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border-left: 4px solid var(--accent-blue);
  color: var(--text-main);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideIn 0.3s ease;
}

.toast.success { border-left-color: #10b981; }
.toast.error { border-left-color: #ef4444; }
.toast.warning { border-left-color: #f59e0b; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- LOGIN VIEW --- */
.login-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at center, #172338 0%, #080c14 100%);
  padding: 20px;
  transition: background 0.3s ease;
}

[data-theme="light"] .login-container {
  background: radial-gradient(circle at center, #ffffff 0%, #e2e8f0 100%);
}

.login-theme-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.login-card {
  background: #141d2f;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 40px 36px;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .login-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 20px 35px -5px rgba(15, 23, 42, 0.12), 0 8px 15px -6px rgba(15, 23, 42, 0.06);
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-header h1 {
  font-size: 1.85rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 1.5px;
  text-shadow: 0 2px 12px rgba(37, 99, 235, 0.35);
}

[data-theme="light"] .login-header h1 {
  color: #0f172a;
  text-shadow: none;
}

.login-header p {
  font-size: 0.92rem;
  font-weight: 500;
  color: #cbd5e1;
  margin-top: 8px;
  line-height: 1.45;
}

[data-theme="light"] .login-header p {
  color: #475569;
}

.form-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.92rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: 0.2px;
}

[data-theme="light"] .form-group label {
  color: #1e293b;
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-main);
  font-size: 16px;
  font-weight: 500;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-card .form-control {
  background: #0c1424;
  border: 1px solid #283955;
  color: #ffffff;
}

[data-theme="light"] .login-card .form-control {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #0f172a;
}

.form-control:focus,
.login-card .form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}


select.form-control {
  cursor: pointer;
}

.btn {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-blue-hover);
}

.btn-secondary {
  background: #334155;
  color: #f1f5f9;
}
.btn-secondary:hover {
  background: #475569;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}
.btn-danger:hover {
  background: #b91c1c;
}

.btn-block {
  width: 100%;
}

/* --- HEADER & NAVBAR --- */
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-mobile-menu {
  display: none; /* Hidden on Desktop */
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 1.25rem;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-mobile-menu:hover {
  border-color: var(--border-focus);
  color: var(--border-focus);
}

/* --- MOBILE SIDEBAR DRAWER --- */
.mobile-drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.mobile-drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 290px;
  max-width: 85vw;
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  z-index: 1200;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 25px rgba(0, 0, 0, 0.3);
}

.mobile-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-drawer-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.btn-drawer-close:hover {
  color: var(--text-main);
}

.drawer-user-card {
  padding: 14px 18px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.drawer-avatar {
  font-size: 1.6rem;
  background: var(--bg-card);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
}

.drawer-user-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.drawer-user-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-main);
}

.drawer-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  width: 100%;
}

.drawer-nav-item:hover {
  background: var(--bg-secondary);
  color: var(--text-main);
}

.drawer-nav-item.active {
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent-blue);
  font-weight: 700;
  border-left: 3px solid var(--accent-blue);
}

.drawer-nav-icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
}

.drawer-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: 0.5px;
}

.brand-tag {
  font-size: 0.72rem;
  background: var(--bg-card);
  color: var(--accent-blue);
  padding: 3px 9px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info {
  text-align: right;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-role-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-block;
  margin-top: 2px;
}

.role-admin { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }
.role-leader { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.4); }
.role-worker { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }

[data-theme="light"] .role-admin { background: rgba(239, 68, 68, 0.12); color: #b91c1c; border: 1px solid rgba(185, 28, 28, 0.35); }
[data-theme="light"] .role-leader { background: rgba(245, 158, 11, 0.12); color: #b45309; border: 1px solid rgba(180, 83, 9, 0.35); }
[data-theme="light"] .role-worker { background: rgba(16, 185, 129, 0.12); color: #047857; border: 1px solid rgba(4, 120, 87, 0.35); }

/* --- MAIN CONTAINER & NAV TABS --- */
main {
  flex: 1;
  padding: 20px 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  user-select: none;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--border-focus);
  border-bottom-color: var(--border-focus);
}

[data-theme="light"] .brand-title {
  color: #0f172a;
}

[data-theme="light"] .tab-btn {
  color: #334155;
}

[data-theme="light"] .tab-btn:hover {
  color: #0f172a;
}

[data-theme="light"] .tab-btn.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}

.journal-subtab-btn {
  padding: 8px 16px;
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.journal-subtab-btn.active {
  background: var(--accent-blue) !important;
  color: #fff !important;
  border-color: var(--accent-blue) !important;
}

.item-link {
  color: #60a5fa;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.item-link:hover {
  color: #93c5fd;
}

[data-theme="light"] .item-link {
  color: #1d4ed8;
}

[data-theme="light"] .item-link:hover {
  color: #1e40af;
}

/* --- FILTER BAR & ACTIONS --- */
.toolbar {
  display: flex;
  flex-wrap: nowrap;
  gap: 24px;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 20px;
  background: var(--bg-card);
  padding: 18px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.filter-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 8px 12px;
  max-width: 52%;
  width: 52%;
  flex: 1;
}

.search-input {
  grid-column: span 2;
  width: 100%;
}

.select-filter {
  width: 100%;
  min-width: unset;
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 360px;
  max-width: 44%;
  flex-shrink: 0;
  margin: 0 auto;
}

.action-buttons .btn {
  padding: 12px 18px;
  font-size: 0.94rem;
  font-weight: 600;
  min-height: 44px;
  justify-content: center;
  white-space: nowrap;
}

/* Hide QR scanner button in Desktop Web interface */
#btn-qr-scan {
  display: none !important;
}

/* Tablet view (769px to 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
  #btn-qr-scan {
    display: inline-flex !important;
  }
  .toolbar {
    flex-wrap: wrap;
    gap: 16px;
  }
  .filter-group {
    max-width: 100%;
    width: 100%;
  }
  .action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    max-width: 100%;
  }
  .action-buttons .btn {
    padding: 10px 14px;
    font-size: 0.88rem;
    min-height: 38px;
  }
}

/* --- TABLE & MOBILE CARDS --- */
.table-responsive {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: auto !important;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-x pan-y !important;
  overscroll-behavior-x: contain !important;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: block !important;
  position: relative !important;
}

body.modal-open {
  overflow: hidden !important;
}

.data-table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th {
  background: #1e293b;
  color: #f8fafc;
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 26px !important;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.data-table th.sortable:hover {
  background: #334155;
  color: #38bdf8;
}

.data-table th.sortable::after {
  content: ' ⇅';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  opacity: 0.35;
  transition: opacity 0.15s;
}

.data-table th.sortable:hover::after {
  opacity: 0.8;
}

.data-table th.sortable.sort-asc {
  color: #38bdf8;
}

.data-table th.sortable.sort-asc::after {
  content: ' ▲';
  opacity: 1;
  color: #38bdf8;
}

.data-table th.sortable.sort-desc {
  color: #38bdf8;
}

.data-table th.sortable.sort-desc::after {
  content: ' ▼';
  opacity: 1;
  color: #38bdf8;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.15s;
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

/* --- AUDIT TABLE & DETAILS STYLING --- */
.audit-table {
  width: 100%;
}

.audit-details-cell {
  max-width: 480px;
  min-width: 260px;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

.audit-details-content {
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  color: var(--text-main);
  background: var(--bg-card-hover);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  max-height: 120px;
  overflow-y: auto;
}

/* Mobile cards grid */
.cards-grid {
  display: none;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  word-break: break-word;
}

.item-card:hover {
  border-color: var(--border-focus);
}

.item-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.item-card-header > div {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  max-width: 100%;
}

.item-code {
  font-family: monospace;
  font-weight: 700;
  color: #60a5fa;
  font-size: 1rem;
}

.item-title {
  font-weight: 600;
  font-size: 0.95rem;
}

/* --- BADGES --- */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.item-card .badge {
  white-space: normal !important;
  word-break: break-word !important;
  line-height: 1.25;
  text-align: right;
  max-width: 100%;
}

.status-SPRAVNYI { background: var(--badge-spravnyi-bg); color: var(--badge-spravnyi-text); }
.status-NOVYI { background: var(--badge-novyi-bg); color: var(--badge-novyi-text); }
.status-V_REMONTI { background: var(--badge-remont-bg); color: var(--badge-remont-text); }
.status-DOUKOMPLEKT { background: var(--badge-doukomplekt-bg); color: var(--badge-doukomplekt-text); }
.status-DONOR { background: var(--badge-donor-bg); color: var(--badge-donor-text); }
.status-SPYSANYI { background: var(--badge-spysanyi-bg); color: var(--badge-spysanyi-text); }

.class-g {
  font-family: monospace;
  font-weight: 700;
  padding: 2px 6px;
  background: #334155;
  border-radius: 4px;
  color: #e2e8f0;
}

/* --- MODALS --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom)) 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* --- HISTORY TABLE --- */
.history-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.history-item {
  background: var(--bg-secondary);
  border-left: 3px solid var(--border-focus);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

/* Responsive adjustments for Mobile & Tablets */
@media (max-width: 768px) {
  /* Prevent iOS Safari auto-zoom on input focus */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Prevent WebKit GPU compositor crashes when mobile keyboard appears */
  .login-container {
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    align-items: flex-start;
    justify-content: center;
    padding-top: max(36px, env(safe-area-inset-top, 24px));
    padding-bottom: 24px;
  }

  .login-card {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(20, 29, 47, 0.98) !important;
    box-shadow: none !important;
    transition: none !important;
  }

  .login-card .form-control {
    font-size: 16px !important;
    box-shadow: none !important;
    transition: none !important;
    -webkit-appearance: none;
    border-radius: var(--radius-sm);
  }

  [data-theme="light"] .login-card {
    background: #ffffff !important;
  }

  header {
    padding: 8px 12px;
    flex-wrap: nowrap;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  main {
    padding: 12px 10px 75px 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  .header-left {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .brand {
    gap: 6px;
  }
  .brand-title {
    font-size: 1.05rem;
    white-space: nowrap;
  }
  .brand-tag {
    display: none; /* Hide in mobile header to prevent blowout; visible in side drawer */
  }
  .user-profile {
    gap: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
  }
  #btn-header-ai-chat {
    display: none; /* Hide duplicate in mobile header; available via FAB & side drawer */
  }
  .user-info {
    display: none; /* Hide on mobile header; role and name displayed in side drawer */
  }
  .user-name {
    display: none; /* Hide long user name text on narrow screens */
  }
  .user-role-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
  }
  #btn-logout {
    padding: 4px 8px !important;
    font-size: 0.78rem !important;
    flex-shrink: 0;
  }
  .btn-theme-toggle {
    padding: 4px 8px;
    font-size: 0.95rem;
    flex-shrink: 0;
  }

  .btn-mobile-menu {
    display: inline-flex;
    flex-shrink: 0;
  }

  /* Hide top horizontal tabs on mobile/tablets in favor of Side Drawer */
  .nav-tabs {
    display: none !important;
  }

  /* Tables vs Mobile Cards: Only hide raw table in inventory where mobile cards exist */
  #tab-inventory .table-responsive {
    display: none;
  }
  #tab-inventory .cards-grid {
    display: grid;
    gap: 10px;
  }

  /* Toolbar & Filter Bar on Mobile */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 14px;
  }
  .search-box {
    width: 100%;
    min-width: unset;
  }
  .filter-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    gap: 8px;
  }
  .filter-group .search-input {
    grid-column: span 2;
    width: 100%;
  }
  .filter-group .form-control {
    width: 100%;
    min-width: unset;
  }
  #btn-qr-scan {
    display: inline-flex !important;
  }
  .action-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    max-width: 100%;
    margin: 4px 0 0 0;
    box-sizing: border-box;
    min-width: unset;
  }
  .action-buttons .btn {
    width: 100%;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 11px 12px;
    min-height: 44px;
    white-space: normal;
    line-height: 1.25;
    gap: 6px;
    border-radius: var(--radius-sm);
  }
  .action-buttons #btn-qr-scan {
    grid-column: span 2;
    min-height: 44px;
  }

  /* Journals Subnavigation & Toolbars Mobile Layout */
  .journals-subnav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
    margin-bottom: 16px;
    padding-bottom: 12px;
    box-sizing: border-box;
  }

  .journal-subtab-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px 8px;
    font-size: 0.82rem;
    font-weight: 600;
    min-height: 42px;
    white-space: normal;
    line-height: 1.25;
    border-radius: var(--radius-sm);
    box-sizing: border-box;
  }

  .audit-toolbar-actions {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
  }

  .audit-toolbar-actions .btn {
    flex: 1 1 0;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    min-height: 42px;
    white-space: normal;
    line-height: 1.25;
    border-radius: var(--radius-sm);
    box-sizing: border-box;
  }

  .journal-orders-toolbar-actions {
    display: flex;
    gap: 8px;
    width: 100%;
    align-items: center;
    box-sizing: border-box;
  }

  .journal-orders-toolbar-actions input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
  }

  .journal-orders-toolbar-actions button {
    flex-shrink: 0;
    min-height: 38px;
    padding: 6px 14px;
  }

  /* 1-column vertical stack for KPI cards on mobile */
  .stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-bottom: 16px;
  }
  .stat-card {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px !important;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 95px;
    height: auto;
  }
  .stats-grid > .stat-card:nth-child(-n+4) {
    height: auto;
    min-height: 95px;
    max-height: unset;
  }
  .stat-card-header {
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.25;
    height: auto;
    min-height: unset;
    max-height: unset;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-transform: uppercase;
    color: var(--text-muted);
  }
  .stat-card-header span {
    font-size: 1.15rem;
    line-height: 1;
    flex-shrink: 0;
  }
  .stat-card-val {
    font-size: 1.45rem !important;
    font-weight: 800;
    line-height: 1.15;
    margin: 4px 0 2px 0;
  }
  .stat-card-sub {
    font-size: 0.78rem;
    line-height: 1.25;
    height: auto;
    min-height: unset;
    max-height: unset;
    display: block;
    color: var(--text-dim);
    white-space: normal;
    text-overflow: unset;
  }
  .stat-card:last-child:nth-child(odd) {
    grid-column: auto;
    height: auto;
    min-height: 105px;
    max-height: unset;
    padding: 14px 16px;
  }
  .stat-card:last-child:nth-child(odd) .stat-card-header,
  .stat-card:last-child:nth-child(odd) .stat-card-sub {
    height: auto;
    min-height: unset;
    max-height: unset;
  }

  /* Dashboard panels on mobile */
  .dashboard-sections-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-bottom: 16px;
  }
  .dashboard-panel {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    padding: 14px 10px;
    overflow-x: hidden;
  }
  .dashboard-panel h3 {
    font-size: 0.95rem;
    word-break: break-word;
  }
  .dashboard-panel .table-responsive {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .readiness-bar-row {
    font-size: 0.85rem;
  }

  /* BOM Grid on Mobile */
  .bom-templates-grid {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    gap: 12px;
  }

  /* Modals on mobile */
  .modal-overlay {
    padding: max(12px, env(safe-area-inset-top)) 8px max(16px, env(safe-area-inset-bottom)) 8px !important;
    align-items: flex-start !important;
  }
  .modal-content {
    width: 96vw !important;
    max-width: 96vw !important;
    max-height: calc(100dvh - max(28px, env(safe-area-inset-top) + 20px)) !important;
    margin: max(10px, env(safe-area-inset-top)) auto 16px auto !important;
    border-radius: var(--radius-md);
  }
  .modal-header {
    padding: 12px 14px;
  }
  .modal-header h2 {
    font-size: 1.05rem;
  }
  .modal-body {
    padding: 14px 12px;
    max-height: calc(100dvh - max(130px, env(safe-area-inset-top) + 110px)) !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-footer {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-footer .btn {
    flex: 1;
    min-width: 100px;
    min-height: 42px;
  }

  /* Order Detail Modal Mobile Footer */
  .order-detail-modal-footer {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 12px 14px !important;
    box-sizing: border-box !important;
  }

  .order-detail-quick-actions {
    display: flex !important;
    width: 100% !important;
    gap: 8px !important;
    box-sizing: border-box !important;
  }

  .order-detail-quick-actions .btn {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    width: 100% !important;
    height: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;
    padding: 8px 10px !important;
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    border-radius: var(--radius-sm) !important;
    box-sizing: border-box !important;
  }

  .order-detail-main-actions {
    display: flex !important;
    width: 100% !important;
    gap: 8px !important;
    align-items: center !important;
    box-sizing: border-box !important;
  }

  .order-detail-main-actions .btn {
    min-width: 0 !important;
    height: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;
    padding: 8px 10px !important;
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    border-radius: var(--radius-sm) !important;
    box-sizing: border-box !important;
  }

  .order-detail-main-actions .btn-order-detail-delete {
    flex: 0 0 42px !important;
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    padding: 0 !important;
    font-size: 1.15rem !important;
    justify-content: center !important;
  }

  .order-detail-main-actions .btn-order-detail-delete .btn-del-text {
    display: none !important;
  }

  .order-detail-main-actions .btn-modal-close,
  .order-detail-main-actions .btn-order-detail-save {
    flex: 1 1 0 !important;
    width: 100% !important;
  }

  .order-detail-main-actions .btn-order-detail-save .btn-save-extra {
    display: none !important;
  }

  /* Dashboard Category stock control on mobile (Issue 1) */
  .category-bars-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .category-bar-row {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 6px 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .category-bar-label {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    font-size: 0.8rem !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  .category-bar-track {
    flex: 0 0 50px !important;
    min-width: 40px !important;
    max-width: 60px !important;
    height: 8px !important;
  }
  .category-bar-count {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 62px !important;
    text-align: right !important;
    font-size: 0.8rem !important;
    white-space: nowrap !important;
  }

  /* Table horizontal scrolling min-widths for iOS WebKit (Issues 1, 10, 11, 12, 13) */
  .table-responsive {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x pan-y !important;
    overscroll-behavior-x: contain !important;
  }
  .table-responsive > table,
  .table-responsive > .data-table {
    min-width: 820px !important;
    width: 100% !important;
  }
  .orders-table {
    min-width: 880px !important;
  }
  .audit-table {
    min-width: 950px !important;
  }
  #journal-view-orders .data-table,
  #journal-orders-view .data-table {
    min-width: 880px !important;
  }
  #journal-view-repairs .data-table,
  #journal-repairs-view .data-table {
    min-width: 840px !important;
  }
  #journal-view-write-offs .data-table,
  #journal-write-offs-view .data-table {
    min-width: 780px !important;
  }
  #journal-view-purchases .data-table,
  #journal-purchases-view .data-table {
    min-width: 780px !important;
  }
  #journal-view-assemblies .data-table,
  #journal-assemblies-view .data-table,
  #assembly-history-tbody-wrap .data-table,
  #tab-assembly .data-table {
    min-width: 820px !important;
  }
  #users-view .data-table,
  #tab-users .data-table {
    min-width: 680px !important;
  }
  #audit-view .data-table,
  #tab-audit .data-table {
    min-width: 950px !important;
  }
  #finances-view .data-table,
  #tab-finances .data-table {
    min-width: 780px !important;
  }

  /* Inventory cards containment on mobile (Issue 3) */
  #tab-inventory .cards-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 2px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
  }
  .item-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 12px 14px !important;
  }

  /* BOM Card Header & Template Edit (Issue 9) */
  .bom-card-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
  }
  .bom-item-input-row,
  .edit-bom-item-input-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    background: var(--bg-secondary) !important;
    padding: 10px !important;
    border-radius: var(--radius-sm) !important;
    margin-bottom: 8px !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }

  /* Responsive toolbars for Audit & Finance on Mobile (Issues 11, 12) */
  .audit-toolbar-actions,
  .finance-period-toolbar {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .audit-toolbar-actions > div,
  .finance-period-toolbar > div {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 4px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .audit-toolbar-actions > div:nth-child(3),
  .finance-period-toolbar > div:nth-child(3) {
    grid-column: span 2 !important;
  }
  .audit-toolbar-actions input,
  .audit-toolbar-actions select,
  .finance-period-toolbar input,
  .finance-period-toolbar select {
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .audit-toolbar-actions .btn,
  .finance-period-toolbar .btn {
    min-height: 42px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 8px 10px !important;
    font-size: 0.82rem !important;
  }
  #btn-export-audit-excel,
  #btn-create-backup {
    grid-column: span 2 !important;
  }

  /* Global typography reduction (~15-20%) on mobile */
  .view-header h2 {
    font-size: 1.15rem !important;
  }
  .view-header h3 {
    font-size: 1.0rem !important;
  }
  .dashboard-panel h3 {
    font-size: 0.92rem !important;
  }
}

@media (min-width: 601px) and (max-width: 768px) {
  .journals-subnav {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 420px) {
  .brand-title {
    font-size: 0.95rem;
  }
  .brand-tag {
    display: none;
  }
}

/* QR Code Identification & Scanner Styles */
#detail-qr-code img, #detail-qr-code canvas {
  margin: 0 auto;
  max-width: 120px;
  max-height: 120px;
}

#qr-reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

/* --- THEME TOGGLE BUTTON --- */
.btn-theme-toggle {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 1.1rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-theme-toggle:hover {
  border-color: var(--border-focus);
  transform: scale(1.05);
}

/* --- EXECUTIVE DASHBOARD STYLES --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow);
  transition: transform 0.2s, border-color 0.2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-focus);
}

.stat-card.interactive {
  cursor: pointer;
  user-select: none;
}
.stat-card.interactive:hover {
  transform: translateY(-3px);
  border-color: var(--border-focus);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.22);
}
.stat-card.interactive:active {
  transform: scale(0.98);
}

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
}

.stat-card-val {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 10px 0 4px 0;
}

.stat-card-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.dashboard-sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.dashboard-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow);
}

.dashboard-panel h3 {
  font-size: 1.05rem;
  margin-bottom: 16px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.readiness-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.readiness-bar-label {
  width: 60px;
  font-weight: 700;
  font-size: 0.85rem;
}

.readiness-bar-track {
  flex: 1;
  height: 12px;
  background: var(--bg-secondary);
  border-radius: 6px;
  overflow: hidden;
}

.readiness-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s ease;
}

.fill-g0 { background: #10b981; }
.fill-g1 { background: #3b82f6; }
.fill-g2 { background: #f59e0b; }
.fill-g3 { background: #ef4444; }

.readiness-bar-count {
  width: 45px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

/* --- CATEGORY STOCK CONTROL BARS --- */
.category-bars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 10px 24px;
}

.category-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease;
}

.category-bar-row:hover {
  background: var(--bg-secondary);
}

.category-bar-label {
  width: 190px;
  min-width: 160px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-bar-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--border-color);
  color: var(--text-dim);
}

.category-bar-track {
  flex: 1;
  height: 10px;
  background: var(--bg-secondary);
  border-radius: 5px;
  overflow: hidden;
  min-width: 60px;
}

.category-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s ease;
}

.category-bar-count {
  width: 65px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}


/* --- BADGES --- */
.badge-overdue {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid #ef4444;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.75rem;
  animation: pulseWarning 2s infinite;
}

.badge-lowstock {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid #f59e0b;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.75rem;
}

@keyframes pulseWarning {
  0% { opacity: 1; }
  50% { opacity: 0.6; }
  100% { opacity: 1; }
}

/* --- ORDERS STYLES --- */
.badge-priority-critical {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid #ef4444;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.75rem;
}

.badge-priority-urgent {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid #f59e0b;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.75rem;
}

.badge-priority-normal {
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
  border: 1px solid #3b82f6;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.75rem;
}

.badge-order-status {
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-order-status.status-new {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid #6366f1;
}

.badge-order-status.status-in-progress {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid #f59e0b;
}

.badge-order-status.status-done {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid #10b981;
}

.badge-order-status.status-issued {
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border: 1px solid #0ea5e9;
}

.badge-order-status.status-cancelled {
  background: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
  border: 1px solid #64748b;
}

/* Payment Status Badges & Toggle */
.payment-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  width: 100%;
  justify-content: center;
}
.payment-toggle-btn.not-paid {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}
.payment-toggle-btn.not-paid:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: #ef4444;
}
.payment-toggle-btn.paid {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.5);
}
.payment-toggle-btn.paid:hover {
  background: rgba(16, 185, 129, 0.25);
  border-color: #10b981;
}

.badge-payment {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.badge-payment:hover {
  opacity: 0.85;
}
.badge-payment.paid {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-payment.unpaid {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-unpaid-counter {
  background: #f59e0b;
  color: #0f172a;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}


.order-item-tag {
  display: inline-block;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  margin-right: 4px;
  margin-bottom: 3px;
  color: var(--text-main);
}

.order-link {
  cursor: pointer;
  color: var(--border-focus);
  font-weight: 700;
  text-decoration: underline dotted;
  transition: all 0.15s ease;
}
.order-link:hover {
  color: #60a5fa;
  text-decoration: underline;
}

.order-table-row {
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.order-table-row:hover {
  background-color: rgba(59, 130, 246, 0.08);
}

/* --- ORDERS TOOLBAR & ACTION BUTTONS --- */
.orders-toolbar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}

.orders-search-input {
  flex: 1 1 240px;
  max-width: 320px;
  min-width: 180px;
}

.orders-filter-select {
  flex: 0 1 170px;
  min-width: 140px;
}

.btn-create-order {
  margin-left: 0;
  white-space: nowrap;
  padding: 8px 16px;
  font-weight: 600;
}

.order-actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-wrap: nowrap;
}

.btn-order-action {
  height: 32px;
  font-size: 0.82rem;
  padding: 4px 12px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.btn-order-cancel-icon {
  height: 32px;
  width: 32px;
  min-width: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-order-cancel-icon:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

@media (max-width: 900px) {
  .orders-search-input {
    max-width: 100%;
    flex: 1 1 100%;
  }
  .btn-create-order {
    margin-left: 0;
    width: 100%;
  }
}

/* --- ORDER DETAIL MODAL FOOTER --- */
.order-detail-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.order-detail-quick-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.order-detail-main-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
}

.btn-order-detail-delete {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-order-detail-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* --- JOURNALS NAVIGATION & TOOLBARS --- */
.journals-subnav {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
  flex-wrap: wrap;
}

.journal-subtab-btn {
  white-space: nowrap;
}

.audit-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.journal-orders-toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.journal-orders-toolbar-actions input {
  width: 240px;
}

/* --- BOM ASSEMBLY STYLES --- */
.bom-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  margin-top: 15px;
}

.bom-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.bom-card h4 {
  font-size: 1.15rem;
  color: var(--text-main);
  margin-bottom: 6px;
}

.bom-spec-list {
  list-style: none;
  margin: 14px 0;
  font-size: 0.85rem;
}

.bom-spec-list li {
  padding: 5px 0;
  border-bottom: 1px dashed var(--border-color);
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
}

.bom-spec-list li strong {
  color: var(--text-main);
}

/* Print CSS */
@media print {
  body * {
    visibility: hidden;
  }
  .printable-act, .printable-act * {
    visibility: visible;
  }
  .printable-act {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
}

/* ==========================================================================
   AI ASSISTANT (JARVIS STUB) STYLES
   ========================================================================== */

.ai-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 990;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  padding: 12px 18px;
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.ai-chat-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.55);
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

.ai-fab-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.ai-fab-text {
  letter-spacing: 0.2px;
}

.ai-chat-modal-content {
  max-width: 580px;
  height: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.ai-modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-stub {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 600;
}

.ai-chat-modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  gap: 12px;
  overflow: hidden;
}

.ai-chat-status-banner {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ai-status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
  flex-shrink: 0;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.ai-chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 4px;
  word-break: break-word;
}

.ai-bubble-sender {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-bubble-time {
  font-size: 0.7rem;
  align-self: flex-end;
  opacity: 0.7;
}

.ai-bubble-assistant {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-bottom-left-radius: 2px;
}

.ai-bubble-assistant .ai-bubble-sender {
  color: #3b82f6;
}

.ai-bubble-user {
  align-self: flex-end;
  background: var(--accent-blue);
  color: #ffffff;
  border-bottom-right-radius: 2px;
}

.ai-bubble-user .ai-bubble-sender {
  color: rgba(255, 255, 255, 0.85);
}

.ai-bubble-stub-alert {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: var(--text-main);
}

.ai-bubble-stub-alert .ai-bubble-sender {
  color: #ef4444;
}

.ai-chat-input-form {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-shrink: 0;
}

.ai-chat-input-form input {
  flex: 1;
}

.btn-ai-send {
  flex-shrink: 0;
  padding: 8px 16px;
}

@media (max-width: 600px) {
  .ai-chat-fab {
    bottom: 16px;
    right: 16px;
    padding: 10px 14px;
    font-size: 0.8rem;
  }

  .ai-chat-modal-content {
    height: 90vh;
  }
}

/* --- PASSWORD INPUT WITH EYE TOGGLE --- */
.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-input-wrap input {
  padding-right: 40px !important;
  width: 100%;
}

.btn-toggle-password {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
  line-height: 1;
}

.btn-toggle-password:hover {
  color: var(--text-main);
  background-color: var(--bg-hover);
}

.btn-toggle-password svg {
  display: block;
}

/* ==========================================================================
   FINANCES, PURCHASES & ORDERS EXTENSION STYLES
   ========================================================================== */

/* Clickable Table Rows */
tr.clickable-row {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

tr.clickable-row:hover {
  background-color: var(--bg-card-hover) !important;
}

/* Supplier Clickable Links */
.supplier-link {
  color: var(--border-focus);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
  display: inline-inline-block;
  transition: color 0.15s ease;
}

.supplier-link:hover {
  color: #60a5fa;
}

/* Order Preorder Badge */
.category-badge[data-type="Передзамовлення"] {
  background: rgba(139, 92, 246, 0.2);
  color: #a78bfa;
  border-color: rgba(139, 92, 246, 0.4);
}

/* Finance Order Block in Order Modals */
.finance-order-block {
  background: var(--bg-secondary);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-top: 10px;
}

.finance-order-grid-top {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.2fr;
  gap: 12px;
  align-items: center;
}

.finance-order-grid-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

/* 3-column form rows with bottom input alignment */
.form-row-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  align-items: end;
  width: 100%;
  box-sizing: border-box;
}

.form-row-3col .form-group {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin-bottom: 0;
  width: 100%;
}

.form-row-3col .form-group label {
  min-height: 2.4em;
  display: flex;
  align-items: flex-end;
  margin-bottom: 6px;
  line-height: 1.2;
}

@media (max-width: 540px) {
  .form-row-3col {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .form-row-3col .form-group:last-child {
    grid-column: span 2;
  }
}

/* Finance Tab Analytics Grid */
.finance-analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .finance-analytics-grid {
    grid-template-columns: 1fr;
  }
}

.finance-chart-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  min-height: 280px;
}

.finance-donut-chart-svg-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.finance-donut-center-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.finance-donut-center-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.finance-donut-center-val {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 2px;
}

.finance-legend {
  flex: 1;
  min-width: 200px;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.finance-legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 0.85rem;
  transition: background-color 0.15s ease;
}

.finance-legend-item:hover {
  background: var(--bg-card-hover);
}

.finance-legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-legend-bullet {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.finance-legend-val {
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}

/* --- CLICKABLE KPI CARDS & FINANCE PERIOD BAR --- */
.clickable-kpi-card {
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.clickable-kpi-card:hover {
  transform: translateY(-3px);
  border-color: var(--color-primary, #3b82f6);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.2);
}

.clickable-kpi-card:active {
  transform: scale(0.98);
}

.finance-period-toolbar input[type="date"] {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

/* --- ORDERS COMPACT FINANCIAL CELL --- */
.order-finance-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.8rem;
  line-height: 1.25;
  white-space: nowrap;
}

.order-finance-cost {
  color: var(--text-dim, #94a3b8);
  font-size: 0.76rem;
}

.order-finance-cost strong {
  color: var(--text-muted, #cbd5e1);
  font-weight: 500;
}

.order-finance-margin {
  font-weight: 600;
  font-size: 0.8rem;
}

.order-finance-margin.positive {
  color: #10b981;
}

.order-finance-margin.negative {
  color: #ef4444;
}

.order-finance-margin.neutral {
  color: var(--text-dim, #94a3b8);
}

/* --- COMPACT ORDERS TABLE OPTIMIZATIONS --- */
.orders-table {
  font-size: 0.83rem;
  width: 100%;
}

.orders-table th {
  padding: 8px 8px;
  font-size: 0.8rem;
  letter-spacing: 0.2px;
}

.orders-table td {
  padding: 7px 8px;
}

.orders-table .order-actions-cell {
  gap: 4px;
  justify-content: center;
  white-space: nowrap;
}

.orders-table .btn-order-action {
  height: 28px;
  font-size: 0.78rem;
  padding: 2px 8px;
}

.orders-table .btn-order-cancel-icon {
  height: 28px;
  width: 28px;
  min-width: 28px;
  font-size: 0.85rem;
}

.orders-table .order-finance-cell {
  font-size: 0.76rem;
  line-height: 1.2;
}

.orders-table .order-finance-cost {
  font-size: 0.74rem;
}

.orders-table .order-finance-margin {
  font-size: 0.76rem;
}

.orders-table .category-badge {
  font-size: 0.74rem;
  padding: 2px 6px;
  white-space: nowrap;
}

.orders-table .badge-priority-critical,
.orders-table .badge-priority-urgent,
.orders-table .badge-priority-normal,
.orders-table .badge-order-status {
  font-size: 0.72rem;
  padding: 2px 6px;
  white-space: nowrap;
}

.orders-table .order-item-tag {
  font-size: 0.72rem;
  padding: 1px 5px;
  margin-right: 3px;
  margin-bottom: 2px;
}

/* Password Input & Visibility Toggle */
.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-input-wrap .form-control {
  padding-right: 40px;
  width: 100%;
}

.btn-toggle-password {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.btn-toggle-password:hover {
  color: var(--text-main, #f8fafc);
}

.btn-change-password {
  white-space: nowrap;
}

/* ==========================================================================
   INVENTORY SEARCHABLE COMBOBOX COMPONENT
   ========================================================================== */

.inv-combobox-wrapper {
  position: relative;
  width: 100%;
  min-width: 220px;
}

.inv-combobox-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.inv-combobox-input {
  width: 100%;
  padding-right: 28px !important;
  font-size: 0.82rem;
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 6px);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.inv-combobox-input:focus {
  border-color: var(--border-focus);
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.inv-combobox-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 50%;
  display: none;
  transition: color 0.15s ease;
}

.inv-combobox-clear:hover {
  color: #ef4444;
}

.inv-combobox-dropdown {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  width: 100%;
  min-width: 280px;
  max-width: 380px;
  max-height: 250px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.15);
  z-index: 3000;
  padding: 4px 0;
  display: none;
}

.inv-combobox-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  color: var(--text-main);
  transition: background-color 0.12s ease;
}

.inv-combobox-item:last-child {
  border-bottom: none;
}

.inv-combobox-item:hover, .inv-combobox-item.active {
  background-color: rgba(37, 99, 235, 0.12);
}

.inv-combobox-badge {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(37, 99, 235, 0.15);
  color: #3b82f6;
  margin-right: 8px;
  flex-shrink: 0;
}

.inv-combobox-stock-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  margin-left: 8px;
}

.inv-combobox-stock-badge.in-stock {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.inv-combobox-stock-badge.out-of-stock {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.inv-combobox-custom-option {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-blue);
  background: rgba(37, 99, 235, 0.05);
  border-top: 1px dashed var(--border-color);
  display: flex;
  align-items: center;
}

.inv-combobox-custom-option:hover {
  background: rgba(37, 99, 235, 0.12);
}

.inv-combobox-empty {
  padding: 12px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* BOM & Assembly Styling */
.bom-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.bom-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.bom-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.bom-spec-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0 0;
  border-top: 1px solid var(--border-color);
  padding-top: 8px;
  max-height: 160px;
  overflow-y: auto;
}

.bom-spec-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 0.82rem;
  border-bottom: 1px dashed var(--border-color);
}

.receipt-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.15s;
}

.receipt-link-btn:hover {
  background: rgba(59, 130, 246, 0.2);
}


