/* ============================================================
   Panel cliente v2 — sistema visual "Actual" (prototipo aprobado
   por Pame, 2026-10-16). Se carga DESPUÉS de ds.css y del <style>
   de panel.html, así que pisa tokens y componentes solo en el panel
   cliente (el admin sigue con ds.css tal cual).
   Referencias: plantillas Alytics y Qarin (Framer), flujo de Wigy.
   ============================================================ */

:root {
  --accent:      #7a1538;   /* bordó de marca, sin degradé en botones */
  --accent-dim:  #5f0f2b;
  --accent-text: #f2c9d6;
  --accent-wash: #fbeef3;
  --accent-tint: #f7e4ec;
  --surface:     #f5f5f7;   /* fondo de la app */
  --surface-2:   #eeeef1;
  --white:       #ffffff;
  --ink:         #111014;
  --ink-soft:    #5f5b66;
  --ink-faint:   #9a96a1;
  --rule-light:  #e7e6eb;
  --ok:          #1f8a5b;  --ok-bg: #e6f4ed;  --ok-line: #bfe3cf;
  --warn:        #b26a00;  --warn-bg: #fbf1e1; --warn-line: #f0d6a8;
  --font:         'Figtree', 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Onest', 'Helvetica Neue', Arial, sans-serif;
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px;
  --shadow-soft: 0 1px 2px rgba(17,16,20,.04), 0 8px 24px rgba(17,16,20,.04);
  --shadow-card: 0 1px 2px rgba(17,16,20,.04), 0 8px 24px rgba(17,16,20,.05);
  --shadow-lift: 0 24px 60px rgba(17,16,20,.18);
}

body { background: var(--surface); font-size: 14px; }

/* ── Componentes base ── */
.btn { height: 40px; padding: 0 16px; border-radius: 10px; font-weight: 600; font-size: 13.5px; background: var(--accent); }
.btn:hover { background: var(--accent-dim); }
.btn--ghost { background: var(--white); color: var(--ink); border: 1px solid var(--rule-light); }
.btn--ghost:hover { background: var(--white); border-color: var(--ink-faint); }
.card { border-radius: var(--r-lg); border: 1px solid var(--rule-light); box-shadow: var(--shadow-soft); background: var(--white); }
.switch { width: 38px; height: 22px; }
.switch .slider::before { width: 16px; height: 16px; }
.switch input:checked + .slider::before { transform: translateX(16px); }
.f-field input, .field input, .input, .f-field textarea, .f-field select, select.input { border-radius: 10px; }
.fixed-note { border-radius: 12px; background: var(--white); }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.01em; }

/* ── Barra superior (reemplaza al sidebar) ── */
#app.visible { flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; height: 64px; flex: none;
  /* Mismo ancho que el contenido (.page, 1360px): logo y avatar no quedan en las esquinas. */
  padding: 0 max(clamp(16px, 3vw, 32px), calc((100% - 1360px) / 2 + clamp(16px, 3vw, 32px))); background: var(--white); border-bottom: 1px solid var(--rule-light);
  position: sticky; top: 0; z-index: 30;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: 15px; min-width: 0; }
.topbar__brand img { width: 26px; height: 26px; flex: none; }
.topbar__brand .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.ptabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--rule-light); border-radius: 12px; padding: 4px; margin: 0 auto; }
.ptab {
  border: 0; background: none; padding: 7px 18px; border-radius: 9px; cursor: pointer; font-family: inherit;
  font-size: 13.5px; font-weight: 600; color: var(--ink-soft); white-space: nowrap;
}
.ptab:hover { color: var(--ink); }
.ptab.active { background: var(--ink); color: #fff; }
.topbar__right { display: flex; align-items: center; gap: 8px; position: relative; }
/* Botón de la cuenta: nombre de la tienda + flecha (como Wigy). */
.account-btn {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 4px; border-radius: 10px;
  border: 1px solid var(--rule-light); background: var(--white); color: var(--ink); cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 600; max-width: 260px;
}
.account-btn:hover { background: var(--surface); }
.account-btn__av { flex: none; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-family: var(--font-display); font-size: 12px; font-weight: 600; }
.account-btn__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-btn__chev { flex: none; color: var(--ink-soft); transition: transform .15s; }
.account-btn[aria-expanded="true"] .account-btn__chev { transform: rotate(180deg); }
.account-menu {
  position: absolute; right: 0; top: 48px; min-width: 260px; z-index: 40; background: var(--white); border: 1px solid var(--rule-light);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(17,16,20,.14); padding: 6px; display: none;
}
.account-menu.open { display: block; }
.account-menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--rule-light); margin-bottom: 4px; font-size: 13px; }
.account-menu .who small { display: block; color: var(--ink-faint); }
.account-menu .logout-btn { border-radius: 8px; font-weight: 500; }
.main { height: auto; overflow: visible; }

