/* ===================================================================
   DIFAB — Sistema de Gestión ERP/CRM
   Design System & Styles
   Palette: Orange / White / Black
   =================================================================== */

/* ---- CSS Custom Properties ---- */
:root {
  /* Orange Scale */
  --orange-50:  #fff7ed;
  --orange-100: #ffedd5;
  --orange-200: #fed7aa;
  --orange-300: #fdba74;
  --orange-400: #fb923c;
  --orange-500: #f97316;
  --orange-600: #ea580c;
  --orange-700: #c2410c;
  --orange-800: #9a3412;
  --orange-900: #7c2d12;

  /* Neutrals */
  --white:       #ffffff;
  --neutral-50:  #fafafa;
  --neutral-100: #f5f5f5;
  --neutral-200: #e5e5e5;
  --neutral-300: #d4d4d4;
  --neutral-400: #a3a3a3;
  --neutral-500: #737373;
  --neutral-600: #525252;
  --neutral-700: #404040;
  --neutral-800: #262626;
  --neutral-900: #171717;
  --black:       #0a0a0a;

  /* Semantic */
  --green-100: #dcfce7;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --blue-500:  #3b82f6;
  --purple-500:#8b5cf6;
  --red-500:   #ef4444;

  /* Surfaces */
  --surface-bg:     #f8f8f8;
  --surface-card:   #ffffff;
  --surface-hover:  #fafafa;
  --surface-sidebar:#0a0a0a;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.06);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.06);
  --shadow-xl:  0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.06);
  --shadow-glow:0 0 20px rgba(249,115,22,0.15);

  /* Spacing */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 250ms;
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--surface-bg);
  color: var(--neutral-800);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--neutral-300); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--neutral-400); }

/* ===================================================================
   SIDEBAR
   =================================================================== */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--surface-sidebar);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: width var(--duration) var(--ease), transform var(--duration) var(--ease);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--orange-500);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon .material-icons-round {
  font-size: 22px;
  color: var(--white);
}

.logo-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .user-info,
.sidebar.collapsed .user-menu-btn {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.logo-name {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--orange-400), var(--orange-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-sub {
  font-size: 0.7rem;
  color: var(--neutral-400);
  font-weight: 400;
  letter-spacing: 0.5px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--neutral-400);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--duration) var(--ease);
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  color: var(--white);
  background: rgba(255,255,255,0.08);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--neutral-500);
  padding: 8px 12px 4px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity var(--duration) var(--ease);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--neutral-400);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: all var(--duration) var(--ease);
  position: relative;
  white-space: nowrap;
  cursor: pointer;
}

.nav-item .material-icons-round {
  font-size: 20px;
  flex-shrink: 0;
}

.nav-item:hover {
  color: var(--white);
  background: rgba(255,255,255,0.06);
}

.nav-item.active {
  color: var(--white);
  background: rgba(249, 115, 22, 0.15);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--orange-500);
  border-radius: 0 4px 4px 0;
}

.nav-item.active .material-icons-round {
  color: var(--orange-400);
}

.nav-badge {
  margin-left: auto;
  background: var(--orange-500);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
  transition: opacity var(--duration) var(--ease);
}

.nav-label {
  transition: opacity var(--duration) var(--ease);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

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

.user-card:hover {
  background: rgba(255,255,255,0.06);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity var(--duration) var(--ease), width var(--duration) var(--ease);
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.user-role {
  font-size: 0.7rem;
  color: var(--neutral-500);
}

.user-menu-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--neutral-500);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--duration) var(--ease);
  flex-shrink: 0;
}

.user-menu-btn:hover {
  color: var(--white);
  background: rgba(255,255,255,0.08);
}

/* ===================================================================
   MAIN CONTENT
   =================================================================== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  transition: margin-left var(--duration) var(--ease);
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed);
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--neutral-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.85);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--neutral-600);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--neutral-400);
  font-size: 0.9rem;
}

.breadcrumb .material-icons-round { font-size: 18px; }
.breadcrumb-sep { font-size: 0.75rem; }
.breadcrumb-current {
  color: var(--neutral-800);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--neutral-100);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  border: 1px solid transparent;
  transition: all var(--duration) var(--ease);
}

.search-box:focus-within {
  background: var(--white);
  border-color: var(--orange-300);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.1);
}

.search-box .material-icons-round {
  font-size: 18px;
  color: var(--neutral-400);
}

.search-box input {
  border: none;
  background: none;
  outline: none;
  font-size: 0.85rem;
  width: 200px;
  font-family: inherit;
  color: var(--neutral-800);
}

.search-box input::placeholder {
  color: var(--neutral-400);
}

.topbar-btn {
  background: none;
  border: none;
  color: var(--neutral-500);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  position: relative;
  transition: all var(--duration) var(--ease);
}

.topbar-btn:hover {
  color: var(--neutral-800);
  background: var(--neutral-100);
}

.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--orange-500);
  border-radius: 50%;
  border: 2px solid var(--white);
  animation: pulse-dot 2s ease infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* ===================================================================
   PAGES
   =================================================================== */
