/* ============================================================================
   NexoPrice · Panel
   Sistema visual v0.6 (Claude Design · Panel.dc.html):
   tinta sobre papel cálido, sidebar oscuro, naranja como único acento,
   Archivo para texto y JetBrains Mono para datos, etiquetas y códigos.
   Radios cortos (2–4 px), líneas finas, sin sombras decorativas.
   Las fuentes se cargan con <link> en header.php / login_layout.php.
   ============================================================================ */

:root {
    /* ── Tinta y texto ── */
    --ink: #14171a;
    --ink-soft: #3d4144;
    --muted: #6b6f73;
    --muted-2: #8b8e91;
    --muted-3: #b9bbbd;

    /* ── Superficies ── */
    --paper: #f6f5f2;
    --paper-2: #faf9f7;
    --vellum: #ffffff;
    --chip: #eceae6;

    /* ── Líneas ── */
    --line: #e2e1dd;
    --line-strong: #d6d5d0;
    --line-fine: #f0efec;

    /* ── Zona oscura (sidebar, login) ── */
    --dark: #14171a;
    --dark-2: #22262a;
    --dark-hover: #1b1f22;
    --dark-line: #2b2f33;
    --dark-line-2: #4a4e52;

    /* ── Marca ── */
    --brand: #ff6600;
    --brand-text: #c25000;
    --brand-tint: #fff1e6;
    --brand-soft: #fff8f3;
    --brand-ring: rgba(255, 102, 0, .18);

    /* ── Estados ── */
    --ok: #1f7a4d;
    --ok-tint: #e7f3ec;
    --ok-line: #bfdccb;
    --warn: #b4540a;
    --warn-tint: #fdf3ee;
    --warn-line: #f3d9cc;
    --bad: #b3261e;
    --bad-tint: #fdf1f0;
    --bad-line: #f0c9c4;

    /* ── Alias heredados (vistas antiguas y JS los referencian) ── */
    --paper-deep: var(--paper-2);
    --paper-dark: var(--dark);
    --rule: var(--line-strong);
    --rule-soft: var(--line);
    --rule-fine: var(--line-fine);
    --brand-deep: var(--brand-text);
    --accent: var(--ok);
    --accent-deep: var(--ok);
    --accent-tint: var(--ok-tint);
    --danger: var(--bad);
    --danger-tint: var(--bad-tint);
    --warning: var(--warn);
    --warning-tint: var(--warn-tint);

    /* ── Tipografía ── */
    --font-sans: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: var(--font-sans);
    --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, Menlo, monospace;

    /* ── Radios ── */
    --r-xs: 2px;
    --r-sm: 3px;
    --r-md: 4px;
    --r-lg: 6px;

    --content-max: 1600px;
    --sidebar-w: 248px;
    --gutter: 26px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

html {
    background: var(--paper);
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-variant-numeric: tabular-nums lining-nums;
}

h1, h2, h3, h4 {
    font-family: var(--font-sans);
    letter-spacing: -.015em;
}

a {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--line-strong);
    transition: border-color .15s ease, color .15s ease;
}

a:hover {
    border-bottom-color: var(--brand);
    color: var(--brand);
}

code,
pre,
.mono,
.nums {
    font-family: var(--font-mono);
    font-size: .875em;
    font-feature-settings: 'tnum', 'zero';
}

code {
    overflow-wrap: anywhere;
    word-break: break-word;
}

pre {
    overflow-x: auto;
    max-width: 100%;
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 10px 12px;
}

small {
    font-size: 11.5px;
    letter-spacing: .01em;
}

strong {
    font-weight: 600;
}

::selection {
    background: var(--brand);
    color: #fff;
}

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* ════════════════════════════════════════════════════════════════════════════
   LAYOUT PRINCIPAL — sidebar oscuro + contenido
   ════════════════════════════════════════════════════════════════════════════ */

.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
    /* La columna del sidebar sigue oscura aunque la página sea más alta que él. */
    background: linear-gradient(to right, var(--dark) var(--sidebar-w), transparent var(--sidebar-w));
}

/* ───── Sidebar ───── */
.sidebar {
    background: var(--dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 18px 0 22px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--dark-line-2) transparent;
}

.sidebar-brand {
    display: block;
    padding: 4px 18px 0;
    border: none !important;
}

.sidebar-brand:hover {
    border: none !important;
}

.sidebar-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-logo-full {
    display: block;
    height: 22px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    object-position: left center;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
}

.sidebar-section {
    font-family: var(--font-mono);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: .1em;
    font-weight: 500;
    color: var(--muted);
    padding: 0 18px 8px;
    margin: 18px 0 0;
}

.sidebar-nav > .sidebar-section:first-child {
    margin-top: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 18px 7px 16px;
    font-size: 13.5px;
    font-weight: 400;
    line-height: 1.4;
    color: var(--muted-3);
    border: none;
    border-left: 2px solid transparent;
    transition: color .15s ease, background .15s ease, border-color .15s ease;
}

