/* ============================================
   PHICAN INGENIEROS - Estilos principales
   Paleta cálida y profesional
   ============================================ */

/* ---------- Variables ----------
   Paleta corporativa Phican Ingenieros
   Azul navy + gris (colores oficiales del logo)
*/
:root {
  --color-bg: #FFFFFF;
  --color-bg-alt: #F4F6F8;
  --color-surface: #FFFFFF;
  --color-text: #1A2B3C;
  --color-text-muted: #5E6B7A;
  --color-border: #E1E6EC;
  --color-primary: #1E4A6B;        /* Phican Blue */
  --color-primary-dark: #143752;
  --color-primary-light: #2D6691;
  --color-secondary: #8C8C8C;      /* Phican Gray */
  --color-secondary-light: #B5B5B5;
  --color-accent: #5B9BD5;         /* azul claro para acentos */
  --color-success: #2E7D5B;
  --color-warning: #C18B2A;
  --color-danger: #B14B3C;

  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --shadow-sm: 0 1px 3px rgba(44, 36, 24, 0.06);
  --shadow-md: 0 4px 12px rgba(44, 36, 24, 0.08);
  --shadow-lg: 0 12px 32px rgba(44, 36, 24, 0.12);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;

  --container: 1200px;
  --transition: 0.25s ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; transition: var(--transition); }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
ul { list-style: none; }

/* ---------- Tipografía ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-text);
}
h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.6rem); letter-spacing: -0.01em; }
h3 { font-size: 1.4rem; }
h4 { font-size: 1.15rem; }
p { color: var(--color-text-muted); }

.eyebrow {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-primary);
  margin-bottom: 1rem;
  display: inline-block;
}

/* ---------- Layout ---------- */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1.5rem;
}
section { padding: 5rem 0; }
.section-header { text-align: center; max-width: 720px; margin: 0 auto 3.5rem; }
.section-header p { margin-top: 1rem; font-size: 1.05rem; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.8rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition);
  cursor: pointer;
}
.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-outline {
  border: 1.5px solid var(--color-text);
  color: var(--color-text);
}
.btn-outline:hover { background: var(--color-text); color: white; }
.btn-ghost { color: var(--color-primary); }
.btn-ghost:hover { gap: 0.8rem; }

/* ---------- Header / Navegación ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 246, 240, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--color-text);
}
/* Logo del header — escala como % del ancho de pantalla.
   clamp(min, ideal, max):
   - mínimo 40px (móviles pequeños)
   - ideal 6vw (= 6% del ancho de la pantalla)
   - máximo 84px (no se hace gigante en monitores 4K) */
.logo img, .logo-mark {
  height: clamp(40px, 6vw, 84px);
  width: auto;
  display: block;
}
.nav-links { display: flex; gap: 2rem; align-items: center; }
.nav-links a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text);
  position: relative;
}
.nav-links a:hover { color: var(--color-primary); }
.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -6px; left: 0;
  width: 100%; height: 2px;
  background: var(--color-primary);
}
.nav-cta { display: flex; gap: 0.75rem; align-items: center; }
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
}
.menu-toggle span {
  width: 24px; height: 2px;
  background: var(--color-text);
  transition: var(--transition);
}

/* ---------- Hero ---------- */
.hero {
  padding: 6rem 0 5rem;
  background: linear-gradient(180deg, var(--color-bg) 0%, var(--color-bg-alt) 100%);
  position: relative;
  overflow: hidden;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
}
.hero-content h1 { margin-bottom: 1.5rem; }
.hero-content p {
  font-size: 1.15rem;
  margin-bottom: 2rem;
  max-width: 520px;
}
.hero-cta { display: flex; gap: 1rem; flex-wrap: wrap; }
.hero-stats {
  display: flex;
  gap: 2.5rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}
.hero-stats .stat strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 2rem;
  color: var(--color-primary);
}
.hero-stats .stat span {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.hero-visual {
  position: relative;
  aspect-ratio: 4/5;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(184,114,63,0.15), rgba(139,111,71,0.25)),
    url('https://images.unsplash.com/photo-1503387762-592deb58ef4e?w=900&q=80') center/cover;
  box-shadow: var(--shadow-lg);
}
.hero-badge {
  position: absolute;
  bottom: 2rem; left: -2rem;
  background: white;
  padding: 1.2rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-width: 240px;
}
.hero-badge strong { font-family: var(--font-serif); font-size: 1.2rem; display: block; margin-bottom: 0.25rem; }
.hero-badge span { font-size: 0.85rem; color: var(--color-text-muted); }