.page {
  display: none;
  padding: 24px;
  animation: fadeIn 0.3s var(--ease);
}

.page.active {
  display: block;
}

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

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--black);
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--neutral-500);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===================================================================
   BUTTONS
   =================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
}

.btn .material-icons-round { font-size: 18px; }

.btn-primary {
  background: var(--orange-500);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(249,115,22,0.3);
}

.btn-primary:hover {
  background: var(--orange-600);
  box-shadow: 0 4px 12px rgba(249,115,22,0.4);
  transform: translateY(-1px);
}

.btn-outline {
  background: var(--white);
  color: var(--neutral-700);
  border: 1px solid var(--neutral-200);
}

.btn-outline:hover {
  border-color: var(--orange-300);
  color: var(--orange-600);
  background: var(--orange-50);
}

.btn-dark {
  background: var(--black);
  color: var(--white);
}

.btn-dark:hover {
  background: var(--neutral-800);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--neutral-400);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--duration) var(--ease);
}

.icon-btn:hover {
  color: var(--orange-500);
  background: var(--orange-50);
}

/* Filter buttons */
.filter-group {
  display: flex;
  background: var(--neutral-100);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.filter-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--neutral-500);
  font-family: inherit;
  transition: all var(--duration) var(--ease);
}

.filter-btn.active {
  background: var(--white);
  color: var(--neutral-800);
  box-shadow: var(--shadow-sm);
}

.filter-btn:hover:not(.active) {
  color: var(--neutral-700);
}

/* ===================================================================
   BADGES
   =================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-production  { background: var(--orange-100); color: var(--orange-700); }
.badge-cutting     { background: #fef3c7; color: #92400e; }
.badge-design      { background: #e0e7ff; color: #3730a3; }
.badge-qa          { background: var(--green-100); color: var(--green-600); }
.badge-quote       { background: var(--neutral-100); color: var(--neutral-600); }
.badge-dispatch    { background: #f3e8ff; color: #7c3aed; }

/* ===================================================================
   KPI CARDS
   =================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  border: 1px solid var(--neutral-200);
  transition: all var(--duration) var(--ease);
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  border-color: transparent;
  transform: translateY(-2px);
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon .material-icons-round { font-size: 24px; }

.kpi-orange { background: var(--orange-100); color: var(--orange-600); }
.kpi-green  { background: var(--green-100);  color: var(--green-600); }
.kpi-blue   { background: #dbeafe; color: var(--blue-500); }
.kpi-purple { background: #ede9fe; color: var(--purple-500); }

.kpi-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-label {
  font-size: 0.78rem;
  color: var(--neutral-500);
  font-weight: 500;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--black);
  letter-spacing: -1px;
  line-height: 1.1;
}

.kpi-trend {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 600;
}

.kpi-trend .material-icons-round { font-size: 14px; }
.kpi-trend.up { color: var(--green-600); }
.kpi-trend.neutral { color: var(--orange-500); }
.kpi-trend.down { color: var(--red-500); }

/* ===================================================================
   CARDS
   =================================================================== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--neutral-200);
  padding: 20px;
  transition: all var(--duration) var(--ease);
}

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

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

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--black);
}

.card-link {
  font-size: 0.8rem;
  color: var(--orange-500);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--duration) var(--ease);
}

.card-link:hover { color: var(--orange-600); }

/* ===================================================================
   DASHBOARD GRID
   =================================================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
}

.card-lg { grid-column: 1; grid-row: 1 / 3; }
.card-md { grid-column: 2; }
.card-sm { grid-column: span 1; }

/* ===================================================================
   PROJECT LIST (Dashboard)
   =================================================================== */
.project-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius-sm);
  transition: background var(--duration) var(--ease);
  cursor: pointer;
  position: relative;
}

