/* ============================================================
   DUKLASTAV CRM — Design System
   Dark premium theme · Gold accents · Mobile-first
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=DM+Mono:wght@400;500&display=swap');

/* ── 1. DESIGN TOKENS ─────────────────────────────────────── */
:root {
  /* Gold palette */
  --gold:          #d4af37;
  --gold-hover:    #b8962e;
  --gold-dim:      #a07c20;
  --gold-glow:     rgba(212, 175, 55, 0.18);
  --gold-subtle:   rgba(212, 175, 55, 0.08);

  /* Surfaces (dark → light) */
  --bg:            #141720;
  --surface-0:     #1b1f2b;
  --surface-1:     #222736;
  --surface-2:     #2b3045;
  --surface-3:     #333a52;

  /* Text */
  --text-1:        #eceef4;
  --text-2:        #9aa0b4;
  --text-3:        #636b82;

  /* Borders */
  --border:        rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);

  /* Status */
  --danger:        #e05c6a;
  --danger-bg:     rgba(224, 92, 106, 0.12);
  --warning:       #f5a623;
  --warning-bg:    rgba(245, 166, 35, 0.12);
  --success:       #3ecf8e;
  --success-bg:    rgba(62, 207, 142, 0.12);
  --info:          #38b2e0;

  /* Radii & shadows */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  20px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.45);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);

  /* Transitions */
  --t-fast:   0.15s ease;
  --t-normal: 0.25s ease;
}

/* ── 2. RESET & BASE ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.65;
  margin: 0;
  min-height: 100vh;
  /* subtle noise-grain overlay for depth */
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(212,175,55,0.06) 0%, transparent 60%);
}

a {
  color: var(--gold);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--gold-hover); }

/* ── 3. SCROLLBAR ─────────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) var(--surface-0);
}
*::-webkit-scrollbar       { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: var(--surface-0); }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }

/* ── 4. TYPOGRAPHY ────────────────────────────────────────── */
h1,h2,h3,h4,h5,h6 {
  color: var(--text-1);
  font-weight: 700;
  line-height: 1.25;
  margin-top: 0;
}

code, .mono {
  font-family: 'DM Mono', 'Fira Code', monospace;
  font-size: 0.875em;
  background: var(--surface-2);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

/* ── 5. NAVBAR ────────────────────────────────────────────── */
.navbar {
  background: var(--surface-0) !important;
  border-bottom: 1px solid var(--border);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 2px 20px rgba(0,0,0,0.4);
  min-height: 58px;
}

.navbar-brand {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--gold) !important;
  letter-spacing: 0.3px;
  padding: 0.9rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.navbar-brand img { height: 26px; width: auto; }

.navbar .nav-link {
  color: var(--text-2) !important;
  font-weight: 500;
  font-size: 0.88rem;
  padding: 0.9rem 0.9rem;
  transition: color var(--t-fast);
  position: relative;
  white-space: nowrap;
}
.navbar .nav-link:hover,
.navbar .nav-link.active {
  color: var(--gold) !important;
}

/* active underline — layout-safe */
.navbar .nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0.9rem;
  right: 0.9rem;
  height: 2px;
  background: var(--gold);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.2s ease;
}
.navbar .nav-link.active::after { transform: scaleX(1); }
.navbar .nav-link:hover::after   { transform: scaleX(0.6); }

/* Search */
.navbar .input-group-text {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-right: none;
  color: var(--text-3);
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}
.navbar .form-control {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-left: none;
  color: var(--text-1);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 0.45rem 0.9rem;
  font-size: 0.875rem;
}
.navbar .form-control::placeholder { color: var(--text-3); }
.navbar .form-control:focus {
  background: var(--surface-2);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
  color: var(--text-1);
  outline: none;
}

/* Hamburger */
.navbar-toggler {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 0.3rem 0.6rem;
  color: var(--text-2);
}
.navbar-toggler:focus { box-shadow: 0 0 0 3px var(--gold-glow); outline: none; }
.navbar-toggler-icon {
  filter: invert(70%) sepia(20%) saturate(300%) hue-rotate(10deg);
}

