/* Estilos de fsstorage. CSS propio, sin build. La marca llega por variables CSS (--brand). */
:root {
  --brand: #2f5bea;
  --brand-contrast: #fff;
  --bg: #f6f7f9;
  --surface: #fff;
  --text: #1b1f27;
  --muted: #5d6675;
  --border: #dfe3ea;
  --ok: #167a45;
  --warn: #9a6200;
  --danger: #b3261e;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--text); background: var(--bg);
  line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column;
}
body.has-bg { background-size: cover; background-position: center; background-attachment: fixed; }
a { color: var(--brand); }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
.hidden, [hidden] { display: none !important; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: #fff; padding: .5rem; z-index: 10; }

/* Cabecera y pie */
.site-header { background: var(--surface); border-bottom: 3px solid var(--brand); }
.site-header .bar { max-width: 1100px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); font-weight: 650; }
.logo img { height: 34px; width: auto; max-width: 160px; object-fit: contain; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a { padding: .4rem .7rem; border-radius: 6px; text-decoration: none; color: var(--text); font-size: .95rem; }
.nav a:hover, .nav a[aria-current="page"] { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.nav-toggle { display: none; margin-left: auto; }
@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; margin-left: 0; }
  .nav.open { display: flex; }
}
main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
main.narrow { max-width: 480px; }
main.medium { max-width: 760px; }
.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .85rem; }
.site-footer .bar { max-width: 1100px; margin: 0 auto; padding: 1rem; display: flex; gap: 1rem; flex-wrap: wrap; justify-content: space-between; }