/* ── Páginas ── */
.page { max-width: 1360px; margin: 0 auto; padding: 28px clamp(16px, 3vw, 32px) 56px; }
.page-head { align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -.03em; }
.page-head .sub { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Métricas: saludo + avisos */
.todo-card { padding: 4px 0; margin-bottom: 16px; }
.todo-card h3 { margin: 0; padding: 14px 20px 8px; font-size: 16px; font-weight: 600; }
.todo-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--rule-light); }
.todo-item .tic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.todo-item .tic svg { width: 16px; height: 16px; }
.tic--warn { background: var(--warn-bg); color: var(--warn); }
.tic--acc { background: var(--accent-wash); color: var(--accent); }
.tic--ok { background: var(--ok-bg); color: var(--ok); }
.todo-item .txt { flex: 1; min-width: 0; }
.todo-item .txt b { display: block; font-weight: 600; }
.todo-item .txt small { color: var(--ink-faint); font-size: 12.5px; }
.todo-empty { padding: 12px 20px 16px; color: var(--ink-soft); font-size: 13px; border-top: 1px solid var(--rule-light); }
.mx-card__num { font-family: var(--font-display); letter-spacing: -.03em; }
.mx-card, .mx-panel { border-radius: var(--r-lg); }

/* Módulos: lista agrupada por alcance */
.mod-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.mod-chip { border: 1px solid var(--rule-light); background: var(--white); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-family: inherit; font-size: 12.5px; color: var(--ink-soft); }
.mod-chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.mod-search { flex: 1; min-width: 200px; height: 38px; border-radius: 10px; }
.scope-group { overflow: visible; margin-bottom: 14px; }
.sg-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--rule-light); }
.sg-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface); color: var(--ink-soft); background-size: cover; background-position: center; }
.sg-icon svg { width: 18px; height: 18px; }
.sg-title { font-weight: 600; }
.sg-meta { color: var(--ink-faint); font-size: 12.5px; }
.sg-head .btn { margin-left: auto; height: 34px; font-size: 12.5px; }
/* Sin métricas en la fila: están en Métricas y en el botón de cada módulo. */
.cfg-line { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 1px solid var(--rule-light); position: relative; }
.cfg-line:last-child { border-bottom: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.cfg-line:hover { background: #fafafb; }
.cfg-line .mname { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cfg-line .micon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent); flex: none; }
.cfg-line .micon svg { width: 16px; height: 16px; }
.cfg-line .mname b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cfg-line .mname-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.cfg-line .mname-head b { min-width: 0; }
.cfg-line .mname small { display: block; color: var(--ink-faint); font-size: 12px; }
.cfg-line .stats { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.cfg-line .stats b { color: var(--ink); font-weight: 600; }
.cfg-line.is-off .micon, .cfg-line.is-off .mname b, .cfg-line.is-off .mname small, .cfg-line.is-off .stats { opacity: .5; }
.cfg-line .acts { display: flex; gap: 4px; position: relative; justify-content: flex-start; min-width: 148px; } /* lugar para 4 íconos: alineados aunque falte el menú */
.ibtn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent; background: none; display: grid; place-items: center; cursor: pointer; color: var(--ink-soft); }
.ibtn:hover { background: var(--white); border-color: var(--rule-light); color: var(--ink); }
.ibtn--danger:hover { color: var(--danger); border-color: var(--danger-line); }
.ibtn:disabled { opacity: .5; cursor: default; }
.ibtn svg { width: 16px; height: 16px; }
.pill-off { flex: none; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--ink-soft); }
.row-menu { position: absolute; right: 0; top: 40px; z-index: 40; background: var(--white); border: 1px solid var(--rule-light); border-radius: 12px; box-shadow: 0 12px 32px rgba(17,16,20,.14); padding: 5px; min-width: 230px; }
.row-menu button { display: flex; gap: 9px; align-items: center; width: 100%; border: 0; background: none; text-align: left; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 13px; color: var(--ink); }
.row-menu button:hover { background: var(--surface); }
.row-menu button.danger { color: var(--danger); }
.row-menu hr { border: 0; border-top: 1px solid var(--rule-light); margin: 4px 0; }

