:root {
  --bg: #0d0f12;
  --bg-card: #161a1f;
  --bg-hover: #1c2128;
  --border: #2d333b;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-primary: #e6edf3; /* alias para --text, usado en componentes */
  --accent: #58a6ff;
  --accent-rgb: 88, 166, 255; /* para rgba(var(--accent-rgb), 0.05) */
  --accent-soft: rgba(88, 166, 255, 0.15);
  --success: #3fb950;
  --success-soft: rgba(63, 185, 80, 0.15);
  --warning: #d29922;
  --warning-soft: rgba(210, 153, 34, 0.15);
  --danger: #f85149;
  --danger-soft: rgba(248, 81, 73, 0.15);
  --info: #58a6ff;
  --secondary: #6e7681;
  --radius: 10px;
  --font: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --touch-min: 44px;
  --header-pad: 14px 24px;
  --main-pad: 24px;
  /* Aliases usados en componentes */
  --card-bg: var(--bg-card);
  --input-bg: var(--bg);
  --bg-soft: var(--bg-hover);
  /* SKILL: viewport stability on mobile (avoid layout jump) */
  --viewport-min-height: 100dvh;
}

[data-theme="light"] {
  --bg: #f0f2f5;
  --bg-card: #fff;
  --bg-hover: #e8eaed;
  --border: #dadce0;
  --text: #202124;
  --text-muted: #5f6368;
  --text-primary: #202124;
  --accent: #1a73e8;
  --accent-rgb: 26, 115, 232;
  --accent-soft: rgba(26, 115, 232, 0.12);
  --success-soft: rgba(46, 125, 50, 0.12);
  --warning-soft: rgba(237, 108, 2, 0.12);
  --danger-soft: rgba(198, 40, 40, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: var(--viewport-min-height);
  min-height: 100vh; /* fallback */
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

#root {
  min-height: var(--viewport-min-height);
  min-height: 100vh; /* fallback */
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button {
  font-family: var(--font);
  cursor: pointer;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input, textarea, select {
  font-family: var(--font);
}

/* ========== CRM Layout ========== */
.crm-layout {
  min-height: var(--viewport-min-height);
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}
.crm-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.crm-sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px 0;
}
.crm-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 24px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.2rem;
}
.crm-logo:hover { color: var(--text); text-decoration: none; }
.crm-logo-icon { color: var(--accent); }
.crm-nav {
  flex: 1;
  padding: 12px 0;
}
.crm-nav-item {
  display: block;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
}
.crm-nav-item:hover { color: var(--text); background: var(--bg-hover); }
.crm-nav-item-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
}
.crm-sidebar-footer {
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.crm-sidebar-btn {
  padding: 8px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}
.crm-sidebar-btn:hover { background: var(--border); }
.crm-sidebar-btn-muted { color: var(--text-muted); }
.crm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
@media (max-width: 900px) {
  .crm-layout:has(.crm-sidebar-open) .crm-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
}
.crm-main {
  flex: 1;
  margin-left: 220px;
  display: flex;
  flex-direction: column;
  min-height: var(--viewport-min-height);
  min-height: 100vh;
}
.crm-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.crm-menu-btn {
  display: none;
  padding: 8px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
}
.crm-banner {
  padding: 6px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  border-radius: var(--radius);
}
.crm-banner-error { background: rgba(248,81,73,0.15); color: var(--danger); }
.crm-content {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  .crm-sidebar {
    transform: translateX(-100%);
  }
  .crm-sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
  .crm-main { margin-left: 0; }
  .crm-menu-btn { display: block; }
}

/* CRM cards & table */
.crm-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.crm-card-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 16px;
}
.crm-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}
.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.crm-table th {
  text-align: left;
  padding: 12px 16px;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
}
.crm-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.crm-table tbody tr:hover { background: var(--bg-hover); }
.crm-table tbody tr:last-child td { border-bottom: none; }
.crm-table a { color: var(--accent); text-decoration: none; }
.crm-table a:hover { text-decoration: underline; }

.crm-dashboard { }
.dashboard-chart-card .recharts-legend-item-text { fill: var(--text); }
.dashboard-chart-card .recharts-default-legend { padding: 0 8px; }
.crm-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.crm-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.crm-kpi-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
.crm-kpi-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.crm-kpi-warning .crm-kpi-value { color: var(--warning); }
.crm-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}
.crm-link:hover { text-decoration: underline; }

