:root {
  --bg: #0b0f14;
  --panel: #121924;
  --panel-2: #0e141d;
  --border: #2a3444;
  --text: #f2f5f8;
  --muted: #8a96a8;
  --accent: #00b4d8;
  --accent-2: #0284c7;
  --accent-deep: #023e8a;
  --danger: #ff5c5c;
  --shadow-sm: 0 1px 3px rgba(0,180,216,0.12);
  --shadow-md: 0 6px 24px rgba(0,180,216,0.20);
  --shadow-lg: 0 16px 48px rgba(0,180,216,0.28);
  --ease: cubic-bezier(.2,.7,.3,1);
  --font-body: 'Manrope', -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --font-head: 'Barlow Condensed', Impact, Arial, sans-serif;
}
* { box-sizing: border-box; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.94); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
@keyframes bgDrift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(2%, -3%) scale(1.05); }
  100% { transform: translate(-2%, 2%) scale(1.02); }
}
@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(48,209,88,0.55); }
  50% { box-shadow: 0 0 0 6px rgba(48,209,88,0); }
}
@keyframes pulseRing {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,180,216,0.35), var(--shadow-sm); }
  50% { box-shadow: 0 0 0 8px rgba(0,180,216,0), var(--shadow-sm); }
}
@keyframes growBar {
  from { transform: scaleY(0); opacity: .4; }
  to { transform: scaleY(1); opacity: 1; }
}
@keyframes sweep {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(220%); }
}
@keyframes pulseOpacity {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(1100px 560px at 100% -12%, rgba(0,180,216,0.10), transparent),
    radial-gradient(900px 520px at -10% 110%, rgba(2,62,138,0.16), transparent),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  position: relative;
}
body::before {
  content: '';
  position: fixed; inset: -10%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(560px 560px at 18% 22%, rgba(0,180,216,0.09), transparent 60%),
    radial-gradient(640px 640px at 82% 78%, rgba(2,62,138,0.13), transparent 60%);
  animation: bgDrift 16s ease-in-out infinite alternate;
}
a { color: inherit; text-decoration: none; }
.container { max-width: 1000px; margin: 0 auto; padding: 16px; animation: fadeInUp .35s var(--ease) both; }

h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .02em;
  color: var(--text);
}

/* ---------- Marca "OK" (insignia en CSS, igual que okservice.tech - el sitio
   tampoco usa una imagen de logo, solo esta insignia estilizada) ---------- */
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; background: var(--accent); color: #ffffff;
  font-family: var(--font-head); font-weight: 800; font-size: 17px;
  letter-spacing: .02em; border-radius: 6px; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), var(--shadow-sm);
}
.brand-mark-lg { width: 64px; height: 64px; font-size: 26px; margin: 0 auto 12px; border-radius: 10px; }
.brand-text { font-family: var(--font-head); font-weight: 800; text-transform: uppercase; letter-spacing: .02em; font-size: 17px; }
.brand-text small { display: block; font-size: 10px; font-weight: 600; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; margin-top: -2px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: rgba(14,20,29,0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 8px;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 2px 16px rgba(0,0,0,0.35);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; color: var(--text); transition: transform .2s var(--ease); }
.topbar .brand:hover { transform: scale(1.02); }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: var(--muted); position: relative; padding: 8px 10px; border-radius: 6px;
  font-size: 14px; transition: color .15s var(--ease), background .15s var(--ease);
}
.topbar nav a:hover { color: var(--accent); background: rgba(0,180,216,0.08); }
.topbar nav a.active { color: var(--accent); font-weight: 700; background: rgba(0,180,216,0.12); }
.topbar nav a.active::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: 2px; height: 2px;
  background: var(--accent); border-radius: 2px;
}
.user-info { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.user-info a { color: var(--accent); transition: opacity .15s; }
.user-info a:hover { opacity: .7; }

.live-dot {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: #30d158;
  text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
}
.live-dot::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: #30d158;
  animation: pulseDot 1.8s ease-out infinite;
}

#nav-toggle { display: none; background: none; border: none; box-shadow: none; color: var(--accent); font-size: 22px; padding: 4px 8px; }
.user-info-movil { display: none; }

