@font-face {
  font-family: 'PoppinsBanner';
  src: url('/fonts/Poppins-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: block;
}

/* Paleta de Linktic (la misma de certificacion_linktic) */
:root {
  --azul: #0a9bdc;
  --azul-oscuro: #0b6fa4;
  --verde: #46b649;
  --verde-oscuro: #389a3b;
  --tinta: #16222c;
  --gris: #5b6b78;
  --borde: #dde6ec;
  --fondo: #f3f7fa;
  --panel: #ffffff;
  --ok: #2f7d32;
  --ok-bg: #edf8ee;
  --err: #8c2f2f;
  --err-bg: #fff5f5;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(16, 36, 50, .06), 0 8px 24px rgba(16, 36, 50, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--tinta);
  font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; letter-spacing: -0.01em; font-weight: 700; }

/* ---------- Pantalla de ingreso ---------- */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1000px 500px at 15% -10%, #e4f4fd 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 110%, #e8f7e9 0%, transparent 55%),
    var(--fondo);
}
.login-card {
  width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--borde);
  border-radius: 20px; box-shadow: var(--sombra); padding: 40px 32px; text-align: center;
}
.login-card img { width: 180px; height: auto; margin-bottom: 26px; }
.login-card h1 { font-size: 21px; margin: 0 0 8px; }
.login-card > p { margin: 0 0 28px; color: var(--gris); font-size: 14px; }
.login-card .aviso { margin-bottom: 20px; text-align: left; }
.btn-google {
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 11px;
  padding: 12px 18px; border: 1px solid var(--borde); border-radius: 10px; background: #fff;
  color: var(--tinta); font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn-google:hover { background: #f7fafc; border-color: #c6d5e0; box-shadow: var(--sombra); }
/* Mientras se contacta a Google: sin más clics */
.btn-google[aria-disabled="true"] { pointer-events: none; color: var(--gris); background: #f7fafc; }
.login-card .nota-dominio { margin: 22px 0 0; font-size: 12.5px; color: var(--gris); }
.nota-dominio b { color: var(--azul-oscuro); }
.aviso { padding: 13px 15px; border-radius: 11px; font-size: 14px; border: 1px solid; }
.aviso.error { background: var(--err-bg); border-color: #f3c9c9; color: var(--err); }

.cargando { display: grid; place-items: center; min-height: 100dvh; color: var(--gris); text-align: center; }
.giro {
  width: 26px; height: 26px; margin: 0 auto 12px; border: 3px solid #d8e5ee; border-top-color: var(--azul);
  border-radius: 50%; animation: girar .8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 28px; background: var(--panel); border-bottom: 1px solid var(--borde);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand img { height: 48px; width: auto; margin: -4px 0; }
.brand a { display: flex; flex-shrink: 0; border-radius: 6px; }
.brand a:focus-visible { outline: 2px solid var(--azul); outline-offset: 2px; }
.brand h1 { font-size: 15px; }
.brand p { margin: 0; font-size: 12px; color: var(--gris); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #eef3f6; color: var(--gris); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.err { background: var(--err-bg); color: var(--err); }
.usuario { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gris); }
.usuario .avatar { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--borde); }
.topbar form { margin: 0; }
.btn-salir {
  border: 1px solid var(--borde); background: #fff; color: var(--gris); border-radius: 8px;
  padding: 7px 13px; cursor: pointer; font: inherit; font-size: 13px;
}
.btn-salir:hover { background: #f7fafc; color: var(--tinta); }
@media (max-width: 900px) {
  .usuario span, .brand p { display: none; }
}

/* ---------- Layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 680px);
  gap: 24px; padding: 24px; max-width: 1500px; margin: 0 auto;
}
.col-editor { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.col-preview {
  position: sticky; top: 94px; align-self: start;
  height: calc(100vh - 118px); display: flex; flex-direction: column; min-width: 0;
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .col-preview { position: static; height: 80vh; }
}
@media (max-width: 600px) {
  .layout { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .brand h1, .pill { display: none; }
}

/* ---------- Tarjetas ---------- */
.card { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); padding: 20px 22px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.card-head h2 { font-size: 16px; }
.step {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--azul); color: #fff; font-weight: 700; font-size: 12px; flex: none;
}
.hint { color: var(--gris); margin: 0 0 12px; font-size: 13px; }
#quotaInfo.bad { color: var(--err); font-weight: 600; }
kbd { font: 11px ui-monospace, monospace; padding: 1px 5px; border: 1px solid var(--borde); border-bottom-width: 2px; border-radius: 4px; background: #f8f9fb; }

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.field > span { font-weight: 600; font-size: 13px; }
.field small { font-weight: 400; color: var(--gris); }
.field input[type=text], .field input[type=email], .field input[type=password], .field textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--borde); border-radius: 8px; background: #fff; color: var(--tinta);
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus, .toolbar select:focus { outline: 2px solid var(--azul); outline-offset: -1px; border-color: transparent; }
.field input[type=range] { width: 100%; accent-color: var(--azul); }

.row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.grow { flex: 1; min-width: 200px; }

/* ---------- Botones ---------- */
.btn {
  font: 600 13px/1 inherit; font-family: inherit; padding: 10px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--borde); background: #fff; color: var(--tinta); white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #f4f6f9; }
.btn.small { padding: 8px 12px; }
.btn.primary { background: var(--azul); border-color: var(--azul); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--azul-oscuro); border-color: var(--azul-oscuro); }
.btn.accent { background: var(--verde); border-color: var(--verde); color: #fff; }
.btn.accent:hover:not(:disabled) { background: var(--verde-oscuro); border-color: var(--verde-oscuro); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Colores ---------- */
.swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 600px) { .swatches { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.swatch {
  display: flex; flex-direction: column; gap: 8px; padding: 8px; border: 2px solid var(--borde); border-radius: 10px;
  background: #fff; cursor: pointer; font: 600 12px inherit; font-family: inherit; color: var(--tinta); text-align: left;
}
.swatch .chip { height: 38px; border-radius: 6px; display: grid; place-items: center; font: 700 12px 'PoppinsBanner', sans-serif; }
.swatch[aria-checked=true] { border-color: var(--azul); box-shadow: 0 0 0 3px rgba(10, 155, 220, .15); }

/* ---------- Editor ---------- */
.editor-wrap { border: 1px solid var(--borde); border-radius: 10px; overflow: hidden; }
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 8px;
  background: #f8f9fb; border-bottom: 1px solid var(--borde); position: sticky; top: 0;
}
.tgroup { display: flex; align-items: center; gap: 2px; padding-right: 8px; border-right: 1px solid var(--borde); }
.tgroup:last-of-type { border-right: 0; }
.toolbar button, .colorbtn {
  position: relative; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 6px;
  border: 0; background: transparent; color: var(--tinta); cursor: pointer; font-size: 15px; font-family: Georgia, serif;
}
.toolbar button:hover, .colorbtn:hover { background: #e8ecf2; }
.toolbar button.active { background: #e2f4fc; color: var(--azul); }
.toolbar svg, .lock svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toolbar select { font: inherit; font-size: 13px; height: 30px; padding: 0 6px; border: 1px solid var(--borde); border-radius: 6px; background: #fff; }
.colorbtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }
.colorbar { position: absolute; left: 7px; right: 7px; bottom: 4px; height: 3px; border-radius: 2px; }
.colorbtn svg { margin-top: -4px; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--gris); cursor: pointer; }

/* El editor reproduce los estilos del correo para que lo que ves sea lo que se envía */
.editor {
  min-height: 340px; max-height: 70vh; overflow: auto; padding: 24px 32px; outline: none;
  font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 1.6; color: #222;
}
.editor:empty::before { content: 'Pega aquí el texto del correo…'; color: #9aa4b2; }
.editor p { margin: 0 0 14px; }
.editor h1 { font-size: 22px; line-height: 1.3; margin: 0 0 14px; font-family: Arial, Helvetica, sans-serif; }
.editor h2 { font-size: 18px; line-height: 1.35; margin: 0 0 12px; font-family: Arial, Helvetica, sans-serif; }
.editor h3 { font-size: 16px; line-height: 1.4; margin: 0 0 10px; font-family: Arial, Helvetica, sans-serif; }
.editor ul, .editor ol { margin: 0 0 14px; padding-left: 26px; }
.editor li { margin: 0 0 6px; }
.editor blockquote { margin: 0 0 0 40px; padding: 0; border: 0; }
.editor a { color: #0b6fa4; }
.editor hr { border: 0; border-top: 1px solid #d0d5dd; margin: 18px 0; }
.editor table { border-collapse: collapse; margin: 0 0 14px; }
.editor td, .editor th { border: 1px solid #c8ced6; padding: 6px 8px; vertical-align: top; }

/* ---------- Mensajes ---------- */
.msg { margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.err { background: var(--err-bg); color: var(--err); }
.msg.info { background: #eaf6fc; color: var(--azul-oscuro); }

.lock {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 8px;
  background: #fff6e5; color: #8a5300; font-size: 13px; margin: 6px 0 4px;
}
.lock.open { background: var(--ok-bg); color: var(--ok); }
.summary { font-size: 13px; color: var(--gris); margin-top: 8px; }
.summary b { color: var(--tinta); }
.summary .bad { color: var(--err); word-break: break-all; }

/* ---------- Vista previa ---------- */
.preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.preview-head h2 { font-size: 16px; }
.seg { display: inline-flex; border: 1px solid var(--borde); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 6px 12px; font: 600 12px inherit; font-family: inherit; cursor: pointer; color: var(--gris); }
.seg button.on { background: var(--azul); color: #fff; }
.preview-meta {
  background: #fff; border: 1px solid var(--borde); border-bottom: 0; border-radius: var(--radio) var(--radio) 0 0;
  padding: 10px 14px; font-size: 13px; display: grid; gap: 2px;
}
.preview-meta span { color: var(--gris); display: inline-block; width: 56px; }
.preview-frame {
  flex: 1; min-height: 0; background: #e9edf2; border: 1px solid var(--borde);
  border-radius: 0 0 var(--radio) var(--radio); overflow: hidden; display: flex; justify-content: center;
}
.preview-frame iframe { width: 100%; height: 100%; border: 0; background: #fff; transition: width .2s; }
.preview-frame.mobile iframe { width: 375px; max-width: 100%; }

/* ---------- Diálogo ---------- */
dialog { border: 0; border-radius: var(--radio); padding: 22px; max-width: 460px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0, 20, 35, .5); }
dialog h3 { font-size: 17px; margin-bottom: 8px; }
dialog p { color: var(--gris); }

/* ---------- Historial ---------- */
#historyBtn.on { background: #e2f4fc; border-color: var(--azul); color: var(--azul-oscuro); }
.history { max-width: 1200px; margin: 0 auto; padding: 24px; }
.history-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.history-head h2 { font-size: 19px; }
.history-head .hint { margin: 2px 0 0; }
.history-tools { display: flex; gap: 10px; flex-wrap: wrap; }
.history-tools input, .recipient-tools input {
  font: inherit; padding: 9px 11px; border: 1px solid var(--borde); border-radius: 8px; background: #fff; color: var(--tinta);
}
.history-tools input { width: 280px; max-width: 100%; }
.history-tools input:focus, .recipient-tools input:focus { outline: 2px solid var(--azul); outline-offset: -1px; border-color: transparent; }
.history-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
.history-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.history-table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--gris);
  padding: 12px 16px; border-bottom: 1px solid var(--borde); background: #f8fbfd; font-weight: 700;
}
.history-table td { padding: 12px 16px; border-bottom: 1px solid var(--borde); vertical-align: top; }
.history-table tbody tr { cursor: pointer; }
.history-table tbody tr:hover, .history-table tbody tr:focus { background: #f2fbff; outline: none; }
.history-table td small { display: block; color: var(--gris); font-size: 12px; }
.history-table .num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.history-empty { margin: 0; padding: 40px 20px; text-align: center; color: var(--gris); }
.row.center { justify-content: center; padding: 12px; }
.row.center:has(> [hidden]:only-child) { display: none; }
@media (max-width: 700px) {
  .history { padding: 16px; }
  .col-sender { display: none; }
  .history-tools, .history-tools input { width: 100%; }
}

/* ---------- Detalle de una divulgación ---------- */
.detail-dialog { max-width: 1200px; width: calc(100% - 32px); height: calc(100dvh - 48px); padding: 0; }
.detail-dialog[open] { display: flex; flex-direction: column; }
.detail-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--borde);
}
.detail-title { min-width: 0; flex: 1; }
.detail-title h3 { font-size: 17px; margin: 0; overflow-wrap: anywhere; }
.detail-title .hint { margin: 2px 0 0; }
.detail-actions { display: flex; gap: 8px; }
.detail-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.detail-preview { background: #e9edf2; min-height: 0; }
.detail-preview iframe { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
.detail-info { overflow-y: auto; padding: 18px 20px; border-left: 1px solid var(--borde); }
.facts { display: grid; grid-template-columns: 112px 1fr; gap: 9px 10px; margin: 0 0 16px; font-size: 13.5px; }
.facts dt { color: var(--gris); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.facts dd small { display: block; font-weight: 400; color: var(--gris); font-size: 12px; }
.facts .bad { color: var(--err); }
.recipients { border-top: 1px solid var(--borde); padding-top: 12px; }
.recipients summary { cursor: pointer; font-weight: 600; font-size: 13.5px; }
.recipient-tools { display: flex; gap: 8px; margin: 10px 0; }
.recipient-tools input { flex: 1; min-width: 0; padding: 7px 9px; font-size: 13px; }
.recipients ul { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.recipients li { padding: 4px 0; border-bottom: 1px dashed var(--borde); overflow-wrap: anywhere; }
.recipients li.failed { color: var(--err); }
.recipients li.more { color: var(--gris); border: 0; font-style: italic; }
.recipients + .recipients { margin-top: 12px; }
.recipients.invalid summary { color: var(--err); }
.recipients.invalid .hint { margin: 8px 0; font-size: 12.5px; }
.recipients.invalid li { color: var(--err); }
@media (max-width: 860px) {
  .detail-dialog { height: calc(100dvh - 32px); }
  .detail-body { grid-template-columns: 1fr; grid-template-rows: minmax(320px, 1fr) auto; overflow-y: auto; }
  .detail-info { border-left: 0; border-top: 1px solid var(--borde); overflow: visible; }
}

/* ---------- Campos obligatorios ---------- */
.req { color: var(--err); font-weight: 700; }
.field input.invalid { border-color: #e5a3a3; background: var(--err-bg); }
.field input.invalid:focus { outline-color: var(--err); }

/* ---------- Vista previa en modo oscuro (simulado) ---------- */
.preview-toggles { display: flex; gap: 8px; flex-wrap: wrap; }
.preview-frame.dark { background: #121212; }
.preview-frame.dark iframe { background: #1f1f1f; }