.sidebar-link > span:not(.sidebar-num):not(.sidebar-badge) {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-link small {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    letter-spacing: .04em;
}

.sidebar-link:hover {
    color: #fff;
    background: var(--dark-hover);
    border-bottom: none;
    border-left-color: var(--dark-line-2);
}

.sidebar-link.is-active {
    color: #fff;
    background: var(--dark-2);
    border-left-color: var(--brand);
    font-weight: 600;
}

/* El diseño no numera las entradas: el número queda en el DOM pero oculto. */
.sidebar-num {
    display: none;
}

.sidebar-badge {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    background: var(--brand);
    padding: 2px 6px;
    min-width: 18px;
    border-radius: var(--r-xs);
    text-align: center;
    line-height: 1.4;
    display: inline-block;
    flex-shrink: 0;
}

.sidebar-badge[hidden] {
    display: none !important;
}

.sidebar-link:hover .sidebar-badge {
    background: var(--brand-text);
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 18px 0;
    border-top: 1px solid var(--dark-line);
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 500;
    color: #fff;
}

.sidebar-user-email {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-links {
    display: flex;
    gap: 12px;
    margin-top: 4px;
}

.sidebar-user-links a {
    color: var(--muted-2);
    border-bottom: 1px solid var(--dark-line-2);
    font-size: 12px;
}

.sidebar-user-links a:hover {
    color: #fff;
    border-bottom-color: var(--brand);
}

.sidebar-version {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: .07em;
    color: var(--muted);
}

.sidebar-footer-mark {
    width: 14px;
    height: 14px;
    opacity: .45;
}

/* ───── Topbar sticky ───── */
.content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 20px;
    padding: 12px var(--gutter);
    background: rgba(255, 255, 255, .95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.topbar-context {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex-wrap: wrap;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.topbar-user-name {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

/* Cliente en contexto. Para un usuario normal es una etiqueta; para el
   superadmin es el selector con el que cambia de cliente. Se muestra
   siempre en la barra superior: equivocarse de cliente al tocar precios
   o ajustes es el error caro de una instalación multicliente. */
.topbar-tenant,
.topbar-tenant-name {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--vellum);
    padding: 4px 4px 4px 12px;
    min-height: 34px;
    transition: border-color .2s ease;
}

.topbar-tenant-name {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
}

.topbar-tenant:hover,
.topbar-tenant:focus-within {
    border-color: var(--ink);
}

.topbar-tenant::before,
.topbar-tenant-name::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--brand);
    flex-shrink: 0;
}

.topbar-tenant-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .09em;
}

.topbar-tenant .topbar-tenant-select {
    width: auto;
    min-width: 150px;
    padding: 4px 6px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    background-color: transparent;
    box-shadow: none;
}

.topbar-tenant .topbar-tenant-select:focus {
    box-shadow: none;
}

.topbar-tenant .btn {
    padding: 5px 10px;
    font-size: 12px;
}

.topbar-tenant-slug {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.topbar .badge {
    font-size: 11px;
    padding: 4px 8px;
}

.topbar .topbar-logout {
    display: none;
}

/* ───── Cabecera de página ───── */
.page-heading {
    padding: 26px var(--gutter) 0;
    max-width: var(--content-max);
}

.page-heading-eyebrow,
.topbar-eyebrow {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
}

.page-heading-title,
.topbar-title {
    margin: 10px 0 0;
    font-size: 27px;
    font-weight: 700;
    letter-spacing: -.025em;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

/* Si la vista ya trae su propio .page-header, no se repite el título. */
.content:has(.page-header) .page-heading {
    display: none;
}

.page {
    padding: 22px var(--gutter) 60px;
    max-width: var(--content-max);
    min-width: 0;
}

/* ════════════════════════════════════════════════════════════════════════════
   AUTH — login y cambio de contraseña: pantalla partida oscuro / blanco
   ════════════════════════════════════════════════════════════════════════════ */

.auth-body {
    background: var(--dark);
    min-height: 100vh;
    color: var(--ink);
    position: relative;
}

.auth-stage {
    min-height: 100vh;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.auth-stage > .auth-side {
    padding: 56px 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 48px;
    color: #fff;
    background: var(--dark);
    border-right: 1px solid var(--dark-line);
}

.auth-card {
    padding: 56px 48px 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--vellum);
    position: relative;
}

.auth-card > * {
    width: 100%;
    max-width: 380px;
}

.auth-eyebrow {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin: 0 0 22px;
}

.auth-brand {
    display: block;
    margin: 0;
}

.auth-logo {
    display: block;
    height: 26px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.auth-headline {
    font-size: clamp(26px, 3vw, 38px);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -.03em;
    margin: 0;
    max-width: 16em;
    color: #fff;
}

.auth-headline em {
    font-style: normal;
    color: var(--brand);
}

.auth-lede {
    margin: 18px 0 0;
    font-size: 15px;
    line-height: 1.6;
    color: var(--muted-2);
    max-width: 26em;
}

.auth-meta {
    display: flex;
    flex-direction: column;
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    border-top: 1px solid var(--dark-line);
}

.auth-meta-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--dark-line);
    padding: 9px 0 8px;
}

.auth-meta-row:last-child {
    border-bottom: none;
}

.auth-meta-row span:last-child {
    color: var(--muted-3);
}

.auth-kicker {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--brand-text);
    margin: 0 0 14px;
}

.auth-section-title {
    margin: 0 0 12px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -.025em;
    line-height: 1.15;
    color: var(--ink);
}

.auth-help {
    color: var(--muted);
    font-size: 14px;
    margin: 0 0 28px;
    line-height: 1.6;
}

.auth-policy {
    color: var(--muted);
    font-size: 12px;
    margin: -4px 0 0;
    line-height: 1.5;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-form .form-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--ink-soft);
    gap: 7px;
}

.auth-form .form-input {
    font-size: 14px;
    padding: 12px 13px;
}

.auth-form .btn-primary {
    margin-top: 10px;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
}

.auth-foot {
    position: absolute;
    right: 48px;
    bottom: 24px;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ════════════════════════════════════════════════════════════════════════════
   FORMULARIOS
   ════════════════════════════════════════════════════════════════════════════ */

.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--ink-soft);
}

.form-input,
.form-control {
    font: inherit;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 400;
    color: var(--ink);
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background-color: var(--vellum);
    text-transform: none;
    letter-spacing: 0;
    max-width: 100%;
    transition: border-color .15s, box-shadow .15s;
}

.form-input:hover,
.form-control:hover {
    border-color: var(--muted-3);
}

.form-input:focus,
.form-control:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px var(--brand-ring);
}

.form-input:disabled,
.form-control:disabled {
    background-color: var(--paper-2);
    color: var(--muted);
    cursor: not-allowed;
}

select.form-input,
select.form-control {
    padding-right: 30px;
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                      linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

textarea.form-input,
textarea.form-control {
    line-height: 1.5;
}

input[type=number].form-input,
input[type=text].form-input,
.form-input.nums {
    font-variant-numeric: tabular-nums;
}

input[type=checkbox],
input[type=radio] {
    accent-color: var(--brand);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--ink);
    font-family: var(--font-sans);
}

.form-fieldset {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 16px 18px 18px;
    margin: 8px 0 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--vellum);
}

.form-fieldset legend {
    padding: 0 6px;
    margin-left: -6px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--ink);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.form-inline {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 14px;
}

.form-errors {
    background: var(--bad-tint);
    color: var(--bad);
    border: 1px solid var(--bad-line);
    border-radius: var(--r-md);
    padding: 10px 14px 10px 30px;
    margin: 0 0 16px;
    list-style: disc;
    font-size: 13px;
}

.form-errors li {
    margin: 2px 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin: 0;
}

.form-hint {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    margin-top: 2px;
    font-family: var(--font-sans);
    font-weight: 400;
    letter-spacing: 0;
}

