/* ═══════════════════════════════════════════════════════════════════
   Recreo — Premium Design System v2 (MBC Consulting)
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
  /* ── Surfaces (tinted toward brand burgundy) ── */
  --bg-base: #f4f1ec;
  --bg-panel: #3d0d1a;
  --bg-panel-alt: #f7f4ef;
  --bg-card: #ffffff;
  --surface-1: #ffffff;
  --surface-2: #faf6f1;
  --surface-3: #f0ebe4;
  --surface-sunken: rgba(76, 17, 31, 0.04);

  /* ── Brand ── */
  --accent: #e94e77;
  --accent-hover: #d13d64;
  --accent-soft: rgba(233, 78, 119, 0.10);
  --accent-glow: rgba(233, 78, 119, 0.18);

  /* ── Text ── */
  --text-primary: #1e293b;
  --text-on-light: #2d0e17;
  --text-muted: rgba(61, 13, 26, 0.55);
  --text-faint: rgba(61, 13, 26, 0.35);
  --text-secondary: #fce7f3;

  /* ── Status (semantic) ── */
  --success: #059669;
  --status-ok: #047857;
  --status-ok-bg: #ecfdf4;
  --status-ok-border: rgba(4, 120, 87, 0.18);
  --status-warn: #b45309;
  --status-warn-bg: #fef6e3;
  --status-warn-border: rgba(180, 83, 9, 0.22);
  --status-crit: #b91c1c;
  --status-crit-bg: #fef0f0;
  --status-crit-border: rgba(185, 28, 28, 0.22);
  --status-info: #6d28d9;
  --status-info-bg: #f3eefe;

  /* ── Borders ── */
  --border: rgba(61,13,26,0.1);
  --border-soft: rgba(61,13,26,0.06);
  --border-strong: rgba(61,13,26,0.18);

  /* ── Brand tints (graduated alpha of bg-panel & accent for inline use) ── */
  --brand-tint-3:   rgba(76, 17, 31, 0.03);
  --brand-tint-4:   rgba(76, 17, 31, 0.04);
  --brand-tint-5:   rgba(76, 17, 31, 0.05);
  --brand-tint-8:   rgba(76, 17, 31, 0.08);
  --brand-tint-10:  rgba(76, 17, 31, 0.10);
  --brand-tint-12:  rgba(76, 17, 31, 0.12);
  --brand-tint-15:  rgba(76, 17, 31, 0.15);
  --brand-tint-25:  rgba(76, 17, 31, 0.25);
  --accent-tint-3:  rgba(233, 78, 119, 0.03);
  --accent-tint-4:  rgba(233, 78, 119, 0.04);
  --accent-tint-10: rgba(233, 78, 119, 0.10);
  --accent-tint-20: rgba(233, 78, 119, 0.20);

  --sidebar-width: 270px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius: 18px;

  /* Easings inspirados en Emil Kowalski (spring / out-expo) */
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out-expo: cubic-bezier(0.83, 0, 0.17, 1);

  /* Duraciones estratificadas */
  --dur-micro: 140ms;
  --dur-normal: 220ms;
  --dur-medium: 320ms;
  --dur-large: 420ms;

  --transition: all var(--dur-normal) var(--ease-spring);
  --transition-fast: all var(--dur-micro) var(--ease-out-quart);
  --shadow-sm: 0 2px 8px rgba(61,13,26,0.06);
  --shadow-md: 0 8px 24px rgba(61,13,26,0.08);
  --shadow-lg: 0 20px 48px rgba(61,13,26,0.14);
  --glass: rgba(255,255,255,0.9);
  --glass-border: 1px solid rgba(255,255,255,0.6);
}

/* Status Badge */
.status-badge {
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
}
.status-badge.online {
  background: #dcfce7;
  color: #166534;
  border: 1px solid rgba(22,101,52,0.15);
}
.status-badge.offline {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid rgba(153,27,27,0.15);
}

* { margin:0; padding:0; box-sizing:border-box; font-family:'Inter',system-ui,-apple-system,sans-serif; }

body {
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(233,78,119,0.07) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(61,13,26,0.06) 0%, transparent 50%);
  color: var(--text-on-light);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  left:0; top:0; bottom:0;
  width: var(--sidebar-width);
  background: linear-gradient(170deg, #3d0d1a 0%, #5c1428 60%, #3d0d1a 100%);
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: 6px 0 40px rgba(0,0,0,0.18);
}

.sidebar::before {
  content:'';
  position:absolute;
  top:0; left:0; right:0;
  height:200px;
  background: radial-gradient(ellipse at 50% -20%, rgba(233,78,119,0.25) 0%, transparent 70%);
  pointer-events:none;
}