/* ── 6. BUTTONS ───────────────────────────────────────────── */
.btn {
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 1.2rem;
  transition: all var(--t-normal);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  line-height: 1.4;
  cursor: pointer;
}

.btn-primary {
  background: var(--gold);
  color: #12141a;
}
.btn-primary:hover {
  background: var(--gold-hover);
  color: #12141a;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--gold-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-outline-primary {
  background: transparent;
  color: var(--gold);
  border: 1.5px solid var(--gold);
}
.btn-outline-primary:hover {
  background: var(--gold-subtle);
  color: var(--gold);
  border-color: var(--gold);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-1);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
  background: var(--surface-3);
  color: var(--text-1);
  border-color: var(--border-strong);
}

.btn-success { background: var(--success); color: #0a1a12; }
.btn-success:hover {
  background: #31b87a;
  color: #0a1a12;
  transform: translateY(-1px);
}

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover {
  background: #c94f5b;
  color: #fff;
  transform: translateY(-1px);
}

.btn-warning { background: var(--warning); color: #1a1000; }
.btn-warning:hover { background: #dd9520; color: #1a1000; }

.btn-sm  { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-xs  { padding: 0.2rem 0.5rem; font-size: 0.75rem; }
.btn:disabled, .btn.disabled {
  opacity: 0.45;
  pointer-events: none;
  transform: none !important;
  box-shadow: none !important;
}

/* ── 7. CARDS ─────────────────────────────────────────────── */
.card {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  color: var(--text-1);
  overflow: hidden;
}
.card-header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  font-weight: 600;
}
.card-body  { padding: 1.25rem; }
.card-footer {
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  padding: 0.875rem 1.25rem;
}

/* ── 8. STAT CARDS ────────────────────────────────────────── */
.stat-card {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: transform var(--t-normal), box-shadow var(--t-normal), border-color var(--t-normal);
  cursor: default;
}

/* gold top stripe */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-dim));
  opacity: 0.8;
  transition: opacity var(--t-normal);
}

/* ambient glow behind number */
.stat-card::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 100px; height: 100px;
  background: radial-gradient(circle, var(--gold-subtle) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(212,175,55,0.3);
}
.stat-card:hover::before { opacity: 1; }

.stat-card .stat-value {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--gold);
  line-height: 1.1;
  letter-spacing: -0.5px;
}
.stat-card .display-6 {
  color: var(--gold);
  font-weight: 800;
  font-size: 2.25rem;
  line-height: 1.1;
}
.stat-card .text-muted,
.stat-card .stat-label {
  color: var(--text-2) !important;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 0.35rem;
}

