:root {
    --brand-950: #0b1220;
    --brand-900: #101a2e;
    --brand-800: #16213d;
    --brand-600: #2f6fed;
    --brand-500: #4b83f0;
    --brand-100: #eaf1ff;
    --ink-900: #10182b;
    --ink-600: #5b6478;
    --ink-400: #9399a8;
    --bg-app: #f4f6fb;
    --card-border: #e6e9f2;
    --ok-600: #17a673;
    --warn-600: #e2a03f;
    --danger-600: #d9534f;
    --radius: 14px;
}

* { box-sizing: border-box; }

body {
    background: var(--bg-app);
    color: var(--ink-900);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 14.5px;
}

a { text-decoration: none; }

/* ---------- Shell layout ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 250px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--brand-950), var(--brand-900) 60%, var(--brand-800));
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.25rem 1.25rem 1rem;
    font-size: 1.05rem;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand i { font-size: 1.35rem; color: var(--brand-500); }

.sidebar-nav { flex: 1; padding: .9rem .6rem; display: flex; flex-direction: column; gap: .2rem; }

.sidebar-nav .nav-link {
    color: rgba(255,255,255,.72);
    padding: .62rem .8rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: .65rem;
    font-size: .92rem;
    transition: background .15s ease, color .15s ease;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active {
    background: var(--brand-600);
    color: #fff;
    box-shadow: 0 4px 14px rgba(47,111,237,.35);
}

.sidebar-footer { padding: 1rem 1.1rem 1.3rem; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: .5rem; color: rgba(255,255,255,.85); font-size: .88rem; }
.user-chip i { font-size: 1.2rem; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
    background: #fff;
    border-bottom: 1px solid var(--card-border);
    padding: .95rem 1.6rem;
    display: flex;
    align-items: center;
    gap: .8rem;
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar-title { font-size: 1.15rem; font-weight: 600; margin: 0; color: var(--ink-900); }

.app-content { padding: 1.6rem; flex: 1; }

/* ---------- Cards / widgets ---------- */
.card-soft {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(16,24,43,.04);
}

.stat-tile {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
}
.stat-tile .stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-400); font-weight: 600; }
.stat-tile .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--ink-900); margin-top: .15rem; }
.stat-tile .stat-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: var(--brand-100); color: var(--brand-600); font-size: 1.1rem;
}

/* ---------- KPI sticky panel (constructor de recetas) ---------- */
.kpi-panel {
    position: sticky;
    top: 5.2rem;
}
.kpi-panel .kpi-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: .45rem 0;
    border-bottom: 1px dashed var(--card-border);
    font-size: .88rem;
}
.kpi-panel .kpi-row:last-child { border-bottom: none; }
.kpi-panel .kpi-label { color: var(--ink-600); }
.kpi-panel .kpi-value { font-weight: 600; color: var(--ink-900); }
.kpi-panel .kpi-total {
    background: var(--brand-100);
    border-radius: 10px;
    padding: .8rem .9rem;
    margin-top: .6rem;
}
.kpi-panel .kpi-total .kpi-value { color: var(--brand-600); font-size: 1.05rem; }
.kpi-panel .kpi-price {
    background: linear-gradient(135deg, var(--brand-600), #6a9bff);
    color: #fff;
    border-radius: 12px;
    padding: 1rem 1.1rem;
    margin-top: .7rem;
}
.kpi-panel .kpi-price .kpi-label { color: rgba(255,255,255,.85); }
.kpi-panel .kpi-price .kpi-value { color: #fff; font-size: 1.6rem; font-weight: 700; }

/* ---------- Tables ---------- */
.table-clean thead th {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-400);
    border-bottom: 2px solid var(--card-border);
    font-weight: 700;
    white-space: nowrap;
}
.table-clean td { vertical-align: middle; font-size: .9rem; }
.table-clean tbody tr:hover { background: #fafbfe; }

.badge-categoria-materia_prima { background: #e8f6ef; color: var(--ok-600); }
.badge-categoria-empaque_insumo { background: #fff2df; color: #b9791f; }

/* ---------- Login ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #1c2b4d, var(--brand-950) 60%);
    padding: 1rem;
}
.login-card {
    background: #fff;
    border-radius: 18px;
    padding: 2.2rem 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-card .brand-icon {
    width: 52px; height: 52px; border-radius: 14px;
    background: var(--brand-100); color: var(--brand-600);
    display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
    margin-bottom: .9rem;
}

/* ---------- Recipe builder rows ---------- */
.item-row td { vertical-align: middle; }
.item-row .form-select-sm, .item-row .form-control-sm { font-size: .85rem; }

.section-title {
    font-size: .95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .9rem;
}
.section-title i { color: var(--brand-600); }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        left: -260px;
        transition: left .2s ease;
    }
    .app-sidebar.open { left: 0; }
    .kpi-panel { position: static; margin-top: 1.5rem; }
}
