/* Instyle Retail Control — UI base (mobile-first, sin frameworks) */

:root {
    --navy: #0b1626;
    --navy-2: #111f33;
    --navy-3: #17263d;
    --blue: #2563eb;
    --blue-soft: #dbeafe;
    --green: #16a34a;
    --green-soft: #dcfce7;
    --orange: #f59e0b;
    --orange-soft: #fef3c7;
    --red: #dc2626;
    --red-soft: #fee2e2;
    --bg: #eef2f7;
    --card: #ffffff;
    --line: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --radius: 14px;
    --sidebar-w: 252px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .07), 0 6px 24px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); }
h1, h2, h3 { margin: 0; }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--navy);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .22s ease;
    overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }

.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(2, 6, 23, .55);
    z-index: 30;
    opacity: 0; pointer-events: none;
    transition: opacity .22s ease;
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

.main { min-height: 100vh; display: flex; flex-direction: column; }

@media (min-width: 960px) {
    .sidebar { transform: none; }
    .sidebar-backdrop { display: none; }
    .main { margin-left: var(--sidebar-w); }
    #sidebarToggle { display: none; }
}

/* ---------- Sidebar ---------- */
.brand {
    display: flex; align-items: center; gap: 12px;
    padding: 22px 20px 18px;
}
.brand-mark {
    width: 40px; height: 40px; border-radius: 11px;
    background: var(--navy-3);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.brand-mark.big { width: 48px; height: 48px; background: var(--navy); }
.brand-text { color: #fff; font-weight: 800; letter-spacing: .12em; font-size: 15px; line-height: 1.1; }
.brand-text small { font-weight: 500; font-size: 8.5px; letter-spacing: .38em; color: #94a3b8; }

.nav { flex: 1; padding: 4px 12px 16px; }
.nav-label {
    font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
    color: #64748b; font-weight: 700;
    padding: 18px 10px 7px;
}
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 10px;
    border-radius: 9px;
    color: #b9c5d6;
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 2px;
}
.nav-item:hover { background: var(--navy-2); color: #fff; }
.nav-item.active { background: var(--navy-3); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--blue); }
.nav-icon { display: flex; opacity: .85; }
.nav-badge {
    margin-left: auto;
    background: var(--red); color: #fff;
    border-radius: 999px;
    font-size: 11px; font-weight: 700;
    min-width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 6px;
}
.sidebar-foot { padding: 14px 20px; border-top: 1px solid var(--navy-2); }
.version { font-size: 11.5px; color: #64748b; }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 14px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 12px 18px;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--blue); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { font-size: 13.5px; }
.user-meta small { color: var(--muted); font-size: 11.5px; }
@media (max-width: 560px) { .user-meta { display: none; } }

.icon-btn {
    background: none; border: 1px solid var(--line);
    border-radius: 9px;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted);
    cursor: pointer;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ---------- Contenido ---------- */
.content { padding: 18px; display: flex; flex-direction: column; gap: 16px; max-width: 1280px; width: 100%; }
@media (min-width: 960px) { .content { padding: 24px 28px; } }

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h2 { font-size: 16px; }

.grid-2 { display: grid; gap: 16px; }
@media (min-width: 1000px) { .grid-2 { grid-template-columns: 3fr 2fr; align-items: start; } }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.kpi { display: flex; gap: 14px; align-items: center; }
.kpi-icon {
    width: 48px; height: 48px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.kpi-icon.blue { background: var(--blue-soft); color: var(--blue); }
.kpi-icon.green { background: var(--green-soft); color: var(--green); }
.kpi-icon.orange { background: var(--orange-soft); color: var(--orange); }
.kpi-icon.navy { background: #e2e8f0; color: var(--navy); }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.kpi-foot { font-size: 12px; color: var(--muted); }
.text-red { color: var(--red); font-weight: 700; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
    color: var(--muted); font-weight: 700;
    padding: 8px 10px; border-bottom: 1px solid var(--line);
}
td { padding: 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; }
th.num { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

.badge {
    display: inline-block;
    font-size: 11.5px; font-weight: 700;
    padding: 3px 10px; border-radius: 999px;
    white-space: nowrap;
}
.badge.blue { background: var(--blue-soft); color: #1d4ed8; }
.badge.green { background: var(--green-soft); color: #15803d; }
.badge.orange { background: var(--orange-soft); color: #b45309; }
.badge.red { background: var(--red-soft); color: #b91c1c; }
.badge.gray { background: #f1f5f9; color: var(--muted); }

/* ---------- Formularios ---------- */
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 720px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
    .form-grid .span-2 { grid-column: span 2; }
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-size: 12.5px; font-weight: 600; color: #334155; }
.field input, .field select {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    font-size: 15px;
    background: #fff;
    width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
.check { display: flex; align-items: center; gap: 9px; margin: 14px 0 0; font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; }
.check-grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin-top: 6px; }
.check-grid .check { margin: 0; }
.form-section { font-size: 14px; margin-top: 20px; color: #334155; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 14px; }
.inline-form .field { flex: 1; min-width: 150px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 16px;
    border-radius: 9px;
    font-size: 14px; font-weight: 600;
    text-decoration: none;
    border: 0; cursor: pointer;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: #334155; }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; margin-top: 18px; }

/* ---------- Estados / misceláneos ---------- */
.flash {
    margin: 14px 18px 0;
    padding: 11px 15px;
    border-radius: 10px;
    font-size: 14px;
}
@media (min-width: 960px) { .flash { margin: 16px 28px 0; max-width: 1224px; } }
.flash-ok { background: var(--green-soft); color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: var(--red-soft); color: #b91c1c; border: 1px solid #fecaca; }
.auth-card .flash, .auth-card .flash-error { margin: 0 0 14px; }

.empty {
    text-align: center;
    color: var(--muted);
    padding: 34px 16px;
    font-size: 14px;
    line-height: 1.6;
    background: #f8fafc;
    border: 1px dashed var(--line);
    border-radius: 10px;
}
.hint {
    margin-top: 14px;
    background: #f0f6ff;
    border: 1px solid #dbeafe;
    color: #1e40af;
    font-size: 13px;
    line-height: 1.55;
    padding: 11px 14px;
    border-radius: 10px;
}
.link { color: var(--blue); font-weight: 600; text-decoration: none; font-size: 13.5px; }
.link:hover { text-decoration: underline; }

.stat-list { list-style: none; margin: 0; padding: 0; }
.stat-list li {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 2px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
}
.stat-list li:last-child { border-bottom: 0; }
.stat-list span { color: var(--muted); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
    display: flex; gap: 14px;
    padding: 8px 2px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13.5px;
    align-items: baseline;
}
.timeline li:last-child { border-bottom: 0; }
.timeline .time { color: var(--muted); font-size: 12px; white-space: nowrap; font-family: ui-monospace, Menlo, monospace; }
.timeline .what { min-width: 0; }

/* ---------- Módulo placeholder ---------- */
.module-card h2 { font-size: 20px; margin: 12px 0 6px; }
.module-head { display: flex; gap: 8px; flex-wrap: wrap; }
.module-desc { color: var(--muted); line-height: 1.6; margin: 0 0 16px; }
.module-card h3 { font-size: 14px; color: #334155; margin-bottom: 8px; }
.feature-list { margin: 0; padding: 0 0 0 2px; list-style: none; }
.feature-list li {
    padding: 7px 0 7px 26px;
    position: relative;
    font-size: 14px;
    border-bottom: 1px solid #f8fafc;
}
.feature-list li::before {
    content: "✓";
    position: absolute; left: 2px;
    color: var(--green); font-weight: 800;
}

/* ---------- Login ---------- */
.auth-body {
    background: linear-gradient(160deg, var(--navy) 0%, #10233c 60%, #132b49 100%);
    min-height: 100vh; margin: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card {
    background: var(--card);
    border-radius: 18px;
    padding: 28px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .brand-mark { color: #fff; }
.auth-brand-name { font-weight: 800; letter-spacing: .1em; font-size: 15px; }
.auth-brand-sub { font-size: 12px; color: var(--muted); }
.auth-card h1 { font-size: 20px; }
.auth-sub { color: var(--muted); font-size: 13.5px; margin: 6px 0 18px; line-height: 1.5; }
.auth-card .field { margin-bottom: 12px; }
.auth-foot { text-align: center; color: #64748b; font-size: 12px; margin-top: 18px; letter-spacing: .04em; }
