/* ==========================================================================
   Portal de administración · HubSpot ERP Bridge
   Sistema de diseño: negro #1c1c1c (base) + rojo #E30F2F (acento).
   Sin degradados, sin transparencias, sin blur.
   ========================================================================== */

:root {
    --ink: #1c1c1c;
    --ink-soft: #2b2b2e;
    --ink-line: #3a3a3e;
    --accent: #E30F2F;
    --accent-hover: #c20c27;
    --accent-soft: #fdecef;

    --bg: #f4f4f5;
    --surface: #ffffff;
    --surface-alt: #fafafa;
    --border: #e4e4e7;
    --border-strong: #d1d1d6;

    --text: #1c1c1c;
    --text-muted: #6b6b73;

    --success: #15803d;
    --success-soft: #e8f5ec;
    --warning: #a16207;
    --warning-soft: #fdf3dc;
    --error: #b4132b;
    --error-soft: #fdecef;
    --info: #1c1c1c;
    --info-soft: #ececee;

    /* Alias para vistas que usan nombres anteriores */
    --primary: var(--accent);
    --primary-hover: var(--accent-hover);
    --card-bg: var(--surface);

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(28, 28, 28, 0.05);
    --topbar-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
code {
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.85em;
    background: var(--info-soft);
    border: 1px solid var(--border);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ==========================================================================
   Barra superior (menú horizontal)
   ========================================================================== */

.topbar {
    background: var(--ink);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 3px solid var(--accent);
}

.topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 2rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #fff;
    flex-shrink: 0;
}

.brand-mark {
    width: 30px;
    height: 30px;
    background: var(--accent);
    border-radius: 6px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: -0.02em;
}

.brand-logo {
    display: block;
    height: 34px;
    width: auto;
    flex-shrink: 0;
}

.brand-logo + .brand-name {
    padding-left: 0.85rem;
    border-left: 1px solid rgba(255, 255, 255, 0.22);
}

.brand-name {
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.brand-name small {
    display: block;
    font-weight: 500;
    font-size: 0.68rem;
    color: #a1a1a8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.nav {
    display: flex;
    align-items: stretch;
    gap: 0.25rem;
    height: 100%;
    flex: 1;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1rem;
    color: #b4b4bb;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    position: relative;
    transition: color 0.15s;
}

.nav a:hover { color: #fff; }

.nav a.active { color: #fff; }

.nav a.active::after {
    content: '';
    position: absolute;
    left: 1rem;
    right: 1rem;
    bottom: -3px;
    height: 3px;
    background: var(--accent);
}

.nav svg, .btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: #d4d4d8;
}
a.user-chip { text-decoration: none; padding: 0.2rem 0.5rem 0.2rem 0.2rem; border-radius: 999px; transition: background .15s, color .15s; }
a.user-chip:hover, a.user-chip.is-active { background: var(--ink-soft); color: #fff; }
.nav .nav-user .nav-user-link { color: #d4d4d8; text-decoration: none; border: 0; padding: 0; }

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--ink-line);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.btn-logout {
    background: transparent;
    color: #d4d4d8;
    border: 1px solid var(--ink-line);
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-logout:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--ink-line);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-left: auto;
    place-items: center;
}

.menu-toggle svg { width: 20px; height: 20px; }

/* ==========================================================================
   Contenido
   ========================================================================== */

.page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-top: 0.25rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Tarjetas de métricas */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats.compact { grid-template-columns: repeat(auto-fill, minmax(200px, 240px)); }

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--ink);
}

.stat.is-accent  { border-top-color: var(--accent); }
.stat.is-success { border-top-color: var(--success); }
.stat.is-warning { border-top-color: #d97706; }

.stat-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-top: 0.25rem;
}

/* ==========================================================================
   Botones
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-alt); border-color: var(--ink); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #116632; }

.btn-danger { background: var(--accent); color: #fff; }
.btn-danger:hover { background: var(--accent-hover); }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.82rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ==========================================================================
   Formularios
   ========================================================================== */

.form-group { margin-bottom: 1.25rem; }

.form-label, label.field-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: var(--text);
    font-size: 0.82rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control::placeholder { color: #9a9aa3; }

.form-control:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(28, 28, 28, 0.1);
}

select.form-control {
    width: auto;
    min-width: 150px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231c1c1c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 1rem;
    padding-right: 2.2rem;
}

select.form-control.is-full { width: 100%; }
textarea.form-control { resize: vertical; }

.check {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    background: var(--surface);
    transition: border-color 0.15s;
}

.check:hover { border-color: var(--ink); }
.check input { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }

/* ==========================================================================
   Barra de herramientas / filtros
   ========================================================================== */

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.filters {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}

.filters .form-control { width: auto; }
.filters input.form-control { min-width: 240px; }

.per-page {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.per-page select.form-control { min-width: 76px; padding-top: 0.4rem; padding-bottom: 0.4rem; }

/* Pestañas de vista */
.tabs {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.25rem;
    background: var(--info-soft);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
}

.tabs a {
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
}

.tabs a:hover { color: var(--text); }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ==========================================================================
   Tablas
   ========================================================================== */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    -webkit-overflow-scrolling: touch;
}

table { width: 100%; border-collapse: collapse; background: var(--surface); }

th, td {
    padding: 0.8rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--surface-alt);
    white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-alt); }

