/* ==========================================================================
   IMPLANT STOCK TRACKER - DESIGN SYSTEM & RESPONSIVE STYLES
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-float: 0 20px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Base / Reset */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 13px;
}

.mobile-only {
  display: none !important;
}
.mobile-dock {
  display: none !important;
}

/* Constrain all SVG icons globally so they never expand out of bounds */
svg {
  max-width: 24px;
  max-height: 24px;
  flex-shrink: 0;
  vertical-align: middle;
}

.hidden {
  display: none !important;
}

/* Layout Container */
.wrap {
  padding: 20px;
  min-height: 100vh;
}

.wrap.wide {
  max-width: 1480px;
  margin: 0 auto;
}

/* ==========================================================================
   NAVIGATION & TOPBAR
   ========================================================================== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  background: var(--bg-card);
  padding: 10px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.brand-section-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  border-radius: var(--radius-md);
  transition: opacity 0.15s ease;
}
.brand-section-link:hover {
  opacity: 0.9;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 19px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.2;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--slate-100);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-600);
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.nav-item:hover {
  color: var(--slate-900);
  background: rgba(255, 255, 255, 0.6);
}

.nav-item.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 1024px) {
  .topbar {
    gap: 12px;
  }
}

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .brand-section-link {
    justify-content: flex-start;
  }
  .topbar-nav {
    overflow-x: auto;
    padding: 3px;
    width: 100%;
    scrollbar-width: none;
  }
  .topbar-actions {
    justify-content: space-between;
    width: 100%;
  }
  .topbar-actions .btn {
    flex: 1;
  }
}

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-300);
  background: #ffffff;
  color: var(--slate-700);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 38px;
  white-space: nowrap;
}

.btn:hover {
  background: var(--slate-100);
  border-color: var(--slate-400);
  color: var(--slate-900);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn.small {
  padding: 5px 10px;
  font-size: 12px;
  min-height: 30px;
  border-radius: var(--radius-sm);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--slate-600);
}

.btn.ghost:hover {
  background: var(--slate-100);
  color: var(--slate-900);
}

.btn.danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.btn.danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.btn.success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}

/* Form inputs & dropdowns */
select.dd,
select.nf,
input.nf,
textarea.nf {
  background: #ffffff;
  border: 1px solid var(--slate-300);
  color: var(--slate-900);
  font-size: 13px;
  border-radius: var(--radius-md);
  padding: 6px 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 34px;
  box-sizing: border-box;
}

select.dd:focus,
select.nf:focus,
input.nf:focus,
textarea.nf:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Inline Editing on Table - STRICTLY HIDDEN UNLESS ACTIVE EDITING */
.ro { display: inline; }
.editfield { display: none !important; }
tr.editing .ro { display: none !important; }
tr.editing .editfield { display: inline-block !important; width: 100%; }
tr.newrow td { background: #fffdf5; }

/* ==========================================================================
   FILTER TOOLBAR
   ========================================================================== */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.left-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}

.scanner-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-wrapper {
  position: relative;
  min-width: 260px;
  flex: 1;
  max-width: 380px;
}

.search-wrapper input {
  width: 100%;
  padding-left: 36px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-400);
  pointer-events: none;
}

.tabs-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.pill-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--slate-300);
  color: var(--slate-600);
  background: var(--bg-card);
  transition: all 0.15s ease;
  cursor: pointer;
}

.pill-tab:hover {
  background: var(--slate-100);
  color: var(--slate-900);
}

.pill-tab.active {
  background: var(--slate-900);
  color: #ffffff;
  border-color: var(--slate-900);
  box-shadow: var(--shadow-sm);
}

.pill-tab .badge-count {
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.2);
}

.pill-tab:not(.active) .badge-count {
  background: var(--slate-200);
  color: var(--slate-700);
}