.sidebar-brand {
  padding: 28px 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: relative;
}

.sidebar-brand h1 {
  font-size: 1.3rem;
  font-weight: 800;
  color: white;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand p {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  margin-top: 5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 10px;
  overflow-y: auto;
}

.nav-item {
  width: 100%;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
  font-size: 0.9rem;
  border-radius: 12px;
  margin-bottom: 3px;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
  transform: translateX(3px);
}

.nav-item.active {
  background: rgba(233,78,119,0.2);
  color: white;
  font-weight: 700;
  border: 1px solid rgba(233,78,119,0.3);
  box-shadow: 0 4px 16px rgba(233,78,119,0.15);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 36px 44px;
  max-width: 1600px;
}

.page-header {
  margin-bottom: 32px;
  animation: fadeIn var(--dur-medium) var(--ease-out-expo) both;
}

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

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

.slide-up { animation: slideUp var(--dur-medium) var(--ease-spring) both; }

.page-header h2 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--bg-panel);
  letter-spacing: -0.04em;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  margin-top: 3px;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.section { margin-bottom: 36px; }

/* ===== CARDS ===== */
.card {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-md);
  border: var(--glass-border);
  transition: var(--transition);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 28px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  background: white;
  border: 1px solid rgba(61,13,26,0.07);
  transition: var(--transition);
}

.stat-card::before {
  content:'';
  position:absolute;
  inset:0;
  background: linear-gradient(135deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.5) 100%);
  pointer-events:none;
}