td.center, th.center { text-align: center; }

.text-muted { color: var(--text-muted) !important; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.78rem; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-accent  { color: var(--accent); }
.fw-600 { font-weight: 600; }

.master-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    margin-right: 0.5rem;
}

/* ==========================================================================
   Badges y alertas
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--info-soft);
    color: var(--text);
    white-space: nowrap;
}

.badge-pending,  .badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-approved, .badge-success { background: var(--success-soft); color: var(--success); }
.badge-rejected, .badge-danger  { background: var(--error-soft);   color: var(--error); }
.badge-reviewed, .badge-neutral { background: var(--info-soft);    color: var(--text); }
.badge-dark { background: var(--ink); color: #fff; }

.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    border: 1px solid;
    border-left-width: 4px;
    font-size: 0.9rem;
}

.alert-success { background: var(--success-soft); border-color: #b7dfc2; border-left-color: var(--success); color: #0f5a2b; }
.alert-error   { background: var(--error-soft);   border-color: #f5c2cb; border-left-color: var(--accent);  color: #8a0f21; }
.alert-info    { background: var(--info-soft);    border-color: var(--border-strong); border-left-color: var(--ink); color: var(--text); }

/* ==========================================================================
   Paginación (Laravel)
   ========================================================================== */

.pagination { display: flex; justify-content: center; margin-top: 1.5rem; }

nav[role="navigation"] { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; width: 100%; }
nav[role="navigation"] > div:last-child { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
nav[role="navigation"] > div:last-child > div:last-child > span { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem; }
nav[role="navigation"] > div:first-child { display: none; width: 100%; justify-content: space-between; gap: 0.5rem; }
nav[role="navigation"] > div:first-child:only-child { display: flex; }
nav[role="navigation"] p { font-size: 0.82rem; color: var(--text-muted); margin: 0; text-align: center; }
nav[role="navigation"] p span { font-weight: 600; color: var(--text); }

nav[role="navigation"] a,
nav[role="navigation"] > div:first-child > span,
nav[role="navigation"] span[aria-current="page"] > span,
nav[role="navigation"] span[aria-disabled="true"] > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.1rem;
    height: 2.1rem;
    padding: 0 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    text-decoration: none;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
}

nav[role="navigation"] a:hover { border-color: var(--ink); background: var(--surface-alt); }
nav[role="navigation"] span[aria-current="page"] > span { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
nav[role="navigation"] span[aria-disabled="true"] > span,
nav[role="navigation"] > div:first-child > span { opacity: 0.45; cursor: not-allowed; }
nav[role="navigation"] svg { width: 1rem; height: 1rem; fill: currentColor; }

@media (max-width: 640px) {
    nav[role="navigation"] > div:first-child { display: flex; }
    nav[role="navigation"] > div:last-child { display: none; }
}

/* ==========================================================================
   Detalle de entidad (show)
   ========================================================================== */

.entity-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    background: var(--surface);
}