.project-row:hover {
  background: var(--neutral-50);
}

.project-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.project-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--black);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-client {
  font-size: 0.78rem;
  color: var(--neutral-500);
}

.project-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.project-date {
  font-size: 0.78rem;
  color: var(--neutral-500);
  white-space: nowrap;
}

.project-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--neutral-100);
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar.sm { height: 4px; }

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--orange-400), var(--orange-500));
  border-radius: 10px;
  transition: width 1s var(--ease);
}

.progress-text {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--neutral-700);
  min-width: 32px;
  text-align: right;
}

/* ===================================================================
   PIPELINE (Dashboard)
   =================================================================== */
.pipeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pipeline-stage {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
}

.pipeline-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--neutral-100);
  color: var(--stage-color);
  flex-shrink: 0;
  transition: all var(--duration) var(--ease);
}

.pipeline-icon .material-icons-round { font-size: 20px; }

.pipeline-stage:hover .pipeline-icon {
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
}

.pipeline-info { display: flex; flex-direction: column; }
.pipeline-name { font-weight: 600; font-size: 0.9rem; color: var(--black); }
.pipeline-count { font-size: 0.78rem; color: var(--neutral-500); }

.pipeline-connector {
  width: 2px;
  height: 8px;
  background: var(--neutral-200);
  margin-left: 19px;
}

/* ===================================================================
   ACTIVITY (Dashboard)
   =================================================================== */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 4px;
  align-items: flex-start;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}

.activity-content p {
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--neutral-700);
}

.activity-content em { color: var(--orange-600); font-style: normal; font-weight: 600; }
.activity-time {
  font-size: 0.72rem;
  color: var(--neutral-400);
  margin-top: 2px;
  display: block;
}

/* ===================================================================
   CHART (Dashboard)
   =================================================================== */
.chart-container { padding: 8px 0; }

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 160px;
  padding-top: 20px;
}

.chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  height: var(--height);
  background: linear-gradient(180deg, var(--orange-400), var(--orange-500));
  border-radius: 6px 6px 0 0;
  position: relative;
  transition: all 0.6s var(--ease);
  cursor: pointer;
  min-height: 20px;
}

.chart-bar:hover {
  background: linear-gradient(180deg, var(--orange-500), var(--orange-600));
  transform: scaleY(1.05);
  transform-origin: bottom;
}

.chart-tooltip {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--black);
  color: var(--white);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
  pointer-events: none;
}

.chart-bar:hover .chart-tooltip { opacity: 1; }

.chart-label {
  font-size: 0.72rem;
  color: var(--neutral-500);
  font-weight: 500;
}

/* ===================================================================
   COST BREAKDOWN (Dashboard)
   =================================================================== */
.cost-breakdown {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cost-item {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 12px;
  align-items: center;
}

.cost-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--neutral-600);
  font-weight: 500;
}

.cost-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cost-bar-wrapper {
  height: 8px;
  background: var(--neutral-100);
  border-radius: 10px;
  overflow: hidden;
}

.cost-bar {
  height: 100%;
  border-radius: 10px;
  transition: width 1s var(--ease);
}

.cost-value {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--black);
  min-width: 60px;
  text-align: right;
}

/* ===================================================================
   DATA TABLE (Projects)
   =================================================================== */
.table-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--neutral-200);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background: var(--neutral-50);
  border-bottom: 1px solid var(--neutral-200);
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--neutral-500);
}

.data-table td {
  padding: 14px 16px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--neutral-100);
  color: var(--neutral-700);
}

.data-table tbody tr {
  transition: background var(--duration) var(--ease);
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: var(--orange-50);
}

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

.cell-project {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-code {
  font-size: 0.72rem;
  color: var(--neutral-400);
  font-weight: 600;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.project-name-sm {
  font-weight: 600;
  color: var(--black);
}

.cell-person {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}

.cell-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.cell-money {
  font-weight: 700;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.82rem;
  color: var(--black);
}

/* ===================================================================
   QUOTES
   =================================================================== */
.quotes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.quote-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--neutral-200);
  padding: 20px;
  transition: all var(--duration) var(--ease);
}

.quote-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--orange-200);
  transform: translateY(-2px);
}

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

.quote-number {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.78rem;
  color: var(--neutral-400);
  font-weight: 600;
}

.quote-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--black);
  margin-bottom: 4px;
}

