/* ============================================================
   GestionDeObras — Design System
   Corporate, professional, scalable
   ============================================================ */

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

/* ── CSS Variables ── */
:root {
  /* Brand palette GV Construcciones */
  --primary: #0C5528;          /* Deep elegant forest green */
  --primary-light: #12823F;    /* Rich grass green for UI actions */
  --primary-dark: #073819;     /* Deep shade for headers/contrast */
  --accent: #E8950A;           /* Vibrant corporate amber */
  --accent-light: #FBBE45;     /* Lighter amber */
  --accent-dark: #B56E00;      /* Dark gold/bronze */

  /* Neutrals */
  --bg: #F5F7FA;               /* Clean slate white background */
  --bg-card: #FFFFFF;          /* Pure card base */
  --bg-sidebar: linear-gradient(180deg, #073819 0%, #031c0c 100%); /* Premium dark gradient */
  --bg-sidebar-hover: rgba(255, 255, 255, 0.05);

  /* Text */
  --text-primary: #1E293B;     /* Slate-800 for top readability */
  --text-secondary: #475569;   /* Slate-600 */
  --text-muted: #64748B;       /* Slate-500 */
  --text-sidebar: #A7F3D0;     /* Mint-100 for high-contrast soft readable labels */
  --text-sidebar-active: #FFFFFF;

  /* Status colors */
  --status-activa: #10B981;
  --status-presupuesto: #3B82F6;
  --status-pausada: #F59E0B;
  --status-finalizada: #8B5CF6;
  --status-cancelada: #EF4444;

  /* Borders */
  --border: #E2E8F0;           /* Soft border grey */
  --border-focus: #12823F;

  /* Premium Shadows */
  --shadow-sm: 0 1px 3px 0 rgba(0,0,0,0.05), 0 1px 2px -1px rgba(0,0,0,0.03);
  --shadow: 0 10px 15px -3px rgba(15,23,42,0.04), 0 4px 6px -4px rgba(15,23,42,0.02);
  --shadow-lg: 0 20px 25px -5px rgba(15,23,42,0.08), 0 8px 10px -6px rgba(15,23,42,0.04);
  --shadow-xl: 0 25px 50px -12px rgba(15,23,42,0.12);

  /* Layout */
  --sidebar-width: 260px;
  --topbar-height: 65px;
  --radius: 12px;
  --radius-lg: 20px;

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

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Layout ── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  grid-row: 1 / -1;
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  border-right: 1px solid rgba(255,255,255,0.03);
  transition: var(--transition);
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.sidebar-logo .logo-mark {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(232, 149, 10, 0.3);
}

.sidebar-logo .logo-text {
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1.25;
}

.sidebar-logo .logo-text span {
  display: block;
  font-size: 9.5px;
  font-weight: 500;
  color: var(--text-sidebar);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-top: 2px;
  opacity: 0.85;
}

.sidebar-section {
  padding: 20px 14px 4px;
}

.sidebar-section-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  min-height: 44px;
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 4px;
  transition: var(--transition);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
  padding-left: 20px; /* Subtle indent on hover */
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-left: 4px solid var(--accent);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  box-shadow: inset 10px 0 15px -10px rgba(0,0,0,0.5);
  font-weight: 700;
}

.nav-item .nav-icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 12px;
  min-width: 20px;
  text-align: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  transition: var(--transition);
}

.user-card:hover { background: var(--bg-sidebar-hover); cursor: pointer; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info .user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

/* ── Topbar ── */
.topbar {
  grid-column: 2;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.5);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-breadcrumb span { color: var(--text-muted); }

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

/* ── Main Content ── */
.main-content {
  padding: 24px;
  overflow-y: auto;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  padding: 20px;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.card:hover { box-shadow: var(--shadow); }

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

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

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-color, var(--primary-light));
}

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

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.kpi-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 24px;
  opacity: 0.15;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background: var(--primary-light);
  color: #fff;
}
.btn-primary:hover { background: var(--primary); }

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: var(--accent-dark); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); border-color: var(--primary-light); color: var(--primary-light); }

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-success {
  background: #dcfce7;
  color: #16a34a;
  border: 1px solid #86efac;
}
.btn-success:hover { background: #16a34a; color: #fff; }

.btn-sm { padding: 8px 14px; font-size: 12.5px; min-height: 36px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; }

/* ── Badges / Status ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-activa    { background: #dcfce7; color: #15803d; }
.badge-presupuesto { background: #dbeafe; color: #1d4ed8; }
.badge-pausada   { background: #fef3c7; color: #b45309; }
.badge-finalizada { background: #f3e8ff; color: #7c3aed; }
.badge-cancelada { background: #fee2e2; color: #dc2626; }
.badge-borrador  { background: #f1f5f9; color: #475569; }
.badge-aprobado  { background: #dcfce7; color: #15803d; }
.badge-vigente   { background: #dbeafe; color: #1d4ed8; }
.badge-cobrado   { background: #f0fdf4; color: #166534; }
.badge-pendiente { background: #fef3c7; color: #92400e; }
.badge-pagado    { background: #dcfce7; color: #15803d; }
.badge-anulado   { background: #fee2e2; color: #dc2626; }
.badge-solicitado { background: #e0f2fe; color: #0369a1; }
.badge-urgente   { background: #fee2e2; color: #dc2626; }
.badge-normal    { background: #f1f5f9; color: #475569; }
.badge-recibido  { background: #dcfce7; color: #15803d; }
.badge-emitida   { background: #dbeafe; color: #1d4ed8; }

/* ── Table ── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.data-table thead th.sortable { cursor: pointer; }
.data-table thead th.sortable:hover { color: var(--primary-light); }

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }

.data-table tbody td {
  padding: 12px 14px;
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody td.text-muted { color: var(--text-muted); }
.data-table tbody td.numeric { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-label .required { color: #ef4444; margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 168, 0.12);
}

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

.form-error {
  font-size: 12px;
  color: #dc2626;
  margin-top: 4px;
}

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

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

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}

.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.modal-title { font-size: 16px; font-weight: 700; }

.modal-body { padding: 20px 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: var(--transition);
}
.btn-close:hover { color: var(--text-primary); }

/* ── Progress bars ── */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 10px;
  background: var(--primary-light);
  transition: width 0.5s ease;
}

