/* ============================================================
   GreyCell POS — Estilo "Black Gold" · dark premium · mobile-first
   Todo local, sin CDNs ni fuentes externas.
   ============================================================ */

:root {
    --bg:        #0a0a0a;
    --bg-2:      #121212;
    --panel:     rgba(255, 255, 255, 0.035);
    --panel-2:   rgba(255, 255, 255, 0.06);
    --stroke:    rgba(212, 175, 55, 0.16);
    --stroke-2:  rgba(255, 255, 255, 0.08);
    --gold:      #d4af37;
    --gold-2:    #f0c96b;
    --gold-soft: rgba(212, 175, 55, 0.12);
    --text:      #f4f4f5;
    --muted:     #9a9a9a;
    --muted-2:   #6b6b6b;
    --ok:        #4ade80;
    --warn:      #fbbf24;
    --danger:    #f87171;
    --radius:    16px;
    --radius-sm: 11px;
    --shadow:    0 10px 30px rgba(0, 0, 0, 0.45);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    font-size: 16px;
    line-height: 1.45;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(212, 175, 55, 0.07), transparent 60%),
        radial-gradient(900px 500px at -10% 10%, rgba(212, 175, 55, 0.04), transparent 55%),
        var(--bg);
    padding-bottom: 40px;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 .3em; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.08rem; }
small { color: var(--muted); }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(10, 10, 10, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--stroke-2);
}
.topbar-brand { display: flex; align-items: center; gap: 9px; }
.brand-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-2), var(--gold));
    box-shadow: 0 0 14px rgba(212, 175, 55, 0.6);
}
.brand-name { font-weight: 700; letter-spacing: .02em; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: .9rem; color: var(--text); }
.user-role {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
    padding: 3px 8px; border-radius: 999px; border: 1px solid var(--stroke);
    color: var(--gold-2); background: var(--gold-soft);
}
.user-role.role-vendedora { color: #cbd5e1; background: rgba(255,255,255,.05); border-color: var(--stroke-2); }
.btn-logout {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px;
    border: 1px solid var(--stroke-2); color: var(--muted);
}
.btn-logout:hover { color: var(--danger); border-color: var(--danger); }
.btn-logout svg { width: 18px; height: 18px; }

/* ---------- Nav pills (scroll horizontal) ---------- */
.nav-pills {
    display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
    padding: 12px 16px; position: sticky; top: 62px; z-index: 15;
    background: rgba(10,10,10,.7); backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--stroke-2);
}
.nav-pills::-webkit-scrollbar { display: none; }
.pill {
    display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
    padding: 9px 14px; border-radius: 999px; font-size: .86rem; font-weight: 550;
    color: var(--muted); border: 1px solid var(--stroke-2);
    background: var(--panel); transition: .15s;
}
.pill:hover { color: var(--text); border-color: var(--stroke); }
.pill.is-active {
    color: #1a1400; background: linear-gradient(135deg, var(--gold-2), var(--gold));
    border-color: transparent; font-weight: 650;
}
.pill-ico svg { width: 16px; height: 16px; display: block; }

/* ---------- Layout ---------- */
.wrap { max-width: 940px; margin: 0 auto; padding: 18px 16px 30px; }