.stat-card.accent { background: linear-gradient(135deg, var(--bg-panel) 0%, #5c1428 100%); border-color: transparent; }
.stat-card.accent .stat-value, .stat-card.accent .stat-label, .stat-card.accent .stat-icon { color: white; }
.stat-card.success { background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%); border-color: rgba(5,150,105,0.2); }
.stat-card.success .stat-value { color: #065f46; }
.stat-card.warning { background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); border-color: rgba(180,83,9,0.2); }
.stat-card.warning .stat-value { color: #92400e; }
.stat-card.danger { background: linear-gradient(135deg, #fff1f2 0%, #fee2e2 100%); border-color: rgba(185,28,28,0.2); }
.stat-card.danger .stat-value { color: #991b1b; }

.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.stat-icon { font-size: 2rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08)); }
.stat-value { font-size: 2.4rem; font-weight: 900; color: var(--bg-panel); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--bg-panel); font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; opacity: 0.75; }

/* ===== RISK SEMAPHORE ===== */
.risk-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 36px;
}

.risk-column {
  background: white;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(61,13,26,0.05);
}

.risk-column-header {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.risk-header-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.risk-header-critical { background: linear-gradient(135deg, #fff1f2, #fee2e2); }
.risk-header-warning  { background: linear-gradient(135deg, #fffbeb, #fef3c7); }
.risk-header-safe     { background: linear-gradient(135deg, #f0fdf4, #dcfce7); }

.risk-col-critical { border-top: 3px solid #dc2626; }
.risk-col-warning  { border-top: 3px solid #d97706; }
.risk-col-safe     { border-top: 3px solid #059669; }

.risk-header-count { margin-left: auto; text-align: right; }
.risk-count  { font-size: 1.7rem; font-weight: 900; display: block; }
.risk-pct    { font-size: 0.7rem; font-weight: 700; opacity: 0.6; }

.risk-col-critical .risk-count { color: #dc2626; }
.risk-col-warning  .risk-count { color: #d97706; }
.risk-col-safe     .risk-count { color: #059669; }

.risk-column-body { padding: 10px; max-height: 460px; overflow-y: auto; }

.risk-person-card {
  width: 100%;
  background: var(--surface-1);
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 1px solid var(--border-soft);
  transition: var(--transition);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.risk-person-card.risk-crit { background: var(--status-crit-bg); border-color: var(--status-crit-border); }
.risk-person-card.risk-warn { background: var(--status-warn-bg); border-color: var(--status-warn-border); }
.risk-person-card.risk-debt { background: var(--accent-soft);    border-color: rgba(233,78,119,0.22); }
.risk-person-card.risk-safe,
.risk-person-card.risk-ok   { background: var(--surface-2);      border-color: var(--border-soft); }

.risk-person-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.risk-person-card.risk-crit:hover { border-color: var(--status-crit-border); }
.risk-person-card.risk-warn:hover { border-color: var(--status-warn-border); }
.risk-person-card.risk-debt:hover { border-color: rgba(233,78,119,0.45); }

.risk-person-meta {
  font-size: 0.65rem;
  margin-top: 2px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.risk-days-accent { color: var(--accent); }

.risk-avatar {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.9rem;
  border-radius: 12px;
  background: var(--bg-panel);
  color: white;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.risk-person-info { flex: 1; min-width: 0; }
.risk-person-name  { font-weight: 700; font-size: 0.88rem; color: var(--bg-panel); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.risk-person-cargo { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

.risk-person-days  { 
  text-align: right; 
  flex-shrink: 0; 
  width: 75px; 
  display: flex; 
  flex-direction: column; 
  align-items: flex-end; 
}
.risk-days-number  { font-size: 1.3rem; font-weight: 800; color: var(--bg-panel); display: block; line-height: 1; margin-bottom: 2px; }
.risk-days-label   { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; display: block; text-align: right; width: 100%; }

.risk-header-text h4 { font-size: 1rem; font-weight: 800; color: var(--bg-panel); }
.risk-header-text p  { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; margin-top: 1px; }

/* ===== TABLES ===== */
.table-container {
  background: white;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(61,13,26,0.07);
  box-shadow: var(--shadow-sm);
}

table { width: 100%; border-collapse: separate; border-spacing: 0; }

th {
  background: rgba(61,13,26,0.03);
  padding: 16px 18px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  border-bottom: 1px solid rgba(61,13,26,0.07);
}

td {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(61,13,26,0.04);
  font-size: 0.9rem;
  vertical-align: middle;
  transition: background 0.15s;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(233,78,119,0.025); }

/* ===== FORMS ===== */
.form-control {
  background: white;
  border: 1.5px solid rgba(61,13,26,0.12);
  border-radius: 10px;
  padding: 11px 16px;
  color: var(--text-on-light);
  font-weight: 500;
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition);
  width: 100%;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%233d0d1a'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 36px;
  cursor: pointer;
  font-weight: 600;
  color: var(--bg-panel);
}

/* ===== BUTTONS ===== */
.btn {
  padding: 11px 22px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: var(--bg-panel);
  color: white;
  box-shadow: 0 4px 12px rgba(61,13,26,0.2);
}

.btn-primary:hover {
  background: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(233,78,119,0.3);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid rgba(61,13,26,0.2);
  color: var(--bg-panel);
}

.btn-outline:hover {
  background: var(--bg-panel);
  border-color: var(--bg-panel);
  color: white;
}

.btn-sm {
  padding: 9px 14px;
  font-size: 0.78rem;
  min-height: 36px;
}
@media (max-width: 768px) {
  .btn-sm { padding: 11px 16px; min-height: 44px; }
  .btn-danger-soft, .btn-edit-soft { min-height: 44px; min-width: 44px; padding: 10px 12px; }
}
.btn-group { display: flex; gap: 8px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(30,5,12,0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: white;
  width: 92%; max-width: 720px;
  box-shadow: 0 40px 120px rgba(0,0,0,0.25);
  transform: translateY(24px) scale(0.98);
  transition: var(--transition);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.modal.wide { max-width: 1020px; }
.modal-overlay.active .modal { transform: translateY(0) scale(1); }

.modal-header {
  background: linear-gradient(135deg, var(--bg-panel) 0%, #5c1428 100%);
  padding: 22px 28px;
  color: white;
  display: flex; justify-content: space-between; align-items: center;
}

.modal-header h3 { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }

.modal-body { padding: 32px; max-height: 78vh; overflow-y: auto; }
.modal-footer { padding: 18px 28px; border-top: 1px solid rgba(61,13,26,0.07); text-align: right; }

/* ===== STATUS BADGES ===== */
.status {
  padding: 5px 12px;
  border-radius: 30px;
  font-size: 0.7rem;
  font-weight: 800;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status.red    { background: var(--status-crit-bg); color: var(--status-crit); border: 1px solid rgba(185,28,28,0.2); }
.status.yellow { background: var(--status-warn-bg); color: var(--status-warn); border: 1px solid rgba(180,83,9,0.2); }
.status.green  { background: var(--status-ok-bg);   color: var(--status-ok);   border: 1px solid rgba(5,150,105,0.2); }
.status.blue   { background: rgba(37,99,235,0.08);  color: #1d4ed8;            border: 1px solid rgba(37,99,235,0.2); }

/* ===== UPLOAD ZONE ===== */
.upload-zone {
  border: 2px dashed rgba(61,13,26,0.18);
  border-radius: var(--radius-md);
  padding: 28px;
  text-align: center;
  transition: var(--transition);
  background: rgba(61,13,26,0.02);
}

.upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-icon  { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.empty-state h4  { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; color: var(--bg-panel); opacity: 0.6; }
.empty-state p   { font-size: 0.85rem; font-weight: 500; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 3000;
}

.toast {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow:
    0 1px 0 rgba(61,13,26,0.04),
    0 12px 32px rgba(61,13,26,0.10);
  display: flex; align-items: center; gap: 12px;
  min-width: 280px;
  animation: slideInRight 0.35s cubic-bezier(0.4,0,0.2,1);
  color: var(--text-on-light);
  font-weight: 500;
}
.toast.success { background: var(--status-ok-bg);   border-color: var(--status-ok-border);   color: var(--status-ok); }
.toast.error   { background: var(--status-crit-bg); border-color: var(--status-crit-border); color: var(--status-crit); }
.toast.info    { background: var(--surface-2);      border-color: var(--border-soft);        color: var(--text-on-light); }

@keyframes slideInRight {
  from { opacity:0; transform:translateX(40px); }
  to   { opacity:1; transform:translateX(0); }
}

/* legacy variants superseded by the new background-tint approach above */
.toast-icon { font-size: 1.1rem; }
.toast-msg  { font-size: 0.88rem; font-weight: 600; color: var(--text-on-light); }

/* ===== ALERT CARD ===== */
.alert-card {
  padding: 16px 20px;
  border-radius: 14px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border: 1px solid transparent;
  transition: var(--transition);
}

.alert-card.critical { background: rgba(220,38,38,0.06); border-color: rgba(220,38,38,0.15); }
.alert-card.warning  { background: rgba(217,119,6,0.06);  border-color: rgba(217,119,6,0.15); }
.alert-card.ok       { background: rgba(5,150,105,0.05);  border-color: rgba(5,150,105,0.12); }

.alert-icon { font-size: 1.3rem; margin-top: 1px; }
.alert-content h4 { font-size: 0.92rem; font-weight: 700; color: var(--bg-panel); }
.alert-content p  { font-size: 0.82rem; color: var(--text-muted); margin-top: 3px; font-weight: 500; }

/* ===== SIDEBAR OVERLAY (mobile) ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20,5,10,0.5);
  z-index: 2400;
  backdrop-filter: blur(3px);
}

.sidebar-overlay.active { display: block; }

/* ===== MOBILE HEADER ===== */
.mobile-header {
  display: none;
  background: var(--bg-panel);
  color: white;
  padding: 14px 18px;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.menu-toggle {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s;
}

.menu-toggle:hover { background: rgba(255,255,255,0.12); }

/* ===== LAPTOP (≤1400px) ===== */
@media (max-width: 1400px) {
  .main-content { padding: 28px 32px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .grid-3     { grid-template-columns: repeat(3, 1fr); gap: 14px; }
}

/* ===== TABLET (≤1024px) ===== */
@media (max-width: 1024px) {
  :root { --sidebar-width: 230px; }
  .main-content { padding: 24px 24px; }
  .stats-grid   { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .grid-3       { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .risk-grid    { grid-template-columns: repeat(2, 1fr); }
  .stat-value   { font-size: 2rem; }
  .page-header h2 { font-size: 1.7rem; }

  /* Make tables scroll horizontally */
  .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 700px; }

  /* Section title wraps filter */
  .section-title { flex-wrap: wrap; }

  /* Conciliación filter wraps */
  .section-title input.form-control { max-width: 100% !important; width: 100%; }
}

/* ===== MOBILE (≤768px) ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    z-index: 2500;
    width: 270px;
  }
  .sidebar.active { transform: translateX(0); }

  .main-content  { margin-left: 0; padding: 16px; }
  .mobile-header { display: flex; }

  .stats-grid, .grid-3, .risk-grid { grid-template-columns: 1fr; gap: 12px; }

  .page-header h2 { font-size: 1.5rem; }
  .page-header p  { font-size: 0.82rem; }
  .page-header    { flex-direction: column; gap: 12px; margin-bottom: 20px; }

  /* Vertical filter buttons — scroll horizontal */
  .page-header > div:last-child {
    align-items: flex-start !important;
  }
  .page-header > div:last-child > div {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    padding-bottom: 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .page-header > div:last-child > div::-webkit-scrollbar { display: none; }

  .stat-value { font-size: 1.8rem; }
  .stat-icon  { font-size: 1.6rem; }

  /* Section titles wrap search */
  .section-title { flex-direction: column; align-items: flex-start; }
  .section-title span { width: 100%; }
  .section-title input.form-control { max-width: 100% !important; width: 100%; }

  /* Tables scroll */
  .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }
  th, td { padding: 12px 14px; font-size: 0.78rem; }

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

  /* Risk columns become full-width on mobile */
  .risk-column-header { padding: 14px 16px; }
  .risk-column-body   { max-height: 320px; }

  /* Form rows stack on mobile */
  .form-row { flex-direction: column !important; }
  .form-group { width: 100% !important; }
}

/* ===== SMALL MOBILE (≤480px) ===== */
@media (max-width: 480px) {
  .main-content { padding: 12px; }
  .modal        { width: 98%; border-radius: 16px; }
  .modal-header, .modal-footer { padding: 14px 16px; }
  .modal-body   { padding: 16px; max-height: 80vh; }
  .modal-header h3 { font-size: 0.9rem; }

  .stat-value   { font-size: 1.6rem; }
  .page-header h2 { font-size: 1.3rem; }

  .btn { padding: 10px 16px; font-size: 0.8rem; }
  .btn-group { flex-wrap: wrap; }

  /* Conciliación section title bar */
  .section-title { font-size: 0.68rem; }

  .risk-avatar { width: 36px; height: 36px; font-size: 0.8rem; }
  .risk-days-number { font-size: 1.1rem; }

  /* Nav buttons wrap text */
  .nav-item { padding: 11px 14px; font-size: 0.85rem; }

  th { font-size: 0.65rem; padding: 10px 10px; }
  td { font-size: 0.78rem; padding: 10px 10px; }

  .toast { min-width: 0; width: calc(100vw - 32px); }
  .toast-container { right: 16px; left: 16px; }
}

/* ===== iOS SAFARI & IPHONE 16 PRO SPECIFIC FIXES ===== */
@supports (-webkit-touch-callout: none) {
  /* Fix for 100vh issue on mobile Safari */
  .sidebar, body {
    min-height: -webkit-fill-available;
  }
  
  /* Ensure inputs don't zoom on focus */
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Safe area support for iPhone with notch/dynamic island */
.mobile-header {
  padding-top: calc(14px + env(safe-area-inset-top));
}

.sidebar-brand {
  padding-top: calc(28px + env(safe-area-inset-top));
}

.main-content {
  padding-bottom: calc(36px + env(safe-area-inset-bottom));
}

/* Improve tap targets for mobile */
.nav-item, .btn, .risk-person-card, tr {
  -webkit-tap-highlight-color: transparent;
}

/* Prevent accidental text selection during navigation */
.sidebar-nav, .mobile-header {
  -webkit-user-select: none;
  user-select: none;
}

/* Better table scrolling on iOS */
.table-container {
  -webkit-overflow-scrolling: touch;
}

/* ═══════════════════════════════════════════════════════════════════
   ANIMATION LAYER — Emil Kowalski-inspired motion
   Spring easings, transform-based, GPU-accelerated, reduced-motion safe.
   ═══════════════════════════════════════════════════════════════════ */

/* === Page transitions === */
.main-content > * {
  animation: pageEnter var(--dur-large) var(--ease-spring) both;
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === Stat / risk / card stagger ===
   Each card lands ~50ms after the previous, max 8 cards. */
.stats-grid > .card,
.risk-person-card,
.card.stat-card {
  animation: cardEnter var(--dur-medium) var(--ease-out-expo) both;
}
.stats-grid > .card:nth-child(1) { animation-delay: 0ms; }
.stats-grid > .card:nth-child(2) { animation-delay: 60ms; }
.stats-grid > .card:nth-child(3) { animation-delay: 120ms; }
.stats-grid > .card:nth-child(4) { animation-delay: 180ms; }
.risk-person-card:nth-of-type(1) { animation-delay: 60ms; }
.risk-person-card:nth-of-type(2) { animation-delay: 110ms; }
.risk-person-card:nth-of-type(3) { animation-delay: 160ms; }
.risk-person-card:nth-of-type(4) { animation-delay: 210ms; }
.risk-person-card:nth-of-type(5) { animation-delay: 250ms; }
.risk-person-card:nth-of-type(6) { animation-delay: 290ms; }
.risk-person-card:nth-of-type(7) { animation-delay: 320ms; }
.risk-person-card:nth-of-type(n+8) { animation-delay: 350ms; }
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* === Refined hover states (more subtle, transform-only) === */
.stat-card { will-change: transform; }
.stat-card:hover {
  transform: translateY(-2px) scale(1.005);
  transition: transform var(--dur-normal) var(--ease-spring),
              box-shadow var(--dur-normal) var(--ease-spring);
}
.stat-card:active {
  transform: translateY(0) scale(0.995);
  transition-duration: var(--dur-micro);
}

.risk-person-card { will-change: transform; }
.risk-person-card:hover {
  transform: translateX(2px) scale(1.005);
  transition: transform var(--dur-normal) var(--ease-spring),
              border-color var(--dur-normal) var(--ease-spring),
              box-shadow var(--dur-normal) var(--ease-spring);
}
.risk-person-card:active {
  transform: translateX(0) scale(0.99);
  transition-duration: var(--dur-micro);
}

.card { will-change: transform; }
.card:hover {
  transform: translateY(-1px);
  transition: transform var(--dur-normal) var(--ease-spring),
              box-shadow var(--dur-normal) var(--ease-spring);
}

/* === Buttons with press feedback === */
.btn {
  will-change: transform;
  transition: transform var(--dur-micro) var(--ease-out-quart),
              background var(--dur-normal) var(--ease-spring),
              border-color var(--dur-normal) var(--ease-spring),
              color var(--dur-normal) var(--ease-spring),
              box-shadow var(--dur-normal) var(--ease-spring);
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0) scale(0.97);
  transition-duration: 90ms;
}

/* === Sidebar nav: smooth color + indicator === */
.nav-item {
  position: relative;
  transition: color var(--dur-normal) var(--ease-spring),
              background var(--dur-normal) var(--ease-spring);
}
.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  transform: translateY(-50%) scaleY(0);
  transform-origin: center;
  transition: transform var(--dur-medium) var(--ease-spring);
}
.nav-item.active::before {
  transform: translateY(-50%) scaleY(1);
}
.nav-item:hover {
  transform: translateX(2px);
  transition: transform var(--dur-normal) var(--ease-spring),
              background var(--dur-normal) var(--ease-spring);
}

/* === Modal entry: spring scale + fade === */
.modal {
  transition: transform var(--dur-large) var(--ease-spring),
              opacity var(--dur-medium) var(--ease-out-expo);
}
.modal-overlay {
  transition: opacity var(--dur-medium) var(--ease-out-expo);
}

/* === Toast: smoother slide-in === */
.toast {
  animation: toastSlideIn var(--dur-large) var(--ease-spring) both;
}
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(36px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* === Status pills: micro-pop on appearance === */
.status {
  animation: pillIn var(--dur-medium) var(--ease-out-expo) both;
}
@keyframes pillIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

/* === Table row hover === */
tbody tr {
  transition: background var(--dur-micro) var(--ease-out-quart),
              transform var(--dur-normal) var(--ease-spring);
}
tbody tr:hover {
  background: rgba(76,17,31,0.025);
}

/* === Inputs: gentle focus === */
.form-control {
  transition: border-color var(--dur-normal) var(--ease-spring),
              box-shadow var(--dur-normal) var(--ease-spring),
              background var(--dur-normal) var(--ease-spring);
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

/* === Risk-card border color transition for context updates === */
.risk-person-card {
  transition: transform var(--dur-normal) var(--ease-spring),
              border-color var(--dur-medium) var(--ease-out-expo),
              box-shadow var(--dur-normal) var(--ease-spring),
              background-color var(--dur-medium) var(--ease-out-expo);
}

/* ═══════════════════════════════════════════════════════════════════
   Reduced motion: respect user preference
   ═══════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   DESIGN-ENG OVERRIDES — Emil-style craft pass
   Last layer; intentionally overrides earlier rules where needed.
   ═══════════════════════════════════════════════════════════════════ */

/* === Focus visible: ring uniforme con accent === */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: inherit;
}
button:focus-visible,
.nav-item:focus-visible,
.btn:focus-visible,
.risk-person-card:focus-visible,
.modal-close:focus-visible,
.menu-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px var(--accent-glow);
}

/* === Glass cleanup: solo modal-overlay justifica blur === */
.card {
  background: var(--surface-1);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid var(--border-soft);
}
.toast-container { backdrop-filter: none; -webkit-backdrop-filter: none; }

/* === Sidebar brand: bajar a span (h1 lo asume cada vista) === */
.sidebar-brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* === Stat-cards: rebalance editorial ===
   Eliminamos el "hero metric template" idéntico × 4. Las stat-cards
   ahora se diferencian por escala dentro del grid (la primera carga
   más peso visual gracias a .stat-card.lead). */
.stat-card { background: var(--surface-1); }
.stat-card .stat-value { font-feature-settings: "tnum","ss01"; letter-spacing: -0.04em; }
.stat-card.lead { padding: 30px 28px; }
.stat-card.lead .stat-value { font-size: 3.6rem; line-height: 0.95; font-weight: 800; }
.stat-card.lead .stat-label { font-size: 0.7rem; }
.stat-card.compact { padding: 20px; }
.stat-card.compact .stat-value { font-size: 1.8rem; }

/* === Editorial hero strip (alternative to .stats-grid 4×) === */
.hero-strip {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 28px;
}
@media (max-width: 1024px) {
  .hero-strip { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .hero-strip { grid-template-columns: 1fr; }
}

/* === Numbers feel like numbers === */
.stat-value, .risk-days-number, [data-numeric] {
  font-feature-settings: "tnum", "ss01", "cv01";
  font-variant-numeric: tabular-nums;
}

/* === Page header rhythm === */
.page-header h1,
.page-header h2 {
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.page-header h2 { font-size: 1.95rem; }
.page-header p { font-size: 0.95rem; max-width: 65ch; }

/* === Section title rhythm === */
.section-title {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
}

/* === Reduce body weight: the page should feel still === */
body { background: var(--bg-base); }

/* === Toast: ensure new tinted variants override legacy === */
.toast {
  font-size: 0.88rem;
  letter-spacing: -0.01em;
}

/* === Editorial hero strip styling === */
.hero-strip .stat-card {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: default;
}
.hero-strip .stat-card::before { display: none; }
.hero-strip .stat-card .stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--text-muted);
  opacity: 1;
}
.hero-strip .stat-card .stat-value {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text-on-light);
  line-height: 1;
  margin-top: 6px;
}
.hero-strip .stat-card .stat-meta {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 6px;
  line-height: 1.3;
}

.hero-strip .stat-card.lead {
  background: linear-gradient(165deg, var(--bg-panel) 0%, #5c1428 100%);
  border-color: transparent;
  color: white;
  padding: 28px 28px;
}
.hero-strip .stat-card.lead .stat-label { color: rgba(255,255,255,0.55); }
.hero-strip .stat-card.lead .stat-value { color: white; font-size: 4rem; font-weight: 800; }
.hero-strip .stat-card.lead .stat-meta  { color: rgba(255,255,255,0.65); font-size: 0.85rem; }

.hero-strip .stat-card.stat-tone-crit {
  background: var(--status-crit-bg);
  border-color: var(--status-crit-border);
}
.hero-strip .stat-card.stat-tone-crit .stat-value { color: var(--status-crit); }
.hero-strip .stat-card.stat-tone-warn {
  background: var(--status-warn-bg);
  border-color: var(--status-warn-border);
}
.hero-strip .stat-card.stat-tone-warn .stat-value { color: var(--status-warn); }

.stat-clickable {
  cursor: pointer;
  transition: var(--transition);
}
.stat-clickable:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.stat-clickable:active { transform: translateY(0) scale(0.99); }

@media (max-width: 720px) {
  .hero-strip .stat-card.lead .stat-value { font-size: 3rem; }
  .hero-strip .stat-card .stat-value { font-size: 2rem; }
}

/* === Sidebar brand: sin h1, sólo composición tipográfica === */
.brand-mark {
  font-size: 1.15rem;
  font-weight: 700;
  color: white;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}
.brand-tag {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  margin-top: 5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.page-header h1 {
  font-size: 1.95rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--bg-panel);
}

/* ═══════════════════════════════════════════════════════════════════
   UTILITY CLASSES — replace inline hex/rgba in views.js
   ═══════════════════════════════════════════════════════════════════ */

/* Danger-soft button: small destructive action (eliminar) */
.btn-danger-soft {
  background: var(--status-crit-bg);
  color: var(--status-crit);
  border-color: transparent;
  padding: 8px 10px;
  min-height: 36px;
  min-width: 36px;
}
.btn-danger-soft:hover {
  background: var(--status-crit-bg);
  color: var(--status-crit);
  border-color: var(--status-crit-border);
}

/* Edit button: same shape, neutral */
.btn-edit-soft {
  background: var(--surface-sunken);
  color: var(--bg-panel);
  border-color: transparent;
  padding: 8px 10px;
  min-height: 36px;
  min-width: 36px;
}
.btn-edit-soft:hover {
  background: var(--surface-sunken);
  color: var(--bg-panel);
  border-color: var(--border-strong);
}

/* Callouts (the conciliación + cobertura tinted blocks) */
.callout {
  padding: 18px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.callout-ok    { background: var(--status-ok-bg);   border-color: var(--status-ok-border); }
.callout-warn  { background: var(--status-warn-bg); border-color: var(--status-warn-border); }
.callout-crit  { background: var(--status-crit-bg); border-color: var(--status-crit-border); }
.callout-debt  { background: var(--accent-soft);    border-color: rgba(233,78,119,0.22); }

/* Approval tag (orange pill "X sin aprobar") */
.tag-pending {
  background: var(--status-warn);
  color: white;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 10px;
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE UX OVERHAUL — drawer sidebar, bottom tab bar, sticky header
   Fixes critical layout bug where body's flex display + fixed sidebar
   was reserving sidebar width even when off-canvas.
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Body no longer flex on mobile: sidebar floats over content */
  body {
    display: block;
    overflow-x: hidden;
  }
  .main-content {
    margin-left: 0 !important;
    width: 100%;
    max-width: 100%;
    padding: 14px 16px 96px;  /* room for bottom tab bar */
  }
  .sidebar {
    width: 84vw;
    max-width: 320px;
    transform: translateX(-105%);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2500;
    box-shadow: 0 0 60px rgba(0,0,0,0.4);
  }
  .sidebar.active { transform: translateX(0); }
  .sidebar-overlay {
    background: rgba(20,5,10,0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  /* ── Mobile header: clean, sticky, with alert badge ── */
  .mobile-header {
    display: flex;
    padding: 12px 16px;
    background: var(--bg-panel);
    color: white;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1500;
    box-shadow: 0 1px 0 rgba(0,0,0,0.15);
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .mobile-header strong { letter-spacing: 0.14em; font-weight: 700; font-size: 1rem; }
  .menu-toggle {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px;
    font-size: 1.2rem;
  }

  /* ── Page header: stack cleanly, no horizontal cramming ── */
  .page-header {
    display: block !important;
    margin-bottom: 18px;
  }
  .page-header h1, .page-header h2 {
    font-size: 1.45rem;
    letter-spacing: -0.025em;
    line-height: 1.15;
  }
  .page-header p {
    font-size: 0.84rem;
    margin-top: 4px;
  }
  .page-header > .status-badge {
    margin-top: 10px;
    display: inline-flex;
  }
  /* Vertical filter on its own row, horizontal scrollable */
  .page-header > div:last-child {
    margin-top: 14px;
    width: 100%;
    align-items: flex-start !important;
  }
  .page-header > div:last-child > div {
    width: 100%;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 6px;
    gap: 8px !important;
  }
  .page-header > div:last-child > div::-webkit-scrollbar { display: none; }
  .page-header > div:last-child > div > button { flex-shrink: 0; }

  /* Hero strip stacks 1 column; lead stays prominent */
  .hero-strip { grid-template-columns: 1fr; gap: 10px; margin-bottom: 18px; }
  .hero-strip .stat-card { padding: 16px 18px; border-radius: 14px; }
  .hero-strip .stat-card.lead { padding: 20px 22px; }
  .hero-strip .stat-card.lead .stat-value { font-size: 2.8rem; }
  .hero-strip .stat-card .stat-value { font-size: 1.8rem; }

  /* Risk grid stacks; preserve column tints */
  .risk-grid { grid-template-columns: 1fr !important; gap: 12px; }
  .risk-column { border-radius: 14px; }
  .risk-person-card { padding: 12px; }

  /* Cards & sections breathe less */
  .card { padding: 16px; border-radius: 12px; }
  .section { margin-bottom: 20px; }

  /* Tables: hint horizontal scroll */
  .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
  table { min-width: 640px; font-size: 0.84rem; }
  thead th, tbody td { padding: 9px 10px; }

  /* Modal: full-screen drawer on mobile */
  .modal-overlay.active { padding: 0; }
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
  }
  .modal-overlay.active .modal { transform: translateY(0); }
  .modal-header { padding: 14px 16px; }
  .modal-body   { padding: 14px 16px; }
  .modal-footer { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
  .modal-footer .btn { flex: 1 1 auto; min-width: 0; }

  /* ── BOTTOM TAB BAR: iOS-style native nav ── */
  .bottom-tab-bar {
    position: fixed;
    left: 0; right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.92);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--border-soft);
    display: flex;
    z-index: 1400;
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .bottom-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 4px 10px;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    position: relative;
    min-height: 56px;
    transition: color var(--dur-fast) var(--ease-out-quart);
  }
  .bottom-tab svg { width: 22px; height: 22px; stroke-width: 1.8; }
  .bottom-tab.active { color: var(--bg-panel); }
  .bottom-tab.active::before {
    content: '';
    position: absolute;
    top: 6px;
    width: 32px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--bg-panel);
  }
  .bottom-tab .tab-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 22px);
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    background: var(--accent);
    color: white;
    font-size: 0.58rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 0 0 2px white;
  }
}

/* Hide tab bar on desktop */
.bottom-tab-bar { display: none; }
@media (max-width: 768px) {
  .bottom-tab-bar { display: flex; }
}

/* ═══════════════════════════════════════════════════════════════════
   Small phones (≤380px): tighten further
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
  .main-content { padding: 12px 12px 88px; }
  .page-header h1, .page-header h2 { font-size: 1.3rem; }
  .hero-strip .stat-card.lead .stat-value { font-size: 2.4rem; }
  .mobile-header { padding: 11px 14px; }
}