/* ==========================================================================
   STATUS BADGES
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

select.badge {
  appearance: auto;
  -webkit-appearance: menulist;
  padding-right: 20px;
  font-size: 12px;
  font-weight: 700;
}

.badge-instock {
  background: var(--success-bg) !important;
  color: var(--success) !important;
  border: 1px solid var(--success-border) !important;
}

.badge-allocated {
  background: var(--warning-bg) !important;
  color: var(--warning) !important;
  border: 1px solid var(--warning-border) !important;
}

.badge-placed {
  background: var(--primary-light) !important;
  color: var(--primary) !important;
  border: 1px solid var(--primary-border) !important;
}

.badge-replaced,
.badge-exchanged {
  background: #f5f3ff !important;
  color: #7c3aed !important;
  border: 1px solid #ddd6fe !important;
}

/* ==========================================================================
   DESKTOP TABLE STYLING
   ========================================================================== */
.tablewrap {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 901px) {
  .tablewrap table {
    min-width: 1200px;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }

  .tablewrap thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f8fafc;
    color: var(--slate-700);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
  }

  .tablewrap thead th a {
    color: inherit;
    text-decoration: none;
  }

  .tablewrap thead th a:hover {
    color: var(--primary);
  }

  .tablewrap tbody tr {
    transition: background-color 0.12s ease;
    cursor: pointer;
  }

  .row-gads td {
    background-color: #f6fcf7;
    border-bottom: 1px solid #e6f4ea;
  }
  .row-gads:hover td {
    background-color: #eaf8ec;
  }
  .row-gads td:first-child {
    border-left: 4px solid #10b981;
  }

  .row-other td {
    background-color: #f6faff;
    border-bottom: 1px solid #e8f1fa;
  }
  .row-other:hover td {
    background-color: #eaf3fd;
  }
  .row-other td:first-child {
    border-left: 4px solid #3b82f6;
  }

  .tablewrap tbody td {
    padding: 10px;
    font-size: 13px;
    vertical-align: middle;
  }

  .col-id { width: 140px; font-weight: 700; color: var(--primary); }
  .col-brand { width: 110px; font-weight: 600; color: #475569; }
  .brand-pill { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #f1f5f9; font-size: 11px; font-weight: 600; color: #334155; border: 1px solid #e2e8f0; }
  .col-lot { width: 120px; font-variant-numeric: tabular-nums; }
  .col-status { width: 120px; white-space: nowrap; }
  .col-location { width: 90px; text-align: center; }
  .col-patient { max-width: 160px; }
  .col-tooth { width: 80px; text-align: center; }
  .col-date { width: 100px; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .col-invoice { width: 80px; text-align: center; }
  .col-notes { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .col-staff { width: 130px; font-size: 12px; }
  .col-actions { width: 110px; text-align: right; }

  .mobile-only {
    display: none !important;
  }
  .mobile-dock {
    display: none !important;
  }
}

/* ==========================================================================
   MOBILE RESPONSIVE: CARDS & ERGONOMICS (< 900px)
   ========================================================================== */
@media (max-width: 900px) {
  .wrap {
    padding: 12px;
    padding-bottom: 100px; /* Room for floating bottom dock */
  }

  .topbar {
    padding: 12px 14px;
    margin-bottom: 12px;
  }

  .brand-title {
    font-size: 17px;
  }

  .brand-subtitle {
    display: none;
  }

  .topbar-nav {
    display: flex;
    gap: 6px;
  }

  .topbar-nav .btn {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
  }

  .desktop-nav-item {
    display: none !important;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    gap: 10px;
  }

  .left-filters {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .search-wrapper {
    max-width: 100%;
    min-width: 0;
  }

  .left-filters select,
  .left-filters input[type="text"],
  .left-filters button,
  .left-filters .btn {
    width: 100%;
    min-height: 38px;
  }

  .scanner-toolbar {
    display: none;
  }

  .tablewrap {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
  }

  .tablewrap table,
  .tablewrap tbody,
  .tablewrap thead {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .tablewrap thead {
    display: none;
  }

  .tablewrap tbody {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .stock-row {
    display: block;
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px;
    position: relative;
    overflow: hidden;
  }

  .row-gads {
    border-left: 5px solid #10b981 !important;
  }

  .row-other {
    border-left: 5px solid #3b82f6 !important;
  }

  .stock-row td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border: none;
    border-bottom: 1px dashed #f1f5f9;
    font-size: 13px;
    width: 100% !important;
    color: var(--slate-800);
  }

  .stock-row td:last-child {
    border-bottom: none;
    padding-top: 10px;
  }

  .stock-row td.addcol {
    display: none !important;
  }

  .stock-row td.col-id {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 17px;
    font-weight: 800;
    color: var(--slate-900);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 6px;
  }

  .stock-row td.col-id::before {
    display: none;
  }

  .stock-row td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--slate-500);
    margin-right: 12px;
    flex-shrink: 0;
  }

  .stock-row td.col-actions::before {
    display: none;
  }

  .stock-row td.col-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    width: 100% !important;
  }

  .stock-row td.col-actions select {
    width: 100%;
    min-height: 38px;
  }

  .mobile-dock {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 28px);
    max-width: 420px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 32px;
    padding: 6px 12px;
    box-shadow: var(--shadow-float);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-dock .dock-btn {
    background: transparent !important;
    border: none !important;
    color: var(--slate-600) !important;
    padding: 6px;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    gap: 2px;
  }

  .mobile-dock .dock-btn svg {
    width: 20px !important;
    height: 20px !important;
  }

  .mobile-dock .mobile-fab {
    background: var(--primary) !important;
    color: #ffffff !important;
    border-radius: var(--radius-full) !important;
    width: 50px;
    height: 50px;
    padding: 0;
    flex: 0 0 50px;
    transform: translateY(-14px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.45) !important;
    border: 3px solid #ffffff !important;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-dock .mobile-fab svg {
    width: 26px !important;
    height: 26px !important;
  }
}

/* ==========================================================================
   DRAWER & BOTTOM SHEET (HIDDEN UNLESS .OPEN)
   ========================================================================== */
.drawer-overlay {
  display: none !important;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
}

.drawer-overlay.open {
  display: block !important;
}

.drawer-container {
  display: none !important;
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 520px;
  height: 100%;
  background: #ffffff;
  z-index: 2001;
  flex-direction: column;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
}

.drawer-container.open {
  display: flex !important;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--slate-50);
}

.drawer-header h2 {
  margin: 4px 0 0 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--slate-900);
}

