/* Neutral white-label styles shared by the portal and the admin panel. */
:root {
  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --text: #18181b;
  --muted: #6b6b75;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --accent: #18181b;
  --accent-text: #ffffff;
  --focus: #3b82f6;
  --danger: #c2262d;
  --danger-bg: #fdf0f0;
  --ok: #17803d;
  --ok-bg: #effaf3;
  --warn-bg: #fff8e6;
  --warn: #8a5a00;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f11;
    --surface: #18181b;
    --surface-2: #202024;
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --border: #2a2a2f;
    --border-strong: #3a3a40;
    --accent: #f4f4f5;
    --accent-text: #18181b;
    --focus: #60a5fa;
    --danger: #f87171;
    --danger-bg: #2a1416;
    --ok: #4ade80;
    --ok-bg: #11251a;
    --warn-bg: #2a2110;
    --warn: #fbbf24;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- forms */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label, .label { font-size: 13px; font-weight: 600; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search],
input[type=month], select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 42px;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
input[readonly] { background: var(--surface-2); }
.code-input {
  font-family: var(--mono);
  font-size: 22px !important;
  letter-spacing: .35em;
  text-align: center;
}
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

button, .btn {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 16px;
  min-height: 42px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: opacity .15s, background .15s;
}
.btn-primary { background: var(--accent); color: var(--accent-text); width: 100%; }
.btn-primary.auto { width: auto; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-small { min-height: 32px; padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .55; cursor: default; }
.is-busy { position: relative; color: transparent !important; }
.is-busy::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--accent-text);
  border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.btn-ghost.is-busy::after, .btn-danger.is-busy::after { border-color: var(--text); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.link {
  background: none;
  border: none;
  padding: 0;
  min-height: 0;
  font-weight: 500;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link:hover { color: var(--text); }

.alert {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }

/* ------------------------------------------------------- portal (auth) */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 16px;
}
.auth-top { display: flex; justify-content: flex-end; }
.auth-main { display: grid; place-items: center; padding: 24px 0 48px; }
.card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}
.card.wide { max-width: 520px; }
.card h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 6px; }
.card .sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.card .actions { display: grid; gap: 12px; margin-top: 8px; }
.card .center { text-align: center; }
.card .spacer { height: 8px; }

.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.lang-switch button {
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  color: var(--muted);
}
.lang-switch button[aria-pressed=true] { background: var(--surface-2); color: var(--text); }

.qr { display: grid; place-items: center; padding: 16px; background: #fff; border-radius: var(--radius); border: 1px solid var(--border); margin: 0 0 14px; }
.qr svg { width: 196px; height: 196px; display: block; }
.secret {
  display: flex; gap: 8px; align-items: center;
  font-family: var(--mono); font-size: 13px; word-break: break-all;
  background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin: 6px 0 18px;
}
.secret span { flex: 1; }
.secret button { font-family: var(--font); }
.mb { margin-bottom: 16px !important; }

.auth-foot { text-align: center; font-size: 12px; color: var(--muted); padding: 8px 0 4px; }
.auth-foot a { color: inherit; text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }
.auth-foot span { margin: 0 6px; }

/* ------------------------------------------------- privacy / terms pages */
.legal-top {
  max-width: 760px; margin: 0 auto; padding: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.legal { max-width: 760px; margin: 0 auto; padding: 8px 16px 64px; }
.legal-doc h1 { font-size: 26px; font-weight: 600; letter-spacing: -.01em; margin: 8px 0 4px; }
.legal-meta { color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.legal-doc h2 { font-size: 16px; font-weight: 600; margin: 28px 0 8px; }
.legal-doc p, .legal-doc li { line-height: 1.65; overflow-wrap: anywhere; }
.legal-doc p { margin: 0 0 12px; }
.legal-doc ul { padding-left: 20px; margin: 0 0 12px; }
.legal-doc li { margin: 0 0 6px; }
.legal-doc a { text-underline-offset: 3px; }
.legal-sep { border: none; border-top: 1px solid var(--border); margin: 40px 0; }
html[data-lang="es"] .legal-doc[lang="en"],
html[data-lang="en"] .legal-doc[lang="es"],
html[data-lang] .legal-sep { display: none; }

.dest-list { display: grid; gap: 10px; margin: 0 0 20px; padding: 0; list-style: none; }
.dest {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; background: var(--surface);
}
.dest:hover { border-color: var(--border-strong); background: var(--surface-2); }
.dest strong { display: block; font-weight: 600; }
.dest small { color: var(--muted); font-size: 13px; }
.dest .arrow { color: var(--muted); font-size: 18px; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section { border-top: 1px solid var(--border); padding-top: 20px; margin-top: 20px; }
.section h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.method { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.method:last-of-type { border-bottom: none; }
.method small { display: block; color: var(--muted); font-size: 13px; }
.pill { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.on { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.off { background: var(--danger-bg); color: var(--danger); }
.footer-links { display: flex; justify-content: center; gap: 18px; margin-top: 18px; font-size: 14px; }

/* ----------------------------------------------------------------- admin */
.admin-header {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.admin-header .inner {
  max-width: 1120px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.admin-header h1 { font-size: 16px; font-weight: 600; margin: 0; }
.admin-header .who { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.tabs { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: flex; gap: 4px; overflow-x: auto; }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--muted); padding: 10px 12px; min-height: 0;
}
.tabs button[aria-selected=true] { color: var(--text); border-bottom-color: var(--text); }
.admin-main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 64px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar .grow { flex: 1; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
td .muted, .muted { color: var(--muted); }
td.actions { text-align: right; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
dialog .dlg-head { padding: 18px 20px 6px; }
dialog .dlg-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
dialog .dlg-body { padding: 12px 20px; overflow-y: auto; }
dialog .dlg-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
dialog .dlg-foot .left { margin-right: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.site-access { border: 1px solid var(--border); border-radius: var(--radius); }
.site-access .item { display: grid; grid-template-columns: 1fr 140px; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.site-access .item:last-child { border-bottom: none; }
.site-access .item input[type=text] { min-height: 34px; padding: 5px 8px; font-size: 13px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--accent); color: var(--accent-text);
  padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 50;
  max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 640px) {
  .card { padding: 24px 18px; }
  .grid-2 { grid-template-columns: 1fr; }
  .site-access .item { grid-template-columns: 1fr 110px; }
  .hide-sm { display: none; }
  th, td { padding: 10px; }
}