.crm-page { }
.crm-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.crm-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.crm-btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
}
.crm-btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.crm-btn-primary:hover { filter: brightness(1.1); }
.crm-btn-secondary {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border);
}
.crm-btn-secondary:hover { background: var(--border); }
.crm-btn-danger {
  background: rgba(248, 81, 73, 0.15);
  color: var(--danger);
  border-color: var(--danger);
  font-size: 0.85rem;
}
.crm-btn-danger:hover { background: rgba(248, 81, 73, 0.25); }
.crm-btn-muted {
  background: var(--bg-hover);
  color: var(--text-muted);
  border-color: var(--border);
}
.crm-btn-muted:hover { background: var(--border); color: var(--text); }
.crm-input {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  min-width: 140px;
}
.crm-search { min-width: 180px; }
.crm-select {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
}
.crm-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  animation: modalBackdropIn 0.2s ease;
}
@keyframes modalBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.crm-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 320px;
  max-width: 100%;
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@media (max-width: 640px) {
  .crm-toolbar { flex-direction: column; align-items: stretch; }
  .crm-toolbar-actions { flex-direction: column; }
  .crm-input, .crm-search { min-width: 0; width: 100%; }
}

/* Legacy main-content (keep for any refs) */
.main-content {
  flex: 1;
  padding: var(--main-pad);
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* Stats grid */
.stats-grid-mobile {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

/* Project list: toolbar y filtros apilados en móvil */
.project-list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.project-list-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.project-list-controls .search-input {
  min-width: 180px;
}
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.project-grid a:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}
@media (max-width: 640px) {
  .project-list-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .project-list-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .project-list-controls .search-input {
    min-width: 0;
    width: 100%;
  }
  .project-list-controls select {
    width: 100%;
    min-height: var(--touch-min);
  }
  .project-grid {
    grid-template-columns: 1fr;
  }
}

/* Detail: tabs con scroll horizontal en móvil */
.detail-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0;
}
.detail-tabs button {
  flex-shrink: 0;
  min-height: var(--touch-min);
  padding: 10px 14px;
}

/* Finanzas: filas como tarjetas en móvil */
.finanzas-invoice-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
@media (max-width: 640px) {
  .finanzas-invoice-row {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    border-bottom: none;
  }
  .finanzas-invoice-row .row-project { order: 1; }
  .finanzas-invoice-row .row-meta { order: 2; display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.9rem; color: var(--text-muted); }
  .finanzas-invoice-row .row-amount { order: 3; font-weight: 700; font-size: 1.1rem; }
  .finanzas-invoice-row .row-action { order: 4; margin-top: 8px; margin-left: 0 !important; width: 100%; min-height: var(--touch-min); }
}

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

/* ========== Responsive global ========== */
.crm-content {
  max-width: 100%;
  overflow-x: hidden;
}

@media (max-width: 768px) {
  .crm-content { padding: 16px !important; }
  .crm-kpis { grid-template-columns: repeat(2, 1fr); }
  .crm-topbar { padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
}

@media (max-width: 480px) {
  .crm-content { padding: 12px !important; }
  .crm-kpis { grid-template-columns: 1fr; gap: 10px; }
  .crm-card { padding: 14px; margin-bottom: 14px; }
}

/* Formularios responsivos */
.invoice-form,
.form-responsive {
  max-width: 100%;
  width: 100%;
}
.invoice-form .form-section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.invoice-form .invoice-line-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.invoice-form .invoice-line-row select { min-width: 90px; }
.invoice-form .invoice-line-row .line-desc { flex: 1; min-width: 100px; }
.invoice-form .invoice-line-row .line-qty,
.invoice-form .invoice-line-row .line-rate { width: 70px; min-width: 60px; }
.invoice-form .invoice-line-row .line-uom { width: 56px; min-width: 50px; }
.invoice-form .invoice-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.invoice-form .invoice-actions button { flex: 1; min-width: 140px; }

@media (max-width: 640px) {
  .invoice-form .form-section-grid,
  .form-section-grid {
    grid-template-columns: 1fr;
  }
  .invoice-form .invoice-line-row {
    gap: 6px;
  }
  .invoice-form .invoice-line-row select { min-width: 0; width: 100%; }
  .invoice-form .invoice-line-row .line-desc { min-width: 0; width: 100%; }
  .invoice-form .invoice-line-row .line-qty,
  .invoice-form .invoice-line-row .line-rate { width: 100%; min-width: 0; }
  .invoice-form .invoice-line-row .line-uom { width: 100%; }
  .invoice-form .invoice-actions { flex-direction: column; }
  .invoice-form .invoice-actions button { min-width: 0; width: 100%; }
}

/* Tablas: scroll horizontal en móvil */
.crm-table-wrap {
  -webkit-overflow-scrolling: touch;
}
.crm-table { min-width: 400px; }
@media (max-width: 640px) {
  .crm-table th, .crm-table td { padding: 8px 10px; font-size: 0.8rem; }
}

/* Modal overlay (Layout modals) */
.crm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  animation: modalBackdropIn 0.2s ease;
}
.crm-modal-overlay .crm-card {
  animation: modalIn 0.25s ease;
}

