:root {
  --bg: #0c0c11;
  --bg-2: #13131a;
  --card: #181822;
  --card-2: #1f1f2b;
  --line: #2a2a38;
  --text: #ececf2;
  --muted: #8f8fa3;
  --accent: #6b5bff;
  --accent-2: #8676ff;
  --ok: #2ecc71;
  --warn: #f5a623;
  --danger: #ef5350;
  --radius: 12px;
  --radius-sm: 8px;
  --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: #5c5c70; }
textarea { min-height: 90px; resize: vertical; }
select option { background: var(--bg-2); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.campo { margin-bottom: 14px; }
.campo-fila { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.campo-fila-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #2a2a3a; border-color: #3a3a4c; }
.btn-primario { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primario:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-peligro { color: var(--danger); }
.btn-peligro:hover { border-color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-link { background: none; border: none; color: var(--accent-2); padding: 0; font-size: 13px; }
.btn-link:hover { text-decoration: underline; background: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icono { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: 8px; }

/* Layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.barra-lateral {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.logo-marca {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  display: grid; place-items: center;
  color: #fff; font-size: 13px; font-weight: 700;
}
.selector-sitio { margin-bottom: 18px; }
.selector-sitio label { font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.nav button:hover { background: var(--card); }
.nav button.activo { background: var(--card-2); font-weight: 600; }
.nav .sub { padding-left: 24px; font-size: 13px; color: var(--muted); }
.nav .sub.activo { color: var(--text); }
.barra-lateral-pie {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.barra-lateral-pie .usuario { color: var(--text); word-break: break-all; margin-bottom: 8px; }

.contenido { padding: 28px 40px 60px; max-width: 1180px; width: 100%; }
.migas { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.migas span { color: var(--text); }
.cabecera { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }

.tarjeta {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.tarjeta-cab {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
}
.tarjeta-cuerpo { padding: 18px 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; align-items: start; }

.fila-dato {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.fila-dato:last-child { border-bottom: none; }
.fila-dato .etiqueta { color: var(--muted); font-size: 13px; }
.fila-dato .valor { font-weight: 600; text-align: right; word-break: break-all; }
.fila-dato .valor.mono { font-weight: 500; font-size: 13px; }

.esencial {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.esencial:last-child { border-bottom: none; }
.esencial .titulo { font-weight: 600; }
.esencial .detalle { color: var(--muted); font-size: 13px; }

.insignias { display: flex; gap: 8px; flex-wrap: wrap; }
.insignia {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-2);
}
.insignia::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
}
.insignia.ok::before { background: var(--ok); }
.insignia.warn::before { background: var(--warn); }
.insignia.danger::before { background: var(--danger); }
.insignia.info::before { background: var(--accent); }

.aviso {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.aviso .texto { font-size: 13px; }
.aviso .texto strong { display: block; font-size: 14px; margin-bottom: 2px; }

.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th {
  text-align: left; font-weight: 500; color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.tabla td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabla tr:last-child td { border-bottom: none; }
.tabla .mono { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 12px; }
.tabla-scroll { overflow-x: auto; }
.tabla input, .tabla select { padding: 7px 9px; font-size: 13px; }

.vacio { padding: 30px 20px; text-align: center; color: var(--muted); font-size: 13px; }

.medidor { display: flex; align-items: center; gap: 18px; }
.anillo { width: 64px; height: 64px; border-radius: 50%; background: conic-gradient(var(--accent) 0deg, var(--bg-2) 0deg); display: grid; place-items: center; }
.anillo::after { content: ""; width: 46px; height: 46px; border-radius: 50%; background: var(--card); }
.metricas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; font-size: 13px; }
.metricas .k { color: var(--muted); font-size: 12px; }
.metricas .v { font-weight: 600; }
.metricas .v em { color: var(--muted); font-style: normal; font-weight: 400; }

/* Planes email */
.planes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.plan {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column;
  position: relative;
}
.plan.destacado { border-color: var(--accent); }
.plan .popular {
  position: absolute; top: -10px; left: 20px;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
}
.plan h3 { font-size: 16px; margin-bottom: 4px; }
.plan .para { color: var(--muted); font-size: 13px; min-height: 40px; margin-bottom: 14px; }
.plan .precio { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.plan .precio small { font-size: 13px; font-weight: 400; color: var(--muted); }
.plan .tachado { color: var(--muted); text-decoration: line-through; font-size: 13px; margin-right: 8px; }
.plan .ahorro {
  display: inline-block; background: rgba(46,204,113,.15); color: var(--ok);
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
}
.plan .renovacion { color: var(--muted); font-size: 12px; margin: 8px 0 16px; line-height: 1.5; }
.plan ul { list-style: none; padding: 0; margin: 16px 0 0; font-size: 13px; }
.plan li { padding: 5px 0 5px 20px; position: relative; }
.plan li::before {
  content: ""; position: absolute; left: 0; top: 11px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
}
.plan li.no { color: var(--muted); }
.plan li.no::before { background: var(--line); }
.plan .grupo { color: var(--muted); font-size: 12px; margin: 14px 0 2px; font-weight: 600; }

/* Modal */
.modal-fondo {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: none; align-items: center; justify-content: center;
  padding: 20px; z-index: 50;
}
.modal-fondo.abierto { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
}
.modal-cab { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-cuerpo { padding: 20px 22px; }
.modal-pie { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.modal .nota { color: var(--muted); font-size: 13px; margin-bottom: 16px; line-height: 1.55; }
.modal .texto-largo { font-size: 13px; line-height: 1.65; color: #cfcfdc; }
.modal .texto-largo p { margin-bottom: 12px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--card-2); border: 1px solid var(--line);
  color: var(--text); padding: 12px 18px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60;
}
.toast.visible { opacity: 1; }
.toast.error { border-color: var(--danger); }

.pie-pagina {
  margin-top: 50px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: #4e4e60;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.pie-pagina button { background: none; border: none; color: #4e4e60; font-size: 11px; padding: 0; }
.pie-pagina button:hover { color: var(--muted); }

.oculto { display: none !important; }
.muted { color: var(--muted); }
.texto-sm { font-size: 12px; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.separador { height: 1px; background: var(--line); margin: 16px 0; }

/* Login */
.login-pantalla { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-caja { width: 100%; max-width: 380px; }
.login-caja .tarjeta-cuerpo { padding: 28px; }
.login-caja .logo { justify-content: center; padding-bottom: 8px; }
.login-caja .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

.zona-subida {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.zona-subida input { display: none; }
.zona-subida .btn { margin: 6px 4px 0; }
.progreso { height: 4px; background: var(--bg-2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progreso div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.estado-select { width: auto; padding: 6px 28px 6px 10px; font-size: 12px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .barra-lateral { position: static; height: auto; }
  .contenido { padding: 20px 16px 50px; }
  .grid-2, .grid-3, .planes, .campo-fila, .campo-fila-3, .metricas { grid-template-columns: 1fr; }
}