.drawer-close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--slate-400);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.drawer-close-btn:hover {
  background: var(--slate-200);
  color: var(--slate-900);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.drawer-section {
  margin-bottom: 24px;
  background: var(--bg-card);
}

.drawer-section h3 {
  margin: 0 0 14px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--slate-800);
  border-bottom: 1px solid var(--slate-100);
  padding-bottom: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-grid label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.detail-grid p {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--slate-900);
}

.drawer-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--slate-50);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Mobile Bottom Sheet conversion (< 640px) */
@media (max-width: 640px) {
  .drawer-container {
    top: auto;
    bottom: 0;
    right: 0;
    max-width: 100%;
    max-height: 88vh;
    border-radius: 20px 20px 0 0;
  }

  .detail-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* ==========================================================================
   MODALS (HIDDEN UNLESS .OPEN)
   ========================================================================== */
.modal-container {
  display: none !important;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-container.open {
  display: flex !important;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-float);
  overflow: hidden;
  position: relative;
}

.modal-content form {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 90vh;
  min-height: 0;
  overflow: hidden;
  margin: 0;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--slate-50);
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--slate-900);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--slate-50);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--slate-700);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   DASHBOARD KPI CARDS & WIDGETS
   ========================================================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.kpi-card-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--slate-900);
}

.kpi-card-value a {
  color: inherit;
}

.kpi-card.kpi-instock .kpi-card-value { color: var(--success); }
.kpi-card.kpi-allocated .kpi-card-value { color: var(--warning); }
.kpi-card.kpi-needs-attention .kpi-card-value { color: var(--danger); }
.kpi-card.kpi-stale .kpi-card-value { color: #7c3aed; }

.activity-feed {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.activity-feed h2 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 700;
}

.activity-item {
  border-bottom: 1px solid var(--slate-100);
  padding: 12px 0;
  font-size: 13px;
}

.activity-item:last-child {
  border-bottom: none;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--slate-900);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: #065f46;
  border-left: 4px solid #10b981;
}

.toast-error {
  background: #991b1b;
  border-left: 4px solid #f87171;
}