.entity-card + .entity-card { margin-top: 1rem; }
.entity-card.is-master { border: 2px solid var(--success); background: #f7fbf8; }

.entity-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.entity-title { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.entity-score { text-align: center; }
.entity-score strong { font-size: 1.5rem; display: block; line-height: 1; }
.entity-score span { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.entity-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }

.section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text);
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 0.45rem 1rem; font-size: 0.88rem; }
.kv dt { color: var(--text-muted); }
.kv dd { word-break: break-word; }

.page-actions { display: flex; gap: 0.75rem; justify-content: flex-end; flex-wrap: wrap; }

.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

.info-list { list-style: none; color: var(--text-muted); line-height: 1.9; font-size: 0.9rem; }
.info-list li::before { content: '—'; color: var(--accent); margin-right: 0.6rem; font-weight: 700; }

/* ==========================================================================
   Sincronización (terminal)
   ========================================================================== */

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem 1.25rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .form-group { margin-bottom: 0; }

.status {
    display: none;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    border: 1px solid;
    border-left-width: 4px;
}
.status.show { display: flex; }
.status.running { background: var(--info-soft); border-color: var(--border-strong); border-left-color: var(--ink); }
.status.done    { background: var(--success-soft); border-color: #b7dfc2; border-left-color: var(--success); color: #0f5a2b; }
.status.error   { background: var(--error-soft); border-color: #f5c2cb; border-left-color: var(--accent); color: #8a0f21; }

.terminal {
    display: none;
    margin-top: 1.5rem;
    background: var(--ink);
    border-radius: var(--radius);
    overflow: hidden;
}
.terminal.visible { display: block; }

.terminal-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    font-size: 0.72rem;
    color: #a1a1a8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--ink-line);
}
.terminal-bar i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }

pre#output {
    color: #e4e4e7;
    padding: 1rem 1.25rem;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    max-height: 340px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ==========================================================================
   Login
   ========================================================================== */

.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    background: var(--surface);
}

.auth-aside {
    background: var(--ink);
    color: #fff;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: 4px solid var(--accent);
}

.auth-aside .brand-logo { height: 44px; }

.auth-aside h2 {
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
    max-width: 14ch;
}

.auth-aside h2 em { font-style: normal; color: var(--accent); }