/* Modal responsivo */
.crm-modal-backdrop { padding: 16px; align-items: flex-start; overflow-y: auto; }
.crm-modal { width: 100%; max-width: min(400px, 100%); margin: 16px auto; }

/* Proyecto detalle: título y pestañas */
.detail-title-row { flex-wrap: wrap; gap: 10px; }
.detail-title-input { min-width: 0 !important; width: 100%; }
@media (min-width: 420px) {
  .detail-title-input { width: auto; flex: 1; }
}

/* Login responsivo */
.login-page { padding: 16px !important; box-sizing: border-box; }
.login-card { max-width: 100% !important; padding: 24px !important; }
@media (min-width: 380px) {
  .login-page { padding: 24px !important; }
  .login-card { max-width: 360px !important; padding: 32px !important; }
}

/* Códigos del proyecto: fila añadir en móvil */
@media (max-width: 640px) {
  .project-codes-card .add-code-row { flex-direction: column; align-items: stretch; }
  .project-codes-card .add-code-row select { min-width: 0 !important; width: 100% !important; }
}

/* Inputs y selects táctiles */
input[type="search"],
input[type="text"],
input[type="password"],
input[type="email"],
select {
  min-height: var(--touch-min);
}
@media (min-width: 641px) {
  input[type="search"],
  input[type="text"],
  input[type="password"],
  input[type="email"] {
    min-height: 0;
  }
  select {
    min-height: 0;
  }
}

/* Enhanced Dashboard Styles */
.dashboard-container {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}

.dashboard-header h1 {
  color: var(--text);
  font-size: 2rem;
  font-weight: 700;
}

.dashboard-tabs {
  display: flex;
  gap: 0.5rem;
}

.tab-btn {
  padding: 0.75rem 1.5rem;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  font-weight: 500;
}

.tab-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.tab-btn-ai {
  border-color: var(--success);
  color: var(--success);
}
.tab-btn-ai:hover,
.tab-btn-ai.active {
  border-color: var(--success);
  background: var(--success);
  color: white;
}