@media (max-width: 600px) {
  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 84px;
  }
  .toast {
    width: 100%;
  }
}

/* ==========================================================================
   FLOATING BULK ACTIONS TOOLBAR
   ========================================================================== */
.bulk-toolbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2500;
  background: var(--slate-900);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 16px;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 92vw;
}

@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.bulk-toolbar-content {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.bulk-count {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  background: var(--primary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bulk-action-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.bulk-action-group select {
  background: transparent;
  color: #ffffff;
  border: none;
  font-size: 12px;
  padding: 4px 8px;
  outline: none;
  cursor: pointer;
}

.bulk-action-group select option {
  background: var(--slate-800);
  color: #ffffff;
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

/* ==========================================================================
   INTERACTIVE ODONTOGRAM (DENTAL TOOTH CHART)
   ========================================================================== */
.odontogram-wrapper {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 6px;
}

.odontogram-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--slate-600);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--slate-200);
}

.odontogram-selection-text {
  color: var(--primary);
  font-weight: 600;
}

.odontogram-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.odontogram-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.odontogram-quadrant {
  display: flex;
  gap: 3px;
}

.odontogram-midline {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  font-size: 9px;
  font-weight: 700;
  color: var(--slate-400);
  text-align: center;
  border-left: 1px dashed var(--slate-300);
  border-right: 1px dashed var(--slate-300);
  padding: 0 4px;
  user-select: none;
}

.odontogram-midline span {
  display: none;
}

.odontogram-tooth {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 42px;
  background: #ffffff;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 2px;
  transition: all 0.15s ease-in-out;
  box-shadow: var(--shadow-sm);
}

.odontogram-tooth:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
}

.odontogram-tooth.active {
  background: var(--primary) !important;
  color: #ffffff !important;
  border-color: var(--primary-hover) !important;
  box-shadow: 0 0 0 2px var(--primary-border), var(--shadow-md);
  transform: scale(1.05);
  font-weight: 700;
}

.odontogram-tooth .tooth-fdi {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
}

.odontogram-tooth .tooth-palmer {
  font-size: 9px;
  opacity: 0.75;
  line-height: 1;
}

.odontogram-tooth.active .tooth-palmer {
  opacity: 0.95;
  color: #e0f2fe;
}

/* Mobile Odontogram responsiveness */
@media (max-width: 640px) {
  .odontogram-chart {
    gap: 12px;
  }
  .odontogram-row {
    flex-direction: column;
    gap: 6px;
    background: #ffffff;
    padding: 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--slate-200);
  }
  .odontogram-quadrant {
    width: 100%;
    justify-content: space-between;
    gap: 2px;
  }
  .odontogram-midline {
    width: 100%;
    border-left: none;
    border-right: none;
    border-top: 1px dashed var(--slate-300);
    padding: 2px 0;
  }
  .odontogram-tooth {
    min-width: 34px;
    height: 40px;
    flex: 1;
  }
}

/* ==========================================================================
   PHASE 2: VIEW MODE SELECTOR, SURGICAL MATRIX & BATCH RECALL TRACER
   ========================================================================== */

/* View Mode Selector Bar */
.view-mode-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  background: #ffffff;
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  width: fit-content;
}

.view-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--slate-600);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.view-mode-btn:hover {
  background: var(--slate-100);
  color: var(--slate-900);
}

.view-mode-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.view-mode-btn svg {
  stroke-width: 2.2;
}

/* Surgical Matrix Wrapper */
.surgical-matrix-wrapper {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.matrix-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--slate-200);
}

.matrix-filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.matrix-filter-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--slate-700);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.matrix-filter-group select {
  min-width: 170px;
  height: 38px;
  font-size: 13.5px;
}