.auth-aside p { color: #a1a1a8; margin-top: 1rem; max-width: 38ch; font-size: 0.95rem; }

.auth-flow {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #a1a1a8;
}
.auth-flow b { color: #fff; }
.auth-flow span.line { width: 36px; height: 2px; background: var(--accent); }

.auth-main { display: grid; place-items: center; padding: 2rem 1.5rem; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.auth-box .lead { color: var(--text-muted); margin: 0.35rem 0 2rem; font-size: 0.92rem; }
.auth-box .form-control { padding: 0.75rem 0.9rem; font-size: 0.95rem; }
.auth-box .btn { padding: 0.8rem 1rem; font-size: 0.95rem; }
.auth-box .check { border: none; padding: 0; background: none; margin-bottom: 1.5rem; color: var(--text-muted); font-size: 0.85rem; }
.auth-foot { margin-top: 2rem; font-size: 0.75rem; color: var(--text-muted); text-align: center; }

.auth-mobile-brand { display: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 960px) {
    .topbar-inner { gap: 1rem; padding: 0 1rem; }

    .menu-toggle { display: grid; }
    .topbar-user { display: none; }

    .nav {
        display: none;
        position: absolute;
        top: var(--topbar-h);
        left: 0;
        right: 0;
        flex-direction: column;
        height: auto;
        background: var(--ink);
        padding: 0.5rem 1rem 1rem;
        border-top: 1px solid var(--ink-line);
        border-bottom: 3px solid var(--accent);
        margin-bottom: -3px;
    }

    .topbar.open .nav { display: flex; }

    .nav a { padding: 0.85rem 0.5rem; border-bottom: 1px solid var(--ink-line); }
    .nav a.active { color: #fff; box-shadow: inset 3px 0 0 var(--accent); padding-left: 0.9rem; }
    .nav a.active::after { display: none; }

    .nav .nav-user {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 1rem 0.5rem 0;
        color: #d4d4d8;
        font-size: 0.85rem;
    }
}

@media (min-width: 961px) {
    .nav .nav-user { display: none; }
}

@media (max-width: 860px) {
    .auth { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .auth-main { align-items: start; padding-top: 3rem; }
    .auth-mobile-brand {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin-bottom: 2.5rem;
    }
    /* El logo es blanco: sobre fondo claro va dentro de una pastilla oscura */
    .auth-mobile-brand .brand-logo {
        height: 40px;
        box-sizing: content-box;
        background: var(--ink);
        padding: 0.6rem 0.9rem;
        border-radius: 8px;
        border-bottom: 3px solid var(--accent);
    }
    .auth-mobile-brand .brand-logo + .brand-name { border-left-color: var(--border); }
    .auth-mobile-brand .brand-name { color: var(--text); }
    .auth-mobile-brand .brand-name small { color: var(--text-muted); }
}

@media (max-width: 720px) {
    .page { padding: 1.25rem 1rem 2.5rem; }
    .page-header h1 { font-size: 1.35rem; }
    .card { padding: 1.1rem; }

    .filters, .filters form { width: 100%; }
    .filters .form-control, .filters input.form-control, .filters select.form-control { width: 100%; min-width: 0; }
    .filters form { display: flex; flex-direction: column; align-items: stretch; }
    .filters .btn { width: 100%; }

    .toolbar { align-items: stretch; }
    .per-page { justify-content: flex-end; }

    .entity-cols { grid-template-columns: 1fr; gap: 1.5rem; }
    .form-grid { grid-template-columns: 1fr; }

    .tabs { display: flex; width: 100%; }
    .tabs a { flex: 1; text-align: center; }

    .page-actions .btn { flex: 1; }

    th, td { padding: 0.7rem 0.75rem; }
}

@media (max-width: 420px) {
    .stats { grid-template-columns: 1fr 1fr; }
    .stat-value { font-size: 1.5rem; }
    .kv { grid-template-columns: 1fr; gap: 0.1rem 0; }
    .kv dd { margin-bottom: 0.5rem; }
}

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

.nowrap { white-space: nowrap; }

/* ==========================================================================
   Sincronización de productos: pasos, progreso, resumen
   ========================================================================== */

.alert-warning { background: var(--warning-soft); border-color: #ecd9a0; border-left-color: #d97706; color: #6b4a06; }

.fieldset-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}
.fieldset-title:first-of-type { margin-top: 0; }

.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem; }

.criteria {
    margin-top: 1.5rem;
    padding: 0.9rem 1.1rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-left: 4px solid var(--ink);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-muted);
}
.criteria strong { color: var(--text); }
.criteria ul { list-style: none; margin-top: 0.4rem; display: grid; gap: 0.2rem; }
.criteria li::before { content: '—'; color: var(--accent); margin-right: 0.5rem; font-weight: 700; }

.form-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.5rem; }

/* Pasos */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; list-style: none; }

.step {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    min-width: 0;
}

.step-dot {
    flex: 0 0 26px;
    height: 26px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--info-soft);
    color: var(--text-muted);
}
.step-dot svg { width: 14px; height: 14px; }

.step-title { font-weight: 600; font-size: 0.88rem; color: inherit; }
.step-note { font-size: 0.78rem; margin-top: 0.1rem; overflow-wrap: anywhere; }

