/* POS MVP - estilos base */
:root {
    --color-bg: #f4f6f9;
    --color-card: #ffffff;
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-success: #16a34a;
    --color-warn: #d97706;
    --color-danger: #dc2626;
    --color-text: #1f2937;
    --color-muted: #6b7280;
    --color-border: #e5e7eb;
    --radius: 8px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #111827;
    color: #fff;
    padding: 10px 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 28px; width: auto; border-radius: 4px; background: #fff; }
.btn-icon { background: none; border: none; color: #fff; font-size: 1.3rem; cursor: pointer; display: none; }
.user-chip { font-size: 0.85rem; color: #d1d5db; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: #16a34a33; color: #4ade80; }
.badge-warn { background: #d9770633; color: #fbbf24; }

.layout { display: flex; min-height: calc(100vh - 49px); }
.sidebar {
    width: 220px;
    background: #1f2937;
    padding: 14px 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar a {
    color: #d1d5db;
    padding: 10px 18px;
    font-size: 0.92rem;
    border-left: 3px solid transparent;
}
.sidebar a:hover { background: #111827; text-decoration: none; color: #fff; }

.content { flex: 1; padding: 20px; max-width: 1400px; }

.card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
}
.card h2 { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
}
.stat .label { color: var(--color-muted); font-size: 0.85rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--color-border); text-align: left; }
th { background: #f9fafb; font-weight: 600; color: var(--color-muted); font-size: 0.8rem; text-transform: uppercase; }
tr:hover td { background: #f9fafb; }
.table-wrap { overflow-x: auto; }

.btn {
    display: inline-block;
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 600;
}
.btn:hover { background: var(--color-primary-dark); text-decoration: none; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-secondary { background: #6b7280; }
.btn-secondary:hover { background: #4b5563; }
.btn-success { background: var(--color-success); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-warn { background: var(--color-warn); }
.btn-outline { background: #fff; color: var(--color-primary); border: 1px solid var(--color-primary); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 5px; color: var(--color-muted); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], input[type=tel], select, textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.92rem;
    background: #fff;
    color: var(--color-text);
}
textarea { resize: vertical; min-height: 70px; }
.form-inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-inline .form-row { flex: 1; min-width: 160px; margin-bottom: 0; }

.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 0.92rem; }
.alert-ok, .alert-success { background: #dcfce7; color: #166534; }
.alert-error, .alert-danger { background: #fee2e2; color: #991b1b; }
.alert-warn { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.tag-green { background: #dcfce7; color: #166534; }
.tag-red { background: #fee2e2; color: #991b1b; }
.tag-gray { background: #f3f4f6; color: #4b5563; }
.tag-yellow { background: #fef3c7; color: #92400e; }
.tag-blue { background: #dbeafe; color: #1e40af; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; border-radius: 6px 6px 0 0; font-size: 0.9rem; color: var(--color-muted); }
.tabs a.active { background: var(--color-card); color: var(--color-primary); font-weight: 700; border: 1px solid var(--color-border); border-bottom: 1px solid var(--color-card); margin-bottom: -1px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-box { display: flex; gap: 8px; }
.search-box input { min-width: 240px; }

.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; align-items: center; justify-content: center; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 8px; padding: 22px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }

/* ---- POS ---- */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: flex-start; }
.pos-buscador { display: flex; gap: 8px; margin-bottom: 12px; }
.pos-buscador input { font-size: 1.05rem; padding: 12px; }
.pos-resultados { max-height: 55vh; overflow-y: auto; }
.pos-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid var(--color-border); cursor: pointer; }
.pos-item:hover { background: #eff6ff; }
.pos-item .nombre { font-weight: 600; }
.pos-item .meta { font-size: 0.8rem; color: var(--color-muted); }
.carrito-item { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--color-border); font-size: 0.88rem; }
.carrito-item .desc { flex: 1; }
.carrito-item input[type=number] { width: 55px; padding: 4px; text-align: center; }
.carrito-totales { margin-top: 12px; border-top: 2px solid var(--color-border); padding-top: 10px; }
.carrito-totales .fila { display: flex; justify-content: space-between; padding: 3px 0; }
.carrito-totales .total { font-size: 1.3rem; font-weight: 800; color: var(--color-primary); }

/* Factura imprimible */
.factura { max-width: 720px; margin: 0 auto; background: #fff; padding: 30px; }
.factura-head { display: flex; justify-content: space-between; border-bottom: 2px solid #111; padding-bottom: 14px; margin-bottom: 14px; }
.factura-head img { max-height: 60px; }
.factura table td, .factura table th { border: 1px solid #ddd; }

@media print {
    .topbar, .sidebar, .no-print { display: none !important; }
    .content { padding: 0; }
    body { background: #fff; }
}

@media (max-width: 860px) {
    .btn-icon { display: block; }
    .sidebar { position: fixed; left: -240px; top: 49px; bottom: 0; z-index: 30; transition: left .2s; box-shadow: 2px 0 8px rgba(0,0,0,.2); overflow-y: auto; }
    .sidebar.open { left: 0; }
    .pos-layout { grid-template-columns: 1fr; }
    .content { padding: 12px; }
}
