/* Lealtad 3ED · Estilos de paneles (Blu Studio, negocio, caja) */
:root {
  --ground: #F4EEE7;
  --surface: #FFFFFF;
  --espresso: #2A1A12;
  --espresso-2: #1A0F0A;
  --caramel: #C8875A;
  --caramel-dark: #9C5F36;
  --latte: #E3B48F;
  --latte-soft: #EADBCB;
  --line: #EFE5DA;
  --field: #F4EEE7;
  --muted: #7A6252;
  --muted-2: #9A8576;
  --ok: #2F7D5B;
  --ok-bg: #E3F1E4;
  --warn-bg: #FFF1CC;
  --warn: #6B4A00;
  --error: #B42318;
  --error-bg: #FBE3DE;
  --radius-lg: 28px;
  --radius: 18px;
  --shadow: 0 8px 22px rgba(42, 26, 18, .07);
  --font: Urbanist, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--espresso); font-family: var(--font); font-size: 16px; line-height: 1.45; }
::selection { background: var(--latte); color: var(--espresso); }
a { color: var(--caramel-dark); text-underline-offset: 3px; }
a:hover { color: var(--espresso); }
:focus-visible { outline: 3px solid var(--caramel); outline-offset: 2px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.1; }
h1 { font-size: clamp(26px, 3vw, 34px); font-weight: 800; }
h2 { font-size: 20px; font-weight: 800; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }
img { max-width: 100%; }