/* ---------- Servicios ---------- */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}
.service-card {
  background: var(--color-surface);
  padding: 2.2rem 2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  transition: var(--transition);
}
.service-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary);
}
.service-icon {
  width: 56px; height: 56px;
  background: var(--color-bg-alt);
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  margin-bottom: 1.25rem;
  font-size: 1.5rem;
}
.service-card h3 { margin-bottom: 0.75rem; }
.service-card p { font-size: 0.95rem; margin-bottom: 1.25rem; }
.service-card a {
  color: var(--color-primary);
  font-weight: 500;
  font-size: 0.9rem;
}

/* ---------- Proyectos ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}
.project-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 4/3;
  cursor: pointer;
}
.project-card img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}
.project-card:hover img { transform: scale(1.05); }
.project-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(44,36,24,0.85) 0%, rgba(44,36,24,0) 60%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.5rem;
  color: white;
}
.project-overlay .tag {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-bg-alt);
  margin-bottom: 0.4rem;
}
.project-overlay h3 { color: white; font-size: 1.25rem; }
.project-overlay span.location { font-size: 0.85rem; opacity: 0.85; }

/* ---------- Sección sobre / valores ---------- */
.about {
  background: var(--color-text);
  color: var(--color-bg);
  padding: 6rem 0;
}
.about h2, .about h3 { color: var(--color-bg); }
.about p { color: rgba(250, 246, 240, 0.75); }
.about-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 4rem;
  align-items: center;
}
.values { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 2rem; }
.value-item h4 { color: var(--color-primary); font-family: var(--font-sans); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.15em; margin-bottom: 0.5rem; }
.value-item p { font-size: 0.95rem; }

/* ---------- Blog ---------- */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}
.blog-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
  transition: var(--transition);
}
.blog-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.blog-card img { aspect-ratio: 16/10; object-fit: cover; width: 100%; }
.blog-card-body { padding: 1.5rem; }
.blog-meta { font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 0.5rem; }
.blog-card h3 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.blog-card p { font-size: 0.92rem; }

/* ---------- Contacto / Formulario ---------- */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 4rem;
  align-items: start;
}
.contact-info ul { display: flex; flex-direction: column; gap: 1.25rem; margin-top: 2rem; }
.contact-info li { display: flex; gap: 1rem; align-items: flex-start; }
.contact-info .icon {
  width: 42px; height: 42px;
  background: var(--color-bg-alt);
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.contact-info strong { display: block; margin-bottom: 0.2rem; }
.contact-info p { font-size: 0.95rem; }

.form { display: flex; flex-direction: column; gap: 1.2rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--color-text);
}
.form input, .form textarea, .form select {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--color-surface);
  color: var(--color-text);
  transition: var(--transition);
}
.form input:focus, .form textarea:focus, .form select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(184, 114, 63, 0.15);
}
.form textarea { resize: vertical; min-height: 140px; }
.form-msg {
  padding: 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  display: none;
}
.form-msg.success { background: rgba(92, 138, 78, 0.1); color: var(--color-success); display: block; }
.form-msg.error { background: rgba(177, 75, 60, 0.1); color: var(--color-danger); display: block; }

/* ---------- CTA banner ---------- */
.cta-banner {
  background: var(--color-primary);
  color: white;
  padding: 4rem 0;
  text-align: center;
}
.cta-banner h2 { color: white; margin-bottom: 1rem; }
.cta-banner p { color: rgba(255,255,255,0.9); max-width: 540px; margin: 0 auto 2rem; }
.cta-banner .btn-outline { border-color: white; color: white; }
.cta-banner .btn-outline:hover { background: white; color: var(--color-primary); }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--color-text);
  color: rgba(250, 246, 240, 0.7);
  padding: 4rem 0 1.5rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 3rem;
  margin-bottom: 3rem;
}
.footer-grid h4 {
  color: white;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1.25rem;
}
.footer-grid .logo { color: white; margin-bottom: 1rem; }
.footer-grid p { font-size: 0.92rem; color: rgba(250, 246, 240, 0.65); }
.footer-grid ul { display: flex; flex-direction: column; gap: 0.6rem; }
.footer-grid a { font-size: 0.92rem; color: rgba(250, 246, 240, 0.7); }
.footer-grid a:hover { color: var(--color-primary); }
.footer-bottom {
  border-top: 1px solid rgba(250, 246, 240, 0.1);
  padding-top: 1.5rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  flex-wrap: wrap;
  gap: 1rem;
}

