/* ===== Laravel POS – no build step required ===== */
:root {
    --bg: #f8f8f8;
    --panel: #ffffff;
    --border: #d9d9de;
    --border-soft: #e7e7ea;
    --text: #1f1f23;
    --muted: #6b6b73;
    --accent: #e8711c;
    --accent-soft: #fdf1e7;
    --head: #e5e5ea;
    --green: #22a55a;
    --green-dark: #1b8a4a;
    --red: #ef4444;
    --red-dark: #d62f2f;
    --blue: #2f6fde;
    --amber: #d99512;
    --radius: 6px;
    --sidebar: 210px;
    --topbar: 62px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    -webkit-tap-highlight-color: transparent;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }

/* ---------- Top bar ---------- */
.topbar {
    position: fixed; inset: 0 0 auto 0; height: var(--topbar);
    background: var(--panel); border-bottom: 1px solid var(--border-soft);
    display: flex; align-items: center; padding: 0 24px; z-index: 30;
}
.brand { font-weight: 700; font-size: 19px; color: var(--text); width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.collapse-btn {
    background: none; border: 0; cursor: pointer; color: var(--muted);
    width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px;
}
.collapse-btn:hover { background: var(--bg); }
.topbar .spacer { flex: 1; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%; background: #111; color: #fff;
    display: grid; place-items: center; font-weight: 600; font-size: 14px; cursor: pointer; border: 0;
}
.user-menu { position: relative; }
.user-menu .dropdown {
    display: none; position: absolute; right: 0; top: 46px; background: var(--panel);
    border: 1px solid var(--border); border-radius: var(--radius); min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,.08); padding: 6px;
}
.user-menu.open .dropdown { display: block; }
.dropdown .who { padding: 8px 10px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--border-soft); margin-bottom: 4px; }
.dropdown button, .dropdown a { display: block; width: 100%; text-align: left; padding: 10px; border: 0; background: none; font: inherit; color: var(--text); cursor: pointer; border-radius: 4px; }
.dropdown button:hover, .dropdown a:hover { background: var(--bg); text-decoration: none; }

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed; top: var(--topbar); bottom: 0; left: 0; width: var(--sidebar);
    padding: 26px 16px; overflow-y: auto; z-index: 20; background: var(--bg);
    transition: width .15s ease;
}
.nav a {
    display: flex; align-items: center; gap: 14px; padding: 10px 10px; margin-bottom: 4px;
    color: #3a3a40; border-radius: 8px; font-size: 15px; white-space: nowrap; min-height: 42px;
}
.nav a:hover { background: #efefef; text-decoration: none; }
.nav a.active { background: #ededed; color: var(--accent); }
.nav a svg { width: 22px; height: 22px; flex-shrink: 0; stroke: currentColor; }
.nav .group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #9a9aa2; margin: 18px 10px 6px; }

.main { margin-left: var(--sidebar); padding: calc(var(--topbar) + 30px) 32px 40px; transition: margin .15s ease; }

body.collapsed .sidebar { width: 76px; }
body.collapsed .nav a span, body.collapsed .nav .group { display: none; }
body.collapsed .main { margin-left: 76px; }

/* ---------- Generic UI ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--border-soft); border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--panel); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap;
    user-select: none;
}
.btn:hover { background: #f2f2f4; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #d4620f; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: var(--green-dark); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-dark); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, select.input, textarea.input {
    width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font: inherit; background: #fff; color: var(--text);
}
.input:focus { outline: 2px solid #f6c9a4; border-color: var(--accent); }
.field { margin-bottom: 16px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
.check input { width: 20px; height: 20px; }
.error { color: var(--red); font-size: 13px; margin-top: 4px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters .input { width: auto; min-width: 150px; }

.table { width: 100%; border-collapse: collapse; background: var(--panel); }
.table th, .table td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); text-align: left; vertical-align: middle; }
.table th { background: var(--head); font-weight: 600; font-size: 14px; }
.table tr:nth-child(even) td { background: #fafafa; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { border: 1px solid var(--border); border-radius: 6px; overflow-x: auto; }
.table tfoot td { font-weight: 700; background: #fff !important; }

.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eee; color: #444; }
.badge-green { background: #e3f6ea; color: #16784a; }
.badge-red { background: #fde8e8; color: #b32020; }
.badge-amber { background: #fdf3dc; color: #8c5d00; }
.badge-blue { background: #e6eefc; color: #1f4fa8; }

.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 18px; }
.alert-success { background: #e3f6ea; color: #16784a; }
.alert-error { background: #fde8e8; color: #b32020; }

.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.red { color: var(--red); }
.green { color: var(--green); }
.inline { display: inline; }

.pagination-wrap nav { margin-top: 16px; }
.pagination-wrap svg { width: 18px; height: 18px; }
.pagination-wrap .hidden { display: none; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; list-style: none; padding: 0; }
.pager li a, .pager li span { display: inline-block; min-width: 38px; padding: 8px 10px; text-align: center; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); }
.pager li.active span { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager li.disabled span { color: #bbb; }

.bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar div { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar small { color: var(--muted); font-size: 12px; }

/* ================= POS (touch optimised) ================= */
.pos { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; height: calc(100vh - var(--topbar) - 54px); }
.pos-left, .pos-right { display: flex; flex-direction: column; min-height: 0; gap: 12px; }
.pos .top-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pos .input { min-height: 56px; font-size: 17px; }

.customer-btn {
    min-height: 56px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
    display: flex; align-items: center; justify-content: space-between; padding: 0 14px; font: inherit; font-size: 16px;
    cursor: pointer; text-align: left;
}
.customer-btn .tag { background: #eeeef0; border-radius: 4px; padding: 4px 8px; }

.cart { flex: 1; min-height: 0; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.cart table { width: 100%; border-collapse: collapse; }
.cart th { position: sticky; top: 0; background: var(--head); padding: 14px; text-align: left; font-size: 16px; z-index: 1; border-bottom: 1px solid var(--border); }
.cart td { padding: 10px 14px; border-bottom: 1px solid var(--border-soft); font-size: 17px; }
.cart tr:nth-child(even) td { background: #f4f4f5; }
.cart .num { text-align: right; font-variant-numeric: tabular-nums; }
.cart .empty { text-align: center; color: var(--muted); padding: 60px 10px; font-size: 16px; }

.qty { display: inline-flex; align-items: center; gap: 6px; }
.qty button {
    width: 52px; height: 52px; border-radius: 8px; border: 1px solid var(--border); background: #fff;
    font-size: 26px; line-height: 1; cursor: pointer; touch-action: manipulation; user-select: none;
}
.qty button:active { background: #eee; }
.qty .val {
    width: 64px; height: 52px; border: 1px solid var(--border); border-radius: 8px; text-align: center;
    font-size: 18px; font-weight: 600; background: #fff; cursor: pointer; display: grid; place-items: center;
}
.del-btn {
    width: 52px; height: 52px; border-radius: 8px; border: 0; background: var(--red); color: #fff;
    cursor: pointer; display: grid; place-items: center; touch-action: manipulation;
}
.del-btn:active { background: var(--red-dark); }

.totals { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 12px 16px; }
.totals .row { display: flex; justify-content: space-between; font-size: 17px; padding: 4px 0; }
.totals .grand { font-size: 28px; font-weight: 800; border-top: 1px solid var(--border-soft); margin-top: 6px; padding-top: 10px; }

.pos-actions { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 10px; }
.big-btn {
    min-height: 72px; border-radius: 10px; border: 1px solid var(--border); background: #fff;
    font: inherit; font-size: 19px; font-weight: 600; cursor: pointer; touch-action: manipulation; user-select: none;
}
.big-btn:active { transform: scale(.98); }
.big-btn.pay { background: var(--green); border-color: var(--green); color: #fff; font-size: 24px; }
.big-btn.pay:active { background: var(--green-dark); }
.big-btn.pay[disabled] { opacity: .5; }
.big-btn.danger { color: var(--red); }

.cats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; flex-shrink: 0; scrollbar-width: thin; }
.cats button {
    min-height: 52px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--border); background: #fff;
    font: inherit; font-size: 16px; white-space: nowrap; cursor: pointer; touch-action: manipulation;
}
.cats button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.products {
    flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: 10px; align-content: start;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    grid-auto-rows: max-content; /* keep tiles full size and scroll, instead of squashing them */
}
.tile {
    background: #fff; border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
    cursor: pointer; text-align: left; padding: 0; font: inherit; touch-action: manipulation; user-select: none;
    display: flex; flex-direction: column; position: relative;
}
.tile:active { transform: scale(.97); border-color: var(--accent); }
.tile .img { height: 92px; background: #c4c4c4; display: grid; place-items: center; overflow: hidden; }
.tile .img img { width: 100%; height: 100%; object-fit: cover; }
.tile .img svg { width: 64px; height: 64px; }
.tile .name { padding: 10px 10px 2px; font-size: 15px; color: #444; line-height: 1.25; }
.tile .price { padding: 4px 10px 12px; font-size: 18px; color: #333; font-weight: 600; }
.tile .stock { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; padding: 2px 7px; border-radius: 999px; }
.tile.out { opacity: .45; }
.tile.flash { animation: flash .35s; }
@keyframes flash { from { box-shadow: 0 0 0 4px var(--accent); } to { box-shadow: 0 0 0 0 transparent; } }

/* Modal + keypad */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 520px; max-height: 94vh; overflow-y: auto; padding: 22px; }
.modal.wide { max-width: 760px; }
.modal h2 { font-size: 20px; display: flex; justify-content: space-between; align-items: center; }
.modal .close { background: none; border: 0; font-size: 30px; cursor: pointer; width: 48px; height: 48px; }

.display {
    font-size: 36px; font-weight: 700; text-align: right; padding: 12px 16px; border: 2px solid var(--border);
    border-radius: 8px; margin-bottom: 12px; font-variant-numeric: tabular-nums; min-height: 66px;
}
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button {
    min-height: 66px; font-size: 26px; font-weight: 600; border-radius: 8px; border: 1px solid var(--border);
    background: #fff; cursor: pointer; touch-action: manipulation; user-select: none;
}
.keypad button:active { background: #eee; }
.keypad .wide { grid-column: span 3; background: var(--green); color: #fff; border-color: var(--green); }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.quick button { min-height: 56px; font-size: 18px; border-radius: 8px; border: 1px solid var(--border); background: #f6f6f7; cursor: pointer; }
.methods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.methods button { min-height: 60px; font: inherit; font-size: 16px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.methods button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pay-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; text-align: center; }
.pay-summary div { background: #f6f6f7; border-radius: 8px; padding: 10px; }
.pay-summary small { display: block; color: var(--muted); }
.pay-summary strong { font-size: 22px; }

.cust-list { max-height: 50vh; overflow-y: auto; margin-top: 10px; }
.cust-list button {
    display: flex; justify-content: space-between; width: 100%; min-height: 60px; padding: 0 14px; font: inherit; font-size: 17px;
    border: 0; border-bottom: 1px solid var(--border-soft); background: #fff; cursor: pointer; text-align: left; align-items: center;
}
.cust-list button:active, .cust-list button.on { background: var(--accent-soft); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 14px 22px; border-radius: 8px; font-size: 16px; z-index: 200; display: none; }
.toast.show { display: block; }
.toast.err { background: var(--red); }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 400px; }
.login .input, .login .btn { min-height: 52px; font-size: 17px; }

/* Responsive */
@media (max-width: 1100px) {
    .pos { grid-template-columns: 1fr; height: auto; }
    .cart { max-height: 50vh; }
    .products { max-height: 70vh; }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .sidebar { width: 76px; padding: 20px 10px; }
    .nav a span, .nav .group { display: none; }
    .main { margin-left: 76px; padding: calc(var(--topbar) + 16px) 12px 30px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .pos .top-row { grid-template-columns: 1fr; }
    .pos-actions { grid-template-columns: 1fr 1fr; }
    .pos-actions .pay { grid-column: span 2; }
    .brand { width: auto; }
}

@media print {
    .topbar, .sidebar, .no-print { display: none !important; }
    .main { margin: 0; padding: 0; }
}