/* Widget Styles */
.widget {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.widget:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.widget h3 {
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Financial Summary Widget */
.financial-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.financial-card {
  display: flex;
  align-items: center;
  padding: 1.5rem;
  border-radius: 12px;
  border: 2px solid;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.financial-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.financial-card.pending {
  background: var(--warning-soft);
  border-color: var(--warning);
  color: var(--text);
}

.financial-card.paid {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--text);
}

.financial-card.partial {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.financial-card.monthly {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.card-icon {
  font-size: 2rem;
  margin-right: 1rem;
}

.card-content h4 {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  opacity: 0.8;
}

.card-content .amount {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

/* Chart Container */
.chart-container {
  width: 100%;
  height: 300px;
  margin-top: 1rem;
}

/* Task Completion Widget */
.task-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.task-progress {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.progress-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(
    var(--accent) 0deg,
    var(--accent) calc(var(--progress, 0) * 3.6deg),
    var(--border) calc(var(--progress, 0) * 3.6deg),
    var(--border) 360deg
  );
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.3s ease;
}

.progress-circle::before {
  content: '';
  position: absolute;
  width: 80px;
  height: 80px;
  background: var(--card-bg);
  border-radius: 50%;
}

.progress-text {
  position: relative;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  z-index: 1;
}

.task-details p {
  margin: 0.5rem 0;
  color: var(--text);
}

/* Alerts Widget */
.alerts-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.alert-section h4 {
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  border-left: 4px solid;
  transition: opacity 0.2s ease;
}

.alert-item.upcoming {
  background: var(--warning-soft);
  border-left-color: var(--warning);
  color: var(--text);
}

.alert-item.overdue {
  background: var(--danger-soft);
  border-left-color: var(--danger);
  color: var(--text);
}

.alert-item.payment {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--text);
}

.alert-project {
  font-weight: 600;
  min-width: 150px;
}

.alert-type {
  font-size: 0.875rem;
  opacity: 0.8;
}

.alert-date {
  font-size: 0.875rem;
}

.alert-days {
  font-size: 0.875rem;
  font-weight: 500;
}

.alert-days.overdue {
  color: var(--danger);
  font-weight: 700;
}

.alert-amount {
  font-weight: 600;
  color: var(--accent);
}

.alert-percentage {
  font-size: 0.875rem;
  opacity: 0.8;
}

/* Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.project-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.project-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.project-header h4 {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
}

.status-activo {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-completado {
  background: var(--success-soft);
  color: var(--success);
}

.status-pendiente {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-cancelado {
  background: var(--danger-soft);
  color: var(--danger);
}

.project-details p {
  color: var(--text-muted);
  margin: 0.25rem 0;
  font-size: 0.875rem;
}

.project-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--card-bg);
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.modal-close:hover {
  background: var(--border);
}

.modal-body {
  padding: 1.5rem;
}

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

/* Form Styles */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

/* Button Styles */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: #9ca3af;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--border);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* Loading and Error States */
.loading-state, .error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

.error-state h3 {
  color: var(--danger);
  margin-bottom: 1rem;
}

.error-state p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  :root {
    --main-pad: 16px;
    --font-size-lg: 1.1rem;
  }

  .dashboard-container {
    padding: 1rem;
  }
  
  .dashboard-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }
  
  .dashboard-tabs {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    gap: 0.5rem;
  }
  
  .tab-btn {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }
  
  .financial-cards {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .task-stats {
    flex-direction: column;
    gap: 1rem;
  }
  
  .task-progress {
    flex-direction: column;
    gap: 1rem;
  }
  
  .alert-item {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }
  
  .projects-grid {
    grid-template-columns: 1fr;
  }
  
  .project-actions {
    flex-direction: column;
  }
  
  .modal-content {
    width: 95%;
    margin: 1rem;
  }

  /* Sidebar responsivo */
  .crm-sidebar {
    width: 100%;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    max-height: 60px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .crm-main {
    flex: 1;
    margin-left: 0;
    padding-top: 0;
  }

  /* Tablas scrolleables */
  table {
    font-size: 0.85rem;
  }

  .crm-kpis {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .crm-card {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.2rem;
  }

  h3 {
    font-size: 1rem;
  }

  .crm-page {
    padding: 1rem;
  }

  /* Grids responsivos */
  [style*="gridTemplateColumns: repeat(auto-fit"] {
    grid-template-columns: 1fr !important;
  }

  form input, form select, form textarea {
    font-size: 16px; /* Evita zoom en iOS */
  }
}

/* Móviles pequeños */
@media (max-width: 480px) {
  :root {
    --main-pad: 12px;
    --header-pad: 10px 16px;
  }

  body {
    font-size: 14px;
  }

  .crm-layout {
    flex-direction: column;
  }

  .crm-sidebar {
    width: 100%;
    position: static;
    max-height: 55px;
    padding: 0;
    flex-direction: row;
  }

  .crm-main {
    flex: 1;
    margin-left: 0;
  }

  .crm-page {
    padding: 0.75rem;
  }

  .crm-card {
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
  }

  h1 {
    font-size: 1.3rem;
    margin: 0.5rem 0;
  }

  h2 {
    font-size: 1rem;
    margin: 0.4rem 0;
  }

  h3 {
    font-size: 0.9rem;
    margin: 0.3rem 0;
  }

  /* Botones más grandes */
  button, .btn {
    min-height: 44px;
    font-size: 14px;
    padding: 10px 12px;
  }

  /* Input fields - evitar zoom */
  input, textarea, select {
    font-size: 16px !important;
  }

  /* Tablas */
  table {
    font-size: 0.75rem;
  }

  th, td {
    padding: 0.5rem !important;
  }

  /* KPIs */
  .crm-kpis {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .crm-kpi {
    padding: 1rem;
  }

  .crm-kpi-value {
    font-size: 1.3rem;
  }

  /* Modals */
  .modal-content {
    width: 95vw;
    max-width: 100%;
    padding: 1rem;
  }

  /* Tabs */
  .dashboard-tabs {
    gap: 0.25rem;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 0.5rem;
  }

  .tab-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  /* Flex items */
  .flex-row, [style*="display: flex"] {
    flex-wrap: wrap;
    gap: 0.5rem !important;
  }

  /* Grid columns */
  [style*="grid-template-columns: repeat(auto-fit, minmax("] {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-template-columns: repeat(auto-fit, minmax(400px"] {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-template-columns: repeat(auto-fit, minmax(500px"] {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-template-columns: repeat(auto-fit, minmax(200px"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Tabla scroll */
  .overflowX-auto, [style*="overflow-x: auto"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Focus visible */
  button:focus-visible, input:focus-visible {
    outline-offset: -2px;
  }
}

/* Tablets */
@media (min-width: 481px) and (max-width: 1024px) {
  :root {
    --main-pad: 18px;
  }

  .crm-kpis {
    grid-template-columns: repeat(2, 1fr);
  }

  [style*="grid-template-columns: repeat(auto-fit, minmax(200px"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  [style*="grid-template-columns: repeat(auto-fit, minmax(400px"] {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-template-columns: repeat(auto-fit, minmax(500px"] {
    grid-template-columns: 1fr !important;
  }

  .dashboard-tabs {
    overflow-x: auto;
  }

  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.3rem;  }
}/* Tema Admin: misma armonía visual que la página principal (landing dnet.llc) */
[data-theme="admin"] {
  --bg: #e6eef5;
  --bg-card: #ffffff;
  --bg-hover: #dde5ed;
  --border: #c5d0de;
  --text: #1a1615;
  --text-muted: #5c5a58;
  --accent: #1a237e;
  --accent-soft: rgba(26, 35, 126, 0.1);
  --success: #2e7d32;
  --success-soft: rgba(46, 125, 50, 0.12);
  --warning: #ed6c02;
  --warning-soft: rgba(237, 108, 2, 0.12);
  --danger: #c62828;
  --danger-soft: rgba(198, 40, 40, 0.12);
  --radius: 12px;
  --card-bg: var(--bg-card);
  --input-bg: #f5f7fa;
}
[data-theme="admin"] body {
  background: var(--bg);
  color: var(--text);
}

/* Página de login Admin */
.admin-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #e6eef5;
}
.admin-login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}
.admin-login-header { margin-bottom: 28px; }
.admin-login-logo {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #5c5a58;
  margin-bottom: 8px;
}
.admin-login-title {
  margin: 0 0 8px;
  font-size: 1.75rem;
  font-weight: 700;
  color: #1a1615;
}
.admin-login-subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: #5c5a58;
}
.admin-login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.admin-login-input {
  padding: 14px 16px;
  background: #f5f7fa;
  border: 1px solid #c5d0de;
  border-radius: 10px;
  color: #1a1615;
  font-size: 1rem;
}
.admin-login-input:focus {
  outline: none;
  border-color: #1a237e;
  box-shadow: 0 0 0 2px rgba(26, 35, 126, 0.15);
}
.admin-login-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}
.admin-login-btn {
  padding: 14px;
  background: #1a1615;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}
.admin-login-btn:hover:not(:disabled) { background: #2d2926; }
.admin-login-btn:disabled { opacity: 0.7; cursor: not-allowed; }
.admin-login-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.admin-login-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 0;
}
.admin-login-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #c5d0de;
  border-top-color: #1a237e;
  border-radius: 50%;
  animation: admin-spin 0.8s linear infinite;
}
@keyframes admin-spin {
  to { transform: rotate(360deg); }
}
.admin-login-btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: admin-spin 0.7s linear infinite;
}
.admin-login-card {
  animation: admin-card-in 0.35s ease;
}
@keyframes admin-card-in {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}