/* ── 9. TABLES ────────────────────────────────────────────── */
.table-responsive {
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.table {
  color: var(--text-1);
  background: var(--surface-1);
  margin-bottom: 0;
  width: 100%;
  border-collapse: collapse;
}

.table thead th {
  background: var(--surface-2);
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0.875rem 1rem;
  white-space: nowrap;
}

.table tbody td {
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1rem;
  vertical-align: middle;
  font-size: 0.9rem;
}

.table tbody tr:last-child td { border-bottom: none; }

.table-hover tbody tr {
  transition: background var(--t-fast);
}
.table-hover tbody tr:hover {
  background: var(--surface-2);
}

.table-warning { background: var(--warning-bg) !important; }
.table-danger  { background: var(--danger-bg)  !important; }
.table-success { background: var(--success-bg) !important; }

/* Table buttons */
.table .btn-sm, .table .btn-xs {
  margin: 2px;
  white-space: nowrap;
}

/* ── 10. BADGES ───────────────────────────────────────────── */
.badge {
  padding: 0.3rem 0.7rem;
  border-radius: 99px;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.badge.bg-danger  { background: var(--danger-bg)  !important; color: var(--danger); }
.badge.bg-warning { background: var(--warning-bg) !important; color: var(--warning); }
.badge.bg-success { background: var(--success-bg) !important; color: var(--success); }
.badge.bg-info    { background: rgba(56,178,224,0.12) !important; color: var(--info); }
.badge.bg-secondary {
  background: var(--surface-2) !important;
  color: var(--text-2);
}
.badge.bg-primary {
  background: var(--gold-subtle) !important;
  color: var(--gold);
}

/* ── 11. FORMS ────────────────────────────────────────────── */
.form-label {
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.82rem;
  margin-bottom: 0.4rem;
  display: block;
  letter-spacing: 0.2px;
}

.form-control,
.form-select {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-1);
  border-radius: var(--r-sm);
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

.form-control::placeholder { color: var(--text-3); }

.form-control:focus,
.form-select:focus {
  outline: none;
  background: var(--surface-1);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
  color: var(--text-1);
}

.form-control:disabled,
.form-select:disabled {
  background: var(--bg);
  color: var(--text-3);
  cursor: not-allowed;
  opacity: 0.7;
}

.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239aa0b4' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 14px;
  padding-right: 2.5rem;
}

.form-check-input {
  background-color: var(--surface-2);
  border: 1.5px solid var(--border-strong);
  cursor: pointer;
}
.form-check-input:checked {
  background-color: var(--gold);
  border-color: var(--gold);
}
.form-check-input:focus {
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.input-group-text {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  font-size: 0.9rem;
}

/* ── 12. ALERTS ───────────────────────────────────────────── */
.alert {
  border-radius: var(--r-md);
  border: 1px solid;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  animation: alertIn 0.3s ease;
  margin-bottom: 1.25rem;
}

@keyframes alertIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.alert.fade-out {
  animation: alertOut 0.5s ease forwards;
}
@keyframes alertOut {
  to { opacity: 0; transform: translateY(-8px); }
}

.alert-success {
  background: var(--success-bg);
  border-color: rgba(62,207,142,0.3);
  color: var(--success);
}
.alert-danger {
  background: var(--danger-bg);
  border-color: rgba(224,92,106,0.3);
  color: #f08090;
}
.alert-warning {
  background: var(--warning-bg);
  border-color: rgba(245,166,35,0.3);
  color: var(--warning);
}
.alert-info {
  background: rgba(56,178,224,0.1);
  border-color: rgba(56,178,224,0.3);
  color: var(--info);
}

.alert .btn-close {
  filter: invert(1) opacity(0.5);
  margin-left: auto;
  flex-shrink: 0;
}

/* ── 13. MODALS ───────────────────────────────────────────── */
.modal-content {
  background: var(--surface-0);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  color: var(--text-1);
  box-shadow: var(--shadow-lg);
}
.modal-header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 1.5rem;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.modal-title { font-weight: 700; font-size: 1.05rem; }
.modal-body  { padding: 1.5rem; }
.modal-footer {
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.modal-backdrop { background: rgba(0,0,0,0.7); }
.btn-close { filter: invert(0.7); }

/* ── 14. PAGINATION ───────────────────────────────────────── */
.pagination { margin-top: 1.25rem; gap: 0.25rem; }

.page-link {
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 0.45rem 0.9rem;
  border-radius: var(--r-sm) !important;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--t-fast);
}
.page-link:hover {
  background: var(--surface-2);
  color: var(--gold);
  border-color: rgba(212,175,55,0.4);
}
.page-item.active .page-link {
  background: var(--gold);
  color: #12141a;
  border-color: var(--gold);
  font-weight: 700;
}
.page-item.disabled .page-link {
  background: var(--surface-0);
  color: var(--text-3);
  opacity: 0.5;
}

/* ── 15. FLOATING ACTION BUTTON ───────────────────────────── */
.fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 54px;
  height: 54px;
  background: var(--gold);
  color: #12141a;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 20px var(--gold-glow), 0 2px 8px rgba(0,0,0,0.5);
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 1020;
  border: none;
  cursor: pointer;
}
.fab:hover {
  background: var(--gold-hover);
  transform: scale(1.12) rotate(90deg);
  box-shadow: 0 8px 28px var(--gold-glow);
}
.fab:active { transform: scale(0.96); }

/* ── 16. SORTABLE TABLE HEADERS ───────────────────────────── */
th.sortable {
  cursor: pointer;
  user-select: none;
  padding-right: 2rem !important;
  position: relative;
}
th.sortable:hover { color: var(--text-1); }

th.sortable::after {
  content: '';
  position: absolute;
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  border: 0.3rem solid transparent;
  border-top-color: var(--text-3);
  opacity: 0.5;
  transition: opacity var(--t-fast);
}
th.sortable:hover::after         { opacity: 1; border-top-color: var(--gold); }
th.sortable.sort-asc::after  {
  border-top-color: transparent;
  border-bottom-color: var(--gold);
  opacity: 1;
  margin-top: -0.15rem;
}
th.sortable.sort-desc::after { border-top-color: var(--gold); opacity: 1; }

/* ── 17. LOGIN PAGE ───────────────────────────────────────── */
body.login-page {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(212,175,55,0.08) 0%, transparent 60%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.login-page .card {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}

/* ── 18. FOOTER ───────────────────────────────────────────── */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.62rem;
  color: var(--text-3);
  background: transparent;
  z-index: 1000;
  pointer-events: none;
}

/* ── 19. SCAN MODAL ───────────────────────────────────────── */
#scanModal .modal-dialog { max-width: 960px; }
#scanModal .modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
}
#scanModal .scan-video {
  width: 100%;
  height: 60vh;
  max-height: 520px;
  border-radius: var(--r-md);
  overflow: hidden;
  background: #000;
}
#scanModal video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--r-md);
  display: block;
}