/* ---------- Layout con menú lateral ---------- */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 240px; max-width: 100%; background: var(--espresso); color: #fff; padding: 22px 16px; display: flex; flex-direction: column; gap: 4px; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.side-brand strong { display: block; font-size: 16px; }
.side-brand div span { font-size: 13px; color: #D9C9BA; }
.side-brand .logo-dot { color: var(--espresso); }
.logo-dot { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; background: var(--latte); color: var(--espresso); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; overflow: hidden; }
.logo-dot img { width: 100%; height: 100%; object-fit: cover; }
.side a.nav { height: 46px; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-radius: 999px; color: #fff; text-decoration: none; font-size: 15px; font-weight: 600; }
.side a.nav:hover { background: rgba(255,255,255,.08); }
.side a.nav.active { background: var(--latte); color: var(--espresso); font-weight: 700; }
.side a.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.side .grow { flex-grow: 1; }
.side form { margin: 0; }
.side .user { padding: 12px 8px 4px; border-top: 1px solid rgba(255,255,255,.12); margin-top: 12px; font-size: 14px; color: #D9C9BA; display: flex; flex-direction: column; gap: 8px; }
.side .user strong { color: #fff; }
.link-btn { background: none; border: 0; padding: 0; color: #E3B48F; font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.main { flex: 999 1 560px; min-width: 0; padding: 28px clamp(16px, 3vw, 44px) 48px; display: flex; flex-direction: column; gap: 22px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.page-head p { margin-top: 6px; }

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .side { flex: 0 0 auto; flex-direction: row; flex-wrap: wrap; align-items: center; align-content: flex-start; gap: 6px; padding: 12px; }
  .side .user > span { display: none; }
  .main { flex: 1 1 auto; }
  .side-brand { padding: 0 8px 0 0; }
  .side .grow { display: none; }
  .side .user { border: 0; margin: 0; padding: 0 8px; flex-direction: row; align-items: center; }
  .side a.nav { height: 42px; padding: 0 14px; }
}

/* ---------- Superficies ---------- */
.card { background: var(--surface); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border-radius: 24px; padding: 18px 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 14px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 38px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi.dark { background: var(--espresso); color: #fff; }
.kpi.dark .label { color: var(--latte); }

/* ---------- Botones ---------- */
.btn { height: 48px; padding: 0 22px; border-radius: 999px; border: 0; font: inherit; font-size: 15px; font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; transition: background-color .2s ease, transform .1s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--espresso); color: #fff; box-shadow: 0 10px 22px rgba(42,26,18,.22); }
.btn-primary:hover { background: #3D271C; color: #fff; }
.btn-accent { background: var(--caramel-dark); color: #fff; }
.btn-accent:hover { background: #84502D; color: #fff; }
.btn-ghost { background: var(--surface); color: var(--espresso); border: 1.5px solid #E2D3C4; }
.btn-ghost:hover { background: var(--latte-soft); color: var(--espresso); }
.btn-danger { background: var(--surface); color: var(--error); border: 1.5px solid #F2C4BC; }
.btn-sm { height: 38px; padding: 0 16px; font-size: 14px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Formularios ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
legend { font-size: 18px; font-weight: 800; padding: 0; margin-bottom: 4px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label-text { font-size: 14px; font-weight: 700; }
.field .hint { font-size: 13px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=url], input[type=date], select, textarea {
  width: 100%; height: 50px; border-radius: 999px; border: 2px solid transparent; background: var(--field); padding: 0 18px; font: inherit; font-size: 16px; font-weight: 600; color: var(--espresso);
}
input:not([type]) { width: 100%; height: 50px; border-radius: 999px; border: 2px solid transparent; background: var(--field); padding: 0 18px; font: inherit; font-size: 16px; font-weight: 600; color: var(--espresso); }
textarea { height: auto; min-height: 96px; border-radius: 20px; padding: 14px 18px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%232A1A12' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 18px center; padding-right: 44px; }
input:focus, select:focus, textarea:focus { border-color: var(--caramel); outline: none; background: #fff; }
input::placeholder, textarea::placeholder { color: var(--muted-2); font-weight: 500; }
input[type=color] { width: 64px; height: 50px; padding: 4px; border-radius: 16px; border: 0; background: var(--field); cursor: pointer; }
input[type=file] { font: inherit; font-size: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }

/* Interruptor */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; background: var(--field); border-radius: 22px; cursor: pointer; }
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-text strong { font-size: 15px; }
.switch-text span { font-size: 13px; color: var(--muted); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 52px; height: 30px; border-radius: 999px; background: #D9C9BA; position: relative; flex-shrink: 0; transition: background-color .2s ease; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.18); transition: transform .25s cubic-bezier(.16,1,.3,1); }
.switch input:checked + .track { background: var(--espresso); }
.switch input:checked + .track::after { transform: translateX(22px); }
.switch input:focus-visible + .track { outline: 3px solid var(--caramel); outline-offset: 2px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 6px 18px; }
table.table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 640px; }
.table th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 700; padding: 14px 10px; }
.table td { padding: 14px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: #FCFAF7; }
.table .actions { text-align: right; white-space: nowrap; }
.biz { display: flex; align-items: center; gap: 12px; }
.biz .swatch { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 14px; overflow: hidden; }
.biz .swatch img { width: 100%; height: 100%; object-fit: cover; }
.biz strong { display: block; }
.biz span { font-size: 13px; color: var(--muted); }

/* ---------- Etiquetas ---------- */
.badge { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: #1E5B2A; }
.badge-off { background: #EFE9E2; color: var(--muted); }
.badge-red { background: var(--espresso); color: #fff; }
.badge-plan { background: var(--latte-soft); color: var(--espresso); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- Avisos ---------- */
.alert { padding: 14px 18px; border-radius: 20px; font-size: 15px; font-weight: 600; }
.alert-ok { background: var(--ok-bg); color: #1E5B2A; }
.alert-error { background: var(--error-bg); color: #8A2A1B; }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.flash-stack { display: flex; flex-direction: column; gap: 8px; }

.empty { text-align: center; padding: 40px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty p { max-width: 420px; color: var(--muted); }

/* ---------- Acceso (login / instalador / errores) ---------- */
body.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--espresso); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 34px; padding: 32px 28px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 30px 60px rgba(0,0,0,.3); }
.auth-card.wide { max-width: 560px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }
.checklist { list-style: none; margin: 0; padding: 14px 18px; background: var(--field); border-radius: 20px; display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.checklist .ok { color: #1E5B2A; }
.checklist .bad { color: var(--error); }

.logo-preview { width: 72px; height: 72px; border-radius: 50%; background: var(--field); display: inline-flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; font-weight: 800; }
.logo-preview img { width: 100%; height: 100%; object-fit: cover; }
.row-center { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.placeholder-hero { background: var(--espresso); color: #fff; border-radius: 32px; padding: 32px; display: flex; flex-direction: column; gap: 10px; }
.placeholder-hero p { color: #E9DCCF; max-width: 560px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.card h2 .badge { margin-left: 8px; vertical-align: middle; }
