:root {
  /* === Brand Colors (Villa Surgical official blue) === */
  --brand:          #004AAD;
  --brand-light:    #1a63c4;
  --brand-dark:     #003580;
  --brand-glow:     rgba(0, 74, 173, 0.25);
  --brand-subtle:   rgba(0, 74, 173, 0.1);

  /* === Keep primary as teal for accents/charts === */
  --primary:        #004AAD;
  --primary-dark:   #003580;
  --primary-glow:   rgba(0, 74, 173, 0.2);
  --secondary:      #0ea5e9;
  --accent:         #38bdf8;
  --success:        #10b981;
  --warning:        #f59e0b;
  --danger:         #f43f5e;
  --info:           #0dcaf0;

  --bg-dark:        #080d1a;
  --bg-card:        rgba(12, 20, 40, 0.75);
  --bg-card2:       rgba(20, 32, 58, 0.5);
  --bg-sidebar:     #040a16;
  --bg-input:       rgba(12, 20, 40, 0.8);

  --text-primary:   #f0f4ff;
  --text-secondary: #a8b8d8;
  --text-muted:     #5a6a8a;

  --border:         rgba(100, 130, 190, 0.1);
  --border-hover:   rgba(0, 74, 173, 0.4);

  --sidebar-width:  260px;
  --header-height:  64px;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow:      0 4px 30px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 24px rgba(0, 74, 173, 0.2);

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: #1a2540; border-radius: 4px; border: 2px solid var(--bg-dark); }
::-webkit-scrollbar-thumb:hover { background: #004AAD; }

/* ===== LAYOUT ===== */
.app-layout { display: flex; min-height: 100vh; position: relative; z-index: 1; width: 100%; overflow-x: hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid rgba(0,74,173,0.15);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  overflow: hidden;
  box-shadow: 4px 0 40px rgba(0,0,0,0.5);
}

/* Logo area */
.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-bottom: 1px solid rgba(0,74,173,0.2);
  text-decoration: none;
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(0,74,173,0.18) 0%, rgba(0,74,173,0.04) 100%);
  position: relative;
  overflow: hidden;
  min-height: 80px;
}
.sidebar-logo::after {
  content: '';
  position: absolute;
  bottom: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,74,173,0.6), transparent);
}
.sidebar-logo-img {
  height: 54px;
  width: auto;
  object-fit: contain;
  padding: 10px 20px;
  filter: brightness(0) invert(1);
  transition: transform 0.3s ease;
}
.sidebar-logo:hover .sidebar-logo-img { transform: scale(1.04); }

/* Nav scroll area */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

/* Section labels */
.nav-section-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 18px 10px 6px;
  opacity: 0.6;
}

/* Nav items — pill style */
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
  margin-bottom: 2px;
  border: 1px solid transparent;
}

.nav-item .nav-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-size: 14px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.04);
  transition: var(--transition);
}

.nav-item .nav-label { flex: 1; }

.nav-item:hover {
  color: #fff;
  background: rgba(0,74,173,0.12);
  border-color: rgba(0,74,173,0.2);
}
.nav-item:hover .nav-icon {
  background: rgba(0,74,173,0.25);
  color: #4d9fff;
}

.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(0,74,173,0.35) 0%, rgba(0,53,128,0.25) 100%);
  border-color: rgba(0,74,173,0.4);
  box-shadow: 0 2px 12px rgba(0,74,173,0.2), inset 0 1px 0 rgba(255,255,255,0.06);
}
.nav-item.active .nav-icon {
  background: #004AAD;
  color: #fff;
  box-shadow: 0 0 14px rgba(0,74,173,0.5);
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 0 8px rgba(244,63,94,0.5);
}

/* Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(0,74,173,0.12);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: rgba(0,74,173,0.05);
}

.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #004AAD, #0ea5e9);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0,74,173,0.3);
}

.user-info .user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-info .user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

.sidebar-footer .logout-btn {
  margin-left: auto;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 16px;
  transition: var(--transition);
  padding: 6px;
  border-radius: 6px;
}
.sidebar-footer .logout-btn:hover { color: var(--danger); background: rgba(244,63,94,0.1); }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 2;
  min-width: 0;
}

.top-header {
  height: var(--header-height);
  background: rgba(8, 12, 21, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
  /* No overflow:hidden here — it breaks position:sticky and clips dropdowns */
}