.req {
    color: var(--bad);
    margin-left: 2px;
}

/* ════════════════════════════════════════════════════════════════════════════
   AVISOS · ALERTAS · FLASH
   ════════════════════════════════════════════════════════════════════════════ */

.alert {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 12px 16px;
    background: var(--vellum);
    margin-bottom: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--ink-soft);
}

.alert:empty {
    display: none;
}

.alert-error {
    border-color: var(--bad-line);
    background: var(--bad-tint);
    color: var(--bad);
}

.alert-success {
    border-color: var(--ok-line);
    background: var(--ok-tint);
    color: var(--ok);
}

.alert-warning {
    border-color: var(--warn-line);
    background: var(--warn-tint);
    color: var(--warn);
}

.alert-info {
    border-color: var(--line);
    background: var(--paper-2);
    color: var(--ink-soft);
}

.flashes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px var(--gutter) 0;
    max-width: var(--content-max);
}

.auth-card .flashes,
.auth-stage .flashes {
    padding: 0;
    margin: 0 0 20px;
}

.flash {
    padding: 11px 14px 11px 16px;
    border: 1px solid var(--line);
    border-left-width: 3px;
    border-radius: var(--r-md);
    font-size: 13.5px;
    line-height: 1.5;
    background: var(--vellum);
}

.flash-success {
    background: var(--ok-tint);
    color: var(--ok);
    border-color: var(--ok-line);
    border-left-color: var(--ok);
}

.flash-error {
    background: var(--bad-tint);
    color: var(--bad);
    border-color: var(--bad-line);
    border-left-color: var(--bad);
}

.flash-warning {
    background: var(--warn-tint);
    color: var(--warn);
    border-color: var(--warn-line);
    border-left-color: var(--warn);
}

.flash-info {
    background: var(--vellum);
    color: var(--ink);
    border-color: var(--line);
    border-left-color: var(--ink);
}

/* ════════════════════════════════════════════════════════════════════════════
   BOTONES
   ════════════════════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: var(--r-sm);
    font: inherit;
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 13px;
    line-height: 1.2;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink-soft);
    text-decoration: none;
    white-space: nowrap;
    transition: background .2s, color .2s, border-color .2s;
}

.btn:hover {
    text-decoration: none;
}

.btn-sm {
    padding: 6px 11px;
    font-size: 12px;
    border-radius: var(--r-xs);
}

.btn-block {
    width: 100%;
}

.btn.is-disabled,
.btn:disabled {
    opacity: .45;
    pointer-events: none;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

.btn-ghost,
.btn-outline {
    background: var(--vellum);
    border-color: var(--line-strong);
    color: var(--ink-soft);
}

.btn-ghost:hover,
.btn-outline:hover {
    border-color: var(--ink);
    color: var(--ink);
    background: var(--vellum);
}

.btn-link {
    background: transparent;
    color: var(--ink-soft);
    border: none;
    padding: 4px 0;
    border-bottom: 1px solid var(--line-strong);
    border-radius: 0;
    font-weight: 500;
}

.btn-link:hover {
    color: var(--brand);
    border-bottom-color: var(--brand);
    background: transparent;
}

.btn-danger {
    background: var(--bad);
    color: #fff;
    border-color: var(--bad);
    font-weight: 600;
}

.btn-danger:hover {
    background: #8e1d17;
    border-color: #8e1d17;
    color: #fff;
}

.btn-destacado {
    outline: 3px solid var(--brand-ring);
    outline-offset: 1px;
}

/* Celda "Cambiar precio" en /productos.php — botones e input apilados */
.precio-actions {
    display: flex !important;
    flex-direction: column !important;
    gap: 5px !important;
    align-items: stretch !important;
    width: 100%;
    min-width: 150px;
}

.precio-actions form {
    margin: 0 !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 5px !important;
}

.precio-actions .btn {
    width: 100% !important;
    display: flex !important;
    justify-content: center;
}

.precio-actions .form-input {
    width: 100% !important;
    padding: 6px 8px;
    font-size: 13px;
}

.actions {
    white-space: nowrap;
}

.actions .btn {
    margin-right: 4px;
}

.search-actions,
.gs-match-actions,
.chart-range-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.gs-match-actions {
    margin-top: 6px;
}

/* ════════════════════════════════════════════════════════════════════════════
   PANELES · TARJETAS · KPI
   ════════════════════════════════════════════════════════════════════════════ */

.panel {
    background: var(--vellum);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 20px 20px 22px;
    margin-bottom: 18px;
    min-width: 0;
}

.panel-narrow {
    max-width: 560px;
}

.panel-title {
    margin: 0 0 14px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.015em;
    line-height: 1.3;
}

.panel-head,
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding-bottom: 14px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.panel-head .panel-title,
.panel-header .panel-title {
    margin: 0;
}

/* Tarjeta de dato suelto (p. ej. "Productos del día") */
.card {
    background: var(--vellum);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 16px 16px 18px;
    position: relative;
    min-width: 0;
}

.card-title {
    margin: 0 0 9px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    line-height: 1.4;
}

.card-big {
    font-family: var(--font-mono);
    font-size: 24px;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -.02em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums lining-nums;
}

.card-sub {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    margin-top: 8px;
    letter-spacing: .02em;
}

.card-warning {
    background: var(--warn-tint);
    border-color: var(--warn-line);
    padding: 16px 18px;
    margin-bottom: 18px;
    color: var(--ink-soft);
}

.card-warning .card-title {
    color: var(--warn);
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: -.01em;
}

.card-warning p {
    margin: 6px 0;
    font-size: 13.5px;
}

.card-warning ul {
    margin: 6px 0 4px 20px;
    font-size: 13px;
}

/* Variante con cabecera (listados de gestión) */
.card.with-header {
    padding: 0;
    margin-bottom: 18px;
    overflow: hidden;
}

.card-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: transparent;
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--ink);
}

