:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #172033;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #1f4e79;
    --primary-dark: #143554;
    --accent: #2f80ed;
    --success: #18864b;
    --danger: #c2410c;
    --warning: #b7791f;
    --sidebar: #050505;
    --sidebar-hover: #171717;
    --radius: 14px;
    --shadow: 0 10px 26px rgba(15, 23, 42, 0.07);
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Arial, sans-serif;
    min-height: 100vh;
}

a { text-decoration: none; }

.app-sidebar {
    background: var(--sidebar);
    min-height: 100vh;
    height: 100vh;
    color: var(--sidebar-text);
    position: sticky;
    top: 0;
    overflow-y: auto;
    border-right: 1px solid rgba(255,255,255,.10);
    scrollbar-width: thin;
}

.sidebar-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-logo-wrap {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.16);
    display: grid;
    place-items: center;
    overflow: hidden;
    flex: 0 0 40px;
}

.brand-logo-empty {
    background: transparent;
    border-style: dashed;
}

.brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.brand-logo-fallback {
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--sidebar-muted);
    font-size: 1.2rem;
}

.brand-name {
    font-weight: 800;
    letter-spacing: .04em;
    line-height: 1.1;
    font-size: .95rem;
}

.brand-subtitle {
    color: var(--sidebar-muted);
    font-size: .72rem;
    margin-top: 3px;
}

.sidebar-nav {
    padding: 12px 10px 18px;
}

.sidebar-section {
    color: var(--sidebar-muted);
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 16px 10px 6px;
}

.sidebar-nav a {
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    margin: 2px 0;
    border-radius: 10px;
    font-weight: 600;
    font-size: .88rem;
    transition: background .15s ease, color .15s ease;
}

.sidebar-nav a i {
    width: 22px;
    text-align: center;
    color: var(--sidebar-muted);
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav a.active {
    box-shadow: inset 3px 0 0 #ffffff;
}

.sidebar-footer {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.main-content {
    padding: 24px;
}

.hero-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

.hero-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.hero-logo {
    width: 58px;
    height: 58px;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid var(--line);
    padding: 4px;
    background: white;
}

.eyebrow {
    display: inline-block;
    color: var(--primary);
    background: #eaf2fb;
    border: 1px solid #d7e6f5;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 7px;
}

.hero-panel h1,
.top-bar h1,
.top-bar h2 {
    font-weight: 800;
    margin: 0;
    letter-spacing: -.02em;
}

.hero-panel p {
    color: var(--muted);
    margin: 6px 0 0;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.top-bar {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.top-bar small,
.text-muted { color: var(--muted) !important; }

.card-soft,
.stat-card,
.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--surface);
}

.card-header {
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0 !important;
    font-weight: 700;
}

.stat-card {
    padding: 18px;
    min-height: 126px;
}

.stat-card.compact h6,
.stat-card h6 {
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-size: .72rem;
    margin: 12px 0 0;
}

.stat-card h3 {
    font-weight: 800;
    margin: 6px 0 0;
    font-size: 1.45rem;
}

.stat-card small {
    color: var(--muted);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-grid;
    place-items: center;
    color: var(--primary);
    background: #edf4fb;
    font-size: 1.2rem;
}

.workflow-panel {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.workflow-panel h4 { margin: 0; font-weight: 800; }
.workflow-panel p { color: var(--muted); margin: 5px 0 0; }

.workflow-steps {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.workflow-step {
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--line);
    padding: 9px 11px;
    border-radius: 999px;
    font-weight: 700;
    font-size: .86rem;
}

.workflow-step span {
    background: var(--primary);
    color: #fff;
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    margin-right: 5px;
}

.automation-alerts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.automation-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

.automation-alert.warning i { color: var(--warning); }
.automation-alert.danger i { color: var(--danger); }

.quick-actions-clean {
    display: grid;
    gap: 10px;
}

.quick-actions-clean a {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 13px;
    background: var(--surface-2);
    font-weight: 700;
}

.quick-actions-clean a:hover {
    border-color: #bfd3e7;
    background: #f1f6fb;
}

.quick-actions-clean i {
    color: var(--primary);
    font-size: 1.1rem;
}

.quick-menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.quick-menu-card {
    display: flex;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text);
}

.quick-menu-card small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

.quick-menu-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #edf4fb;
    color: var(--primary);
    display: grid;
    place-items: center;
    flex: 0 0 38px;
}

.table { vertical-align: middle; }

.table thead th {
    color: #556070;
    background: #f8fafc;
    white-space: nowrap;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--line);
}