.header-title { font-size: 18px; font-weight: 700; flex: 1; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.header-subtitle { font-size: 12px; color: var(--text-muted); font-weight: 400; margin-left: 8px; }

.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.header-btn {
  width: 36px; height: 36px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  text-decoration: none;
  transition: var(--transition);
  position: relative;
}

.header-btn:hover { background: var(--bg-card); color: var(--primary); border-color: var(--border-hover); box-shadow: 0 0 10px rgba(0,74,173,0.2); }
.header-btn .badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 8px rgba(244, 63, 94, 0.5);
}

.page-body { padding: 24px; flex: 1; overflow-x: hidden; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
  min-width: 0;
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 10px 30px rgba(0,74,173,0.08);
}
.card-lg { padding: 28px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== STAT CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  cursor: default;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
  min-width: 0;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: 0.12;
  transform: translate(20px, -20px);
}

.stat-card.blue::before { background: var(--primary); }
.stat-card.purple::before { background: var(--secondary); }
.stat-card.green::before { background: var(--success); }
.stat-card.orange::before { background: var(--warning); }
.stat-card.red::before { background: var(--danger); }
.stat-card.cyan::before { background: var(--accent); }

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0,74,173,0.1);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.blue { background: rgba(0, 74, 173, 0.15); color: var(--primary); }
.stat-icon.purple { background: rgba(168, 85, 247, 0.15); color: var(--secondary); }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.stat-icon.orange { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.stat-icon.red { background: rgba(244, 63, 94, 0.15); color: var(--danger); }
.stat-icon.cyan { background: rgba(13, 202, 240, 0.15); color: var(--accent); }

.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; margin-bottom: 4px; color: var(--text-primary); }
.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-change { font-size: 11px; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }
.btn-block { width: 100%; justify-content: center; }

.btn-primary { background: linear-gradient(135deg, #004AAD, #1a63c4); color: #fff; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 18px rgba(0,74,173,0.45); filter: brightness(1.1); }

.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #b86dfc; box-shadow: 0 4px 16px rgba(168, 85, 247, 0.2); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; box-shadow: 0 4px 16px rgba(16, 185, 129, 0.2); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #e11d48; box-shadow: 0 4px 16px rgba(244, 63, 94, 0.2); }

.btn-warning { background: var(--warning); color: #1a1a1a; }
.btn-warning:hover { background: #d97706; box-shadow: 0 4px 16px rgba(245, 158, 11, 0.2); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(0,74,173,0.08); box-shadow: 0 0 10px rgba(0,74,173,0.12); }

.btn-ghost { background: var(--bg-card2); color: var(--text-secondary); border: 1px solid transparent; }
.btn-ghost:hover { color: var(--text-primary); background: rgba(30, 41, 59, 0.6); border-color: var(--border); }

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 18px;
  position: relative;
}

.form-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  transition: color 0.2s ease;
}

.form-group:focus-within .form-label {
  color: var(--primary);
}

.form-required { color: var(--danger); margin-left: 2px; }

/* ---- Base input / select / textarea ---- */
.form-control {
  width: 100%;
  background-color: rgba(10, 16, 36, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 400;
  padding: 10px 14px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  line-height: 1.5;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.form-control::placeholder {
  color: var(--text-muted);
  font-size: 13px;
  opacity: 0.6;
}

/* Hover */
.form-control:hover {
  border-color: rgba(148, 163, 184, 0.28);
  background-color: rgba(15, 23, 42, 0.7);
}

/* Focus — blue glow */
.form-control:focus {
  border-color: var(--primary);
  background-color: rgba(0, 10, 30, 0.85);
  box-shadow:
    0 0 0 3px rgba(0, 74, 173, 0.15),
    0 0 14px rgba(0, 74, 173, 0.1),
    inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ---- Select dropdown ---- */
select.form-control {
  cursor: pointer;
  padding-right: 36px;
  /* Custom chevron arrow */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' 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/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

select.form-control:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300f2fe' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

select.form-control option {
  background: #0f172a;
  color: var(--text-primary);
}

/* ---- Textarea ---- */
textarea.form-control {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

/* ---- Validation states ---- */
.form-control.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.1);
}

.form-control.is-valid {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.08);
}

.form-error {
  display: block;
  font-size: 11px;
  color: var(--danger);
  margin-top: 5px;
  padding-left: 2px;
}

.form-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
  padding-left: 2px;
  line-height: 1.4;
}

/* ---- Input with prefix icon ---- */
.input-icon-wrap {
  position: relative;
}

.input-icon-wrap .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
  transition: color 0.2s ease;
  z-index: 1;
}

.input-icon-wrap:focus-within .input-icon {
  color: var(--primary);
}

.input-icon-wrap .form-control {
  padding-left: 36px;
}

/* ---- Input suffix (right icon / button) ---- */
.input-icon-wrap .input-suffix {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  z-index: 1;
}

/* ---- Section divider inside forms ---- */
.form-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--primary);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.5);
}