.login-box {
  max-width: 360px; margin: 80px auto; background: var(--panel); padding: 28px;
  border-radius: 10px; border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  text-align: center; animation: popIn .4s var(--ease) both;
}
.login-box h1 { margin: 0 0 4px; font-size: 22px; }
.muted { color: var(--muted); font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; text-align: left; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea, button {
  font-family: var(--font-body); font-size: 15px; padding: 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .1s var(--ease);
}
input::placeholder, textarea::placeholder { color: #576174; }
input:hover, select:hover, textarea:hover { border-color: #3d4a5e; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,180,216,0.22);
}
button {
  background: var(--accent); border: 1px solid var(--accent); color: #ffffff; cursor: pointer; font-weight: 700;
  box-shadow: var(--shadow-sm); text-transform: uppercase; letter-spacing: .03em; font-size: 13px;
}
button:hover { filter: brightness(1.15); box-shadow: var(--shadow-md); transform: translateY(-1px); }
button:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.link-btn {
  background: none; border: none; color: var(--accent); padding: 0; font-size: 13px;
  text-decoration: underline; cursor: pointer; box-shadow: none; font-weight: 400;
  text-transform: none; letter-spacing: normal;
}
.link-btn:hover { color: var(--danger); box-shadow: none; transform: none; filter: none; }

.alert { padding: 10px; border-radius: 6px; margin-bottom: 12px; animation: fadeInUp .3s var(--ease) both; }
.alert.error { background: rgba(255,92,92,0.12); color: var(--danger); border: 1px solid var(--danger); }

.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border);
  font-size: 13px; color: var(--muted); cursor: pointer;
  transition: all .15s var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.chip.active { background: var(--accent); color: #ffffff; border-color: var(--accent); box-shadow: var(--shadow-sm); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.grid > * { animation: fadeInUp .35s var(--ease) both; }
.grid > *:nth-child(1) { animation-delay: .02s; }
.grid > *:nth-child(2) { animation-delay: .06s; }
.grid > *:nth-child(3) { animation-delay: .10s; }
.grid > *:nth-child(4) { animation-delay: .14s; }
.grid > *:nth-child(5) { animation-delay: .18s; }
.grid > *:nth-child(6) { animation-delay: .22s; }
.grid > *:nth-child(7) { animation-delay: .26s; }
.grid > *:nth-child(n+8) { animation-delay: .30s; }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px;
  display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-sm);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
  position: relative; overflow: hidden;
}
.card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  transform: scaleX(0); transform-origin: left; transition: transform .25s var(--ease);
}
.card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.card:hover::before { transform: scaleX(1); }
.card::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(0,180,216,0.06), transparent);
  transform: translateX(-120%); pointer-events: none;
}
.card:hover::after { animation: sweep 1.1s var(--ease); }
.card-top { display: flex; justify-content: space-between; align-items: center; }
.card-body { font-size: 14px; color: var(--muted); }
.card-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 8px; }

.badge {
  font-size: 11px; padding: 3px 10px; border-radius: 999px; text-transform: capitalize;
  font-weight: 700; display: inline-flex; align-items: center; gap: 4px;
  background: rgba(0,180,216,0.14); color: var(--accent);
}
.badge.estado-cotizado { background: rgba(0,180,216,0.14); color: var(--accent); }
.badge.estado-agendado { background: rgba(255,159,10,0.14); color: #ff9f0a; }
.badge.estado-en_proceso { background: rgba(255,214,10,0.14); color: #ffd60a; }
.badge.estado-en_proceso::before { content: '●'; font-size: 8px; animation: pulseOpacity 1.4s ease-in-out infinite; }
.badge.estado-terminado { background: rgba(48,209,88,0.14); color: #30d158; }
.badge.estado-cancelado { background: rgba(255,92,92,0.14); color: var(--danger); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 16px; }
.form-grid .full { grid-column: 1 / -1; }

.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; color: var(--muted); transition: gap .15s var(--ease), color .15s; }
.back:hover { color: var(--accent); gap: 8px; }
.upload-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.foto {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
  animation: popIn .3s var(--ease) both;
}
.foto:hover { transform: translateY(-3px) scale(1.02); box-shadow: var(--shadow-md); z-index: 2; }
.foto img { width: 100%; height: 120px; object-fit: cover; display: block; }
.foto-pdf { display: flex; align-items: center; justify-content: center; height: 120px; background: rgba(0,180,216,0.08); color: var(--accent); font-weight: 600; font-size: 13px; text-align: center; padding: 8px; }
.foto-meta { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; font-size: 12px; color: var(--muted); text-transform: capitalize; }
.pill-tipo { padding: 2px 8px; border-radius: 999px; font-size: 11px; }
.pill-tipo-factura { background: rgba(48,209,88,0.14); color: #30d158; font-weight: 600; text-transform: none; }

.lightbox {
  /* display se controla por JS (style.display), no por el atributo [hidden]:
     un [hidden] con la misma especificidad que una clase pierde contra ella
     segun el orden del cascade, asi que aqui el default visible es intencional
     y JS es quien decide si se ve. */
  position: fixed; inset: 0; background: rgba(2,4,7,0.92); z-index: 100;
  align-items: center; justify-content: center; padding: 24px;
  animation: fadeInUp .2s var(--ease) both; cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 92vh; object-fit: contain; border-radius: 6px; box-shadow: var(--shadow-lg); }
.lightbox-cerrar {
  position: absolute; top: 16px; right: 24px; color: white; font-size: 34px; line-height: 1;
  cursor: pointer; opacity: .8;
}
.lightbox-cerrar:hover { opacity: 1; }

.tabla { width: 100%; border-collapse: collapse; margin-top: 12px; border-radius: 8px; overflow: hidden; }
.tabla th { text-align: left; padding: 10px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 2px solid var(--border); font-family: var(--font-head); font-weight: 700; }
.tabla td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 14px; }
.tabla tbody tr { transition: background .15s var(--ease); animation: fadeInUp .3s var(--ease) both; }
.tabla tbody tr:hover { background: rgba(0,180,216,0.05); }
.tabla tbody tr:nth-child(1) { animation-delay: .02s; }
.tabla tbody tr:nth-child(2) { animation-delay: .05s; }
.tabla tbody tr:nth-child(3) { animation-delay: .08s; }
.tabla tbody tr:nth-child(4) { animation-delay: .11s; }
.tabla tbody tr:nth-child(5) { animation-delay: .14s; }
.tabla tbody tr:nth-child(n+6) { animation-delay: .17s; }

@media (max-width: 600px) {
  .topbar { flex-wrap: nowrap; }
  #nav-toggle { display: block; }
  .topbar nav {
    display: none; flex-direction: column; align-items: stretch; gap: 2px;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--panel); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md); padding: 8px;
  }
  .topbar nav.abierto { display: flex; }
  .topbar nav a { padding: 12px 10px; }
  .topbar .user-info { display: none; }
  .user-info-movil {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 10px 4px; margin-top: 6px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted);
  }
  .user-info-movil a { color: var(--accent); }
}

