/* ===== Tema por variables (fase 1). Los colores de marca los pone theme.js ===== */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #14171f;
  --muted: #5b6472;
  --border: #dfe3ea;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --warn: #93370d;
  --warn-soft: #fffaeb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);

  /* marca (se sobrescriben desde JS por showroom) */
  --brand: #2563eb;
  --on-brand: #ffffff;
  --brand-fg: #1d4ed8;
  --accent: #f59e0b;
  --on-accent: #111111;
  --accent-fg: #92400e;

  --radius: 14px;
  --nav-h: 62px;
  --top-h: 56px;
  color-scheme: light;
}
:root[data-theme="dark_black"] {
  --bg: #000000;
  --surface: #0c0c0d;
  --text: #f2f4f7;
  --muted: #a3acb9;
  --border: #262a31;
  --danger: #f97066;
  --danger-soft: #2a0f0d;
  --ok: #47cd89;
  --ok-soft: #0a2218;
  --warn: #fdb022;
  --warn-soft: #2a1d05;
  --shadow: none;
  color-scheme: dark;
}
:root[data-theme="dark_gray"] {
  --bg: #15171c;
  --surface: #1e2128;
  --text: #eef0f4;
  --muted: #a8b0bd;
  --border: #2d323b;
  --danger: #f97066;
  --danger-soft: #2f1613;
  --ok: #47cd89;
  --ok-soft: #10281d;
  --warn: #fdb022;
  --warn-soft: #2e2208;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .25rem; }
p { margin: 0 0 .75rem; }
a { color: var(--brand-fg); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.boot { text-align: center; margin-top: 30vh; color: var(--muted); }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--brand-fg); outline-offset: 2px; border-radius: 6px; }

/* ===== Estructura ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 700; }
.brand img { width: 34px; height: 34px; object-fit: contain; border-radius: 8px; flex: none; }
.brand .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: var(--on-brand);
  display: grid; place-items: center; font-weight: 800; flex: none; }
.brand span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; gap: 4px; flex: none; }
.icon-btn {
  min-width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--text);
  font-size: 1.15rem; cursor: pointer; padding: 0 8px;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn.txt { font-size: .85rem; font-weight: 600; }

.content { padding: 16px 14px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
.content.public { padding-bottom: 32px; }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: .75rem; font-weight: 600; min-height: 44px;
}
.bottomnav a .ico { font-size: 1.3rem; line-height: 1; }
.bottomnav a.active { color: var(--brand-fg); }

/* ===== Componentes ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 + p.muted { margin-top: -.25rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-decoration: none; color: inherit; display: block; }
.stat b { display: block; font-size: 1.8rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .875rem; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 12px; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px; min-height: 46px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text);
  font: inherit; font-weight: 400;
}
input[type=color] { display: block; width: 100%; height: 46px; margin-top: 4px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
input[type=file] { margin-top: 6px; max-width: 100%; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin-bottom: 10px; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--brand); }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  background: var(--brand); color: var(--on-brand); font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.sec { background: transparent; color: var(--text); border-color: var(--border); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: .875rem; border-radius: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700;
  background: var(--bg); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.off { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.brand { background: var(--brand); color: var(--on-brand); border-color: transparent; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; padding-top: 0; }
.list .who { font-weight: 700; }
.list .sub { color: var(--muted); font-size: .85rem; }
.list .badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }

.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-size: .9rem; }
.alert.err, .error { background: var(--danger-soft); color: var(--danger); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.error { padding: 10px 12px; border-radius: 10px; font-size: .9rem; margin-bottom: 12px; }

.tabs { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 14px; gap: 4px; }
.tabs button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
.tabs button[aria-selected=true] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.auth { max-width: 420px; margin: 8vh auto 0; }
.auth-logo { width: 56px; height: 56px; border-radius: 16px; background: var(--brand); color: var(--on-brand);
  display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; margin-bottom: 12px; }
.center { text-align: center; }

.empty { text-align: center; color: var(--muted); padding: 18px 8px; }
.logo-prev { width: 96px; height: 96px; border: 1px dashed var(--border); border-radius: 16px; display: grid; place-items: center; overflow: hidden; background: var(--bg); }
.logo-prev img { width: 100%; height: 100%; object-fit: contain; }
.swatch-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.radio-card { display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; font-weight: 600; cursor: pointer; }
.radio-card input { width: 20px; height: 20px; accent-color: var(--brand); }
.chip-dark { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border); flex: none; }

/* ===== Modal y avisos ===== */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.modal { width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; background: var(--surface); color: var(--text);
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .modal-bg { align-items: center; } .modal { border-radius: 20px; } }
.modal h2 { margin-bottom: 10px; }
.linkbox { word-break: break-all; font-size: .85rem; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 10px; user-select: all; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); z-index: 60;
  background: #101828; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: .9rem; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.toast.err { background: #b42318; }

.prose h2 { margin-top: 1.2rem; }
.prose ul { padding-left: 1.2rem; margin: 0 0 .75rem; }
.prose li { margin-bottom: .3rem; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