.quote-client {
  font-size: 0.85rem;
  color: var(--neutral-500);
  margin-bottom: 16px;
}

.quote-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.quote-detail {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--neutral-600);
}

.quote-detail .material-icons-round {
  font-size: 16px;
  color: var(--neutral-400);
}

.quote-items-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.quote-item-tag {
  background: var(--neutral-100);
  color: var(--neutral-600);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 500;
}

.quote-actions {
  display: flex;
  gap: 8px;
}

.quote-actions .btn { flex: 1; justify-content: center; }

/* ===================================================================
   KANBAN (Production)
   =================================================================== */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
}

.kanban-column {
  min-width: 240px;
  flex: 1;
}

.kanban-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--white);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border: 1px solid var(--neutral-200);
  border-bottom: 3px solid var(--col-color, var(--neutral-300));
}

.kanban-header .material-icons-round {
  font-size: 18px;
  color: var(--col-color, var(--neutral-500));
}

.kanban-header h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--black);
}

.kanban-count {
  margin-left: auto;
  background: var(--neutral-100);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--neutral-600);
}

.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: var(--neutral-50);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  border: 1px solid var(--neutral-200);
  border-top: none;
  min-height: 120px;
}

.kanban-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 14px;
  border: 1px solid var(--neutral-200);
  cursor: grab;
  transition: all var(--duration) var(--ease);
}

.kanban-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--orange-200);
  transform: translateY(-2px);
}

.kanban-code {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.7rem;
  color: var(--neutral-400);
  font-weight: 600;
}

.kanban-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--black);
  margin: 4px 0;
}

.kanban-client {
  font-size: 0.78rem;
  color: var(--neutral-500);
}

.kanban-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.kanban-due {
  font-size: 0.72rem;
  color: var(--neutral-500);
  font-weight: 500;
}

.kanban-due.urgent {
  color: var(--red-500);
  font-weight: 700;
}

/* ===================================================================
   CLIENTS
   =================================================================== */
.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.client-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--neutral-200);
  padding: 20px;
  transition: all var(--duration) var(--ease);
}

.client-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--orange-200);
  transform: translateY(-2px);
}

.client-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.client-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
}

.client-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--black);
}

.client-rut {
  font-size: 0.78rem;
  color: var(--neutral-400);
  font-family: 'SF Mono', 'Consolas', monospace;
}

.client-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--neutral-100);
  border-bottom: 1px solid var(--neutral-100);
}

.client-stat { text-align: center; }

.stat-number {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--black);
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--neutral-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.client-contact {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--neutral-600);
}

.client-contact .material-icons-round {
  font-size: 16px;
  color: var(--neutral-400);
}

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

.role-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--neutral-200);
  padding: 20px;
  transition: all var(--duration) var(--ease);
}

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

.role-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.role-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--neutral-100);
  color: var(--role-color, var(--neutral-500));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.role-icon .material-icons-round { font-size: 22px; }

.role-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--black);
}

.role-users {
  font-size: 0.78rem;
  color: var(--neutral-500);
}

.role-permissions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.perm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
}

.perm-item .material-icons-round { font-size: 18px; }
.perm-allowed { color: var(--green-600); }
.perm-denied  { color: var(--neutral-400); }

.role-edit-btn { width: 100%; justify-content: center; }

/* ===================================================================
   PLACEHOLDER PAGES
   =================================================================== */
.placeholder-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 400px;
  background: var(--white);
  border-radius: var(--radius-xl);
  border: 2px dashed var(--neutral-200);
  padding: 40px;
}

.placeholder-page .material-icons-round {
  font-size: 64px;
  color: var(--orange-300);
  margin-bottom: 16px;
}

.placeholder-page h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--black);
  margin-bottom: 8px;
}

.placeholder-page p {
  font-size: 0.92rem;
  color: var(--neutral-500);
  max-width: 420px;
  line-height: 1.6;
}

/* ===================================================================
   NOTIFICATION PANEL
   =================================================================== */
.notif-panel {
  position: fixed;
  top: 0;
  right: -380px;
  width: 380px;
  height: 100vh;
  background: var(--white);
  box-shadow: var(--shadow-xl);
  z-index: 200;
  transition: right var(--duration) var(--ease);
  display: flex;
  flex-direction: column;
}

.notif-panel.open {
  right: 0;
}

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--neutral-200);
}

.notif-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.notif-close {
  background: none;
  border: none;
  color: var(--neutral-500);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--duration) var(--ease);
}