.matrix-summary-pill {
  margin-left: auto;
  align-self: center;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.matrix-summary-pill strong {
  font-size: 16px;
  font-weight: 800;
  color: #15803d;
}

.matrix-summary-pill.pill-placed {
  background: #f5f3ff;
  border-color: #ddd6fe;
  color: #5b21b6;
}
.matrix-summary-pill.pill-placed strong {
  color: #6d28d9;
}

.matrix-summary-pill.pill-allocated {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}
.matrix-summary-pill.pill-allocated strong {
  color: #b45309;
}

.matrix-summary-pill.pill-all {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}
.matrix-summary-pill.pill-all strong {
  color: #1d4ed8;
}

/* Matrix Mode Switcher Tabs */
.matrix-mode-switcher {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
  width: 100%;
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
}
.matrix-mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.matrix-mode-btn:hover {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.6);
}
.matrix-mode-btn.active {
  background: #ffffff;
  color: var(--primary, #2563eb);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.matrix-mode-btn.active[data-mode="placed"] {
  color: #6d28d9;
}
.matrix-mode-btn.active[data-mode="allocated"] {
  color: #b45309;
}

/* Matrix Heatmap Grid */
.matrix-grid-scroll {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
}

.matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 1px;
  background: var(--slate-200);
  text-align: center;
}

.matrix-table th, .matrix-table td {
  padding: 12px 14px;
  font-size: 13.5px;
}

.matrix-corner {
  background: var(--slate-100);
  color: var(--slate-700);
  font-weight: 700;
  font-size: 12.5px;
  text-align: left;
  min-width: 130px;
  position: sticky;
  left: 0;
  z-index: 2;
}

.matrix-table thead th {
  background: var(--slate-100);
  color: var(--slate-800);
  font-weight: 700;
  min-width: 95px;
}

.matrix-row-header {
  background: var(--slate-50);
  color: var(--slate-800);
  font-weight: 700;
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 1;
  border-right: 2px solid var(--slate-300);
}

.matrix-cell {
  background: #ffffff;
  transition: background 0.15s ease, transform 0.1s ease;
  vertical-align: middle;
}

.matrix-cell:hover {
  background: #f8fafc;
}

.matrix-cell-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.count-high {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.count-high:hover {
  background: #bbf7d0;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.count-low {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.count-low:hover {
  background: #fde68a;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.count-placed {
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #c4b5fd;
}
.count-placed:hover {
  background: #ddd6fe;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.count-allocated {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}
.count-allocated:hover {
  background: #fde68a;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.count-all {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.count-all:hover {
  background: #dbeafe;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.count-zero {
  background: #f8fafc;
  color: var(--slate-400);
  border: 1px dashed var(--slate-200);
  font-weight: 500;
}

/* Drilldown Drawer inside Matrix */
.matrix-drilldown {
  margin-top: 24px;
  padding: 20px;
  background: #f8fafc;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.2s ease;
}

.drilldown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--slate-200);
}

.drilldown-header h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--slate-900);
}

.drilldown-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.drilldown-table th {
  background: var(--slate-100);
  font-size: 12px;
  font-weight: 700;
  color: var(--slate-700);
  text-transform: uppercase;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--slate-200);
}

.drilldown-table td {
  padding: 10px 14px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--slate-100);
  color: var(--slate-800);
}

.drilldown-table tr:hover td {
  background: var(--slate-50);
}

/* Batch Recall Tracer */
.recall-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.recall-kpi-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.recall-kpi-card .kpi-num {
  font-size: 28px;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1.1;
  margin-bottom: 4px;
}

.recall-kpi-card .kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--slate-600);
}

.recall-kpi-card.alert-danger {
  background: #fef2f2;
  border-color: #fca5a5;
}

.recall-kpi-card.alert-danger .kpi-num {
  color: #dc2626;
}

.recall-kpi-card.alert-warning {
  background: #fffbeb;
  border-color: #fcd34d;
}

.recall-kpi-card.alert-warning .kpi-num {
  color: #d97706;
}