/* ---- Checkbox / Radio ---- */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* ---- Form row grid ---- */
.form-row {
  display: grid;
  gap: 14px;
  margin-bottom: 0;
}

.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ---- Character counter ---- */
.form-counter {
  float: right;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- Dark-theme datetime / date / time inputs ---- */
input[type="date"].form-control,
input[type="datetime-local"].form-control,
input[type="time"].form-control,
input[type="month"].form-control {
  color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(0.6) sepia(1) saturate(3) hue-rotate(155deg);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* ---- Remove number spinner arrows ---- */
input[type="number"].form-control::-webkit-outer-spin-button,
input[type="number"].form-control::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"].form-control { -moz-appearance: textfield; }

/* ---- Compact inline filter selects (used in filter bars) ---- */
.filter-bar .form-control,
select.form-control[style*="width:110px"],
select.form-control[style*="width:120px"],
select.form-control[style*="width:130px"],
select.form-control[style*="width:140px"],
select.form-control[style*="width:150px"],
select.form-control[style*="width:160px"],
select.form-control[style*="width:180px"] {
  padding-top: 7px;
  padding-bottom: 7px;
  font-size: 12.5px;
}

/* ---- Animated focus underline sweep ---- */
.form-group {
  overflow: visible;
}

.form-control {
  position: relative;
}

/* Glowing left-side accent bar on focus within group */
.form-group:focus-within::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, transparent, var(--primary), transparent);
  border-radius: 2px;
  opacity: 0;
  animation: focusBarIn 0.3s ease forwards;
  pointer-events: none;
}

@keyframes focusBarIn {
  from { opacity: 0; transform: scaleY(0.3); }
  to   { opacity: 0.6; transform: scaleY(1); }
}

/* ---- Disabled state ---- */
.form-control:disabled,
.form-control[readonly] {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(5, 8, 17, 0.4);
}

/* ---- Autofill dark override ---- */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px rgba(0, 16, 32, 0.95) inset !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  caret-color: var(--primary);
  border-color: var(--primary) !important;
}