.card-header.is-summary {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header.is-summary:hover {
    background: var(--paper-2);
}

.card-body {
    padding: 16px;
}

.card-body.p-0 {
    padding: 0;
}

.card-body.p-0 .table th:first-child,
.card-body.p-0 .table td:first-child {
    padding-left: 16px;
}

.card-body.p-0 .table th:last-child,
.card-body.p-0 .table td:last-child {
    padding-right: 16px;
}

/* ───── Rejillas ───── */
.grid {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
}

.grid > * {
    min-width: 0;
}

.grid-2,
.grid-3 {
    grid-template-columns: 1fr;
    align-items: start;
}

.grid > .panel,
.grid > .card {
    margin-bottom: 0;
}

.grid-kpi {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
}

@media (min-width: 1100px) {
    .grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ───── KPI ───── */
.kpi {
    background: var(--vellum);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 16px 16px 18px;
    position: relative;
    min-width: 0;
}

.kpi-link {
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: border-color .2s ease, background .2s ease;
}

.kpi-link:hover,
.kpi-link:focus-visible {
    border-color: var(--ink);
    color: inherit;
    background: var(--vellum);
}

.kpi-link:hover .kpi-label,
.kpi-link:focus-visible .kpi-label {
    color: var(--ink);
}

.kpi-value {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: -.02em;
    color: var(--ink);
    font-variant-numeric: tabular-nums lining-nums;
    overflow-wrap: anywhere;
}

.kpi-label {
    margin-top: 9px;
    font-family: var(--font-sans);
    font-size: 12px;
    line-height: 1.35;
    color: var(--ink-soft);
    font-weight: 400;
}

.kpi.badge-success .kpi-value {
    color: var(--ok);
}

.kpi.badge-danger {
    border-color: var(--bad-line);
}

.kpi.badge-danger .kpi-value {
    color: var(--bad);
}

.kpi.badge-warn,
.kpi.badge-gs {
    border-color: var(--warn-line);
}

.kpi.badge-warn .kpi-value,
.kpi.badge-gs .kpi-value {
    color: var(--warn);
}

.kpi.badge-info .kpi-value {
    color: var(--ink);
}

.kpi.badge-muted .kpi-value {
    color: var(--muted);
}

.kpi.badge-danger:hover,
.kpi.badge-danger:focus-visible {
    border-color: var(--bad);
}

/* Las clases de estado no deben pintar el KPI como si fuera un badge. */
.kpi.badge-success,
.kpi.badge-danger,
.kpi.badge-info,
.kpi.badge-muted,
.kpi.badge-warn,
.kpi.badge-gs {
    background: var(--vellum);
    font-family: var(--font-sans);
    text-transform: none;
    letter-spacing: 0;
}

.kpi[data-num]::before {
    content: attr(data-num);
    position: absolute;
    top: 12px;
    right: 12px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted-2);
    letter-spacing: .06em;
}

/* ════════════════════════════════════════════════════════════════════════════
   TABLAS
   ════════════════════════════════════════════════════════════════════════════ */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    font-variant-numeric: tabular-nums lining-nums;
}

.table th,
.table td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line-fine);
    vertical-align: middle;
}

.table th {
    background: var(--paper-2);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table th[data-sort-col] {
    cursor: pointer;
    user-select: none;
}

.table th[data-sort-col]:hover {
    color: var(--ink);
}

.table th.num,
.table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.table td.num {
    font-family: var(--font-mono);
    font-size: 12.5px;
    white-space: nowrap;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: background .18s;
}

.table-hover tbody tr:hover,
.table tbody tr:hover {
    background: var(--paper-2);
}

.table tbody td code {
    color: var(--ink-soft);
    font-size: 12px;
    /* break-word no reduce el ancho mínimo de la columna: un SKU no se parte. */
    overflow-wrap: break-word;
    word-break: normal;
}

.table td small.muted,
.table td .small.muted {
    font-family: var(--font-mono);
    font-size: 11px;
}

.table a {
    border-bottom-color: transparent;
}

.table a:hover {
    border-bottom-color: var(--brand);
}

.table a.btn,
.table a.badge {
    border-bottom-color: inherit;
}

/* Una tabla dentro de un panel se ve a sangre con el borde del panel. */
.panel > .table,
.panel > form > .table {
    width: calc(100% + 40px);
    margin-left: -20px;
    margin-right: -20px;
}

.panel > .table th:first-child,
.panel > .table td:first-child,
.panel > form > .table th:first-child,
.panel > form > .table td:first-child {
    padding-left: 20px;
}

.panel > .table th:last-child,
.panel > .table td:last-child,
.panel > form > .table th:last-child,
.panel > form > .table td:last-child {
    padding-right: 20px;
}

.panel > .table:last-child {
    margin-bottom: -22px;
}

/* Contenedor de scroll horizontal para tablas anchas */
.table-wrap,
.table-responsive {
    overflow-x: auto;
}

.text-right {
    text-align: right;
}

.text-success {
    color: var(--ok);
    font-weight: 600;
}

.text-danger {
    color: var(--bad);
    font-weight: 600;
}

.muted,
.text-muted {
    color: var(--muted);
}

.ink {
    color: var(--ink);
}

.small {
    font-size: 12px;
}

.mb-4 {
    margin-bottom: 24px;
}

.error-list {
    word-break: break-word;
    max-width: 360px;
    display: inline-block;
    white-space: pre-wrap;
    font-family: var(--font-mono);
    font-size: 11.5px;
}

.empty-state {
    padding: 40px 24px;
    color: var(--muted);
    text-align: center;
    font-size: 13.5px;
}

/* ════════════════════════════════════════════════════════════════════════════
   BADGES · ESTADOS
   ════════════════════════════════════════════════════════════════════════════ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: var(--r-xs);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
    line-height: 1.3;
    white-space: nowrap;
    background: var(--chip);
    color: var(--ink-soft);
    border: none;
}

a.badge:hover {
    color: inherit;
    filter: brightness(.96);
}

.badge-success,
.b-suc {
    background: var(--ok-tint);
    color: var(--ok);
}

.badge-danger,
.b-dan {
    background: var(--bad-tint);
    color: var(--bad);
}

.badge-info,
.b-info {
    background: var(--chip);
    color: var(--ink-soft);
}

.badge-gs,
.badge-warn {
    background: var(--warn-tint);
    color: var(--warn);
}

.badge-new {
    background: var(--brand-tint);
    color: var(--brand-text);
}

.badge-muted,
.b-mut {
    background: transparent;
    color: var(--muted);
    box-shadow: inset 0 0 0 1px var(--line);
}

.badge-secondary,
.badge-admin,
.badge-superadmin {
    background: var(--ink);
    color: #fff;
}

.badge-visitante {
    background: var(--chip);
    color: var(--ink-soft);
}

/* Competidores nuevos por revisar (ficha de producto) */
.competidores-url {
    max-width: 360px;
    overflow-wrap: anywhere;
    font-family: var(--font-mono);
    font-size: 12px;
}

.competidores-titulo {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

/* ════════════════════════════════════════════════════════════════════════════
   CABECERA DE VISTA · FILTROS · PAGINACIÓN
   ════════════════════════════════════════════════════════════════════════════ */

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px 20px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.page-title {
    margin: 0;
    font-size: 27px;
    font-weight: 700;
    letter-spacing: -.025em;
    line-height: 1.15;
}

.page-title code {
    font-size: .8em;
    font-weight: 500;
}

.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 18px;
    padding: 12px 14px;
    background: var(--vellum);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}

.filters::before {
    content: "Filtros";
    align-self: center;
    margin-right: 4px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--muted);
}

