/* ============================================================
   VANUTECH TICKET PLATFORM — Global Styles
   ============================================================ */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --primary-bg: #eef2ff;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-dark: #1a1a2e;
  --bg-darker: #0f0f23;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-focus: #6366f1;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
  --transition: 0.2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== LAYOUT ===== */
.page-wrapper { min-height: 100vh; display: flex; flex-direction: column; }
.main-content { flex: 1; padding: 32px 24px; max-width: 1280px; margin: 0 auto; width: 100%; }
.container { max-width: 680px; margin: 0 auto; }
.container-wide { max-width: 1100px; margin: 0 auto; }

/* ===== HEADER ===== */
.header {
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-darker) 100%);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
}
.header-brand svg { width: 32px; height: 32px; }
.header-brand span { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.header-brand small { font-size: 12px; color: var(--text-light); font-weight: 400; margin-left: 8px; }
.header-nav { display: flex; align-items: center; gap: 8px; }
.header-nav a, .header-nav button {
  color: #cbd5e1;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  background: none;
  border: none;
  cursor: pointer;
}
.header-nav a:hover, .header-nav button:hover { background: rgba(255,255,255,0.1); color: #fff; }
.header-nav a.active { background: var(--primary); color: #fff; }
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #e2e8f0;
  font-size: 13px;
}
.header-user .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.card-header h2 { font-size: 18px; font-weight: 700; color: var(--text); }
.card-body { padding: 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--border); background: var(--bg); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-light); }
.form-textarea { resize: vertical; min-height: 120px; }
.form-select { cursor: pointer; appearance: auto; }
.form-hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; display: none; }
.form-group.has-error .form-input,
.form-group.has-error .form-select { border-color: var(--danger); }
.form-group.has-error .form-error { display: block; }