/* ===== TABLES ===== */
.table-container { overflow-x: auto; border-radius: var(--radius); -webkit-overflow-scrolling: touch; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: var(--bg-card2);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
  color: var(--text-secondary);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { background: rgba(0, 242, 254, 0.03); }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-blue { background: rgba(0, 242, 254, 0.15); color: var(--primary); }
.badge-purple { background: rgba(168, 85, 247, 0.15); color: var(--secondary); }
.badge-green { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-yellow { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-red { background: rgba(244, 63, 94, 0.15); color: var(--danger); }
.badge-gray { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }
.badge-cyan { background: rgba(13, 202, 240, 0.15); color: var(--accent); }

/* Status specific */
.badge-status-new { background: rgba(0, 242, 254, 0.15); color: var(--primary); }
.badge-status-open { background: rgba(168, 85, 247, 0.15); color: var(--secondary); }
.badge-status-pending { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-status-responded { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-status-closed { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }
.badge-status-active { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-status-inactive { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }
.badge-status-prospect { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-status-vip { background: rgba(168, 85, 247, 0.15); color: var(--secondary); }

.badge-priority-urgent { background: rgba(244, 63, 94, 0.15); color: var(--danger); }
.badge-priority-high { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-priority-normal { background: rgba(0, 242, 254, 0.15); color: var(--primary); }
.badge-priority-low { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }

/* Keyframe animations for medical pulse indicators */
@keyframes heartbeat {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.4); }
  70% { transform: scale(1.06); box-shadow: 0 0 0 5px rgba(244, 63, 94, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
}
@keyframes pulse-cyan {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.4); }
  70% { transform: scale(1.06); box-shadow: 0 0 0 5px rgba(0, 242, 254, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0, 242, 254, 0); }
}

.badge-priority-urgent, .badge-status-new, .header-btn .badge {
  animation: heartbeat 2s infinite ease-in-out;
}
.badge-priority-high {
  animation: pulse-cyan 2.5s infinite ease-in-out;
}

/* ===== SEARCH & FILTER BAR ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.search-input-wrap .form-control { padding-left: 34px; }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

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

.modal {
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
  box-shadow: var(--shadow);
}

.modal-lg { max-width: 780px; }
.modal-xl { max-width: 980px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  z-index: 1;
}

.modal-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.modal-close {
  width: 28px; height: 28px;
  background: var(--bg-card2);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--danger); background: rgba(244, 63, 94, 0.1); }

.modal-body { padding: 20px 24px; color: var(--text-secondary); }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: rgba(15, 23, 42, 0.3);
}

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert-success { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.2); color: var(--success); }
.alert-danger { background: rgba(244, 63, 94, 0.1); border-color: rgba(244, 63, 94, 0.2); color: var(--danger); }
.alert-warning { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.2); color: var(--warning); }
.alert-info { background: rgba(0, 242, 254, 0.1); border-color: rgba(0, 242, 254, 0.2); color: var(--primary); }

/* ===== TABS ===== */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== PAGINATION ===== */
.pagination { display: flex; align-items: center; gap: 4px; margin-top: 20px; justify-content: center; }
.page-btn {
  min-width: 34px; height: 34px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  padding: 0 8px;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state-text { font-size: 13px; max-width: 320px; margin: 0 auto 20px; line-height: 1.7; }

/* ===== TIMELINE ===== */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--border); }

.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px; top: 6px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-dark);
  box-shadow: 0 0 0 2px var(--primary);
}

.timeline-item.type-note::before { background: var(--text-muted); box-shadow: 0 0 0 2px var(--text-muted); }
.timeline-item.type-status_change::before { background: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.timeline-item.type-product_quote::before { background: var(--success); box-shadow: 0 0 0 2px var(--success); }

.timeline-content {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.timeline-meta { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ===== CALENDAR / DATE CARD ===== */
.follow-up-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  transition: var(--transition);
}
.follow-up-card:hover { border-color: var(--border-hover); }
.follow-up-card.overdue { border-color: rgba(239, 68, 68, 0.2); background: rgba(239, 68, 68, 0.04); }
.follow-up-card.today { border-color: rgba(245, 158, 11, 0.2); background: rgba(245, 158, 11, 0.04); }

.fu-date {
  width: 48px; height: 48px;
  background: var(--bg-card2);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fu-date .day { font-size: 20px; font-weight: 800; line-height: 1; }
.fu-date .month { font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }

.fu-info { flex: 1; min-width: 0; }
.fu-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fu-meta { font-size: 11px; color: var(--text-muted); }
.fu-actions { flex-shrink: 0; }

/* ===== DROPZONE ===== */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--primary);
  background: rgba(14, 165, 233, 0.04);
}
.dropzone-icon { font-size: 40px; margin-bottom: 12px; }
.dropzone-text { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.dropzone-hint { font-size: 12px; color: var(--text-muted); }

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  min-width: 260px;
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  animation: slideInRight 0.3s ease;
  font-size: 13px;
}
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-danger { border-left: 3px solid var(--danger); }
.toast.toast-warning { border-left: 3px solid var(--warning); }
.toast.toast-info { border-left: 3px solid var(--primary); }
.toast-icon { font-size: 16px; }
.toast-msg { flex: 1; }
.toast-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; padding: 0; }

/* ===== MISC ===== */
.text-primary-color { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

.w-100 { width: 100%; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-sidebar { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .grid-sidebar { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-body { padding: 16px; }
}

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0, 242, 254, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 80%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
}

.login-box {
  position: relative;
  z-index: 1;
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 420px;
  max-width: 95vw;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 64px; height: 64px;
  background: transparent;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 12px;
  box-shadow: none;
}

.login-logo .brand-name { font-size: 22px; font-weight: 800; margin-bottom: 4px; color: var(--text-primary); }
.login-logo .brand-name span { color: var(--primary); }
.login-logo .brand-sub { font-size: 12px; color: var(--text-muted); }

.login-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; color: var(--text-primary); }
.login-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }

/* Flat clean line */
.gradient-line {
  height: 1px;
  background: var(--border);
  margin-bottom: 24px;
}
@keyframes gradientShift { 0% { background-position: 0% 0%; } 100% { background-position: 200% 0%; } }

/* ===== CHARTS ===== */
.chart-container { position: relative; height: 220px; width: 100%; min-width: 0; }
canvas { max-width: 100% !important; }

/* ===== AVATAR COLORS ===== */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.avatar-lg { width: 44px; height: 44px; font-size: 16px; }
.avatar-a { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.avatar-b { background: linear-gradient(135deg, #10b981, #0ea5e9); }
.avatar-c { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.avatar-d { background: linear-gradient(135deg, #6366f1, #8b5cf6); }

/* ===== PRODUCT SEARCH DROPDOWN ===== */
.product-search-wrap { position: relative; }
.product-dropdown {
  position: absolute;
  top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 320px;
  overflow-y: auto;
  z-index: 9999;
  display: none;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  animation: dropdownSlide 0.15s ease;
}
@keyframes dropdownSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.product-dropdown.show { display: block; }
.product-dropdown-item {
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.product-dropdown-item:last-child { border-bottom: none; }
.product-dropdown-item:hover { background: rgba(0, 74, 173, 0.12); }
.product-dropdown-item .prod-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.product-dropdown-item .prod-sku { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.product-dropdown-item .prod-price { font-size: 13px; color: var(--primary); font-weight: 700; white-space: nowrap; }

/* ===== SELECTED PRODUCTS TABLE ===== */
.selected-products { margin-top: 12px; }
.selected-product-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-card2);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.selected-product-row .prod-info { flex: 1; min-width: 0; }
.selected-product-row .prod-qty { width: 70px; }
.selected-product-row .remove-btn { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 14px; padding: 2px 4px; }

/* Custom ad-hoc product item rows in quotes/inquiries */
.custom-item-row {
  background: var(--bg-card) !important;
  border: 1px solid var(--border);
  padding: 8px;
}
.custom-item-row .custom-name-col { flex: 1; min-width: 0; }
.custom-item-row .custom-qty-col { width: 80px; }
.custom-item-row .custom-price-col { width: 120px; }


/* ===== NOTIFICATION DROPDOWN ===== */
.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 320px;
  max-height: 420px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: var(--shadow);
  display: none;
}
.notif-dropdown.show { display: block; }
.notif-header { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 700; color: var(--text-primary); background: rgba(15, 23, 42, 0.4); }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: var(--transition); display: flex; gap: 10px; }
.notif-item:hover { background: rgba(0, 74, 173, 0.08); }
.notif-item:last-child { border-bottom: none; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }
.notif-text { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* =======================================================
   RESPONSIVE — Mobile sidebar overlay
======================================================= */
#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
  z-index: 99;
}
#sidebarOverlay.active { display: block; }

/* Sidebar toggle: hide on desktop, always show on mobile */
@media (min-width: 769px) {
  #sidebarToggle { display: none !important; }
}

/* =======================================================
   RESPONSIVE — Tablet (≤ 1024px)
======================================================= */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr 1fr; }
}

/* =======================================================
   RESPONSIVE — Mobile (≤ 768px)
======================================================= */
@media (max-width: 768px) {
  /* Sidebar: hidden off-screen, slides in on .open */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0,0,0,0.6);
  }

  /* Main content takes full width */
  .main-content { margin-left: 0; }

  /* Smaller page padding */
  .page-body { padding: 16px; }

  /* Header */
  .top-header { padding: 0 16px; }
  .header-title { font-size: 16px; }
  .header-subtitle { display: none; }

  /* Stats grid — 2 columns */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }

  /* Tables — the TABLE itself can scroll inside the container */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Do NOT set width/max-width here — let it be the full card width */
  }
  .data-table {
    min-width: 520px; /* Forces table to be wider than phone but scrolls inside container */
  }

  /* Filter bar: selects go full-width, stack vertically */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar .search-input-wrap {
    min-width: 0;
    width: 100%;
    flex: none;
  }
  .filter-bar select.form-control,
  .filter-bar .form-control {
    width: 100% !important;
  }
  .filter-bar .btn {
    width: 100%;
    justify-content: center;
  }
  .filter-bar div[style*="margin-left:auto"],
  .filter-bar div[style*="margin-left: auto"] {
    margin-left: 0 !important;
    width: 100%;
  }

  /* Form rows always stack */
  .form-row, .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 {
    grid-template-columns: 1fr !important;
  }

  /* Cards */
  .card-lg { padding: 18px; }

  /* Buttons */
  .btn-lg { padding: 10px 18px; font-size: 13px; }

  /* Notification dropdown — full width */
  .notif-dropdown { width: calc(100vw - 32px); right: -40px; }

  /* Product picker grid — 1 col */
  #pickerProductGrid { grid-template-columns: 1fr !important; }

  /* Quote/Inquiry detail info boxes — stack */
  .doc-info-row { flex-direction: column; }
  .info-box { width: 100% !important; }

  /* Grids */
  .grid-2, .grid-3, .grid-sidebar { grid-template-columns: 1fr !important; }
}

/* =======================================================
   RESPONSIVE — Small phones (≤ 480px)
======================================================= */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  .stat-card { padding: 12px; gap: 10px; }
  .stat-value { font-size: 22px; }
  .stat-icon { width: 38px; height: 38px; font-size: 17px; }

  .page-body { padding: 10px; }

  .card { padding: 12px; }
  .card-lg { padding: 12px; }

  /* Full-width buttons in footer bars */
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; justify-content: center; }

  /* Make all form controls bigger tap targets */
  .form-control { padding: 11px 12px; font-size: 14px; }
  .btn { min-height: 42px; }
  .nav-item { padding: 11px 12px; min-height: 44px; }

  /* Wider sidebar on tiny screens */
  :root { --sidebar-width: 82vw; }

  /* Selected products — stack qty & price */
  .selected-product-row { flex-wrap: wrap; gap: 8px; }
  .selected-product-row .prod-qty { width: 80px; }

  /* Custom ad-hoc product rows */
  .custom-item-row { flex-wrap: wrap; gap: 8px; }
  .custom-item-row .custom-name-col { flex: 1 1 100% !important; }
  .custom-item-row .custom-qty-col { width: calc(40% - 4px) !important; }
  .custom-item-row .custom-price-col { flex: 1 !important; }

  /* Status tab buttons — wrap and shrink text */
  .btn-sm { padding: 4px 8px; font-size: 11px; }

  /* Inline status selects in tables — shrink */
  .data-table select.form-control {
    width: 100px !important;
    font-size: 11px;
    padding: 3px 6px;
  }
}

/* =======================================================
   RESPONSIVE — Extra small phones (≤ 360px — e.g. Oppo A18)
======================================================= */
@media (max-width: 360px) {
  .page-body { padding: 8px; }
  .card { padding: 10px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 10px; gap: 8px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 10px; }
  .top-header { padding: 0 10px; }
  .header-title { font-size: 14px; }
  .btn-sm { padding: 3px 7px; font-size: 10px; }
  /* Force all inline fixed widths on selects to be overridden */
  select[style*="width:"] { width: 100% !important; }
}

/* =======================================================
   Touch-friendly tap targets (all touch devices)
======================================================= */
@media (hover: none) {
  .nav-item, .btn, select.form-control {
    min-height: 44px;
  }
  .product-dropdown-item { padding: 14px 16px; }
}