.filters .form-input {
    min-width: 180px;
}

.filter-active {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    padding: 10px 14px;
    background: var(--brand-soft);
    border: 1px solid var(--brand);
    border-radius: var(--r-md);
    font-size: 13px;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    margin-top: 0;
    background: var(--paper);
    border-top: 1px solid var(--line);
}

.panel > .pagination:last-child {
    margin: 16px -20px -22px;
    border-radius: 0 0 var(--r-md) var(--r-md);
}

.pagination-info {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.pagination-actions {
    display: flex;
    gap: 8px;
}

.pagination-actions .btn {
    padding: 6px 11px;
    font-size: 12px;
}

/* ════════════════════════════════════════════════════════════════════════════
   FICHA DE PRODUCTO · GRÁFICO
   ════════════════════════════════════════════════════════════════════════════ */

.producto-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 14px 24px;
    margin-bottom: 4px;
}

.producto-head .panel-title {
    font-size: 21px;
    letter-spacing: -.02em;
    margin-bottom: 8px;
}

.producto-head .muted code {
    color: var(--muted);
}

.chart-wrap {
    background: var(--vellum);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 20px;
}

.chart-wrap--tall {
    min-height: 420px;
    display: flex;
    align-items: stretch;
}

.chart-wrap--tall > canvas {
    width: 100% !important;
    height: 380px !important;
    flex: 1;
}

.chart-range-form {
    margin-bottom: 14px;
}

@media (max-width: 720px) {
    .chart-wrap--tall {
        min-height: 320px;
    }

    .chart-wrap--tall > canvas {
        height: 300px !important;
    }
}

/* Cajas internas de la ficha (antes con estilos inline, bloqueados por la CSP) */
.producto-edit-box {
    margin-top: 16px;
    padding: 16px 18px;
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}

.producto-edit-box[hidden] {
    display: none;
}

.aviso-migracion {
    margin-top: 16px;
    padding: 16px 18px;
    background: var(--warn-tint);
    border: 1px solid var(--warn-line);
    border-radius: var(--r-md);
    color: var(--ink-soft);
}

.aviso-migracion .panel-title {
    color: var(--warn);
}

.zona-riesgo {
    margin-top: 16px;
    padding: 18px 20px;
    background: var(--bad-tint);
    border: 1px solid var(--bad-line);
    border-radius: var(--r-md);
    color: var(--ink-soft);
}

.zona-riesgo .panel-title {
    color: var(--bad);
    font-size: 15px;
}

.zona-riesgo .btn-outline {
    border-color: var(--bad);
    color: var(--bad);
    font-weight: 600;
}

.zona-riesgo .btn-outline:hover {
    background: var(--bad);
    color: #fff;
}

/* Acciones de cambio de precio en el detalle: dos tarjetas con divisor "o" */
.precio-actions-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 18px;
    margin-top: 6px;
}

.precio-action-card {
    flex: 1 1 320px;
    min-width: 260px;
    background: var(--vellum);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: space-between;
}

.precio-action-card__title {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    font-weight: 500;
}

.precio-action-card__hint {
    margin: 0;
    font-size: 13.5px;
    color: var(--ink);
    line-height: 1.45;
}

.precio-action-separator {
    position: relative;
    width: 1px;
    background: var(--line);
    margin: 0 4px;
    align-self: stretch;
}

.precio-action-separator > span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--vellum);
    padding: 4px 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
}

@media (max-width: 720px) {
    .precio-action-separator {
        width: 100%;
        height: 1px;
        margin: 6px 0;
    }
}

/* ════════════════════════════════════════════════════════════════════════════
   COMBO DE BÚSQUEDA · LOGO DE INFORME
   ════════════════════════════════════════════════════════════════════════════ */

ul#combo-options {
    background: var(--vellum);
    padding: 0;
    margin: 4px 0 0;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    max-height: 320px;
    overflow-y: auto;
}

li.combo-option {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-fine);
    list-style-type: none;
    font-size: 13.5px;
}

li.combo-option:last-child {
    border-bottom: none;
}

li.combo-option:hover,
li.combo-option.is-active {
    background: var(--paper-2);
    cursor: pointer;
}

input#combo-search {
    width: 100%;
}

.logo-preview {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 16px 18px;
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
}

.logo-preview-img {
    max-width: 100%;
    max-height: 80px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

/* ════════════════════════════════════════════════════════════════════════════
   NAV TOGGLE (hamburguesa) · sólo en móvil
   ════════════════════════════════════════════════════════════════════════════ */

.nav-toggle {
    display: none;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--vellum);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
}

.nav-toggle span {
    display: block;
    width: 16px;
    height: 1.5px;
    background: var(--ink);
    transition: transform .2s ease, opacity .2s ease;
}

.is-sidebar-open .nav-toggle span:nth-child(1) {
    transform: translateY(5.5px) rotate(45deg);
}

.is-sidebar-open .nav-toggle span:nth-child(2) {
    opacity: 0;
}

.is-sidebar-open .nav-toggle span:nth-child(3) {
    transform: translateY(-5.5px) rotate(-45deg);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 23, 26, .45);
    z-index: 40;
}

/* ════════════════════════════════════════════════════════════════════════════
   TOASTS (esquina inferior derecha)
   ════════════════════════════════════════════════════════════════════════════ */

.toast-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
    max-width: calc(100vw - 40px);
}

.toast {
    background: var(--ink);
    color: #fff;
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.4;
    border-left: 3px solid var(--brand);
    border-radius: var(--r-md);
    box-shadow: 0 10px 30px -12px rgba(20, 23, 26, .5);
    min-width: 260px;
    max-width: 420px;
    pointer-events: auto;
    transform: translateX(110%);
    opacity: 0;
    transition: transform .25s ease, opacity .25s ease;
    font-feature-settings: 'tnum';
}