.notif-close:hover {
  color: var(--neutral-800);
  background: var(--neutral-100);
}

.notif-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.notif-item {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  transition: background var(--duration) var(--ease);
  cursor: pointer;
}

.notif-item:hover {
  background: var(--neutral-50);
}

.notif-item.unread {
  background: var(--orange-50);
}

.notif-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notif-icon .material-icons-round { font-size: 20px; }

.notif-content p {
  font-size: 0.85rem;
  color: var(--neutral-700);
  line-height: 1.4;
}

.notif-time {
  font-size: 0.72rem;
  color: var(--neutral-400);
  margin-top: 4px;
  display: block;
}

/* ===================================================================
   MOBILE OVERLAY
   =================================================================== */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration) var(--ease);
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .card-lg { grid-column: 1; grid-row: auto; }
  .card-md, .card-sm { grid-column: 1; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0 !important;
  }

  .mobile-menu-btn {
    display: block;
  }

  .topbar {
    padding: 0 16px;
  }

  .search-box input { width: 120px; }

  .page { padding: 16px; }

  .kpi-grid { grid-template-columns: 1fr; }

  .page-header {
    flex-direction: column;
    gap: 12px;
  }

  .page-actions {
    width: 100%;
    flex-direction: column;
  }

  .page-actions .btn { width: 100%; justify-content: center; }

  .kanban-board {
    flex-direction: column;
  }

  .kanban-column { min-width: 100%; }

  .quotes-grid { grid-template-columns: 1fr; }
  .clients-grid { grid-template-columns: 1fr; }
  .roles-grid { grid-template-columns: 1fr; }

  .data-table { font-size: 0.8rem; }
  .data-table th, .data-table td { padding: 10px 8px; }

  .filter-group { display: none; }
}

@media (max-width: 480px) {
  .page-title { font-size: 1.4rem; }
  .kpi-value { font-size: 1.4rem; }
  .search-box { display: none; }
}

/* ===================================================================
   CRUD TABLE
   =================================================================== */
.crud-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 0.8rem;
}

.crud-table th, .crud-table td {
  border-bottom: 1px solid var(--neutral-100);
  padding: 6px 4px;
  text-align: center;
}

.crud-table th:first-child, .crud-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--neutral-600);
}

.crud-table th {
  font-size: 0.75rem;
  color: var(--neutral-400);
}

.crud-table .check {
  font-size: 16px;
  color: var(--green-500);
}

.crud-table .cancel {
  font-size: 16px;
  color: var(--neutral-300);
}

/* ===================================================================
   PAGE WRAPPER (for layout.js injection)
   =================================================================== */
.page-wrapper {
  padding: 24px;
  animation: fadeIn 0.3s var(--ease);
}

/* ===================================================================
   STATS STRIP
   =================================================================== */
.stats-strip {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--white);
  border: 1px solid var(--neutral-200);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.82rem;
  color: var(--neutral-600);
}

.stat-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.stat-chip-value {
  font-weight: 700;
  color: var(--black);
}

/* ===================================================================
   PAGINATION
   =================================================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding: 0 4px;
}

.pagination-info {
  font-size: 0.82rem;
  color: var(--neutral-500);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--neutral-200);
  background: var(--white);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--neutral-600);
  font-family: inherit;
  transition: all var(--duration) var(--ease);
}

.pagination-btn:hover:not(:disabled) {
  border-color: var(--orange-300);
  color: var(--orange-600);
}

.pagination-btn.active {
  background: var(--orange-500);
  border-color: var(--orange-500);
  color: var(--white);
}

.pagination-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.pagination-btn .material-icons-round { font-size: 18px; }

.pagination-dots {
  padding: 0 4px;
  color: var(--neutral-400);
  font-size: 0.85rem;
}

/* ===================================================================
   RENTABILITY TAGS
   =================================================================== */
.rentab-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: 'SF Mono', 'Consolas', monospace;
  background: var(--neutral-100);
  color: var(--neutral-500);
}

.rentab-tag.rentab-good { background: var(--green-100); color: var(--green-600); }
.rentab-tag.rentab-ok   { background: var(--orange-100); color: var(--orange-700); }
.rentab-tag.rentab-low  { background: #fee2e2; color: #dc2626; }

.cell-urgent { color: var(--red-500); font-weight: 700; }

/* ===================================================================
   PROJECT DETAIL
   =================================================================== */
.detail-back { margin-bottom: 8px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--neutral-500);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: color var(--duration) var(--ease);
}