.table td { border-color: #eef2f6; }

.btn {
    border-radius: 10px;
    font-weight: 700;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: #abc5dd;
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.form-control,
.form-select {
    border-radius: 10px;
    border-color: #cfd8e3;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 .2rem rgba(47, 128, 237, .12);
}

.logo-preview {
    width: 160px;
    max-width: 100%;
    height: 110px;
    object-fit: contain;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
    padding: 10px;
}

.logo-placeholder {
    width: 160px;
    height: 110px;
    max-width: 100%;
    margin: 0 auto;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-weight: 700;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: #eef3f8;
}

.login-card {
    width: 100%;
    max-width: 410px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.login-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    display: block;
    margin: 0 auto 12px;
    border-radius: 12px;
}

.login-logo-placeholder {
    width: 58px;
    height: 58px;
    border-radius: 14px;
    background: #edf4fb;
    color: var(--primary);
    display: grid;
    place-items: center;
    margin: 0 auto 12px;
    font-size: 1.55rem;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        min-height: auto;
        height: auto;
        position: relative;
    }

    .main-content { padding: 18px; }

    .hero-panel,
    .workflow-panel {
        flex-direction: column;
        align-items: flex-start;
    }

    .hero-actions,
    .workflow-steps {
        justify-content: flex-start;
    }
}


/* Sidebar negro compacto con menú completo */
.app-sidebar::-webkit-scrollbar { width: 7px; }
.app-sidebar::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 999px; }
.sidebar-brand { background: #000; }
.brand-name { color: #ffffff; }
.brand-subtitle { color: #a3a3a3; }
.sidebar-section {
    margin-top: 8px;
    border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-nav a:hover {
    background: #1f1f1f;
    transform: translateX(1px);
}
.sidebar-nav a.active {
    background: #262626;
}
.sidebar-nav a span {
    white-space: normal;
    line-height: 1.15;
}
.system-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--muted);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: .78rem;
    font-weight: 700;
}
.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.print-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 24px;
}
@media print {
    .app-sidebar, .btn, .no-print { display: none !important; }
    .main-content, main { width: 100% !important; max-width: 100% !important; padding: 0 !important; }
    body { background: #fff !important; }
    .print-card { border: 0; box-shadow: none; }
}


.empresa-switcher {
    margin: 10px 10px 4px;
    padding: 10px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 12px;
    background: rgba(255,255,255,.04);
}
.empresa-switcher label {
    display: block;
    color: #a3a3a3;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 6px;
    font-weight: 700;
}
.empresa-switcher select {
    width: 100%;
    background: #111;
    color: #fff;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 9px;
    padding: 7px 8px;
    font-size: .82rem;
}
.empresa-switcher small {
    display: block;
    color: var(--sidebar-muted);
    margin-top: 6px;
    line-height: 1.2;
}
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 5px 10px;
    font-weight: 700;
    font-size: .78rem;
    border: 1px solid var(--line);
    background: var(--surface-2);
}
.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.attachments-list a {
    display: inline-flex;
    margin: 3px 4px 3px 0;
    padding: 5px 8px;
    border-radius: 8px;
    background: #f1f5f9;
    color: var(--primary);
    font-size: .82rem;
    font-weight: 700;
}


/* POS completo */
.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px;
}
.pos-product-card {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 12px;
    text-align: left;
    min-height: 104px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    transition: transform .12s ease, box-shadow .12s ease;
}
.pos-product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.pos-product-card strong {
    font-size: .95rem;
}
.pos-product-card small {
    color: var(--muted);
}
.pos-product-card span {
    margin-top: auto;
    font-weight: 800;
    color: var(--primary);
}
.pos-cart-card {
    position: sticky;
    top: 18px;
}
.pos-totals {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: var(--surface-2);
}
.pos-totals > div {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    color: var(--muted);
}
.pos-totals > div strong {
    color: var(--text);
}
.pos-totals .total {
    border-top: 1px solid var(--line);
    margin-top: 5px;
    padding-top: 10px;
    font-size: 1.15rem;
    color: var(--text);
}


/* Tema configurable por cuenta */
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at top left, rgba(255,255,255,.14), transparent 30%),
        linear-gradient(135deg, var(--login-start), var(--login-end));
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 430px;
    background: var(--login-card);
    color: var(--login-text);
    border-radius: 24px;
    padding: 34px;
    box-shadow: 0 24px 70px rgba(0,0,0,.24);
    border: 1px solid rgba(255,255,255,.35);
}

.login-card h1,
.login-card h2 {
    color: var(--login-text);
    font-weight: 800;
}

.login-logo {
    width: 92px;
    height: 92px;
    object-fit: contain;
    display: block;
    margin: 0 auto 16px;
    border-radius: 18px;
    background: #fff;
    padding: 8px;
    border: 1px solid var(--line);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.license-module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.module-pill {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    background: var(--surface-2);
}

.module-pill.locked {
    opacity: .65;
    background: #f3f4f6;
}

.color-preview {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--line);
}


/* Menú desplegable lateral */
.sidebar-accordion .sidebar-group {
    margin: 5px 0;
    border-radius: 12px;
}
.sidebar-accordion .sidebar-group summary {
    list-style: none;
    cursor: pointer;
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 10px;
    font-weight: 800;
    font-size: .86rem;
    user-select: none;
}
.sidebar-accordion .sidebar-group summary::-webkit-details-marker {
    display: none;
}
.sidebar-accordion .sidebar-group summary i {
    width: 22px;
    text-align: center;
    color: var(--sidebar-muted);
}
.sidebar-accordion .sidebar-group summary::after {
    content: "▾";
    margin-left: auto;
    color: var(--sidebar-muted);
    transition: transform .18s ease;
    font-size: .75rem;
}
.sidebar-accordion .sidebar-group:not([open]) summary::after {
    transform: rotate(-90deg);
}
.sidebar-accordion .sidebar-group summary:hover {
    background: var(--sidebar-hover);
}
.sidebar-accordion .sidebar-group[open] {
    background: rgba(255,255,255,.035);
}
.sidebar-accordion .sidebar-group a {
    margin-left: 8px;
    padding-left: 12px;
    font-size: .84rem;
}
.sidebar-accordion .sidebar-group a span {
    line-height: 1.15;
}

@media (max-width: 767.98px) {
    .app-sidebar {
        position: relative;
        height: auto;
        min-height: auto;
    }
}