/* Componentes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.card.flat { padding: 0; overflow: hidden; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; cursor: pointer;
  background: var(--brand); color: var(--brand-contrast); border: 1px solid var(--brand);
  padding: .55rem 1rem; border-radius: 6px; font: inherit; font-weight: 600; text-decoration: none; min-height: 40px;
}
.btn:hover { filter: brightness(.93); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { min-height: 32px; padding: .25rem .65rem; font-size: .85rem; }
.btn.block { width: 100%; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: 2px; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff; color: var(--text); min-height: 40px;
}
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 1rem; }
.field .hint { color: var(--muted); font-size: .82rem; margin-top: .2rem; overflow-wrap: anywhere; }
.field .error, .form-errors { color: var(--danger); font-size: .88rem; }
.form-errors { background: #fdecea; border: 1px solid #f3c1bd; padding: .6rem .8rem; border-radius: 6px; margin-bottom: 1rem; }
.form-errors ul { margin: 0; padding-left: 1.1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-2 > * { min-width: 0; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.check input { width: auto; }

.flash { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid; }
.flash.info { background: #eaf1fe; border-color: #c3d6fa; }
.flash.success { background: #e7f6ee; border-color: #b7e1c9; }
.flash.warning { background: #fff5e0; border-color: #f0d8a0; }
.flash.error { background: #fdecea; border-color: #f3c1bd; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #eceff4; color: var(--muted); }
.badge.lista, .badge.limpio, .badge.ok { background: #e1f4ea; color: var(--ok); }
.badge.subiendo, .badge.preparando, .badge.pendiente { background: #fff1d6; color: var(--warn); }
.badge.caducada, .badge.borrada { background: #eceff4; color: var(--muted); }
.badge.no_analizable { background: #fff1d6; color: var(--warn); }
.badge.subido { background: #e1f4ea; color: var(--ok); }
.badge.rechazado { background: #fdecea; color: var(--danger); }
.badge.activa { background: #e1f4ea; color: var(--ok); }
.badge.prueba { background: #eaf1fe; color: var(--brand); }
.badge.impago, .badge.suspendida, .badge.cancelada { background: #fdecea; color: var(--danger); }
.badge.bloqueada, .badge.infectado { background: #fdecea; color: var(--danger); }

/* Tablas: en móvil pasan a tarjetas */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
@media (max-width: 640px) {
  table.stack thead { display: none; }
  table.stack tr { display: block; padding: .6rem .9rem; border-bottom: 1px solid var(--border); }
  table.stack td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .2rem 0; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; }
}
.pager { display: flex; justify-content: space-between; align-items: center; padding: .75rem .9rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.stat b { display: block; font-size: 1.4rem; }
.meter { height: 8px; background: #e6e9ef; border-radius: 99px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--brand); }

/* Subida */
.upload-box { border: 1px dashed var(--border); border-radius: var(--radius); }
.link-box { display: flex; gap: .5rem; flex-wrap: wrap; }
.link-box input { flex: 1; min-width: 200px; }
.status { display: flex; gap: .6rem; align-items: center; padding: .7rem 1rem; border-radius: 6px; background: #fff5e0; border: 1px solid #f0d8a0; }
.status.ok { background: #e7f6ee; border-color: #b7e1c9; }
.status.err { background: #fdecea; border-color: #f3c1bd; }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* Páginas públicas centradas */
.public-hero { text-align: center; padding: 1rem 0 1.5rem; }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.file-list li:last-child { border-bottom: 0; }
.file-list .name { flex: 1; min-width: 160px; word-break: break-word; }
.scan-warning { flex-basis: 100%; order: 3; background: #fff5e0; border: 1px solid #f0d8a0; border-radius: 6px; padding: .4rem .6rem; color: var(--warn); }
.dns { font-size: .85rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.error-page { text-align: center; padding: 3rem 0; }
.error-page .code { font-size: 4rem; font-weight: 700; color: var(--brand); line-height: 1; }
.pad { padding: 1rem 1rem 0; }
.mt { margin-top: 1rem; }
.meter > .w-0 { width: 0%; }
.meter > .w-5 { width: 5%; }
.meter > .w-10 { width: 10%; }
.meter > .w-15 { width: 15%; }
.meter > .w-20 { width: 20%; }
.meter > .w-25 { width: 25%; }
.meter > .w-30 { width: 30%; }
.meter > .w-35 { width: 35%; }
.meter > .w-40 { width: 40%; }
.meter > .w-45 { width: 45%; }
.meter > .w-50 { width: 50%; }
.meter > .w-55 { width: 55%; }
.meter > .w-60 { width: 60%; }
.meter > .w-65 { width: 65%; }
.meter > .w-70 { width: 70%; }
.meter > .w-75 { width: 75%; }
.meter > .w-80 { width: 80%; }
.meter > .w-85 { width: 85%; }
.meter > .w-90 { width: 90%; }
.meter > .w-95 { width: 95%; }
.meter > .w-100 { width: 100%; }
select.auto { width: auto; }
.field-row { background: #fafbfc; padding: .75rem 1rem; margin-bottom: .75rem; }

/* Banner de correo sin verificar */
.verify-banner { background: #fff5e0; border-bottom: 1px solid #f0d8a0; color: #5c3b00; font-size: .92rem; }
.verify-banner .bar { max-width: 1100px; margin: 0 auto; padding: .5rem 1rem; display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.verify-banner form { margin: 0; }

/* Alta: selector de plan y periodo */
main.wide { max-width: 960px; }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 760px) { .plans { grid-template-columns: 1fr; } }
.plan-card { display: block; position: relative; cursor: pointer; font-weight: 400; background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.plan-card:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.plan-card input { position: absolute; opacity: 0; }
.plan-card:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: 2px; }
.plan-card .plan-name { display: block; font-size: 1.1rem; font-weight: 700; }
.plan-card .price { display: block; font-size: 1.5rem; font-weight: 700; margin: .25rem 0 .5rem; }
.plan-card ul { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: .88rem; }
.period { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface); margin-bottom: 1rem; }
.period label { margin: 0; padding: .4rem 1rem; cursor: pointer; font-weight: 600; }
.period label:has(input:checked) { background: var(--brand); color: var(--brand-contrast); }
.period input { position: absolute; opacity: 0; }
.period label:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: -3px; }
.field input[readonly] { background: #f0f2f6; }

fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.plain:disabled { opacity: .6; }
@media (max-width: 640px) { td.no-actions { display: none !important; } }

/* Diálogo de confirmación (fs.confirm) */
.fs-dialog { border: 0; border-radius: var(--radius); padding: 1.25rem; width: min(440px, 92vw); color: var(--text); box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.fs-dialog::backdrop { background: rgba(20, 24, 33, .5); }
.fs-dialog p { margin: 0 0 1rem; }
.fs-dialog input { margin-bottom: 1rem; }
.fs-dialog-actions { justify-content: flex-end; }

/* Administración de la plataforma: franja propia, inconfundible frente al panel de los clientes */
:root { --admin: #3b1a6b; --admin-soft: #ece4f7; }
.nav a.nav-admin { background: var(--admin); color: #fff; }
.nav a.nav-admin:hover { background: var(--admin); color: #fff; filter: brightness(1.15); }
.admin-bar { background: var(--admin); color: #fff; border-bottom: 4px solid #e0a000; }
.admin-bar .bar { max-width: 1280px; margin: 0 auto; padding: .55rem 1rem 0; }
.admin-bar .admin-title { display: flex; gap: .6rem; align-items: center; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: .85rem; }
.admin-bar .admin-title .tag { background: #e0a000; color: #2a1500; border-radius: 4px; padding: .05rem .45rem; }
.admin-nav { display: flex; gap: .15rem; flex-wrap: wrap; margin-top: .4rem; }
.admin-nav a { color: #e5dbf5; text-decoration: none; padding: .45rem .8rem; border-radius: 6px 6px 0 0; font-size: .93rem; }
.admin-nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.admin-nav a[aria-current="page"] { background: var(--bg); color: var(--admin); font-weight: 700; }
main.admin { max-width: 1280px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 640px; }
.table-scroll table.stack { min-width: 0; }
.admin-sec { margin-bottom: 1.5rem; }
.admin-sec > h2 { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.stat.warn b { color: var(--danger); }
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; gap: .6rem; align-items: baseline; padding: .6rem 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.alert-list li:last-child { border-bottom: 0; }
.alert-kind { background: #fff1d6; color: var(--warn); border-radius: 4px; padding: .05rem .45rem; font-size: .75rem; font-weight: 700; text-transform: uppercase; }
details.act { display: inline-block; vertical-align: top; }
details.act > summary { cursor: pointer; list-style: none; display: inline-flex; }
details.act > summary::-webkit-details-marker { display: none; }
details.act[open] > summary { margin-bottom: .4rem; }
details.act form { display: grid; gap: .4rem; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: .6rem; }
.btn.warn { background: #fff5e0; color: var(--warn); border-color: #f0d8a0; }
.badge.ok-dot { background: #e1f4ea; color: var(--ok); }
.badge.down { background: #fdecea; color: var(--danger); }
.filters { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; }
.filters .field { margin-bottom: 0; flex: 1 1 160px; }