/* ── Editor ── */
.editor-header { padding: 0 clamp(16px, 3vw, 32px); top: 64px; }
.editor-header__inner { max-width: 1280px; }
.editor-header__row { align-items: center; padding: 14px 0 0; }
.editor-header__title-group { gap: 12px; }
.editor-header__title { font-size: 20px; font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; }
.editor-back { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--rule-light); background: var(--white); display: grid; place-items: center; cursor: pointer; color: var(--ink); flex: none; }
.editor-back:hover { border-color: var(--ink-faint); }
.scope-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 5px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--rule-light); color: var(--ink-soft); cursor: pointer; font-family: inherit; }
.scope-chip:hover { border-color: var(--ink-faint); color: var(--ink); }
.editor-header__desc { margin-top: 4px; margin-left: 48px; }
.editor-tabs { gap: 4px; margin-top: 10px; }
.editor-tab-btn { padding: 10px 12px; border-radius: 0; }
#editor-configs { display: none; }
.preview-stage .storefront { border-radius: 14px; box-shadow: 0 10px 40px rgba(17,16,20,.12); }

/* ── Crear (pasos de una decisión) ── */
.cr-ov { position: fixed; inset: 0; background: rgba(17,16,20,.42); z-index: 9999; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.cr-modal { width: 100%; max-width: 720px; background: var(--white); border-radius: 20px; box-shadow: var(--shadow-lift); overflow: hidden; }
.cr-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--rule-light); }
.cr-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.cr-steps { display: flex; gap: 6px; margin-left: auto; align-items: center; font-size: 12px; color: var(--ink-faint); }
.cr-steps i { width: 22px; height: 4px; border-radius: 2px; background: var(--rule-light); display: block; }
.cr-steps i.on { background: var(--accent); }
.cr-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.cr-foot { display: flex; justify-content: space-between; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--rule-light); background: #fafafb; }
.cr-opt { display: flex; gap: 14px; align-items: center; text-align: left; width: 100%; padding: 16px; border: 1px solid var(--rule-light); border-radius: 14px; background: var(--white); cursor: pointer; font-family: inherit; }
.cr-opt:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.cr-opt .ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent); flex: none; }
.cr-opt b { display: block; font-size: 14px; }
.cr-opt small { color: var(--ink-soft); font-size: 12.5px; }
.cr-sub { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }
.cr-groups { display: flex; flex-wrap: wrap; gap: 8px; }
.cr-groups .btn { height: 34px; font-size: 12.5px; }
.cr-list { border: 1px solid var(--rule-light); border-radius: 12px; max-height: 300px; overflow-y: auto; }
.cr-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--rule-light); cursor: pointer; width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; font-family: inherit; font-size: 13px; text-align: left; color: var(--ink); }
.cr-item:last-child { border-bottom: 0; }
.cr-item:hover { background: #fafafb; }
.cr-item .ph { width: 32px; height: 32px; border-radius: 8px; flex: none; background: var(--surface) center/cover no-repeat; }
.cr-item small { display: block; color: var(--ink-faint); font-size: 12px; }
.cr-item input { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.cr-mods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cr-mod { text-align: left; border: 1px solid var(--rule-light); border-radius: 14px; padding: 14px; background: var(--white); cursor: pointer; display: flex; flex-direction: column; gap: 8px; font-family: inherit; color: var(--ink); }
.cr-mod:hover { border-color: var(--accent); }
.cr-mod .micon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent); }
.cr-mod .micon svg { width: 18px; height: 18px; }
.cr-mod b { font-size: 13.5px; }
.cr-mod small { color: var(--ink-soft); font-size: 12px; line-height: 1.4; }
.cr-mod .tag { font-size: 11px; color: var(--ok); font-weight: 600; }
.cr-search { height: 40px; }

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; height: auto; padding-block: 10px; }
  .ptabs { order: 3; width: 100%; margin: 0; }
  .ptab { flex: 1; }
  .topbar__right { margin-left: auto; }
  .editor-header { top: 0; position: static; }
  .editor-header__desc { margin-left: 0; }
  .cfg-line { grid-template-columns: auto minmax(0, 1fr) auto; }
  .cfg-line .stats { grid-column: 2 / -1; grid-row: 2; }
  .cr-mods { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head h1 { font-size: 24px; }
}
@media (max-width: 520px) {
  .cr-mods { grid-template-columns: 1fr; }
  .sg-head .btn span { display: none; }
  .cfg-line { gap: 10px; padding: 12px 14px; }
  .cfg-line .mname b { white-space: normal; }
}
.row-menu svg { width: 15px; height: 15px; flex: none; color: var(--ink-soft); }
.row-menu.up { top: auto; bottom: 40px; }
.cr-mod small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cr-steps { white-space: nowrap; }

