:root {
  --bg-dark: #060B19;
  --bg-card: rgba(13, 21, 43, 0.72);
  --blue: #1E62FF;
  --cyan: #00D2FF;
  --amber: #FFB800;
  --whatsapp: #25D366;
  --danger: #EF4444;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --border-blue: rgba(30, 98, 255, 0.3);
  --border-amber: rgba(255, 184, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, sans-serif; }

html, body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}

#bg-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: -1;
  pointer-events: none;
}

.glass {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-blue);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.glass-amber { border-color: var(--border-amber); }
.hidden { display: none !important; }

.kpi-clickable {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.kpi-clickable:hover {
  transform: translateY(-3px);
  border-color: var(--amber);
  box-shadow: 0 10px 28px rgba(255, 184, 0, 0.22);
}

/* LOGIN */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 400px;
  padding: 36px 28px;
  text-align: center;
  border-top: 2px solid var(--amber);
}

.login-logo { max-width: 190px; margin-bottom: 12px; }
.login-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }

/* Formularios e Inputs */
.form-group { text-align: left; margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  background: rgba(6, 11, 25, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #fff;
  font-size: 0.92rem;
  outline: none;
  transition: border 0.2s;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { border-color: var(--cyan); }

/* Selector de estado compacto en tabla de cotizaciones */
.status-select {
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 20px;
  width: auto;
  cursor: pointer;
}
.status-enviada { border-color: #60A5FA; color: #60A5FA; background: rgba(30, 98, 255, 0.15); }
.status-negociacion { border-color: #FBBF24; color: #FBBF24; background: rgba(245, 158, 11, 0.15); }
.status-aprobada { border-color: #34D399; color: #34D399; background: rgba(16, 185, 129, 0.15); }
.status-rechazada { border-color: #F87171; color: #F87171; background: rgba(239, 68, 68, 0.15); }

/* Botones */
.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--blue), #0044CC);
  color: #fff;
  width: 100%;
}
.btn-primary:hover { box-shadow: 0 0 18px rgba(30, 98, 255, 0.6); transform: translateY(-1px); }
.btn-amber { background: var(--amber); color: #060B19; }
.btn-amber:hover { filter: brightness(1.1); }
.btn-cyan {
  background: rgba(0, 210, 255, 0.16);
  color: var(--cyan);
  border: 1px solid rgba(0, 210, 255, 0.45);
}
.btn-cyan:hover {
  background: var(--cyan);
  color: #060B19;
}
.btn-whatsapp {
  background: rgba(37, 211, 102, 0.18);
  color: #4ADE80;
  border: 1px solid rgba(37, 211, 102, 0.45);
}
.btn-whatsapp:hover {
  background: var(--whatsapp);
  color: #060B19;
  box-shadow: 0 0 12px rgba(37, 211, 102, 0.45);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  color: #F87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}
.btn-sm { padding: 5px 10px; font-size: 0.78rem; width: auto; }
.btn-xs { padding: 3px 7px; font-size: 0.74rem; width: auto; }
.btn-ghost { background: rgba(255,255,255,0.08); color: #fff; width: auto; }
.btn-ghost:hover { background: rgba(255,255,255,0.16); }

/* LAYOUT PRINCIPAL (PC) */
.app-layout { display: flex; min-height: 100vh; width: 100%; }

.sidebar {
  width: 250px;
  padding: 24px 16px;
  border-right: 1px solid var(--border-blue);
  background: rgba(6, 11, 25, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-logo { max-width: 165px; margin: 0 auto 28px; display: block; }
.nav-item {
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  transition: all 0.2s;
}
.nav-item:hover, .nav-item.active {
  background: linear-gradient(90deg, rgba(30, 98, 255, 0.25), transparent);
  color: #fff;
  border-left: 3px solid var(--amber);
}

.main-content { flex: 1; padding: 28px 34px; overflow-y: auto; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 14px; }

/* Barra de filtros y búsqueda en Proyectos */
.projects-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding: 14px 16px;
}
.projects-toolbar input { flex: 2; min-width: 220px; }
.projects-toolbar select { flex: 1; min-width: 210px; }

.section-divider-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Tarjetas KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.kpi-card { padding: 20px; }
.kpi-title { font-size: 0.82rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: 1.7rem; font-weight: 700; margin: 8px 0 4px; color: #fff; }
.kpi-sub { font-size: 0.8rem; color: var(--cyan); }

/* Tablas */
.table-container { padding: 20px; overflow-x: auto; margin-bottom: 24px; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.07); font-size: 0.9rem; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }

/* Badges */
.badge { padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; display: inline-block; }
.badge-vscode { background: rgba(30, 98, 255, 0.2); color: #60A5FA; border: 1px solid #3B82F6; }
.badge-appscript { background: rgba(255, 184, 0, 0.15); color: var(--amber); border: 1px solid var(--amber); }
.badge-paid { background: rgba(16, 185, 129, 0.2); color: #34D399; }
.badge-pending { background: rgba(245, 158, 11, 0.2); color: #FBBF24; }
.badge-delivery {
  background: rgba(0, 210, 255, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(0, 210, 255, 0.35);
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 0.76rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Grid de Proyectos */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 20px; margin-bottom: 30px; }
.project-card { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.project-card-done { border-color: rgba(16, 185, 129, 0.4); opacity: 0.94; }

.project-summary {
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--cyan);
  padding: 9px 12px;
  border-radius: 0 8px 8px 0;
  font-size: 0.84rem;
  color: #CBD5E1;
  line-height: 1.4;
}

.cred-box {
  background: rgba(6, 11, 25, 0.7);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.keyword-tag {
  background: rgba(0, 210, 255, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(0, 210, 255, 0.3);
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Timeline de Bitácora / Historial */
.timeline-item {
  background: rgba(6, 11, 25, 0.65);
  border: 1px solid rgba(30, 98, 255, 0.25);
  border-left: 3px solid var(--amber);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.client-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.client-chip {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; padding: 14px;
}
.modal-box { width: 100%; max-width: 580px; padding: 26px; max-height: 92vh; overflow-y: auto; }
.modal-box-wide { max-width: 820px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* Bloques dinámicos del constructor de Propuesta PDF */
.pdf-section-box {
  background: rgba(6, 11, 25, 0.55);
  border: 1px solid rgba(30, 98, 255, 0.25);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
}
.pdf-section-title {
  color: var(--amber);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dynamic-item-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  position: relative;
}

/* ============================================================================
   ADAPTACIÓN RESPONSIVA PARA CELULARES Y TABLETS (Sin afectar vista en PC)
   ============================================================================ */
@media (max-width: 960px) {
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    padding: 14px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border-blue);
    position: sticky;
    top: 0;
    z-index: 50;
  }

  .sidebar > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .sidebar-logo {
    max-width: 130px;
    margin: 0;
  }

  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .nav-item {
    padding: 9px 10px;
    margin-bottom: 0;
    font-size: 0.82rem;
    justify-content: center;
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    border-left: none;
    border-bottom: 2px solid transparent;
  }

  .nav-item.active {
    border-left: none;
    border-bottom: 2px solid var(--amber);
    background: rgba(30, 98, 255, 0.25);
  }

  .sidebar > div:last-child {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .sidebar > div:last-child p {
    margin-bottom: 0 !important;
    text-align: left !important;
    font-size: 0.75rem !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar > div:last-child button {
    width: auto !important;
    padding: 6px 12px;
    font-size: 0.78rem;
    flex-shrink: 0;
  }

  .main-content {
    padding: 18px 14px;
    width: 100%;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }

  .topbar h2 {
    font-size: 1.35rem;
  }

  .topbar .btn-amber {
    width: 100%;
  }

  .projects-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .kpi-value {
    font-size: 1.45rem;
  }

  .projects-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .project-card {
    padding: 16px;
  }

  .cred-box {
    flex-direction: column;
    align-items: flex-start;
  }

  .cred-box > div:first-child {
    word-break: break-all;
  }

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .modal-box {
    padding: 20px 16px;
    max-height: 92vh;
  }

  .table-container {
    padding: 14px;
    overflow-x: visible;
  }

  table, thead, tbody, th, td, tr {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody tr {
    background: rgba(6, 11, 25, 0.65);
    border: 1px solid rgba(30, 98, 255, 0.25);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
  }

  tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: right;
    font-size: 0.85rem;
    word-break: break-word;
  }

  tbody td:last-child {
    border-bottom: none;
    padding-bottom: 2px;
    padding-top: 10px;
  }

  tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    text-align: left;
    flex-shrink: 0;
  }
}