/* ── 20. UTILITY ──────────────────────────────────────────── */
.text-muted  { color: var(--text-2) !important; }
.text-gold   { color: var(--gold)   !important; }
.bg-surface  { background: var(--surface-1) !important; }
.border-gold { border-color: rgba(212,175,55,0.4) !important; }

.section-title {
  margin: 2rem 0 1rem;
  font-weight: 700;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.bi { vertical-align: -0.125em; }

/* row/col alignment fix */
.row { margin-left: -0.75rem; margin-right: -0.75rem; }
.row > [class*="col-"] { padding-left: 0.75rem; padding-right: 0.75rem; }
.mb-3 { margin-bottom: 1rem !important; }

/* ── 21. MOBILE — NAVBAR ──────────────────────────────────── */
@media (max-width: 991.98px) {
  .navbar-collapse {
    background: var(--surface-0);
    border-top: 1px solid var(--border);
    padding: 0.75rem 0;
    max-height: calc(100dvh - 58px);
    overflow-y: auto;
  }

  .navbar .nav-link {
    padding: 0.6rem 1rem;
    border-radius: var(--r-sm);
    margin: 0.1rem 0.5rem;
  }
  .navbar .nav-link::after { display: none; }
  .navbar .nav-link.active {
    background: var(--gold-subtle);
  }

  .navbar .input-group {
    margin: 0.5rem;
    width: calc(100% - 1rem);
  }
}

/* ── 22. MOBILE — TABLES ──────────────────────────────────── */
@media (max-width: 767.98px) {

  /* Card-style rows */
  .table-responsive {
    border: none;
    background: transparent;
  }
  .table-responsive table,
  .table-responsive thead,
  .table-responsive tbody,
  .table-responsive th,
  .table-responsive td,
  .table-responsive tr {
    display: block;
  }
  .table-responsive thead tr { display: none; }

  .table-responsive tbody tr {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 0.85rem;
    margin-bottom: 0.75rem;
    position: relative;
  }
  .table-responsive tbody tr:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
  }

  .table-responsive tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0.4rem 0;
    border: none;
    font-size: 0.88rem;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
  }
  .table-responsive tbody td:last-child {
    border-bottom: none;
    padding-top: 0.65rem;
    flex-direction: column;
    align-items: stretch;
  }

  /* Label via data-label attribute */
  .table-responsive tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-3);
    min-width: 38%;
    flex-shrink: 0;
    padding-top: 0.1em;
  }
  .table-responsive tbody td:last-child::before { display: none; }

  /* Action buttons full-width */
  .table-responsive td.text-end,
  .table-responsive td:last-child {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-top: 0.65rem;
    justify-content: flex-start;
  }
  .table-responsive td.text-end form.d-inline,
  .table-responsive td:last-child form.d-inline {
    display: contents;
  }
  .table-responsive td.text-end .btn,
  .table-responsive td:last-child .btn {
    flex: 1 1 auto;
    min-width: 90px;
    text-align: center;
    justify-content: center;
  }
}