/* Cuenta y equipo */
.ptab[hidden], .account-stores[hidden] { display:none; }
.account-stores { padding:8px 10px 12px; border-bottom:1px solid var(--rule-light); }
.account-stores label { display:block; font-size:12px; color:var(--ink-soft); margin-bottom:6px; }
.account-stores select { width:100%; }
@media(max-width:540px) { #sidebar-nav .ptab { padding-left:12px; padding-right:12px; } }

/* Franja de administradora (entrada desde el admin) */
.admin-bar { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:6px 16px; padding:9px max(clamp(16px, 3vw, 32px), calc((100% - 1360px) / 2 + clamp(16px, 3vw, 32px))); background:var(--ink, #111014); color:#fff; font-size:13px; }
.admin-bar b { font-weight:600; }
.admin-bar a { color:#fff; font-weight:600; text-decoration:underline; text-underline-offset:3px; white-space:nowrap; }
/* Filas de módulos: toda la fila abre el editor */
.cfg-line.is-clickable { cursor: pointer; }
.cfg-line.is-clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.account-menu .logout-btn[hidden] { display: none; }
.account-stores { padding: 6px 0; border-top: 1px solid var(--rule-light); border-bottom: 1px solid var(--rule-light); margin: 4px 0; }
.account-stores__label { font-size: 11.5px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em; padding: 6px 10px 4px; }
.account-stores__list { max-height: 220px; overflow-y: auto; }
.account-stores__item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px;
  font-family: inherit; font-size: 13.5px; color: var(--ink); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-stores__item:hover:not(:disabled) { background: var(--surface); }
.account-stores__item.is-current { font-weight: 600; color: var(--accent); cursor: default; }
.account-stores__item.is-current::after { content: ' ✓'; }
/* Configuración de la tienda */
.settings-page { max-width: 820px; }
.settings-card { padding: 20px 22px; margin-bottom: 14px; }
.settings-card h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.settings-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.settings-row h2 { margin-bottom: 4px; }
.settings-help { font-size: 12.5px; color: var(--ink-soft); margin: 10px 0 0; }
.settings-dl { display: grid; gap: 10px; margin: 0; }
.settings-dl > div { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 12px; font-size: 13.5px; }
.settings-dl dt { color: var(--ink-soft); }
.settings-dl dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.settings-dl a { color: var(--accent); }
@media (max-width: 640px) {
  .account-btn__name, .account-btn__chev { display: none; }
  .account-btn { padding: 0 4px; border: 0; }
  .settings-dl > div { grid-template-columns: 1fr; gap: 2px; }
}
/* En el menú de la cuenta el texto se ve siempre (una regla vieja de la barra
   lateral lo ocultaba en pantallas chicas). */
.account-menu .logout-btn span { display: inline !important; }
.account-menu .logout-btn { justify-content: flex-start !important; }

/* Período de gracia: cobro pendiente o módulos pausados (lib/grace.js) */
.billing-bar { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px 16px; padding:10px max(clamp(16px, 3vw, 32px), calc((100% - 1360px) / 2 + clamp(16px, 3vw, 32px))); background:#fdf3e1; color:#5c3b00; border-bottom:1px solid #f1dcb0; font-size:13.5px; line-height:1.45; }
.billing-bar button { appearance:none; border:1px solid currentColor; background:transparent; color:inherit; font:inherit; font-weight:600; padding:6px 12px; border-radius:8px; cursor:pointer; white-space:nowrap; }
.billing-bar button:hover { background:rgba(92,59,0,.08); }
.settings-switch { display:inline-flex; align-items:center; gap:8px; font-size:13.5px; font-weight:500; cursor:pointer; white-space:nowrap; }
.settings-switch input { width:18px; height:18px; accent-color:var(--ink, #111); cursor:pointer; }