/* ---------- Página específica: cabecera de subpágina ---------- */
.page-header {
  background: var(--color-bg-alt);
  padding: 5rem 0 4rem;
  text-align: center;
}
.page-header .breadcrumb {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}
.page-header .breadcrumb a { color: var(--color-primary); }

/* ---------- ÁREA DE CLIENTES ---------- */
.cliente-body {
  background: var(--color-bg-alt);
  min-height: 100vh;
}
.login-wrapper {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 2rem;
  background: linear-gradient(135deg, var(--color-bg) 0%, var(--color-bg-alt) 100%);
}
.login-card {
  background: white;
  padding: 3rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
}
.login-card .logo { justify-content: center; margin-bottom: 0.5rem; }
.login-card h2 { text-align: center; margin-bottom: 0.5rem; font-size: 1.6rem; }
.login-card .subtitle { text-align: center; margin-bottom: 2rem; font-size: 0.95rem; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 0.5rem; }
.login-help {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  padding: 0.85rem;
  background: var(--color-bg-alt);
  border-radius: var(--radius-sm);
}
.login-help code { color: var(--color-primary); font-weight: 600; }

/* Dashboard layout */
.dashboard {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--color-text);
  color: var(--color-bg);
  padding: 2rem 1.25rem;
  display: flex;
  flex-direction: column;
}
.sidebar .logo { color: white; margin-bottom: 2.5rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: rgba(250, 246, 240, 0.8);
  transition: var(--transition);
}
.sidebar nav a:hover { background: rgba(255,255,255,0.05); color: white; }
.sidebar nav a.active { background: var(--color-primary); color: white; }
.sidebar nav .icon { width: 20px; text-align: center; }
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 1.25rem;
  margin-top: 1.25rem;
}
.sidebar-user { display: flex; gap: 0.75rem; align-items: center; padding: 0.5rem; }
.avatar {
  width: 38px; height: 38px;
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 600;
}
.sidebar-user strong { display: block; color: white; font-size: 0.9rem; }
.sidebar-user span { font-size: 0.8rem; color: rgba(250,246,240,0.6); }

.main-area { padding: 2rem 2.5rem; overflow-x: hidden; }
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.main-header h1 { font-size: 1.8rem; margin-bottom: 0.25rem; }
.main-header p { font-size: 0.95rem; }

/* Stats cards */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: white;
  padding: 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}
.stat-card .label { font-size: 0.85rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.5rem; }
.stat-card .value { font-family: var(--font-serif); font-size: 2rem; color: var(--color-text); }
.stat-card .trend { font-size: 0.85rem; margin-top: 0.5rem; }
.trend.up { color: var(--color-success); }
.trend.down { color: var(--color-danger); }

/* Cards generales */
.card {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}
.card-header h2 { font-size: 1.2rem; }

/* Tablas */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 0.85rem 1rem; font-size: 0.92rem; }
.table th {
  background: var(--color-bg-alt);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}
.table tbody tr { border-top: 1px solid var(--color-border); }
.table tbody tr:hover { background: var(--color-bg); }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: rgba(92, 138, 78, 0.15); color: var(--color-success); }
.badge-warning { background: rgba(201, 146, 74, 0.15); color: var(--color-warning); }
.badge-danger { background: rgba(177, 75, 60, 0.15); color: var(--color-danger); }
.badge-info { background: rgba(184, 114, 63, 0.12); color: var(--color-primary); }
.badge-muted { background: var(--color-bg-alt); color: var(--color-text-muted); }