/* ── 23. MOBILE — GENERAL ─────────────────────────────────── */
@media (max-width: 767.98px) {

  body { font-size: 14px; }

  .card-body { padding: 1rem; }
  .card-header { padding: 0.85rem 1rem; }

  h4 { font-size: 1.15rem; }
  h5 { font-size: 1rem; }

  .stat-card { padding: 1rem; margin-bottom: 0.75rem; }
  .stat-card .display-6,
  .stat-card .stat-value { font-size: 1.75rem; }

  .btn { font-size: 0.85rem; padding: 0.45rem 0.9rem; }
  .btn-sm { padding: 0.28rem 0.6rem; font-size: 0.78rem; }

  /* Page header: stack title + button group vertically */
  .d-flex.justify-content-between.align-items-center {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0 !important;
    margin-bottom: 1.25rem !important;
  }

  /* The unlabelled <div> wrapping the action buttons */
  .d-flex.justify-content-between.align-items-center > div {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
    width: 100% !important;
    margin-top: 0.85rem;
  }

  /* Every direct-child button — full width, good tap size */
  .d-flex.justify-content-between.align-items-center > div > .btn {
    width: 100% !important;
    min-height: 46px !important;
    margin: 0 !important;
    justify-content: center !important;
  }

  /* Inline forms (e.g. delete) inside the button group */
  .d-flex.justify-content-between.align-items-center > div > form.d-inline {
    display: block !important;
    width: 100% !important;
  }
  .d-flex.justify-content-between.align-items-center > div > form.d-inline > .btn {
    width: 100% !important;
    min-height: 46px !important;
    margin: 0 !important;
    justify-content: center !important;
  }

  .alert { font-size: 0.85rem; padding: 0.7rem 0.9rem; }

  .fab { bottom: 1rem; right: 1rem; width: 48px; height: 48px; font-size: 1.2rem; }

  .pagination .page-link { padding: 0.35rem 0.65rem; font-size: 0.8rem; }

  #maintenance-calendar { font-size: 0.8rem; }
  .fc .fc-toolbar-title { font-size: 1rem; }
  .fc .fc-toolbar { flex-wrap: wrap; gap: 0.4rem; }
}

/* ── 24. EXTRA SMALL (< 480px) ────────────────────────────── */
@media (max-width: 479.98px) {

  .container { padding-left: 0.75rem; padding-right: 0.75rem; }

  .stat-card .display-6,
  .stat-card .stat-value { font-size: 1.5rem; }

  .card-body { padding: 0.85rem; }

  .btn { font-size: 0.82rem; }

  /* Stack inline forms */
  form.d-inline { display: block; margin-bottom: 0.3rem; }
  form.d-inline .btn { width: 100%; }
}

/* ── 25. SCAN MODAL — FULLSCREEN MOBILE ───────────────────── */
@media (max-width: 767.98px) {
  #scanModal .modal-dialog {
    position: fixed;
    inset: 0;
    max-width: 100vw;
    width: 100vw;
    height: 100dvh;
    margin: 0;
  }
  #scanModal .modal-content {
    height: 100dvh;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
  }
  #scanModal .modal-header {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 3;
    padding: 0.5rem 0.75rem;
    background: rgba(20,23,32,0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 0;
    border-bottom: none;
  }
  #scanModal .modal-body {
    flex: 1;
    padding: 0;
    gap: 0;
  }
  #scanModal .modal-footer { display: none; }
  #scanModal .scan-video {
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }
  #scanModal video { border-radius: 0; }
  #scanModal .alert { display: none; }
}

/* ── 26. PRINT ────────────────────────────────────────────── */
@media print {
  .navbar, .fab, footer, .btn, .pagination { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .card { border: 1px solid #ccc; box-shadow: none; }
  .table { color: #000; }
  .table thead th { background: #eee; color: #000; }
}