.toast.is-visible {
    transform: translateX(0);
    opacity: 1;
}

.toast--success {
    border-left-color: #3fbf7f;
}

.toast--error {
    border-left-color: #ff5a4f;
}

.toast-title {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--muted-2);
    margin-bottom: 4px;
}

.toast-msg {
    color: #fff;
}

/* ════════════════════════════════════════════════════════════════════════════
   AJUSTE AUTOMÁTICO DE PRECIOS (alpha)
   ════════════════════════════════════════════════════════════════════════════ */

.aviso-alpha {
    margin-bottom: 14px;
    padding: 10px 14px;
    background: var(--brand-soft);
    border: 1px solid var(--brand);
    border-radius: var(--r-md);
    color: var(--ink);
    font-size: 13.5px;
}

.ajuste-cabecera {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.ajuste-imagen {
    width: 140px;
    height: auto;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--vellum);
}

.ajuste-tabla th {
    width: 220px;
    text-align: left;
}

.ajuste-acciones {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin: 16px 0 8px;
}

.ajuste-rechazo {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ajuste-rechazo .form-input {
    min-width: 260px;
}

.ajustes-hint {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0;
}

@media (max-width: 640px) {
    .ajuste-cabecera {
        flex-direction: column;
    }

    .ajuste-rechazo {
        flex-direction: column;
        align-items: stretch;
    }

    .ajuste-rechazo .form-input {
        min-width: 0;
    }
}

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — tablet / móvil
   ════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
    :root {
        --gutter: 18px;
    }

    html,
    body {
        overflow-x: clip;
    }

    .layout {
        grid-template-columns: 1fr;
        background: none;
    }

    /* Sidebar como cajón lateral fuera de pantalla */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: min(280px, 84vw);
        z-index: 50;
        transform: translateX(-100%);
        transition: transform .25s ease;
    }

    .is-sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(20, 23, 26, .35);
    }

    .is-sidebar-open .sidebar-backdrop {
        display: block;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .topbar {
        padding: 10px var(--gutter);
        gap: 10px;
    }

    .topbar-context {
        flex: 1;
        gap: 8px;
    }

    .topbar-tenant-label,
    .topbar-tenant-slug {
        display: none;
    }

    .topbar-tenant .topbar-tenant-select {
        min-width: 110px;
    }

    .topbar .topbar-logout {
        display: inline-flex;
    }

    .page-heading {
        padding-top: 20px;
    }

    .page-heading-title {
        font-size: 23px;
    }

    .page {
        padding: 18px var(--gutter) 40px;
    }

    .panel {
        padding: 16px 14px;
    }

    .panel > .table,
    .panel > form > .table {
        width: calc(100% + 28px);
        margin-left: -14px;
        margin-right: -14px;
    }

    .panel > .table:last-child {
        margin-bottom: -16px;
    }

    .panel > .pagination:last-child {
        margin: 14px -14px -16px;
    }

    .table th,
    .table td {
        padding: 10px 12px;
        font-size: 12.5px;
    }

    .form-input,
    .form-control,
    input.form-input,
    select.form-input,
    textarea.form-input,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="url"],
    input[type="search"],
    input[type="tel"],
    input[type="date"],
    input[type="file"],
    select,
    textarea {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .topbar-tenant .topbar-tenant-select {
        width: auto;
    }

    .filters {
        gap: 10px;
        padding: 12px 14px;
    }

    .filters::before {
        flex-basis: 100%;
    }

    .filters .form-input,
    .filters select.form-input {
        min-width: 0;
        width: 100%;
    }

    .filters .btn {
        flex: 1;
        min-width: 0;
    }

    .page-header {
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 18px;
    }

    .page-title {
        font-size: 23px;
    }

    .page-actions {
        width: 100%;
    }

    .producto-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-actions .btn {
        flex: 1 1 140px;
    }

    /* Login apilado: la parte oscura se reduce a marca + titular */
    .auth-stage {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .auth-stage > .auth-side {
        padding: 32px 22px 28px;
        gap: 20px;
        border-right: none;
        border-bottom: 1px solid var(--dark-line);
    }

    .auth-brand {
        margin: 0;
    }

    .auth-eyebrow,
    .auth-lede,
    .auth-meta {
        display: none;
    }

    .auth-headline {
        font-size: 24px;
    }

    .auth-card {
        padding: 32px 22px 28px;
        min-height: calc(100vh - 160px);
        justify-content: flex-start;
    }

    .auth-foot {
        position: static;
        padding: 18px 22px;
        background: var(--vellum);
        text-align: center;
    }

    .form-inline > label,
    .form-inline > * {
        min-width: 0 !important;
    }

    .form-inline {
        width: 100%;
    }

    .form-inline > label {
        flex: 1 1 100% !important;
    }
}

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — tablas como tarjetas apiladas (<700px)
   app.js copia el texto de cada <th> en data-label de cada <td>.
   ════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 700px) {
    .table,
    .table thead,
    .table tbody,
    .table tr,
    .table th,
    .table td {
        display: block;
        width: auto;
    }

    .panel > .table,
    .panel > form > .table {
        width: auto;
        margin: 0;
    }

    .panel > .table:last-child {
        margin-bottom: 0;
    }

    .table thead {
        display: none;
    }

    .table tbody {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .table tr {
        border: 1px solid var(--line);
        border-radius: var(--r-md);
        background: var(--vellum);
        padding: 0 14px 6px;
        overflow: hidden;
    }

    .table td {
        padding: 10px 0;
        border-bottom: 1px solid var(--line-fine);
        text-align: left;
        font-size: 13px;
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 14px;
        min-height: 0;
    }

    .table tr td:last-child {
        border-bottom: none;
    }

    .table td.num {
        text-align: left;
    }

    .table td[data-label]::before {
        content: attr(data-label);
        color: var(--muted);
        font-family: var(--font-mono);
        font-size: 10px;
        text-transform: uppercase;
        letter-spacing: .06em;
        font-weight: 500;
        flex-shrink: 0;
        white-space: nowrap;
        align-self: center;
    }

    /* Primera celda: cabecera de la tarjeta */
    .table tr td:first-child {
        margin: 0 -14px 6px;
        padding: 12px 14px 10px;
        background: var(--paper-2);
        border-bottom: 1px solid var(--line);
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
    }

    .table tr td:first-child[data-label]::before {
        color: var(--muted);
        align-self: flex-start;
    }

    .table tr td:first-child,
    .table tr td:first-child code,
    .table tr td:first-child a {
        font-weight: 600;
        font-size: 14px;
    }

    .table td:not([data-label]) {
        justify-content: flex-end;
    }

    .table td:empty {
        display: none;
    }

    .table td[colspan] {
        text-align: center;
        padding: 18px 0;
        justify-content: center;
        color: var(--muted);
    }

    .table td[colspan]::before {
        display: none;
    }

    .panel {
        padding: 14px 12px;
    }

    .card-body.p-0 {
        padding: 12px;
    }

    .card-body.p-0 .table th:first-child,
    .card-body.p-0 .table td:first-child,
    .card-body.p-0 .table th:last-child,
    .card-body.p-0 .table td:last-child {
        padding-left: 0;
        padding-right: 0;
    }

    .table tr td:first-child {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }
}

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — móvil pequeño (<600px)
   ════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
    :root {
        --gutter: 14px;
    }

    body {
        font-size: 13.5px;
    }

    .topbar-user-name {
        display: none;
    }

    .page-title,
    .page-heading-title {
        font-size: 21px;
    }

    .panel-title {
        font-size: 15px;
    }

    .kpi {
        padding: 14px 14px 16px;
    }

    .kpi-value {
        font-size: 22px;
    }

    .card-big {
        font-size: 21px;
    }

    .pagination {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .pagination-actions {
        justify-content: space-between;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .logo-preview {
        padding: 14px;
    }

    .logo-preview-img {
        max-height: 60px;
    }
}

@media print {
    .sidebar,
    .topbar,
    .sidebar-backdrop,
    .toast-stack {
        display: none !important;
    }

    .layout {
        display: block;
    }

    body,
    html {
        background: #fff;
    }
}

/* ---- Dashboard: cabecera y filtro (antes estilos inline que la CSP bloqueaba) ---- */
.dash-head { margin-bottom: 14px; }
.dash-filter { gap: 8px; }
.dash-filter__label { margin: 0; flex-direction: row; align-items: center; gap: 8px; }
.mono-label {
    font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase;
    letter-spacing: .14em; color: var(--muted);
}

/* ---- Antes estilos inline (CSP) ---- */
/* La CSP (style-src sin 'unsafe-inline') bloquea los atributos style="" de las
   vistas. Lo que hacían está aquí: utilidades cortas para espaciado/flex y
   clases con nombre para los bloques con identidad propia. */

/* Utilidades: display y flex */
.d-inline { display: inline; }
.d-inline-flex { display: inline-flex; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-row { flex-direction: row; }
.ai-center { align-items: center; }
.ai-end { align-items: flex-end; }
.ai-start { align-items: flex-start; }
.jc-between { justify-content: space-between; }
.self-end { align-self: flex-end; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.rel { position: relative; }

/* Utilidades: márgenes (px). m-0 va primero para que las direccionales lo maticen. */
.m-0 { margin: 0; }
.mt-n6 { margin-top: -6px; }
.mt-n2 { margin-top: -2px; }
.mt-0 { margin-top: 0; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-24 { margin-top: 24px; }
.mb-6 { margin-bottom: 6px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.mb-14 { margin-bottom: 14px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.ml-8 { margin-left: 8px; }
.ml-auto { margin-left: auto; }

/* Utilidades: tamaños y texto */
.w-160 { width: 160px; }
.mw-120 { max-width: 120px; }
.mw-140 { max-width: 140px; }
.mw-160 { max-width: 160px; }
.mw-260 { max-width: 260px; }
.mw-280 { max-width: 280px; }
.mw-360 { max-width: 360px; }
.mw-640 { max-width: 640px; }
.minw-170 { min-width: 170px; }
.minw-200 { min-width: 200px; }
.minw-220 { min-width: 220px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.break-all { word-break: break-all; }
.ff-mono { font-family: var(--font-mono); }
.fs-11 { font-size: 11px; }
.fs-16 { font-size: 16px; }
.fs-080 { font-size: .8em; }
.fs-085 { font-size: .85em; }
.table th.text-right,
.table td.text-right { text-align: right; }

/* Etiquetas mono (complementan .mono-label) */
.mono-label--warn { color: #7a4a00; }
.mono-label--bad { color: #7a3a3a; }
.mono-caps { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .12em; }

/* Formularios en fila: campos que crecen y botonera alineada abajo */
.field-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.fld { margin: 0; }
.fld-xs { flex: 1 1 180px; min-width: 160px; }
.fld-sm { flex: 1 1 220px; min-width: 180px; }
.fld-md { flex: 1 1 220px; min-width: 200px; }
.fld-lg { flex: 1 1 280px; min-width: 220px; }
.fld-xl { flex: 1 1 320px; min-width: 240px; }
.fld-2x { flex: 2 1 320px; min-width: 240px; }
.fld-grow { flex: 1; min-width: 220px; }
.btn-pair { display: flex; gap: 8px; margin-bottom: 2px; }
.check-inline { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* Cajas desplegables (alta de producto, alta/edición de fuente) */
.inset-box { padding: 14px 16px; background: var(--paper-deep); border: 1px solid var(--rule); }
.inset-cell,
.table td.inset-cell,
.panel > .table td.inset-cell,
.panel > form > .table td.inset-cell { background: var(--paper-deep); padding: 14px 16px; }

/* Productos: barra de filtros activos */
.filtros-activos {
    display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
    margin-bottom: 14px; padding: 10px 14px;
    background: var(--vellum); border: 1px solid var(--rule-soft);
}
.filtro-quitar { color: inherit; text-decoration: none; font-weight: 600; }

/* Ficha de producto: migración de datos a otro producto */
.migra-title { margin: 0 0 6px; color: #7a4a00; }
.migra-text { margin: 0 0 8px; color: #5a3a00; }
.migra-note { margin: 0 0 10px; color: #5a3a00; }
.migra-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 10px 0; }
.migra-item { padding: 10px 12px; background: #fff; border: 1px solid #e3c483; }
.stat-num { font-size: 20px; font-weight: 600; }

/* Ficha de producto: zona peligrosa */
.zona-title { margin: 0 0 4px; color: #a02323; }
.zona-text { margin: 0; color: #7a3a3a; }
.zona-confirm { margin-top: 12px; padding-top: 12px; border-top: 1px dashed #e0a8a8; }
.zona-confirm-text { margin: 0 0 10px; color: #7a3a3a; }

/* Ajustes: historial de envíos de email */
.tabla-simple { width: 100%; border-collapse: collapse; }
.tabla-simple th,
.tabla-simple td { padding: 6px 10px; }
.tabla-simple th { text-align: left; }
.tabla-simple .text-right { text-align: right; }
.tabla-simple tbody tr { border-top: 1px solid #eee; }
.envio-ok { color: #2E7D32; }
.envio-err { color: #C62828; cursor: pointer; }
.envio-err-detalle { white-space: pre-wrap; margin: 6px 0 0; font-size: 12px; }

/* Varios */
.empty-pad { padding: 24px 4px; }
.pad-compact { padding: 12px 16px; }
.summary-toggle { cursor: pointer; user-select: none; }
.page-title-sub { font-size: .75em; color: var(--color-primary-dark); }
.csv-help { margin: 0 0 12px; color: #6B6470; }

/* URLs por producto: combobox de producto (el estado lo cambia monitorizacion.js).
   El aspecto de la lista y de cada opción ya lo da el bloque "COMBO DE BÚSQUEDA"
   (ul#combo-options, li.combo-option) del sistema visual; aquí sólo va lo que el
   inline aportaba y ese bloque no cubre: el desplegable flotante. */
.combo { position: relative; max-width: 640px; }
.combo-selected {
    width: 100%; box-sizing: border-box;
    justify-content: space-between; align-items: center; gap: 10px;
    padding: 10px 12px; background: #f3eee5; border: 1px solid #d8d4cc;
    border-radius: 6px; font-size: .9em;
}
.combo-input { width: 100%; box-sizing: border-box; background: #fff; }
.combo-options {
    position: absolute; left: 0; right: 0; top: calc(100% + 2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12); z-index: 50;
    list-style: none;
}
.combo-options li { list-style: none; }
li.combo-option { cursor: pointer; background: var(--vellum); }
.combo-option-meta { font-family: var(--font-mono, monospace); color: #6B6470; font-size: .78em; }
.combo-msg { padding: 14px 12px; color: #6B6470; font-size: .85em; background: #fff; }

/* ---- Alta de pago (registro.php) ---------------------------------------- */
.reg-form { gap: 14px; }
.reg-modo { margin: 12px 0 0; }
.reg-planes { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.reg-planes legend { margin-bottom: 8px; }
.reg-plan {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 12px;
    border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; cursor: pointer;
    transition: border-color .15s, background .15s;
}
.reg-plan:hover { border-color: var(--ink); }
.reg-plan:has(input:checked), .reg-plan.is-selected { border-color: var(--accent, #ff6600); background: #fff8f3; }
.reg-plan input { margin: 0; accent-color: #ff6600; }
.reg-plan__nombre { font-weight: 600; }
.reg-plan__precio { font-weight: 700; white-space: nowrap; }
.reg-plan__precio small { font-weight: 400; color: var(--muted); margin-left: 2px; }
.reg-plan__limites { grid-column: 2 / -1; font-size: 12.5px; color: var(--muted); }
.reg-trampa { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.reg-acepto { font-size: 13px; line-height: 1.45; align-items: flex-start; }
.reg-login { margin-top: 14px; text-align: center; }
.form-stack { display: flex; flex-direction: column; gap: 12px; max-width: 520px; }

/* ---- Facturación ------------------------------------------------------- */
.fact-resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 18px; }
.fact-plan { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 2px; }
.fact-uso { display: grid; gap: 6px; max-width: 560px; }
.fact-uso__fila { display: flex; justify-content: space-between; font-size: 13.5px; margin-top: 6px; }
.fact-barra { width: 100%; height: 8px; appearance: none; border: 0; border-radius: 4px; background: var(--line); overflow: hidden; }
.fact-barra::-webkit-progress-bar { background: var(--line); border-radius: 4px; }
.fact-barra::-webkit-progress-value { background: #ff6600; border-radius: 4px; }
.fact-barra::-moz-progress-bar { background: #ff6600; border-radius: 4px; }
.fact-baja { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.fact-planes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.fact-plan-card { border: 1px solid var(--line); border-radius: 4px; padding: 18px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.fact-plan-card.is-actual { border-color: #ff6600; background: #fff8f3; }
.fact-plan-card__nombre { font-weight: 700; font-size: 17px; }
.fact-plan-card__precio { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.fact-plan-card__precio small { font-size: 13px; font-weight: 400; color: var(--muted); }
.aviso-impago { margin-bottom: 14px; }

/* ============================================================================
   Mensajes con NexoPrice y avisos de la plataforma
   (también los usa NexoPrice Admin, que carga esta hoja)
   ============================================================================ */
.mensajes-layout { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 18px; align-items: start; }
.mensajes-items { list-style: none; margin: 0; padding: 0; }
.mensajes-items li a { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; padding: 10px 8px; border-bottom: 1px solid var(--line-fine); color: inherit; text-decoration: none; }
.mensajes-items li a .small { flex-basis: 100%; }
.mensajes-items li.is-active a, .mensajes-items li a:hover { background: var(--paper-2); }
.chat { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.chat-msg { max-width: 760px; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--vellum); }
.chat-msg--propio, .chat-msg--plataforma { align-self: flex-end; background: var(--brand-soft); border-color: var(--brand-tint); }
.chat-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.chat-cuerpo { white-space: pre-wrap; overflow-wrap: anywhere; }

.avisos-plataforma { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.aviso-plataforma { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-left: 3px solid var(--ok); background: var(--vellum); padding: 10px 14px; border-radius: var(--r-sm); }
.aviso-plataforma--aviso { border-left-color: var(--warn); background: var(--warn-tint); }
.aviso-plataforma--critico { border-left-color: var(--bad); background: var(--bad-tint); }
.aviso-plataforma__texto { flex: 1; white-space: pre-wrap; }
.aviso-plataforma__texto strong { display: block; margin-bottom: 2px; }
.aviso-plataforma form { margin: 0; }

@media (max-width: 860px) {
    .mensajes-layout { grid-template-columns: 1fr; }
}

/* Ayuda contextual: enlace a la guía (web pública) de cada pantalla */
.page-heading { position: relative; }
.page-heading-ayuda {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 8px;
    font-size: 13px; color: var(--brand-text); text-decoration: none;
    border: 1px solid var(--brand-tint); background: var(--brand-soft);
    padding: 4px 10px; border-radius: 999px;
}
.page-heading-ayuda:hover { border-color: var(--brand); color: var(--ink); }