/* Progress bar */
.progress {
  width: 100%;
  height: 8px;
  background: var(--color-bg-alt);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar { height: 100%; background: var(--color-primary); border-radius: 999px; transition: width 0.6s ease; }

/* Project tracker */
.tracker-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-border);
}
.tracker-item:last-child { border-bottom: none; }
.tracker-item h4 { margin-bottom: 0.25rem; font-size: 1.05rem; }
.tracker-item .meta { font-size: 0.85rem; color: var(--color-text-muted); margin-bottom: 0.6rem; }
.tracker-item .progress-row { display: flex; align-items: center; gap: 1rem; }
.tracker-item .progress-row .progress { flex: 1; }
.tracker-item .pct { font-size: 0.85rem; color: var(--color-primary); font-weight: 600; min-width: 40px; }

/* Documentos */
.doc-list { display: flex; flex-direction: column; gap: 0.5rem; }
.doc-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.doc-item:hover { border-color: var(--color-primary); background: var(--color-bg); }
.doc-icon {
  width: 44px; height: 44px;
  background: var(--color-bg-alt);
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--color-primary);
}
.doc-info strong { display: block; font-size: 0.95rem; margin-bottom: 0.2rem; }
.doc-info span { font-size: 0.82rem; color: var(--color-text-muted); }
.doc-action { color: var(--color-primary); font-size: 0.9rem; font-weight: 500; }