/* ===== FILE UPLOAD ===== */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg);
}
.file-drop:hover, .file-drop.dragover { border-color: var(--primary); background: var(--primary-bg); }
.file-drop-icon { font-size: 32px; margin-bottom: 8px; }
.file-drop-text { font-size: 14px; color: var(--text-secondary); }
.file-drop-text strong { color: var(--primary); cursor: pointer; }
.file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 13px;
}
.file-item .file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .file-size { color: var(--text-light); font-size: 12px; }
.file-item .file-remove { color: var(--danger); cursor: pointer; background: none; border: none; font-size: 16px; padding: 2px 6px; border-radius: 4px; }
.file-item .file-remove:hover { background: var(--danger-bg); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #fff; border-color: var(--text-light); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 8px 12px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-aperto { background: var(--info-bg); color: var(--info); }
.badge-in_lavorazione { background: var(--warning-bg); color: #d97706; }
.badge-in_attesa { background: #faf5ff; color: #7c3aed; }
.badge-chiuso { background: #f1f5f9; color: var(--text-light); }
.badge-bassa { background: #f1f5f9; color: var(--text-light); }
.badge-normale { background: var(--info-bg); color: var(--info); }
.badge-alta { background: var(--warning-bg); color: #d97706; }
.badge-urgente { background: var(--danger-bg); color: var(--danger); }
.badge-hardware { background: #ecfdf5; color: #059669; }
.badge-software { background: var(--info-bg); color: var(--info); }
.badge-commerciale { background: var(--warning-bg); color: #d97706; }
.badge-rma { background: #faf5ff; color: #7c3aed; }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-light); background: var(--bg); border-bottom: 1px solid var(--border); }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
tr:hover td { background: var(--bg); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--primary-bg); }

/* ===== STATS GRID ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 12px; color: var(--text-light); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .stat-value { font-size: 32px; font-weight: 800; color: var(--text); margin-top: 4px; }
.stat-card .stat-icon { font-size: 24px; float: right; }
.stat-card.accent { border-left: 4px solid var(--primary); }

/* ===== TABS ===== */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 24px; overflow-x: auto; }
.tab-btn {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); }
.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}
.tab-count {
  background: var(--bg);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  margin-left: 6px;
  color: var(--text-light);
}

/* ===== TIMELINE ===== */
.timeline { padding: 0; list-style: none; }
.timeline-item { display: flex; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; flex-shrink: 0;
}
.timeline-avatar.staff { background: var(--primary-bg); color: var(--primary); }
.timeline-avatar.customer { background: #ecfdf5; color: #059669; }
.timeline-avatar.internal { background: var(--warning-bg); color: #d97706; }
.timeline-content { flex: 1; }
.timeline-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.timeline-name { font-weight: 600; font-size: 14px; }
.timeline-time { font-size: 12px; color: var(--text-light); }
.timeline-badge { font-size: 10px; }
.timeline-message { font-size: 14px; color: var(--text-secondary); white-space: pre-wrap; line-height: 1.7; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 90%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(20px); transition: transform 0.25s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-light); padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== TOAST ===== */
.toast-container { position: fixed; top: 80px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 14px 20px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  animation: slideIn 0.3s ease;
  max-width: 400px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--info); color: #fff; }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); font-size: 14px; }

/* ===== FILTERS BAR ===== */
.filters-bar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 20px;
}
.filters-bar .form-input, .filters-bar .form-select {
  width: auto; min-width: 160px; padding: 8px 12px; font-size: 13px;
}
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box input { padding-left: 36px; }
.search-box::before { content: '🔍'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; }

/* ===== LOADING ===== */
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.8); display: flex; align-items: center;
  justify-content: center; z-index: 10;
}

/* ===== PAGINATION ===== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 20px; }
.pagination button {
  padding: 6px 12px; border: 1px solid var(--border); background: #fff;
  border-radius: 6px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.pagination button:hover { background: var(--bg); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== SUCCESS SCREEN ===== */
.success-screen { text-align: center; padding: 40px 24px; }
.success-icon { font-size: 64px; margin-bottom: 16px; }
.ticket-number-display {
  font-size: 28px; font-weight: 800; color: var(--primary);
  background: var(--primary-bg); padding: 12px 24px;
  border-radius: var(--radius); display: inline-block; margin: 12px 0;
}

/* ===== SIDEBAR (Admin) ===== */
.layout-admin { display: flex; min-height: calc(100vh - 64px); }
.sidebar {
  width: 240px; background: #fff; border-right: 1px solid var(--border);
  padding: 16px 0; flex-shrink: 0; position: sticky; top: 64px;
  height: calc(100vh - 64px); overflow-y: auto;
}
.sidebar-section { padding: 8px 16px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-light); margin-top: 8px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; font-size: 14px; color: var(--text-secondary);
  text-decoration: none; transition: var(--transition); cursor: pointer;
  border: none; background: none; width: 100%; text-align: left; font-family: inherit;
}
.sidebar-link:hover { background: var(--bg); color: var(--text); }
.sidebar-link.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.sidebar-link .sidebar-count {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 11px; padding: 1px 8px; border-radius: 10px; font-weight: 600;
}
.admin-main { flex: 1; padding: 24px 32px; overflow-x: hidden; }

/* ===== MOBILE HEADER (Admin/Installer) ===== */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 999;
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-darker) 100%);
  padding: 0 16px; height: 56px;
  align-items: center; justify-content: space-between;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.mobile-header .header-brand { font-size: 16px; }
.mobile-header .header-brand span { font-size: 16px; }
.hamburger-btn {
  background: none; border: none; color: #fff; font-size: 24px; cursor: pointer;
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; -webkit-tap-highlight-color: transparent;
}
.hamburger-btn:active { background: rgba(255,255,255,0.1); }
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1001;
}
.sidebar-overlay.show { display: block; }