.progress-fill.warning { background: var(--accent); }
.progress-fill.danger { background: #ef4444; }
.progress-fill.success { background: #22c55e; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Filters bar ── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 300px;
}

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

.search-box input {
  padding-left: 32px;
  width: 100%;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none; /* Firefox */
}
.tabs::-webkit-scrollbar {
  display: none; /* Safari and Chrome */
}

.tab {
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  flex-shrink: 0;
}

.tab:hover { color: var(--primary-light); }
.tab.active { color: var(--primary-light); border-bottom-color: var(--primary-light); }

/* ── Alerts ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
}

.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-info { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }

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

.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state-desc { font-size: 13px; }

/* ── Loading spinner ── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary-light);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}

.spinner-lg { width: 40px; height: 40px; border-width: 3px; }

/* ── Skeleton loader ── */
.skeleton-loader {
  display: inline-block;
  height: 28px;
  width: 80px;
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite linear;
  border-radius: var(--radius);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


/* ── Toast notifications ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  pointer-events: all;
  animation: slideLeft 0.25s ease;
  max-width: 360px;
  background: #fff;
  border-left: 4px solid var(--primary-light);
}

.toast.success { border-color: #22c55e; color: #15803d; }
.toast.error   { border-color: #ef4444; color: #dc2626; }
.toast.warning { border-color: #f59e0b; color: #b45309; }

/* ── Financial amounts ── */
.amount-positive { color: #16a34a; font-weight: 700; }
.amount-negative { color: #dc2626; font-weight: 700; }
.amount-neutral  { color: var(--text-secondary); font-weight: 600; }

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Utility classes ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ══════════════════════════════════════════════════════════════
   MOBILE-FIRST REDESIGN v2
   ══════════════════════════════════════════════════════════════ */

/* ── Role-based visibility ── */
[data-admin-only] { /* visible by default */ }
body.role-jefe_obra [data-admin-only],
body.role-compras_field [data-admin-only] {
  display: none !important;
}

/* ── Hamburger Button ── */
.hamburger-btn {
  display: none;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  margin-right: 8px;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.hamburger-btn:hover { background: var(--bg); }
.hamburger-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background-color: var(--text-secondary);
  border-radius: 1px;
  transition: var(--transition);
}

/* ── Sidebar Overlay Backdrop ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 99;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}
.sidebar-overlay.active { display: block; }

/* ── Bottom Navigation Bar ── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: var(--bg-sidebar);
  border-top: 1px solid rgba(255,255,255,0.08);
  z-index: 98;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  align-items: center;
  gap: 2px;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: 10px;
  color: rgba(255,255,255,0.42);
  font-size: 10px;
  font-weight: 600;
  text-decoration: none;
  min-height: 52px;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.bottom-nav-item .bn-icon { font-size: 20px; line-height: 1; }
.bottom-nav-item .bn-badge {
  position: absolute;
  top: 4px; right: 14px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
.bottom-nav-item.active { color: #fff; background: rgba(255,255,255,0.12); }
.bottom-nav-item:active { transform: scale(0.92); }

.bottom-nav-fab-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}
.bottom-nav-fab {
  width: 48px; height: 48px;
  background: var(--accent);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 14px rgba(249,168,38,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}
.bottom-nav-fab:active { transform: scale(0.88); box-shadow: 0 2px 8px rgba(249,168,38,0.3); }

/* ── Status Border List Items (reemplaza tablas en mobile) ── */
.status-list { border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); background: #fff; }

.status-list-item {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  background: #fff;
  transition: background 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.status-list-item:hover { background: #f8fafc; }
.status-list-item:last-child { border-bottom: none; }
.status-list-item:active { background: #f1f5f9; }

.sli-bar {
  width: 4px;
  flex-shrink: 0;
  border-radius: 0;
}
.sli-green  { background: var(--status-activa); }
.sli-orange { background: var(--status-pausada); }
.sli-red    { background: var(--status-cancelada); }
.sli-blue   { background: var(--status-presupuesto); }
.sli-purple { background: var(--status-finalizada); }
.sli-gray   { background: var(--text-muted); }

.sli-body {
  flex: 1;
  padding: 13px 14px;
  min-width: 0;
}
.sli-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sli-meta {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.sli-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 0 0;
  flex-shrink: 0;
}

/* ── Quick Actions Grid (Dashboard, campo) ── */
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.quick-action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.quick-action-card:hover {
  border-color: var(--primary-light);
  color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.quick-action-card:active { transform: scale(0.96); }
.quick-action-card .qac-icon { font-size: 28px; }

/* ── Role Greeting Banner ── */
.role-greeting {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  overflow: hidden;
  position: relative;
}
.role-greeting::after {
  content: attr(data-emoji);
  position: absolute;
  right: -8px; top: -8px;
  font-size: 80px;
  opacity: 0.12;
  line-height: 1;
}
.role-greeting-text h2 { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.role-greeting-text p  { font-size: 13px; opacity: 0.8; }

/* ── Empty State with CTA ── */
.empty-state-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--primary-light);
  color: #fff;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
  margin-top: 4px;
}
.empty-state-cta:hover { background: var(--primary); }

/* ── Error State with Retry ── */
.load-error {
  text-align: center;
  padding: 32px 24px;
}
.load-error-icon { font-size: 32px; margin-bottom: 10px; }
.load-error-msg { font-size: 13px; color: var(--text-secondary); margin-bottom: 14px; }
.retry-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 18px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
  font-family: inherit;
  font-weight: 600;
}
.retry-btn:hover { border-color: var(--primary-light); color: var(--primary-light); }

/* ── Material Request Status Badges ── */
.badge-falta_info        { background: #fef3c7; color: #b45309; }
.badge-aguardando        { background: #e0f2fe; color: #0369a1; }
.badge-pendiente_admin   { background: #f3e8ff; color: #7c3aed; }
.badge-autopedido        { background: #f1f5f9; color: #475569; }
.badge-requiere_compra   { background: #dbeafe; color: #1d4ed8; }
.badge-pedido_proveedor  { background: #e0f2fe; color: #0369a1; }
.badge-listo_retiro      { background: #dcfce7; color: #15803d; }
.badge-enviado_obra      { background: #dcfce7; color: #15803d; }
.badge-recibido_parcial  { background: #fef3c7; color: #b45309; }
.badge-recibido_total    { background: #dcfce7; color: #15803d; }
.badge-en_reclamo        { background: #fee2e2; color: #dc2626; }

/* ── Tablet (medium screens) ── */
@media (max-width: 1024px) {
  :root { --sidebar-width: 230px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ── Mobile — Primary breakpoint ── */
@media (max-width: 768px) {
  /* Layout */
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) 1fr;
  }

  /* Sidebar → drawer */
  .sidebar {
    position: fixed;
    left: calc(-1 * var(--sidebar-width) - 24px);
    top: 0;
    height: 100dvh;
    z-index: 100;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    width: var(--sidebar-width);
  }
  .sidebar.open {
    left: 0;
    box-shadow: 8px 0 32px rgba(0,0,0,0.3);
  }

  /* Topbar */
  .topbar { grid-column: 1; padding: 0 14px; gap: 10px; }
  .topbar-breadcrumb { display: none; }
  .topbar-title { font-size: 15px; }

  /* Content */
  .main-content { padding: 14px; padding-bottom: 80px; overflow-x: hidden; }

  /* Show mobile nav */
  .hamburger-btn { display: flex; }
  .bottom-nav { display: flex; }

  /* Grids */
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }

  /* Cards */
  .card { padding: 14px; }
  .kpi-card { padding: 14px 16px; }
  .kpi-value { font-size: 22px; }

  /* Tables */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 480px; }

  /* Modals → slide up */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal, .modal-lg, .modal-xl {
    max-width: 100%;
    width: 100%;
    max-height: 92dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .modal-header { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

  /* Toast: push above bottom nav */
  .toast-container { bottom: 76px; right: 12px; left: 12px; }
  .toast { max-width: 100%; }

  /* Agent movement items stack on mobile */
  .agent-movement-item { flex-direction: column !important; gap: 10px !important; }
  .agent-movement-item > div:last-child { flex-wrap: wrap !important; justify-content: flex-start !important; }

  /* Split layouts become single column */
  .split-layout { grid-template-columns: 1fr !important; }

  /* Quick actions */
  .quick-actions-grid { grid-template-columns: repeat(2, 1fr); }

  /* Hide role greeting emoji on very small */
  .role-greeting::after { display: none; }

  /* Filters bar wraps nicely */
  .filters-bar { flex-wrap: wrap; gap: 8px; }
  .search-box { min-width: 100%; max-width: 100%; }

  /* Topbar actions: hide secondary buttons, keep primary */
  .topbar-actions .btn-outline.btn-sm { display: none; }
}

/* ── Small mobile ── */
@media (max-width: 480px) {
  .main-content { padding: 10px; padding-bottom: 80px; }
  .kpi-value { font-size: 20px; }
  .kpi-grid { gap: 8px; }
  html { font-size: 15px; }
}

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  animation: slideUp 0.3s ease;
}

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

.login-logo .logo-icon-lg {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(37,99,168,0.4);
}

.login-logo h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
}

.login-logo p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Obra detail tabs  ── */
.project-header-card {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.project-header-card::after {
  content: '🏗️';
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 96px;
  opacity: 0.08;
}

.project-header-card .project-code {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 4px;
}

.project-header-card h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
}

.project-header-card .project-meta {
  display: flex;
  gap: 20px;
  font-size: 13px;
  opacity: 0.8;
  flex-wrap: wrap;
}

.project-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.project-kpi-item {
  background: rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 10px 14px;
}

.project-kpi-item .label { font-size: 11px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.5px; }
.project-kpi-item .value { font-size: 18px; font-weight: 800; margin-top: 2px; }

/* ── NUEVAS CLASES PARA EL REDISEÑO DE UX/UI ── */

/* Semáforos y Estados de Salud */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-indicator-sana { background: #dcfce7; color: #16a34a; }
.status-indicator-atencion { background: #fef3c7; color: #d97706; }
.status-indicator-critica { background: #fee2e2; color: #dc2626; }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot-green { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.status-dot-yellow { background: #f59e0b; box-shadow: 0 0 8px #f59e0b; }
.status-dot-red { background: #ef4444; box-shadow: 0 0 8px #ef4444; }

/* Dashboard & Obras Cards Grid */
.project-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.project-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.project-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.project-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.project-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.project-card-client {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.project-card-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
  background: var(--bg);
  padding: 10px;
  border-radius: 8px;
}

.project-card-metrics-item {
  display: flex;
  flex-direction: column;
}

.project-card-metrics-item .label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.project-card-metrics-item .value {
  font-size: 13px;
  font-weight: 700;
}

.project-card-alerts {
  margin-top: 12px;
  font-size: 12px;
}

.project-card-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Panel "Qué necesita atención" */
.attention-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.attention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow-sm);
}

.attention-item-critical {
  border-left-color: #ef4444;
}

.attention-item-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.attention-item-icon {
  font-size: 20px;
}

.attention-item-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ══════════════════════════════════════════════════════════════
   VISUAL REDESIGN v3 — Premium Design System
   ══════════════════════════════════════════════════════════════ */

/* ── Fix sidebar-overlay visibility class ── */
.sidebar-overlay.visible { display: block; }

/* ── Page entry animation ── */
.main-content {
  animation: pageIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Background upgrade ── */
body { background: #f0f4f3; }

/* ── Card upgrade ── */
.card {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: box-shadow 0.22s ease, transform 0.22s ease;
}
.card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.09);
  transform: translateY(-1px);
}

/* Card header tighter */
.card-header { margin-bottom: 14px; }
.card-title { font-size: 14.5px; font-weight: 700; }

/* Card accent border variant */
.card-accent { border-top: 3px solid var(--primary-light); }
.card-accent-warning { border-top: 3px solid var(--accent); }
.card-accent-danger { border-top: 3px solid #ef4444; }

/* ── KPI card upgrade ── */
.kpi-card {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.22s ease, transform 0.22s ease;
}
.kpi-card::before {
  height: 4px; /* thicker accent bar */
}
.kpi-card:hover {
  box-shadow: 0 8px 28px rgba(0,0,0,0.10);
  transform: translateY(-2px);
}

/* Icon: bigger, visible, with soft background glow */
.kpi-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  opacity: 1;
  background: rgba(255,255,255,0.6);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.06);
  backdrop-filter: blur(4px);
}

.kpi-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 6px;
}
.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.kpi-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Topbar upgrade ── */
.topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(0,0,0,0.03);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.topbar-title { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.topbar-breadcrumb { font-size: 12px; }

/* ── Sidebar upgrade ── */
.sidebar { box-shadow: 2px 0 20px rgba(0,0,0,0.12); }

/* Active item: left accent pill */
.nav-item { border-radius: 8px; }
.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-weight: 700;
}
.nav-item.active::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 2px 0 0 2px;
}
.nav-item { position: relative; }

/* Sidebar section label slightly bigger */
.sidebar-section-label {
  font-size: 9.5px;
  letter-spacing: 1.4px;
  color: rgba(203, 213, 225, 0.5);
  margin-bottom: 6px;
}

/* ── Table upgrade ── */
.data-table tbody td {
  padding: 14px 14px;
  vertical-align: middle;
}
.data-table tbody tr:hover {
  background: #f0fdf4; /* primary green tint on hover */
  cursor: pointer;
}
/* Sticky table header */
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 11px;
  letter-spacing: 0.7px;
  background: #f8fafc;
}
.table-wrapper { border-radius: 10px; }

/* ── Badge upgrade — dot indicator ── */
.badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px 3px 7px;
  border-radius: 6px;
  gap: 5px;
  letter-spacing: 0.1px;
}
.badge::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.65;
  flex-shrink: 0;
  margin-right: 1px;
}

/* Functional badge classes */
.badge-success   { background: #f0fdf4; color: #15803d; }
.badge-warning   { background: #fefce8; color: #a16207; }
.badge-danger    { background: #fef2f2; color: #b91c1c; }
.badge-info      { background: #eff6ff; color: #1d4ed8; }
.badge-secondary { background: #f8fafc; color: #64748b; }

/* ── Button upgrade ── */
.btn {
  font-weight: 600;
  letter-spacing: 0.1px;
  border-radius: 8px;
  transition: all 0.18s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary-light);
  box-shadow: 0 2px 8px rgba(22, 158, 76, 0.3);
}
.btn-primary:hover {
  background: var(--primary);
  box-shadow: 0 4px 14px rgba(22, 158, 76, 0.4);
}
.btn-outline:hover {
  border-color: var(--primary-light);
  color: var(--primary);
  background: #f0fdf4;
}

/* ── Quick action cards ── */
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.quick-action-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 22px 16px 18px;
  text-align: center;
  transition: all 0.2s ease;
  cursor: pointer;
  color: var(--text-primary);
  position: relative;
  overflow: hidden;
}
.quick-action-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  opacity: 0;
  transition: opacity 0.2s;
}
.quick-action-card > * { position: relative; z-index: 1; }
.quick-action-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(13, 114, 54, 0.15);
}
.quick-action-card:hover::before { opacity: 0.04; }
.quick-action-card:active { transform: scale(0.97); }
.quick-action-card div:first-child {
  font-size: 30px;
  margin-bottom: 10px;
  display: block;
}
.quick-action-card div:nth-child(2) {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.quick-action-card div:nth-child(3) {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Role greeting upgrade ── */
.role-greeting {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  border-radius: 14px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  box-shadow: 0 4px 24px rgba(7, 71, 32, 0.3);
  position: relative;
  overflow: hidden;
}
.role-greeting::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  pointer-events: none;
}

/* ── Agent inbox upgrade ── */
.agent-inbox-container {
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.agent-inbox-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.agent-inbox-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}
.agent-badge-count {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 20px;
  min-width: 22px;
  text-align: center;
}
.agent-movement-list { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

/* Agent movement item — card style */
.agent-movement-item {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: box-shadow 0.2s, transform 0.15s;
}
.agent-movement-item:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.agent-movement-item.posible-duplicado { border-left-color: #ef4444; background: #fef2f2; }
.agent-movement-item.baja-confianza    { border-left-color: #f59e0b; background: #fffbeb; }
.movement-meta-info { flex: 1; min-width: 0; }
.movement-meta-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

/* Source badges */
.movement-source-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 5px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.movement-source-badge.telegram  { background: #dbeafe; color: #1e40af; }
.movement-source-badge.whatsapp { background: #dcfce7; color: #15803d; }
.movement-source-badge.web      { background: #f3e8ff; color: #7c3aed; }

.movement-status-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 5px;
}
.movement-status-badge.pendiente     { background: #fefce8; color: #a16207; }
.movement-status-badge.confianza-baja{ background: #fef2f2; color: #b91c1c; }
.movement-status-badge.duplicado     { background: #fef2f2; color: #b91c1c; }

/* ── Status list items ── */
.status-list { display: flex; flex-direction: column; }
.status-list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}
.status-list-item:last-child { border-bottom: none; }
.status-list-item:hover { background: #f8fafc; }
.sli-bar { width: 4px; min-height: 32px; align-self: stretch; border-radius: 4px; flex-shrink: 0; background: var(--item-color, var(--primary)); }
.sli-body { flex: 1; min-width: 0; }
.sli-title { font-size: 13.5px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sli-sub   { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.sli-right { text-align: right; flex-shrink: 0; }

/* ── Empty state upgrade ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 52px 24px;
  text-align: center;
}
.empty-state-icon { font-size: 48px; margin-bottom: 14px; opacity: 0.55; }
.empty-state-title { font-size: 15px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state-desc  { font-size: 13px; color: var(--text-muted); max-width: 280px; margin-bottom: 20px; }
.empty-state-cta   { margin-top: 4px; }

/* ── Error / retry state ── */
.load-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 20px;
  color: var(--text-muted);
  font-size: 13.5px;
  flex-wrap: wrap;
  text-align: center;
}
.retry-btn {
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 8px;
  color: var(--primary);
  border-color: var(--primary-light);
}
.retry-btn:hover { background: #f0fdf4; color: var(--primary); border-color: var(--primary); }

/* ── Status dot (inline) ── */
.status-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  flex-shrink: 0;
}
.status-dot-activa     { background: var(--status-activa); }
.status-dot-presupuesto{ background: var(--status-presupuesto); }
.status-dot-pausada    { background: var(--status-pausada); }
.status-dot-finalizada { background: var(--status-finalizada); }
.status-dot-cancelada  { background: var(--status-cancelada); }

/* ── Toast: mobile above bottom nav ── */
@media (max-width: 768px) {
  .toast-container { bottom: 76px; right: 12px; left: 12px; }
  .toast { max-width: 100%; font-size: 13px; }
}

/* ── Focus ring upgrade (accessible) ── */
:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Material request status badges (additional) ── */
.badge-falta_info,
.badge-pendiente_informacion { background: #fefce8; color: #a16207; }
.badge-aguardando,
.badge-esperando_respuesta_usuario { background: #eff6ff; color: #1d4ed8; }
.badge-revision,
.badge-pendiente_revision_admin { background: #fef3c7; color: #92400e; }
.badge-sin_accion,
.badge-autopedido_sin_accion { background: #f8fafc; color: #64748b; }
.badge-en_compra,
.badge-requiere_compra { background: #f3e8ff; color: #7c3aed; }
.badge-recibido_total,
.badge-recibido { background: #dcfce7; color: #15803d; }

/* ── Mobile layout for main content ── */
@media (max-width: 768px) {
  .main-content { padding: 16px 14px 80px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 12px; }
  .quick-actions-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .quick-action-card { padding: 18px 12px 14px; }
  .quick-action-card div:first-child { font-size: 26px; }
  .quick-action-card div:nth-child(2) { font-size: 13px; }
  .card { border-radius: 12px; padding: 16px; }
  .kpi-card { padding: 16px; }
  .kpi-value { font-size: 26px; }
  .kpi-icon { width: 36px; height: 36px; font-size: 18px; }
  .role-greeting { padding: 14px 16px; font-size: 14px; border-radius: 12px; }
  .agent-movement-item { flex-direction: column; }
  .agent-movement-item > div:last-child { width: 100%; justify-content: stretch; }
  .agent-movement-item > div:last-child .btn { flex: 1; }
}

/* ── Tablet layout ── */
@media (max-width: 1024px) and (min-width: 769px) {
  .quick-actions-grid { grid-template-columns: repeat(4, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ── Hover glow on interactive list rows ── */
.hover-row { transition: background 0.15s; }
.hover-row:hover { background: #f0fdf4; }

/* ── Pulse animation for pending items ── */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.badge-pending-pulse::before { animation: pulse-dot 1.8s ease-in-out infinite; }

/* ── Wizard stepper upgrade ── */
.wizard-step-node {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.wizard-step-node.active {
  background: var(--primary-light);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(22, 158, 76, 0.2);
}
.wizard-step-node.completed {
  background: var(--primary);
  color: #fff;
}

/* ── Numeric values ── */
.numeric { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── Form control upgrade ── */
.form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(22, 158, 76, 0.15);
}

/* ── Material request mobile card ── */
.request-card-mobile {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--item-color, var(--primary));
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow 0.2s;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.request-card-mobile:active { transform: scale(0.99); }
.request-card-mobile .rc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.request-card-mobile .rc-material {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.request-card-mobile .rc-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.request-card-mobile .rc-obra {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ── Nuevo pedido quick form (mobile) ── */
.quick-request-form {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  border-radius: 14px;
  padding: 18px;
  color: #fff;
  margin-bottom: 16px;
}
.quick-request-form h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.quick-request-form .form-control {
  background: rgba(255,255,255,0.95);
  border: none;
}
.quick-request-form .btn-accent {
  width: 100%;
  justify-content: center;
  margin-top: 10px;
  font-size: 14px;
  padding: 12px;
  background: var(--accent);
  box-shadow: 0 4px 14px rgba(249, 168, 38, 0.4);
}

/* ── Section divider with label ── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 0 2px;
  margin-bottom: 10px;
  margin-top: 20px;
}

/* ── Smooth scrollbar (Webkit) ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Microcopy descriptivo */
.microcopy {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.2;
}

/* Pipeline visual de Materiales */
.pipeline-flow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0;
  position: relative;
  padding: 0 10px;
}

.pipeline-flow::before {
  content: '';
  position: absolute;
  top: 15px;
  left: 20px;
  right: 20px;
  height: 3px;
  background: #e2e8f0;
  z-index: 1;
}

.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
  position: relative;
  flex: 1;
  text-align: center;
}

.pipeline-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #cbd5e1;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 3px solid #fff;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.pipeline-step.active .pipeline-icon {
  background: var(--primary);
  box-shadow: 0 0 10px rgba(13, 114, 54, 0.4);
}

.pipeline-step.complete .pipeline-icon {
  background: #16a34a;
}

.pipeline-step.incomplete .pipeline-icon {
  background: #f59e0b;
}

.pipeline-label {
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
  color: var(--text-secondary);
  max-width: 100px;
}

.pipeline-step.active .pipeline-label {
  color: var(--primary);
  font-weight: 700;
}

/* Asistentes guiados (Step Wizards) */
.step-wizard {
  display: flex;
  flex-direction: column;
}

.wizard-steps-indicator {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.wizard-indicator-item {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.wizard-indicator-item.active {
  color: var(--primary);
}

.wizard-indicator-item.active .step-num {
  background: var(--primary);
  color: #fff;
}

.step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #cbd5e1;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.step-pane {
  display: none;
  animation: fadeIn 0.25s ease;
}

.step-pane.active {
  display: block;
}

/* Timeline lateral o integrada de Historial */
.timeline-compact {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-left: 20px;
}

.timeline-compact::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}

.timeline-event-item {
  position: relative;
  padding-bottom: 16px;
}

.timeline-event-item::after {
  content: '';
  position: absolute;
  left: -19px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
  border: 2px solid #fff;
}

.timeline-event-item.important::after {
  background: var(--accent);
}

.timeline-event-item.success::after {
  background: var(--primary-light);
}

.timeline-event-content {
  font-size: 12px;
}

.timeline-event-time {
  font-size: 10px;
  color: var(--text-muted);
}

/* Dropzone files drag-and-drop */
.dropzone-container {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.2s ease;
}

.dropzone-container:hover, .dropzone-container.drag-over {
  border-color: var(--primary-light);
  background: #fff;
}

.dropzone-icon {
  font-size: 32px;
  margin-bottom: 10px;
  color: var(--text-muted);
}

.dropzone-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.dropzone-input {
  display: none;
}

/* ============================================================
   Nuevas Adiciones de Diseño UX/UI (GV Construcciones)
   ============================================================ */

/* Semáforos y Tarjetas de Obra */
.obras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.obra-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.obra-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary);
}

.obra-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.obra-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.obra-card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.obra-card-client {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Semáforo de Estado */
.health-traffic-light {
  display: flex;
  gap: 6px;
  align-items: center;
}

.traffic-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e2e8f0;
  display: inline-block;
}

.traffic-dot.red { background: #ef4444; box-shadow: 0 0 8px #ef4444; }
.traffic-dot.yellow { background: #f59e0b; box-shadow: 0 0 8px #f59e0b; }
.traffic-dot.green { background: #10b981; box-shadow: 0 0 8px #10b981; }

.obra-card-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
  padding: 12px 0;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
}

.kpi-item {
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.kpi-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.kpi-value.danger { color: #ef4444; }
.kpi-value.success { color: #10b981; }

/* Novedades del Agente (Widget Dashboard) */
.agent-inbox-container {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.agent-inbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.agent-inbox-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-badge-count {
  background: #ef4444;
  color: white;
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
}

.agent-movement-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agent-movement-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #f8fafc;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  transition: var(--transition);
}

.agent-movement-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.agent-movement-item.posible-duplicado {
  border-left-color: #ef4444;
  background: #fef2f2;
}

.agent-movement-item.baja-confianza {
  border-left-color: #f59e0b;
}

.movement-meta-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  margin-right: 16px;
}

.movement-meta-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.movement-source-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e2e8f0;
  color: var(--text-secondary);
  font-weight: 500;
}

.movement-source-badge.telegram { background: #e0f2fe; color: #0369a1; }
.movement-source-badge.whatsapp { background: #dcfce7; color: #15803d; }
.movement-source-badge.manual { background: #f3e8ff; color: #6b21a8; }

.movement-concept-txt {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.movement-meta-bottom {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  gap: 12px;
}

.movement-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}

.movement-status-badge.duplicado { background: #fee2e2; color: #ef4444; }
.movement-status-badge.confianza-baja { background: #fef3c7; color: #d97706; }
.movement-status-badge.pendiente { background: #f1f5f9; color: #475569; }

/* 5 Tabs Detail View */
.tab-row-container {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  gap: 8px;
}

.detail-tab-btn {
  padding: 12px 20px;
  background: transparent;
  border: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  position: relative;
  transition: var(--transition);
}

.detail-tab-btn:hover {
  color: var(--primary);
}

.detail-tab-btn.active {
  color: var(--primary);
}

.detail-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 60px 40px;
  background: #ffffff;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  margin: 20px 0;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-state-desc {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 400px;
  margin: 0 auto 20px;
}

/* Step-by-Step Assistants / Wizards */
.wizard-stepper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  position: relative;
}

.wizard-stepper::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border);
  z-index: 1;
}

.wizard-step-node {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-secondary);
  position: relative;
  z-index: 2;
  transition: var(--transition);
}

.wizard-step-node.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.wizard-step-node.completed {
  border-color: var(--primary);
  background: #ffffff;
  color: var(--primary);
}

.wizard-pane {
  display: none;
}

.wizard-pane.active {
  display: block;
}

.wizard-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}



/* ══════════════════════════════════════════════════════════════
   VISUAL REDESIGN v3 + DASHBOARD COMPONENTS
   ══════════════════════════════════════════════════════════════ */

/* ── Sidebar overlay: usa .visible (no .active) ── */
.sidebar-overlay.visible { display: block; }

/* ── Page entry animation ── */
.main-content { animation: pageIn 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Background más cálido ── */
body { background: #f0f4f2; }

/* ── Card upgrade ── */
.card {
  background: #ffffff;
  border: 1px solid rgba(226,232,240,0.85);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: box-shadow 0.22s ease, transform 0.22s ease;
}
.card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.09); transform: translateY(-1px); }
.card-title { font-size: 14.5px; font-weight: 700; }

/* ── KPI card upgrade ── */
.kpi-card {
  background: #ffffff;
  border: 1px solid rgba(226,232,240,0.85);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.kpi-card::before { height: 4px; }
.kpi-card:hover { box-shadow: 0 8px 28px rgba(0,0,0,0.10); transform: translateY(-2px); }
.kpi-icon {
  position: absolute; top: 14px; right: 14px;
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; opacity: 1;
  background: rgba(255,255,255,0.7);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.06);
}
.kpi-value { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 11px; font-weight: 700; letter-spacing: 0.7px; }

/* ── Topbar ── */
.topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(0,0,0,0.03);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.topbar-title { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }

/* ── Sidebar ── */
.sidebar { box-shadow: 2px 0 20px rgba(0,0,0,0.14); }
.nav-item { position: relative; border-radius: 8px; }
.nav-item.active { background: rgba(255,255,255,0.14); font-weight: 700; }
.nav-item.active::after {
  content: ''; position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; background: var(--accent); border-radius: 2px 0 0 2px;
}
.sidebar-section-label { font-size: 9.5px; letter-spacing: 1.4px; color: rgba(203,213,225,0.5); margin-bottom: 6px; }

/* ── Table upgrade ── */
.data-table tbody td { padding: 14px 14px; }
.data-table tbody tr:hover { background: #f0fdf4; }
.data-table thead th { position: sticky; top: 0; z-index: 1; font-size: 11px; letter-spacing: 0.7px; }
.table-wrapper { border-radius: 10px; }

/* ── Badge: dot indicator ── */
.badge { font-size: 11.5px; font-weight: 700; padding: 3px 9px 3px 7px; border-radius: 6px; gap: 5px; }
.badge::before {
  content: ''; display: inline-block; width: 5px; height: 5px;
  border-radius: 50%; background: currentColor; opacity: 0.65; flex-shrink: 0;
}
.badge-success   { background: #f0fdf4; color: #15803d; }
.badge-warning   { background: #fefce8; color: #a16207; }
.badge-danger    { background: #fef2f2; color: #b91c1c; }
.badge-info      { background: #eff6ff; color: #1d4ed8; }
.badge-secondary { background: #f8fafc; color: #64748b; }

/* ── Button upgrade ── */
.btn { border-radius: 8px; transition: all 0.18s ease; }
.btn:active { transform: scale(0.97); }
.btn-primary { box-shadow: 0 2px 8px rgba(22,158,76,0.28); }
.btn-primary:hover { background: var(--primary); box-shadow: 0 4px 14px rgba(22,158,76,0.4); }
.btn-outline:hover { border-color: var(--primary-light); color: var(--primary); background: #f0fdf4; }

/* ── Focus ring ── */
:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; border-radius: 4px; }
.form-control:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(22,158,76,0.15); }

/* ── Empty state upgrade ── */
.empty-state { display: flex; flex-direction: column; align-items: center; padding: 52px 24px; text-align: center; }
.empty-state-icon { font-size: 48px; margin-bottom: 14px; opacity: 0.55; }
.empty-state-title { font-size: 15px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state-cta { margin-top: 8px; }

/* ── Error / retry state ── */
.load-error {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 28px 20px; color: var(--text-muted); font-size: 13.5px; flex-wrap: wrap;
}
.retry-btn { font-size: 12.5px; padding: 7px 14px; border-radius: 8px; color: var(--primary); border-color: var(--primary-light); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   DASHBOARD — OBRA CARDS
   ══════════════════════════════════════════════════════════════ */

/* Layout 2 columnas dashboard */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}

/* Grid de obras */
.obras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Obra card individual */
.obra-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.obra-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-light), var(--primary-dark));
}
.obra-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.12);
  border-color: var(--primary-light);
}
.obra-card:active { transform: scale(0.99); }

.obra-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.obra-card-title  { font-size: 15px; font-weight: 700; color: var(--text-primary); line-height: 1.3; }
.obra-card-client { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Mini KPIs dentro de la card */
.obra-card-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 14px;
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 10px;
}
.kpi-item { display: flex; flex-direction: column; gap: 2px; }
.kpi-item .kpi-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 0; }
.kpi-item .kpi-value { font-size: 14px; font-weight: 800; color: var(--text-primary); font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }
.kpi-item .kpi-value.danger  { color: #dc2626; }
.kpi-item .kpi-value.success { color: #15803d; }

/* Traffic light de salud */
.health-traffic-light {
  display: flex;
  gap: 5px;
  align-items: center;
  background: rgba(0,0,0,0.04);
  padding: 5px 8px;
  border-radius: 20px;
}
.traffic-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.traffic-dot:hover { transform: scale(1.4); }
.traffic-dot.green  { background: #22c55e; box-shadow: 0 0 5px rgba(34,197,94,0.5); }
.traffic-dot.yellow { background: #f59e0b; box-shadow: 0 0 5px rgba(245,158,11,0.5); }
.traffic-dot.red    { background: #ef4444; box-shadow: 0 0 5px rgba(239,68,68,0.5); }
.traffic-dot.grey   { background: #cbd5e1; }

/* Filter status buttons */
.filter-status-btn { border-radius: 20px; padding: 6px 14px; font-size: 12px; font-weight: 600; transition: all 0.15s; }
.filter-status-btn.active {
  background: var(--primary-light);
  color: #fff;
  border-color: var(--primary-light);
  box-shadow: 0 2px 8px rgba(22,158,76,0.28);
}
.filter-status-btn:hover:not(.active) { background: #f0fdf4; border-color: var(--primary-light); color: var(--primary); }

/* ── Agent inbox ── */
.agent-inbox-container {
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  padding: 0;
  position: sticky;
  top: calc(var(--topbar-height) + 16px);
  max-height: calc(100vh - var(--topbar-height) - 48px);
  overflow-y: auto;
}
.agent-inbox-header {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  position: sticky;
  top: 0;
  z-index: 2;
}
.agent-inbox-title { font-size: 14.5px; font-weight: 700; margin: 0; }
.agent-badge-count {
  background: #ef4444; color: #fff;
  font-size: 10.5px; font-weight: 800;
  padding: 2px 7px; border-radius: 20px; min-width: 20px; text-align: center;
}
.agent-movement-list { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

/* Movement item card */
.agent-movement-item {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: box-shadow 0.2s, transform 0.15s;
}
.agent-movement-item:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); transform: translateY(-1px); }
.agent-movement-item.posible-duplicado { border-left-color: #ef4444; background: #fff8f8; }
.agent-movement-item.baja-confianza    { border-left-color: #f59e0b; background: #fffdf0; }
.movement-meta-info { flex: 1; min-width: 0; }
.movement-meta-top { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: 6px; }
.movement-source-badge {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 800;
  padding: 2px 7px; border-radius: 4px;
  letter-spacing: 0.4px; text-transform: uppercase;
}
.movement-source-badge.telegram { background: #dbeafe; color: #1e40af; }
.movement-source-badge.whatsapp { background: #dcfce7; color: #15803d; }
.movement-status-badge {
  display: inline-flex; align-items: center;
  font-size: 10.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 4px;
}
.movement-status-badge.pendiente      { background: #fefce8; color: #a16207; }
.movement-status-badge.confianza-baja { background: #fef2f2; color: #b91c1c; }
.movement-status-badge.duplicado      { background: #fef2f2; color: #b91c1c; }
.movement-concept-txt { font-size: 12.5px; color: var(--text-secondary); }

/* ── Quick actions ── */
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.quick-action-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 20px 14px 16px;
  text-align: center;
  transition: all 0.2s ease;
  cursor: pointer;
  color: var(--text-primary);
  position: relative;
  overflow: hidden;
}
.quick-action-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(13,114,54,0.13);
  color: var(--primary);
}
.quick-action-card:active { transform: scale(0.97); }

/* ── Role greeting ── */
.role-greeting {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 55%, var(--primary-light) 100%);
  border-radius: 14px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  box-shadow: 0 4px 24px rgba(7,71,32,0.25);
  position: relative;
  overflow: hidden;
}
.role-greeting::after {
  content: '';
  position: absolute; top: -30%; right: -5%;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}

/* ── Stats section (admin) ── */
.corporate-stats-section { margin-top: 24px; }
.stats-section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-muted);
  margin-bottom: 16px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}

/* ── Toast: sobre bottom nav en mobile ── */
@media (max-width: 768px) {
  .toast-container { bottom: 74px; right: 12px; left: 12px; }
  .toast { max-width: 100%; font-size: 13px; }

  /* Dashboard mobile */
  .detail-grid { grid-template-columns: 1fr !important; }
  .agent-inbox-container { position: static; max-height: none; }
  .obras-grid { grid-template-columns: 1fr; }
  .quick-actions-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .quick-action-card { padding: 16px 12px 14px; }
  .main-content { padding: 14px 14px 80px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 12px; }
  .kpi-value { font-size: 26px; }
  .kpi-icon { width: 38px; height: 38px; font-size: 18px; }
  .card, .kpi-card { border-radius: 12px; }
  .role-greeting { padding: 14px 16px; font-size: 14px; border-radius: 12px; }

  /* Obra cards en mobile: full width con más info visible */
  .obra-card { border-radius: 12px; padding: 16px; }
  .obra-card-kpis { grid-template-columns: repeat(2, 1fr); }

  /* Agent inbox mobile: items stack */
  .agent-movement-item { flex-direction: column; }
  .agent-movement-item > div:last-child { display: flex; gap: 6px; width: 100%; }
  .agent-movement-item > div:last-child .btn { flex: 1; font-size: 12px; padding: 8px 6px; }
}

@media (max-width: 1200px) and (min-width: 769px) {
  .detail-grid { grid-template-columns: 1fr 340px; }
  .obras-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* ── Material request status badges adicionales ── */
.badge-pendiente_informacion   { background: #fefce8; color: #a16207; }
.badge-esperando_respuesta_usuario { background: #eff6ff; color: #1d4ed8; }
.badge-pendiente_revision_admin{ background: #fef3c7; color: #92400e; }
.badge-autopedido_sin_accion   { background: #f8fafc; color: #64748b; }
.badge-requiere_compra         { background: #f3e8ff; color: #7c3aed; }
.badge-recibido_total          { background: #dcfce7; color: #15803d; }

/* ══════════════════════════════════════════════════════
   OBRAS GRID & CARDS (dashboard)
   ══════════════════════════════════════════════════════ */
.obras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.obra-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
}
.obra-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.obra-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-light), var(--primary-dark));
}
.obra-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 2px;
  line-height: 1.3;
}
.obra-card-client {
  font-size: 12px;
  color: var(--text-muted);
}
.obra-card-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 14px;
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 10px;
}
.kpi-item .kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.kpi-item .kpi-value {
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  margin-top: 1px;
}

/* Health traffic lights */
.health-traffic-light {
  display: flex; gap: 5px; align-items: center;
  background: rgba(0,0,0,0.04);
  padding: 5px 8px;
  border-radius: 20px;
}
.traffic-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.traffic-dot.green  { background: #22c55e; box-shadow: 0 0 5px rgba(34,197,94,0.5); }
.traffic-dot.yellow { background: #f59e0b; box-shadow: 0 0 5px rgba(245,158,11,0.5); }
.traffic-dot.red    { background: #ef4444; box-shadow: 0 0 5px rgba(239,68,68,0.5); }

/* Filter status pill buttons */
.filter-status-btn { border-radius: 20px; }
.filter-status-btn.active {
  background: var(--primary-light);
  color: #fff;
  border-color: var(--primary-light);
}

/* Agent inbox sticky column */
.agent-inbox-container {
  position: sticky;
  top: calc(var(--topbar-height, 60px) + 16px);
  max-height: calc(100vh - var(--topbar-height, 60px) - 48px);
  overflow-y: auto;
}

/* Detail grid (dashboard 2-col) */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}
.detail-grid > * {
  min-width: 0;
}

/* Role greeting */
.role-greeting {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--bg-card);
  border-left: 3px solid var(--primary-light);
  border-radius: 0 8px 8px 0;
}

@media (max-width: 768px) {
  .obras-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr !important; }
  .agent-inbox-container { position: static; max-height: none; }
  #topbar-date { display: none !important; }
}

/* ── kpi-value color variants (obras listing) ── */
.kpi-value.danger  { color: #dc2626; }
.kpi-value.success { color: #16a34a; }

/* ── obra-card-header layout ── */
.obra-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

/* ── Global split layouts ── */
.split-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
}
.split-layout-1-2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
}
.split-layout-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}
.split-layout-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.pr-item-row {
  display: grid;
  grid-template-columns: 3fr 1fr 1.5fr 1.5fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

@media (max-width: 768px) {
  .split-layout, .split-layout-1-2, .split-layout-2-1, .split-layout-3 {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
  .pr-item-row {
    grid-template-columns: 1fr !important;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    margin-bottom: 12px;
  }
  .modal-body div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  /* Touch target sizes on mobile */
  .btn {
    min-height: 44px !important;
    padding: 12px 20px !important;
  }
  .btn-sm {
    min-height: 40px !important;
    padding: 10px 16px !important;
  }
}