.back-link:hover { color: var(--orange-500); }
.back-link .material-icons-round { font-size: 18px; }

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.project-code-lg {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.85rem;
  color: var(--neutral-400);
  font-weight: 600;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}

.detail-main { display: flex; flex-direction: column; gap: 20px; }
.detail-sidebar { display: flex; flex-direction: column; gap: 16px; }

/* Progress bar large */
.progress-bar.lg {
  height: 10px;
  margin-bottom: 24px;
}

.progress-text-lg {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--orange-500);
}

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  padding-left: 4px;
}

.timeline-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 0;
}

.timeline-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--neutral-200);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--white);
  color: var(--neutral-400);
  transition: all var(--duration) var(--ease);
}

.timeline-dot .material-icons-round { font-size: 16px; }

.timeline-step.completed .timeline-dot {
  background: var(--orange-500);
  border-color: var(--orange-500);
  color: var(--white);
}

.timeline-step.active .timeline-dot {
  background: var(--white);
  border-color: var(--orange-500);
  color: var(--orange-500);
  box-shadow: 0 0 0 4px rgba(249,115,22,0.15);
  animation: pulse-ring 2s ease infinite;
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 4px rgba(249,115,22,0.15); }
  50% { box-shadow: 0 0 0 8px rgba(249,115,22,0.05); }
}

.timeline-info { display: flex; flex-direction: column; }

.timeline-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--black);
}

.timeline-step:not(.completed):not(.active) .timeline-label {
  color: var(--neutral-400);
}

.timeline-date {
  font-size: 0.78rem;
  color: var(--neutral-500);
}

.timeline-step.active .timeline-date {
  color: var(--orange-500);
  font-weight: 600;
}

.timeline-line {
  width: 2px;
  height: 12px;
  background: var(--neutral-200);
  margin-left: 15px;
}

.timeline-line.completed {
  background: var(--orange-500);
}

/* Material Tags */
.material-tag {
  display: inline-flex;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
}

.material-tag.metal { background: #e0e7ff; color: #3730a3; }
.material-tag.wood  { background: #fef3c7; color: #92400e; }
.material-tag.other { background: var(--neutral-100); color: var(--neutral-600); }

/* Table footer */
.cell-total-label {
  text-align: right;
  font-weight: 700;
  color: var(--black);
}

.cell-total {
  font-size: 1rem !important;
  font-weight: 800 !important;
  color: var(--orange-600) !important;
}

/* Info List (detail sidebar) */
.info-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.info-label {
  color: var(--neutral-500);
  font-weight: 500;
}

.info-value {
  color: var(--black);
  font-weight: 600;
  text-align: right;
}

.info-value.mono {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.82rem;
}

.info-value.highlight {
  color: var(--orange-600);
}

.info-value a {
  color: var(--orange-500);
  text-decoration: none;
  font-weight: 600;
}

.info-value a:hover { text-decoration: underline; }

/* Finance Summary */
.finance-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.finance-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--neutral-600);
}

.finance-row.total {
  font-weight: 700;
  color: var(--black);
}

.finance-value {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.85rem;
  font-weight: 600;
}

.finance-value.cost { color: var(--red-500); }
.finance-value.profit { color: var(--green-600); }
.finance-divider { height: 1px; background: var(--neutral-200); margin: 2px 0; }

.rentab-lg {
  font-size: 1.15rem !important;
  font-weight: 800 !important;
}

/* Team List */
.team-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.team-member {
  display: flex;
  align-items: center;
  gap: 10px;
}

.team-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--black);
  display: block;
}

.team-role {
  font-size: 0.75rem;
  color: var(--neutral-500);
  display: block;
}

/* Document List */
.doc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}

.doc-item:hover { background: var(--neutral-50); }

.doc-item .material-icons-round { font-size: 20px; }

.doc-info { display: flex; flex-direction: column; }

.doc-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--black);
}

.doc-size {
  font-size: 0.72rem;
  color: var(--neutral-400);
}

/* Badge dispatch */
.badge-dispatch { background: #f3e8ff; color: #7c3aed; }

/* Responsive Detail */
@media (max-width: 1024px) {
  .detail-grid { grid-template-columns: 1fr; }
}

/* ===================================================================
   PROJECT ROW as link
   =================================================================== */
a.project-row {
  text-decoration: none;
  color: inherit;
}