/* ===== MOBILE TABLE → CARDS ===== */
.mobile-cards { display: none; }
.mobile-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
}
.mobile-card-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.mobile-card-row:last-child { margin-bottom: 0; }
.mobile-card-label { font-size: 11px; color: var(--text-light); text-transform: uppercase; font-weight: 600; }
.mobile-card-value { font-size: 13px; font-weight: 500; text-align: right; }
.mobile-card-header { font-size: 15px; font-weight: 700; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ===== RESPONSIVE — TABLET & MOBILE ===== */
@media (max-width: 768px) {
  /* Mobile header visible */
  .mobile-header { display: flex; }

  /* Desktop header hidden */
  .header { display: none; }

  /* Sidebar as slide-out drawer */
  .sidebar {
    position: fixed; left: -280px; width: 280px; z-index: 1002;
    transition: left 0.25s ease; top: 0; height: 100%;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    box-shadow: none; border-right: none;
  }
  .sidebar.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,0.3); }
  .sidebar-link { padding: 12px 20px; font-size: 15px; min-height: 44px; }
  .sidebar-section { padding: 10px 20px; }

  /* Admin main content */
  .layout-admin { flex-direction: column; }
  .admin-main { padding: 16px; padding-top: 72px; }

  /* Public pages */
  .main-content { padding: 20px 16px; padding-top: 72px; }

  /* Form rows stack */
  .form-row { grid-template-columns: 1fr; }

  /* Inputs — prevent iOS zoom */
  .form-input, .form-select, .form-textarea { font-size: 16px; padding: 12px 14px; }

  /* Buttons — touch-friendly */
  .btn { padding: 12px 20px; font-size: 15px; min-height: 44px; }
  .btn-sm { padding: 10px 14px; font-size: 14px; min-height: 40px; }
  .btn-lg { padding: 14px 24px; font-size: 16px; }
  .btn-block { width: 100%; }

  /* Stats grid */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 24px; }

  /* Tables → scroll or cards */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }

  /* Filters bar */
  .filters-bar { flex-direction: column; gap: 8px; }
  .filters-bar .form-input, .filters-bar .form-select, .search-box { min-width: unset; width: 100%; }

  /* Tabs scroll horizontally */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; flex-wrap: nowrap; gap: 0; }
  .tab-btn { padding: 10px 14px; font-size: 13px; flex-shrink: 0; }

  /* Cards */
  .card-header { padding: 16px; flex-wrap: wrap; }
  .card-header h2 { font-size: 16px; }
  .card-body { padding: 16px; }
  .card-footer { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }

  /* Timeline */
  .timeline-item { gap: 10px; padding: 12px 0; }
  .timeline-avatar { width: 34px; height: 34px; font-size: 12px; }
  .timeline-header { flex-wrap: wrap; gap: 4px; }
  .timeline-message { font-size: 13px; }

  /* Modal — bottom sheet on mobile */
  .modal-overlay { align-items: flex-end; }
  .modal {
    width: 100% !important; max-width: 100% !important;
    max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(0);
  }
  .modal-header { padding: 16px; position: sticky; top: 0; background: #fff; z-index: 1; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; position: sticky; bottom: 0; background: #fff; z-index: 1; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; min-width: 120px; justify-content: center; }
  .modal-close { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; font-size: 28px; }

  /* Toast on mobile — full width */
  .toast-container { top: 64px; right: 12px; left: 12px; }
  .toast { max-width: 100%; }

  /* Pagination */
  .pagination { flex-wrap: wrap; }
  .pagination button { padding: 8px 14px; font-size: 14px; min-height: 40px; }

  /* File upload */
  .file-drop { padding: 16px; }

  /* Detail grid — stack on mobile */
  .detail-grid { grid-template-columns: 1fr !important; }

  /* Plants grid — single column */
  .plants-grid { grid-template-columns: 1fr !important; }

  /* Installer tabs */
  .installer-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .installer-tab { flex-shrink: 0; padding: 10px 16px; font-size: 14px; }

  /* Plant detail 2-col → 1-col (all inline grid variants) */
  [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }

  /* Quick actions / ticket detail inline flex → wrap */
  [style*="display:flex"][style*="gap:12px"][style*="flex:1"] { flex-wrap: wrap !important; }
  .card-body[style*="display:flex"] { flex-wrap: wrap !important; }
  .card-body[style*="display:flex"] .form-group { min-width: 100% !important; flex: 1 1 100% !important; }

  /* Success screen */
  .success-screen { padding: 24px 16px; }
  .success-icon { font-size: 48px; }
  .ticket-number-display { font-size: 22px; padding: 10px 18px; }

  /* Header brand on public pages that still show header */
  .header-brand small { display: none; }
  .header-nav { gap: 4px; }
  .header-nav a, .header-nav button { padding: 6px 10px; font-size: 12px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-card .stat-value { font-size: 20px; }
  .stat-card .stat-label { font-size: 11px; }
  .admin-main { padding: 12px; padding-top: 68px; }
  .main-content { padding: 12px; padding-top: 68px; }

  /* Really small screens: full-width buttons */
  .btn-row { flex-direction: column; }
  .btn-row .btn { width: 100%; }

  /* Smaller page title */
  h1 { font-size: 20px !important; }

  /* Checkbox group wrap */
  .checkbox-group label { padding: 8px 10px; font-size: 12px; }
}

/* ===== iOS SAFE AREA ===== */
@supports (padding: env(safe-area-inset-bottom)) {
  .sidebar { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .modal-footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .admin-main { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* ===== TOUCH OPTIMIZATIONS ===== */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .tab-btn { min-height: 44px; }
  .sidebar-link { min-height: 44px; }
  .pagination button { min-height: 44px; min-width: 44px; }
  tr.clickable td { padding: 14px 16px; }
  .form-select { min-height: 44px; }
}
