:root {
    --red: #b91c1c;
    --red-dark: #991b1b;
    --red-soft: #fee2e2;
    --green: #166534;
    --green-soft: #dcfce7;
    --amber: #92400e;
    --amber-soft: #fef3c7;
    --ink: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --panel: #ffffff;
    --page: #f8fafc;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 58px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; }
.brand { color: var(--red); font-size: 20px; font-weight: 700; text-decoration: none; letter-spacing: -.02em; }
.brand strong { color: var(--ink); }
.brand.big { font-size: 28px; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.topbar-user a { color: var(--red); text-decoration: none; font-weight: 700; }
.nav-tabs { position: sticky; top: 58px; z-index: 19; display: flex; gap: 4px; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--line); padding: 8px 12px; scrollbar-width: none; }
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs a { flex: 0 0 auto; text-decoration: none; padding: 9px 12px; border-radius: 10px; color: #4b5563; font-size: 14px; font-weight: 650; }
.nav-tabs a.active { color: var(--red); background: var(--red-soft); }
.page { max-width: 1280px; margin: 0 auto; padding: 18px 14px 80px; }
.footer { color: var(--muted); text-align: center; padding: 20px 12px 80px; font-size: 13px; }
.page-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.page-title h1 { margin: 0 0 4px; font-size: 24px; }
.page-title p { margin: 0; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 14px; }
.grid.metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { margin-top: 4px; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.metric-note { margin-top: 5px; font-size: 12px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 11px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 10px 14px; font-weight: 700; text-decoration: none; }
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.danger { color: var(--red); border-color: #fecaca; background: #fff; }
.btn.success { color: var(--green); border-color: #bbf7d0; background: #fff; }
.btn.full { width: 100%; }
.btn.small { min-height: 36px; padding: 7px 10px; font-size: 13px; }
.alert { border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; border: 1px solid var(--line); background: #fff; }
.alert.success { background: var(--green-soft); color: var(--green); border-color: #bbf7d0; }
.alert.danger, .alert.error { background: var(--red-soft); color: var(--red-dark); border-color: #fecaca; }
.alert.warning { background: var(--amber-soft); color: var(--amber); border-color: #fde68a; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 800; background: #eef2ff; color: #3730a3; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red-dark); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 12px 13px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { color: var(--muted); background: #f9fafb; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
label { display: grid; gap: 7px; color: #374151; font-weight: 650; font-size: 14px; }
input, select, textarea { width: 100%; min-height: 44px; border: 1px solid #d1d5db; border-radius: 10px; background: #fff; padding: 10px 12px; color: var(--ink); }
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: auto; padding: 0; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(185,28,28,.14); border-color: var(--red); }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.form-grid h2 { margin: 15px 0 0; font-size: 18px; grid-column: 1 / -1; }
.section-gap { margin-top: 16px; }
.login-body, .install-body { min-height: 100vh; background: linear-gradient(180deg, #fff 0%, #fef2f2 100%); }
.login-wrap, .install-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 14px; }
.login-card, .install-card { width: min(100%, 760px); background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 22px; }
.login-card { width: min(100%, 430px); }
.login-card h1, .install-card h1 { margin-bottom: 6px; }
.install-card code { background: #f3f4f6; padding: 2px 5px; border-radius: 5px; }
.pos-shell { display: grid; gap: 14px; }
.pos-catalog { min-width: 0; }
.pos-sidebar { min-width: 0; }
.pos-toolbar { display: grid; gap: 10px; margin-bottom: 12px; }
.category-tabs { display: flex; overflow-x: auto; gap: 8px; padding-bottom: 4px; scrollbar-width: none; }
.category-tabs::-webkit-scrollbar { display: none; }
.category-btn { flex: 0 0 auto; min-height: 42px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 13px; font-weight: 700; }
.category-btn.active { background: var(--red); color: #fff; border-color: var(--red); }
.products-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.product-btn { min-height: 112px; border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 12px; text-align: left; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }
.product-btn:hover { border-color: #fca5a5; }
.product-btn:active { transform: translateY(1px); }
.product-btn.sold { opacity: .5; cursor: not-allowed; }
.product-name { font-weight: 800; line-height: 1.25; }
.product-price { color: var(--red); font-weight: 800; }
.cart-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.cart-head { padding: 14px 15px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.cart-items { display: grid; gap: 1px; background: var(--line); }
.cart-empty { padding: 28px 15px; text-align: center; color: var(--muted); background: #fff; }
.cart-item { background: #fff; padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.cart-item-name { font-weight: 750; }
.cart-item-price { color: var(--muted); font-size: 13px; }
.qty { display: inline-flex; align-items: center; gap: 7px; }
.qty button { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-weight: 800; }
.cart-summary { padding: 14px; border-top: 1px solid var(--line); }
.total-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.total-row strong { font-size: 22px; }
.payment-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-btn { min-height: 58px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 800; }
.pay-btn.active { background: var(--red-soft); color: var(--red-dark); border-color: #fca5a5; }
.checkout-bar { position: sticky; bottom: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); padding-top: 10px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(17,24,39,.68); display: none; align-items: center; justify-content: center; padding: 14px; }
.modal-backdrop.show { display: flex; }
.modal { width: min(100%, 480px); max-height: calc(100vh - 28px); overflow-y: auto; background: #fff; border-radius: 18px; padding: 18px; }
.modal h2 { margin-top: 0; }
.qr-image { display: block; width: min(78vw, 300px); aspect-ratio: 1; object-fit: contain; margin: 12px auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.qr-placeholder { display: grid; place-items: center; width: min(78vw, 300px); aspect-ratio: 1; margin: 12px auto; border: 2px dashed #d1d5db; border-radius: 12px; color: var(--muted); text-align: center; padding: 20px; }
.big-total { font-size: 30px; font-weight: 900; text-align: center; color: var(--red); }
.receipt { max-width: 460px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.receipt h1 { text-align: center; margin-bottom: 4px; }
.receipt-meta { text-align: center; color: var(--muted); font-size: 13px; }
.receipt-list { margin: 16px 0; border-top: 1px dashed #9ca3af; border-bottom: 1px dashed #9ca3af; padding: 10px 0; }
.receipt-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 5px 0; }
.receipt-total { display: flex; justify-content: space-between; font-size: 20px; font-weight: 900; }
@media (min-width: 700px) {
    .page { padding: 24px 22px 60px; }
    .grid.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid .wide { grid-column: 1 / -1; }
    .products-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 920px) {
    .pos-shell { grid-template-columns: minmax(0, 1.7fr) minmax(330px, .9fr); align-items: start; }
    .pos-sidebar { position: sticky; top: 126px; }
    .products-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media print {
    body { background: #fff; }
    .topbar, .nav-tabs, .footer, .no-print, .page-title { display: none !important; }
    .page { padding: 0; }
    .receipt { border: 0; border-radius: 0; }
}