.recall-action-banner {
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.recall-action-banner strong {
  color: #9a3412;
}

.recall-section {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 16px;
}

/* Consignment vs Owned Badges */
.badge-consignment {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  font-weight: 600;
}

.badge-owned {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  font-weight: 600;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   MODERN FORM CONTROLS & SETTINGS UI UPGRADE
   ========================================================================== */

/* Modern universal input, select, textarea styling */
.settings-card input[type="text"],
.settings-card input[type="number"],
.settings-card input[type="email"],
.settings-card input[type="password"],
.settings-card input[type="date"],
.settings-card select,
.settings-card textarea,
.modal-content input[type="text"],
.modal-content input[type="number"],
.modal-content input[type="email"],
.modal-content input[type="password"],
.modal-content input[type="date"],
.modal-content select,
.modal-content textarea {
  width: 100%;
  box-sizing: border-box;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 8px;
  padding: 9px 13px;
  height: 40px;
  line-height: 1.5;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.settings-card textarea,
.modal-content textarea {
  height: auto;
  min-height: 110px;
  line-height: 1.6;
}

/* Modern Hover & Focus states */
.settings-card input:hover,
.settings-card select:hover,
.settings-card textarea:hover,
.modal-content input:hover,
.modal-content select:hover,
.modal-content textarea:hover {
  border-color: #94a3b8;
}

.settings-card input:focus,
.settings-card select:focus,
.settings-card textarea:focus,
.modal-content input:focus,
.modal-content select:focus,
.modal-content textarea:focus {
  outline: none;
  border-color: #2563eb;
  background-color: #ffffff;
  box-shadow: 0 0 0 3.5px rgba(37, 99, 235, 0.12), 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Custom Dropdown Arrow */
.settings-card select,
.modal-content select {
  appearance: none;
  -webkit-appearance: none;
  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='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px 16px;
  padding-right: 38px;
  cursor: pointer;
}

/* Form Groups & Field Labels */
.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-group label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 7px;
  letter-spacing: -0.01em;
}

.form-group label .label-hint {
  font-size: 11.5px;
  font-weight: 500;
  color: #64748b;
  text-transform: none;
}

.form-help-text {
  font-size: 12px;
  color: #64748b;
  margin-top: 6px;
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Input with Prefix or Suffix Unit (e.g. Days, mm, Units) */
.input-with-addon {
  display: flex;
  align-items: stretch;
  position: relative;
}

.input-with-addon input {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  flex: 1;
}

.input-addon-suffix {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-left: none;
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  user-select: none;
}

/* Inline Table Edit Controls */
.data-table input[type="text"],
.data-table input[type="email"],
.data-table input[type="number"] {
  height: 36px !important;
  padding: 6px 11px !important;
  font-size: 13px !important;
  border-radius: 7px !important;
  border: 1px solid #cbd5e1 !important;
  background: #ffffff !important;
  transition: all 0.15s ease !important;
}

.data-table input:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
  outline: none !important;
}

/* Modern iOS-Style Toggle Switch */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-slider {
  position: relative;
  width: 40px;
  height: 22px;
  background-color: #cbd5e1;
  border-radius: 20px;
  transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-block;
  vertical-align: middle;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #10b981;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

.toggle-switch input:focus-visible + .toggle-slider {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.toggle-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.toggle-label.active {
  color: #059669;
}

.toggle-label.inactive {
  color: #64748b;
}

/* Password Input Wrapper with Icon Toggle */
.pw-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.pw-input-wrapper input {
  padding-right: 75px !important;
}

.pw-toggle-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 6px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pw-toggle-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Variable Pills for Email Template */
.template-var-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}

.template-var-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 12px;
  font-family: monospace;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.template-var-pill:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  transform: translateY(-1px);
}

/* Modern Card Layout Improvements */
.settings-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
}

.settings-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
}

.settings-card-header h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.settings-section-divider {
  margin: 24px 0 20px 0;
  border: 0;
  border-top: 1px solid #f1f5f9;
}

.settings-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 16px 0;
}

/* Spinner Animation */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(37, 99, 235, 0.2);
  border-top-color: var(--primary, #2563eb);
  border-radius: 50%;
  animation: IST_spin 0.8s linear infinite;
  vertical-align: middle;
}
@keyframes IST_spin {
  to { transform: rotate(360deg); }
}

/* Invoice Picker Select */
.invoice-picker-select {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.invoice-picker-select:focus {
  border-color: var(--primary, #2563eb);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Quick Invoice Preview Lightbox Modal */
#invoice-preview-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
#invoice-preview-modal.open {
  opacity: 1;
  pointer-events: auto;
  display: flex !important;
}
.invoice-preview-content {
  animation: IST_preview_pop 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes IST_preview_pop {
  0% { transform: scale(0.96) translateY(8px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}