/* ---------- Flash ---------- */
.flash {
    padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px;
    font-size: .92rem; border: 1px solid var(--stroke-2);
}
.flash-ok    { background: rgba(74,222,128,.10); border-color: rgba(74,222,128,.35); color: #bbf7d0; }
.flash-error { background: rgba(248,113,113,.10); border-color: rgba(248,113,113,.35); color: #fecaca; }
.flash-info  { background: var(--gold-soft); border-color: var(--stroke); color: var(--gold-2); }

/* ---------- Cards ---------- */
.card {
    background: var(--panel); border: 1px solid var(--stroke-2);
    border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 620px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Stat cards (dashboard) ---------- */
.stat {
    background: linear-gradient(160deg, var(--panel-2), var(--panel));
    border: 1px solid var(--stroke); border-radius: var(--radius);
    padding: 16px 16px 18px; position: relative; overflow: hidden;
}
.stat::after {
    content: ""; position: absolute; right: -30px; top: -30px;
    width: 90px; height: 90px; border-radius: 50%;
    background: radial-gradient(circle, rgba(212,175,55,.18), transparent 70%);
}
.stat-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.stat-value {
    font-size: 1.9rem; font-weight: 750; margin-top: 6px; letter-spacing: -0.02em;
    background: linear-gradient(120deg, #fff, var(--gold-2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-value.plain { -webkit-text-fill-color: var(--text); color: var(--text); background: none; }
.stat-sub { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.stat-big .stat-value { font-size: 2.4rem; }
.stat-value.neg { background: linear-gradient(120deg, #fff, var(--danger)); -webkit-background-clip: text; background-clip: text; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 18px; border-radius: var(--radius-sm); font-size: .95rem;
    font-weight: 600; cursor: pointer; border: 1px solid var(--stroke-2);
    background: var(--panel-2); color: var(--text); transition: .15s;
    font-family: inherit;
}
.btn:hover { border-color: var(--stroke); }
.btn-gold {
    background: linear-gradient(135deg, var(--gold-2), var(--gold));
    color: #1a1400; border-color: transparent; font-weight: 700;
}
.btn-gold:hover { filter: brightness(1.06); }
.btn-danger { color: #fecaca; border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.08); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: .84rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
    width: 100%; padding: 12px 13px; border-radius: var(--radius-sm);
    background: #0f0f0f; border: 1px solid var(--stroke-2); color: var(--text);
    font-size: .96rem; font-family: inherit; transition: .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft);
}
textarea { min-height: 74px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--stroke-2); white-space: nowrap; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: rgba(255,255,255,.02); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.money { font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }

/* ---------- Badges ---------- */
.badge {
    display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .72rem;
    font-weight: 600; border: 1px solid var(--stroke-2); background: var(--panel);
}
.badge-gold { color: var(--gold-2); background: var(--gold-soft); border-color: var(--stroke); }
.badge-ok   { color: var(--ok); background: rgba(74,222,128,.1); border-color: rgba(74,222,128,.3); }
.badge-warn { color: var(--warn); background: rgba(251,191,36,.1); border-color: rgba(251,191,36,.3); }
.badge-off  { color: var(--muted); }

/* ---------- Buscador de productos (vender) ---------- */
.buscador { position: relative; }
.resultados {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
    background: #101010; border: 1px solid var(--stroke); border-radius: var(--radius-sm);
    max-height: 320px; overflow-y: auto; box-shadow: var(--shadow); display: none;
}
.resultados.show { display: block; }
.res-item {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 11px 13px; cursor: pointer; border-bottom: 1px solid var(--stroke-2);
}
.res-item:last-child { border-bottom: 0; }
.res-item:hover, .res-item.active { background: var(--gold-soft); }
.res-nombre { font-weight: 550; }
.res-meta { font-size: .78rem; color: var(--muted); }
.res-precio { font-weight: 700; color: var(--gold-2); white-space: nowrap; }
.res-sinstock { opacity: .5; }

/* ---------- Carrito ---------- */
.cart-item {
    display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
    padding: 12px 0; border-bottom: 1px solid var(--stroke-2);
}
.cart-item:last-child { border-bottom: 0; }
.cart-nombre { font-weight: 550; font-size: .92rem; }
.cart-sub { font-size: .78rem; color: var(--muted); }
.qty { display: inline-flex; align-items: center; gap: 6px; }
.qty button {
    width: 30px; height: 30px; padding: 0; border-radius: 8px; font-size: 1.1rem;
    line-height: 1; background: var(--panel-2); border: 1px solid var(--stroke-2);
    color: var(--text); cursor: pointer;
}
.qty input { width: 46px; text-align: center; padding: 6px; }
.cart-line-total { font-weight: 650; min-width: 84px; text-align: right; font-variant-numeric: tabular-nums; }
.cart-del { color: var(--danger); cursor: pointer; background: none; border: 0; font-size: 1.1rem; padding: 4px 8px; }
.cart-empty { color: var(--muted); text-align: center; padding: 22px 0; }
.cart-total-row {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--stroke);
}
.cart-total-row .big { font-size: 1.9rem; font-weight: 750; color: var(--gold-2); }

/* ---------- Gráfico ---------- */
.chart-box { width: 100%; }
canvas { width: 100%; display: block; }

/* ---------- Ranking ---------- */
.rank-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--stroke-2); }
.rank-row:last-child { border-bottom: 0; }
.rank-pos {
    width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
    font-weight: 700; font-size: .85rem; background: var(--panel-2); border: 1px solid var(--stroke-2);
}
.rank-pos.top { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #1a1400; border-color: transparent; }
.rank-info { flex: 1; }
.rank-name { font-weight: 600; }
.rank-meta { font-size: .78rem; color: var(--muted); }
.rank-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Alertas de stock ---------- */
.alert-stock { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--stroke-2); }
.alert-stock:last-child { border-bottom: 0; }
.alert-stock .n { font-weight: 700; color: var(--warn); }

/* ---------- Login ---------- */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
    width: 100%; max-width: 380px; background: var(--panel);
    border: 1px solid var(--stroke); border-radius: 20px; padding: 30px 26px;
    box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 22px; }
.login-logo .dot {
    width: 46px; height: 46px; border-radius: 14px; margin: 0 auto 12px;
    background: linear-gradient(135deg, var(--gold-2), var(--gold));
    box-shadow: 0 0 30px rgba(212,175,55,.5);
}
.login-logo h1 { font-size: 1.3rem; }
.login-logo p { color: var(--muted); font-size: .86rem; margin: 0; }

/* ---------- Utilidades ---------- */
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 10px; } .mt-2 { margin-top: 18px; }
.mb-1 { margin-bottom: 10px; } .mb-2 { margin-bottom: 18px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.right { text-align: right; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--stroke-2); margin: 16px 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tag-cost { color: var(--gold-2); font-weight: 600; }
.pos-margin { color: var(--ok); font-weight: 600; }