/* Mensajes */
.message-list { display: flex; flex-direction: column; gap: 1rem; max-height: 500px; overflow-y: auto; padding-right: 0.5rem; }
.message {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  max-width: 75%;
}
.message.from-studio {
  background: var(--color-bg-alt);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.message.from-client {
  background: var(--color-primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.message .author { font-size: 0.78rem; font-weight: 600; margin-bottom: 0.25rem; opacity: 0.85; }
.message .text { font-size: 0.92rem; line-height: 1.5; }
.message .time { font-size: 0.72rem; opacity: 0.65; margin-top: 0.4rem; }
.message-input {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}
.message-input input { flex: 1; padding: 0.75rem 1rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-family: inherit; }
.message-input input:focus { outline: none; border-color: var(--color-primary); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero-grid, .about-grid, .contact-grid { grid-template-columns: 1fr; gap: 3rem; }
  .hero-badge { left: 1rem; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }

  /* Dashboard adaptativo: mini-sidebar fijo con solo iconos */
  .dashboard { grid-template-columns: 64px 1fr; }
  .sidebar {
    position: sticky; top: 0;
    width: 64px;
    height: 100vh;
    padding: 1rem 0;
    overflow: visible;
    align-items: center;
    display: flex;
    flex-direction: column;
  }

  /* Logo solo símbolo, compacto */
  .sidebar .logo {
    margin-bottom: 1rem;
    padding: 0;
    text-align: center;
  }
  .sidebar .logo img {
    height: 30px !important;
    width: auto;
  }

  /* Nav: solo iconos, ocultar el texto */
  .sidebar nav { width: 100%; padding: 0 6px; gap: 4px; align-items: stretch; }
  .sidebar nav a {
    justify-content: center;
    padding: 12px 0;
    gap: 0;
    font-size: 0;          /* oculta el texto */
    position: relative;
    border-radius: 8px;
  }
  .sidebar nav a .icon {
    font-size: 18px;       /* mantiene el icono visible */
    width: auto;
  }

  /* Tooltip al pulsar/hover con el nombre del enlace */
  .sidebar nav a::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--color-text);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 100;
  }
  .sidebar nav a:hover::after { opacity: 1; }

  /* Footer del sidebar: solo avatar */
  .sidebar-footer { padding: 8px 0; border-top-color: rgba(255,255,255,0.08); width: 100%; text-align: center; }
  .sidebar-user { justify-content: center; padding: 4px 0; }
  .sidebar-user .avatar { margin: 0 auto; }
  .sidebar-user > div:not(.avatar) { display: none; }
  .sidebar-footer #logoutBtn,
  .sidebar-footer a[href="#"] {
    font-size: 0 !important;
    display: inline-block !important;
    width: 32px; height: 32px;
    line-height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    margin: 8px auto 0 !important;
    text-align: center;
  }
  .sidebar-footer #logoutBtn::before,
  .sidebar-footer a[href="#"]::before {
    content: "⏏";
    font-size: 14px;
    color: rgba(255,255,255,0.7);
  }

  /* Menu-toggle queda oculto (ya no se necesita hamburger) */
  .menu-toggle { display: none !important; }

  /* Main area pegada al mini-sidebar */
  .main-area { padding: 1.25rem 1rem 2rem; min-width: 0; }
  .main-header h1 { font-size: 1.4rem; }
  .main-header p { font-size: 0.9rem; }

  .stats { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .stat-card { padding: 1rem; }
  .stat-card .value { font-size: 1.5rem; }

  /* Tablas con scroll horizontal */
  .card { padding: 1rem; overflow-x: auto; }
  .table, .leads-table, .q-table, .p-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 0.85rem;
  }
  .table th, .table td,
  .leads-table th, .leads-table td,
  .q-table th, .q-table td,
  .p-table th, .p-table td { padding: 10px 12px; }

  .filter-bar { gap: 6px; }
  .search-input { max-width: 100%; min-width: 0; }
  .chip-filter { font-size: 11px; padding: 5px 10px; }

  .actions-row { flex-direction: column; gap: 4px; align-items: stretch; }
  .actions-row .btn-mini { width: 100%; text-align: center; }

  .modal { padding: 18px; }
  .modal .grid2 { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
  .dashboard { grid-template-columns: 56px 1fr; }
  .sidebar { width: 56px; }
  .sidebar nav a { padding: 10px 0; }
  .stats { grid-template-columns: 1fr; }
  .main-area { padding: 1rem 0.75rem 1.5rem; }
  .main-header h1 { font-size: 1.3rem; }
}

@media (max-width: 720px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column;
    background: var(--color-bg);
    padding: 1.5rem;
    gap: 1rem;
    border-bottom: 1px solid var(--color-border);
  }
  .nav-links.open { display: flex; }
  .nav-cta .btn { display: none; }
  .menu-toggle { display: flex; }
  .form-row { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .values { grid-template-columns: 1fr; }
  section { padding: 3.5rem 0; }
  .hero { padding: 3rem 0; }
  .login-card { padding: 2rem 1.5rem; }
}

/* ==================== Chat tipo WhatsApp (Fase 3) ==================== */
.message .att-image {
  display: block; max-width: 280px; max-height: 320px;
  border-radius: 10px; margin-bottom: 0.35rem; cursor: pointer;
  object-fit: cover; background: rgba(0,0,0,0.06);
}
.message audio.att-audio { max-width: 250px; display: block; margin-bottom: 0.3rem; }
.message .att-file {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.8rem; border-radius: 8px; margin-bottom: 0.35rem;
  background: rgba(0,0,0,0.07); cursor: pointer; text-decoration: none; color: inherit;
  font-size: 0.88rem; max-width: 280px;
}
.message.from-client .att-file { background: rgba(255,255,255,0.15); color: white; }
.message .att-file .att-ico { font-size: 1.3rem; flex-shrink: 0; }
.message .att-file .att-meta { overflow: hidden; }
.message .att-file .att-meta strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.85rem; }
.message .att-file .att-meta span { font-size: 0.75rem; opacity: 0.7; }

/* Composer */
.chat-composer {
  display: flex; align-items: flex-end; gap: 0.5rem;
  margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--color-border);
}
.chat-composer .chat-text {
  flex: 1; padding: 0.7rem 1rem; border: 1px solid var(--color-border);
  border-radius: 22px; font-family: inherit; font-size: 0.95rem;
  resize: none; max-height: 120px; line-height: 1.4;
}
.chat-composer .chat-text:focus { outline: none; border-color: var(--color-primary); }
.chat-icon-btn {
  width: 42px; height: 42px; flex-shrink: 0;
  border: none; border-radius: 50%; cursor: pointer;
  background: var(--color-bg-alt); font-size: 1.15rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.chat-icon-btn:hover { background: var(--color-border); }
.chat-icon-btn.send { background: var(--color-primary); color: white; }
.chat-icon-btn.send:disabled { opacity: 0.5; cursor: default; }
.chat-icon-btn.recording { background: #d9534f; color: white; animation: pulse-rec 1.2s infinite; }
@keyframes pulse-rec { 0%,100% { box-shadow: 0 0 0 0 rgba(217,83,79,0.5); } 50% { box-shadow: 0 0 0 8px rgba(217,83,79,0); } }

/* Previsualización de adjunto antes de enviar */
.chat-preview {
  display: flex; align-items: center; gap: 0.8rem;
  margin-top: 0.8rem; padding: 0.7rem 0.9rem;
  background: var(--color-bg-alt); border-radius: 10px;
  border: 1px dashed var(--color-border);
}
.chat-preview img { max-height: 70px; max-width: 100px; border-radius: 6px; object-fit: cover; }
.chat-preview .cp-name { flex: 1; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-preview .cp-cancel {
  border: none; background: none; cursor: pointer; font-size: 1.1rem;
  color: var(--color-text-muted); padding: 0.3rem;
}

/* Visor de imagen a pantalla completa */
.img-lightbox {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.img-lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 6px; }

@media (max-width: 640px) {
  .message { max-width: 88%; }
  .message .att-image { max-width: 210px; }
}

/* ============================================================
   PHICAN INGENIERÍA — Estilos de los módulos de gestión
   (añadido; no modifica reglas anteriores)
   ============================================================ */
.gestion-tabs { display: flex; flex-wrap: wrap; gap: 0.15rem; border-bottom: 2px solid var(--color-border); margin-bottom: 0.5rem; }
.gestion-tabs a { padding: 0.55rem 0.9rem; font-size: 0.9rem; font-weight: 500; color: var(--color-text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.gestion-tabs a:hover { color: var(--color-primary); }
.gestion-tabs a.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.gestion-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 0.75rem 0; }
.gestion-actions { display: flex; gap: 0.4rem; }
.gestion-filters { display: flex; gap: 0.5rem; }
.gestion-projlabel { font-size: 0.9rem; font-weight: 500; display: flex; align-items: center; gap: 0.4rem; }
.gestion-projlabel select, .gestion-filters select { padding: 0.4rem 0.6rem; border: 1px solid var(--color-border); border-radius: 8px; font: inherit; font-size: 0.85rem; background: #fff; }

.gestion-link { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 0.15rem 0.3rem; border-radius: 6px; line-height: 1; }
.gestion-link:hover { background: var(--color-bg-alt); }

/* Modales */
.gestion-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; padding: 1rem; }
.gestion-modal.open { display: flex; }
.gestion-modal-card { max-width: 660px; width: 100%; margin: 0; max-height: 90vh; overflow-y: auto; }
.gestion-x { font-size: 1.5rem; cursor: pointer; background: none; border: none; color: var(--color-text-muted); }
.gestion-import-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.5rem; border: 1px solid var(--color-border); border-radius: 8px; font-size: 0.85rem; cursor: pointer; margin-bottom: 0.3rem; }
.gestion-import-row input { width: auto; }
.muted { color: var(--color-text-muted); }

/* Carpetas */
.gestion-folder-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.gestion-tree { background: #0e1f2d; color: #d7e3ec; padding: 0.9rem; border-radius: 10px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8rem; line-height: 1.55; overflow: auto; max-height: 360px; white-space: pre; }
.gestion-checklist { display: flex; flex-direction: column; gap: 0.3rem; max-height: 360px; overflow: auto; }
.gestion-check { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.5rem; border: 1px solid var(--color-border); border-radius: 8px; font-size: 0.85rem; cursor: pointer; }
.gestion-check input { width: auto; }

/* Tablas de edición (mediciones, certificaciones, costes) */
.med-table th, .med-table td { padding: 0.4rem 0.5rem; font-size: 0.85rem; vertical-align: middle; }
.med-inp { width: 100%; padding: 0.35rem 0.45rem; border: 1px solid var(--color-border); border-radius: 6px; font: inherit; font-size: 0.85rem; background: #fff; color: var(--color-text); }
.med-inp:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(30,74,107,0.12); }
.med-num { text-align: right; }
.med-unit { text-align: center; }

.med-chapter { padding: 0; overflow: hidden; margin-bottom: 1rem; }
.med-chead { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.8rem; background: var(--color-bg-alt); border-bottom: 1px solid var(--color-border); }
.med-code { max-width: 74px; }
.med-cname { flex: 1; }
.med-cimporte { font-weight: 700; color: var(--color-primary); white-space: nowrap; }
.med-btn { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.med-toggle { font-size: 0.9rem; }
.med-detail > td { background: #fbfcfd; padding: 0.3rem 0.6rem 0.7rem; }
.med-lines { width: 100%; border-collapse: collapse; background: #fff; margin: 0.3rem 0; }
.med-lines th, .med-lines td { padding: 0.25rem 0.4rem; border: 1px solid var(--color-border); font-size: 0.8rem; }
.med-lines th { background: #eef2f6; }
.med-lines-wrap { overflow-x: auto; }

tr.gestion-totrow td { background: var(--color-bg-alt); font-weight: 600; border-top: 2px solid var(--color-border); }
tr.gestion-caprow td { background: #eef2f6; font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-primary); }

/* Totales presupuesto */
.gestion-split { display: grid; grid-template-columns: 1fr 1.2fr; gap: 1rem; margin-top: 1rem; }
.gestion-config h3, .gestion-totals h3 { font-family: var(--font-sans); font-size: 1rem; margin-bottom: 0.6rem; }
.gestion-pct { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.gestion-pct label { font-size: 0.88rem; color: var(--color-text-muted); }
.gestion-pct input { width: 110px; text-align: right; padding: 0.35rem 0.5rem; border: 1px solid var(--color-border); border-radius: 6px; font: inherit; }
.gestion-tot-row { display: flex; justify-content: space-between; padding: 0.35rem 0; font-size: 0.9rem; border-bottom: 1px dashed var(--color-border); }
.gestion-tot-row.strong { font-weight: 600; }
.gestion-tot-grand { display: flex; justify-content: space-between; margin-top: 0.6rem; padding-top: 0.6rem; border-top: 2px solid var(--color-primary); font-family: var(--font-serif); font-size: 1.3rem; color: var(--color-primary); font-weight: 700; }

/* Certificaciones */
.gestion-certtabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0; }
.gestion-certpill { display: flex; flex-direction: column; align-items: flex-start; padding: 0.45rem 0.8rem; border: 1px solid var(--color-border); border-radius: 10px; background: #fff; cursor: pointer; font-size: 0.85rem; font-weight: 600; line-height: 1.2; }
.gestion-certpill small { font-weight: 400; color: var(--color-text-muted); font-size: 0.72rem; }
.gestion-certpill.active { border-color: var(--color-primary); background: var(--color-primary); color: #fff; }
.gestion-certpill.active small { color: rgba(255,255,255,0.85); }

/* Desviaciones de coste */
.desv-over { color: var(--color-danger) !important; }
.desv-under { color: var(--color-success) !important; }
.gestion-warn { background: rgba(201,146,74,0.12); color: var(--color-warning); padding: 0.7rem 1rem; font-size: 0.88rem; margin-bottom: 1rem; border-radius: var(--radius-md); }

/* Gantt */
.gestion-pills { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.gestion-pill { display: inline-flex; align-items: center; gap: 0.2rem; background: var(--color-bg-alt); border: 1px solid var(--color-border); border-radius: 20px; padding: 0.15rem 0.5rem; font-size: 0.78rem; }
.gestion-pill-x { background: none; border: none; cursor: pointer; color: var(--color-danger); font-size: 0.9rem; line-height: 1; padding: 0; }
.gantt-depadd { padding: 0.25rem 0.4rem; border: 1px solid var(--color-border); border-radius: 8px; font-size: 0.78rem; background: #fff; }

.gantt-wrap { font-size: 0.82rem; min-width: 520px; }
.gantt-head { display: flex; }
.gantt-row { display: flex; align-items: center; height: 38px; }
.gantt-label { width: 200px; min-width: 200px; padding-right: 0.6rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.82rem; }
.gantt-track { position: relative; flex: 1; height: 100%; border-left: 1px solid var(--color-border); }
.gantt-ticks { height: 24px; }
.gantt-tick { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--color-border); }
.gantt-tick span { position: absolute; top: 2px; left: 3px; font-size: 0.68rem; color: var(--color-text-muted); white-space: nowrap; }
.gantt-today { position: absolute; top: 0; bottom: 0; border-left: 2px solid var(--color-danger); z-index: 3; }
.gantt-today span { position: absolute; top: 2px; left: 3px; font-size: 0.68rem; color: var(--color-danger); }
.gantt-body { position: relative; }
.gantt-bar { position: absolute; top: 8px; height: 22px; background: #cfe0ee; border-radius: 5px; overflow: hidden; z-index: 2; box-shadow: var(--shadow-sm); }
.gantt-fill { position: absolute; top: 0; left: 0; bottom: 0; background: var(--color-primary); }
.gantt-bar.done .gantt-fill { background: var(--color-success); }
.gantt-bar-label { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); font-size: 0.68rem; color: #12303f; z-index: 2; font-weight: 600; }
.gantt-svg { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 1; }

@media (max-width: 820px) {
  .gestion-folder-grid { grid-template-columns: 1fr; }
  .gestion-split { grid-template-columns: 1fr; }
}

/* ============================================================
   MENÚ ADMIN POR GRUPOS PLEGABLES (reorg lateral)
   ============================================================ */
.sidebar nav .side-group { border-radius: 8px; margin-bottom: 2px; }
.sidebar nav .side-group-head {
  display: flex; align-items: center; gap: 0.6rem; width: 100%;
  padding: 0.5rem 0.7rem; background: transparent; border: none; cursor: pointer;
  color: rgba(255,255,255,0.55); font-family: var(--font-sans);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  border-radius: 8px;
}
.sidebar nav .side-group-head:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }
.sidebar nav .side-group-head .icon { width: 20px; text-align: center; font-size: 0.95rem; }
.sidebar nav .side-group-head .lbl { flex: 1; text-align: left; }
.sidebar nav .side-group-head .chev { font-size: 0.65rem; opacity: 0.7; transition: transform 0.2s; }
.sidebar nav .side-group.open .side-group-head .chev { transform: rotate(90deg); }
.sidebar nav .side-group-items { display: none; padding: 2px 0 6px; }
.sidebar nav .side-group.open .side-group-items { display: block; }

.sidebar nav .side-link {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.7rem 0.45rem 1.3rem;
  color: rgba(255,255,255,0.72); font-size: 0.9rem; border-radius: 8px; margin: 1px 0;
}
.sidebar nav .side-link:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar nav .side-link.active { background: var(--color-primary); color: #fff; }
.sidebar nav .side-link .icon { width: 18px; text-align: center; font-size: 0.95rem; }
.sidebar nav .side-sub { margin-left: 1.35rem; border-left: 1px solid rgba(255,255,255,0.12); }
.sidebar nav .side-link.side-child { padding-left: 0.9rem; font-size: 0.84rem; color: rgba(255,255,255,0.6); }

/* Mini-sidebar móvil: solo iconos, grupos siempre abiertos, tooltip al pulsar */
@media (max-width: 960px) {
  .sidebar nav .side-group-head .lbl,
  .sidebar nav .side-group-head .chev { display: none; }
  .sidebar nav .side-group-head { justify-content: center; padding: 6px 0; }
  .sidebar nav .side-link .lbl { display: none; }
  .sidebar nav .side-link { justify-content: center; padding: 0.5rem 0; margin: 2px 0; }
  .sidebar nav .side-sub { margin-left: 0; border-left: none; }
}

/* ===== Configuración · Tipos de proyecto ===== */
.pt-tree { padding: 0.3rem 0.4rem; }
.pt-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--color-border); }
.pt-row:hover { background: var(--color-bg-alt); }
.pt-name { flex: 1; font-size: 0.92rem; }
.pt-badge { display: inline-block; font-size: 0.62rem; font-weight: 700; background: var(--color-secondary); color: #fff; border-radius: 4px; padding: 1px 5px; vertical-align: middle; }
.pt-l1 > .pt-row .pt-badge { background: var(--color-primary); }
.pt-meta { display: flex; gap: 0.3rem; align-items: center; }
.pt-actions { display: flex; gap: 0.1rem; white-space: nowrap; }
.pt-children { margin-left: 1.1rem; border-left: 2px solid var(--color-border); }
.pt-folders { border: 1px solid var(--color-border); border-radius: 8px; padding: 0.5rem; max-height: 300px; overflow: auto; background: #fbfcfd; }
.pt-folder { display: flex; align-items: center; gap: 0.35rem; margin-bottom: 0.25rem; }
.pt-folder-ic { font-size: 0.9rem; }
.pt-fname { flex: 1; }