.hilos { display: flex; flex-direction: column; gap: 8px; }
.hilo {
  display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px; transition: all .2s var(--ease);
}
.hilo:hover { border-color: var(--accent); transform: translateX(3px); box-shadow: var(--shadow-sm); }
.hilo-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hilo-nombre { font-weight: 600; }
.hilo-tel { font-size: 12px; color: var(--muted); }
.hilo-preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hilo-fecha { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.pill-origen { font-size: 11px; padding: 2px 8px; border-radius: 999px; flex-shrink: 0; }
.pill-origen.cliente { background: rgba(0,180,216,0.14); color: var(--accent); }
.pill-origen.equipo { background: rgba(48,209,88,0.14); color: #30d158; }

.chat-box { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 16px; }
.msg { max-width: 78%; padding: 9px 13px; border-radius: 10px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; animation: fadeInUp .25s var(--ease) both; }
.msg.entrante { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.msg.saliente { align-self: flex-end; background: var(--accent); color: #ffffff; border-bottom-right-radius: 3px; }
.msg-hora { display: block; font-size: 10px; opacity: 0.7; margin-top: 4px; }

/* ---------- Stat tiles (pagina de Inicio) ---------- */
.stat-tile {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
  border-left: 3px solid var(--border);
}
.stat-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-tile.tone-accent { border-left-color: var(--accent); }
.stat-tile.tone-good { border-left-color: #30d158; }
.stat-tile.tone-bad { border-left-color: var(--danger); }
.stat-tile.tone-neutral { border-left-color: #3d4a5e; }
.stat-tile .stat-icon { font-size: 20px; margin-bottom: 4px; display: block; }
.stat-tile .stat-label { color: var(--muted); font-size: 13px; }
.stat-tile .stat-value { font-family: var(--font-head); font-size: 26px; font-weight: 800; margin-top: 2px; letter-spacing: .01em; }
.stat-tile.stat-hero { grid-column: span 2; animation: pulseRing 3.2s ease-in-out infinite; }
.stat-tile.stat-hero .stat-value { font-size: 32px; }

/* ---------- Mini grafica de tendencia ---------- */
.chart-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 18px; box-shadow: var(--shadow-sm); margin-bottom: 24px; }
.chart-bar {
  transition: opacity .15s var(--ease); cursor: default;
  transform-box: fill-box; transform-origin: bottom;
  animation: growBar .6s var(--ease) both;
}
.chart-bar:hover { opacity: .75; }
.chart-bar:nth-of-type(1) { animation-delay: .03s; }
.chart-bar:nth-of-type(2) { animation-delay: .09s; }
.chart-bar:nth-of-type(3) { animation-delay: .15s; }
.chart-bar:nth-of-type(4) { animation-delay: .21s; }
.chart-bar:nth-of-type(5) { animation-delay: .27s; }
.chart-bar:nth-of-type(6) { animation-delay: .33s; }
.chart-bar:nth-of-type(n+7) { animation-delay: .39s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  body::before { animation: none; }
}