.step.is-active { border-color: var(--ink); color: var(--text); }
.step.is-active .step-dot { background: var(--ink); color: #fff; }
.step.is-done { color: var(--text); }
.step.is-done .step-dot { background: var(--success); color: #fff; }
.step.is-error { border-color: var(--accent); color: var(--text); }
.step.is-error .step-dot { background: var(--accent); color: #fff; }

/* Progreso */
.progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.progress-head strong { font-size: 1.6rem; letter-spacing: -0.02em; line-height: 1; }
.progress-head span { font-size: 0.85rem; color: var(--text-muted); }

.progress { height: 10px; background: var(--info-soft); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.4s ease; }
.progress.is-done .progress-fill { background: var(--success); }
.progress.is-indeterminate .progress-fill { width: 35% !important; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

.run-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin: 1.25rem 0; }
.run-stat { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; background: var(--surface-alt); }
.run-stat b { display: block; font-size: 1.35rem; letter-spacing: -0.02em; line-height: 1.2; }
.run-stat span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.run-stat.is-bad b { color: var(--accent); }

.log-toggle { margin-top: 1.25rem; }
.log-toggle summary { cursor: pointer; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); user-select: none; }
.log-toggle summary:hover { color: var(--text); }
.log-toggle .terminal { display: block; margin-top: 0.75rem; }
.log-line-warn { color: #fbbf24; }
.log-line-err  { color: #ff6b81; }
.log-line-ok   { color: #86efac; }

@media (max-width: 720px) {
    .steps { grid-template-columns: 1fr; }
    .run-stats { grid-template-columns: 1fr 1fr; }
    .form-grid.cols-3 { grid-template-columns: 1fr; }
    .form-actions .btn { flex: 1; }
}

[hidden] { display: none !important; }
.progress.is-warn .progress-fill { background: #d97706; }

/* ==========================================================================
   Actividad (feed de acciones)
   ========================================================================== */

a.stat-link { display: block; color: inherit; text-decoration: none; transition: box-shadow .15s, transform .15s; }
a.stat-link:hover { box-shadow: 0 2px 8px rgba(28, 28, 28, 0.12); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed-empty { text-align: center; padding: 3rem 1rem; }

.feed-item {
    display: flex;
    gap: 0.9rem;
    padding: 0.95rem 0.25rem;
    border-bottom: 1px solid var(--border);
}
.feed-item:last-child { border-bottom: 0; }

.feed-dot {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--info-soft);
    color: var(--text-muted);
    margin-top: 2px;
}
.feed-dot svg { width: 14px; height: 14px; }
.feed-item.is-success .feed-dot { background: var(--success-soft); color: var(--success); }
.feed-item.is-error   .feed-dot { background: var(--accent); color: #fff; }
.feed-item.is-warning .feed-dot { background: var(--warning-soft); color: var(--warning); }

.feed-body { min-width: 0; flex: 1; }

.feed-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.feed-title { font-weight: 600; font-size: 0.95rem; overflow-wrap: anywhere; }

.feed-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.9rem;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.feed-meta a { color: var(--accent); font-weight: 600; text-decoration: none; }
.feed-meta a:hover { text-decoration: underline; }
.feed-ref { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.feed-message { margin-top: 0.4rem; font-size: 0.88rem; color: var(--text); overflow-wrap: anywhere; }

.feed-reason, .feed-hint {
    margin-top: 0.5rem;
    padding: 0.55rem 0.8rem;
    border-left: 3px solid var(--accent);
    background: var(--error-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.86rem;
    overflow-wrap: anywhere;
}
.feed-hint { margin-top: 0.35rem; border-left-color: var(--ink); background: var(--info-soft); }
.feed-item.is-warning .feed-reason { border-left-color: #d97706; background: var(--warning-soft); }

.feed-details { margin-top: 0.5rem; font-size: 0.8rem; }
.feed-details summary { cursor: pointer; color: var(--text-muted); user-select: none; }
.feed-details summary:hover { color: var(--text); }
.feed-details dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.2rem 0.9rem;
    margin: 0.5rem 0 0;
}
.feed-details dt { color: var(--text-muted); }
.feed-details dd { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.feed-details pre {
    margin: 0.5rem 0 0;
    padding: 0.7rem 0.85rem;
    background: var(--ink);
    color: #e7e7ea;
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 220px;
    overflow: auto;
    font-size: 0.76rem;
}

@media (max-width: 640px) {
    .feed-item { gap: 0.65rem; }
    .filters input.form-control, .filters .form-control { width: 100%; min-width: 0; }
}

/* Formularios de cuenta */
.account-card { max-width: 520px; }
.field-error { color: var(--error); font-size: 0.8rem; margin-top: 0.3rem; }
.form-control.is-invalid { border-color: var(--accent); }
.pw-rules { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.8rem; color: var(--text-muted); }

/* Stock de un SKU */
.stock-form { display: flex; align-items: flex-end; gap: 0.75rem; flex-wrap: wrap; }
@media (max-width: 480px) { .stock-form .btn { width: 100%; } }

/* ==========================================================================
   Estado del sistema
   ========================================================================== */

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    align-items: stretch; /* todas las tarjetas de una fila con el mismo alto */
}
.status-grid .card { margin-bottom: 0; min-width: 0; height: 100%; }

.status-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.status-card-head .card-title { margin-bottom: 0; }

.status-issues { margin: 0.6rem 0 0 1.1rem; padding: 0; font-size: 0.88rem; }
.status-issues li + li { margin-top: 0.2rem; }

.status-list { list-style: none; margin: 0; padding: 0; }
.status-row { display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.status-row:last-child { border-bottom: none; }
.status-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }

.dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; background: var(--border-strong); }
.dot.is-ok      { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot.is-warning { background: #d97706; box-shadow: 0 0 0 3px var(--warning-soft); }
.dot.is-danger  { background: var(--accent); box-shadow: 0 0 0 3px var(--error-soft); }
.dot.is-neutral { background: var(--border-strong); }

.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-top: 0.5rem; }
.mini-stats > div { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.7rem 0.85rem; }
.mini-stats b { display: block; font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.mini-stats b.is-warning { color: var(--warning); }
.mini-stats b.is-error { color: var(--error); }
.mini-stats span { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }

/* ==========================================================================
   Seguimiento por negocio
   ========================================================================== */

.deal-link { font-weight: 600; color: var(--text); text-decoration: none; }
.deal-link:hover { color: var(--accent); text-decoration: underline; }
.deal-sub { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 0.15rem; }
.link-accent { color: var(--accent); font-weight: 600; }

.step-chip {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--info-soft);
    color: var(--text);
    white-space: nowrap;
    margin: 0 0.2rem 0.2rem 0;
}
.step-chip.is-done    { background: var(--success-soft); color: var(--success); }
.step-chip.is-failed  { background: var(--error-soft);   color: var(--error); }
.step-chip.is-pending { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }
.step-chip.is-na      { background: transparent; color: var(--text-muted); font-weight: 500; }

.deal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.5rem; align-items: start; }
.deal-layout .card { margin-bottom: 1.5rem; }
@media (max-width: 960px) { .deal-layout { grid-template-columns: 1fr; } }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item { display: flex; gap: 1rem; position: relative; padding-bottom: 1.5rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item:not(:last-child)::before {
    content: ''; position: absolute; left: 15px; top: 32px; bottom: 0; width: 2px; background: var(--border);
}
.timeline-dot {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
    font-weight: 700; background: var(--surface-alt); border: 2px solid var(--border-strong); color: var(--text-muted);
}
.timeline-item.is-done .timeline-dot   { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.timeline-item.is-failed .timeline-dot { background: var(--error-soft);   border-color: var(--accent);  color: var(--error); }
.timeline-body { flex: 1; min-width: 0; padding-top: 0.2rem; display: flex; flex-direction: column; gap: 0.25rem; }
.timeline-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

/* Filtros de Actividad: búsqueda arriba, filtros etiquetados en una cuadrícula */
.activity-filters { margin-bottom: 1.25rem; }
.af-search { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 0.9rem; }
.af-search input.form-control { flex: 1; min-width: 0; }
.af-search .btn { white-space: nowrap; display: inline-flex; align-items: center; gap: 0.4rem; }
.af-export { margin-left: 0.4rem; }
.af-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.75rem; }
.af-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.af-field > span { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.af-field select.form-control, .af-field input.form-control { width: 100%; min-width: 0; }

@media (max-width: 1100px) {
    .af-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .af-search { flex-wrap: wrap; }
    .af-search input.form-control { flex-basis: 100%; }
    .af-search .btn { flex: 1; justify-content: center; }
    .af-export { margin-left: 0; }
    .af-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
