:root {
    --green: #0f9f6e;
    --green-soft: #e8fff5;
    --red: #ef4444;
    --red-soft: #fff0f0;
    --amber: #f59e0b;
    --amber-soft: #fff8e8;
    --blue: #2563eb;
    --blue-soft: #eef4ff;
    --ink: #101827;
    --muted: #687386;
    --line: #e6eaf0;
    --panel: #ffffff;
    --bg: #f8fafc;
    --shadow: 0 18px 45px rgba(16, 24, 39, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: #fff;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; background: var(--bg); }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 24px;
    background: #fff;
    border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 900; font-size: 22px; }
.brand img { width: 48px; height: 48px; filter: drop-shadow(0 8px 18px rgba(15, 159, 110, .24)); }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 8px;
    color: #334155;
    font-weight: 750;
    transition: .2s ease;
}
.sidebar nav a:hover { background: var(--green-soft); color: var(--green); transform: translateX(3px); }
.nav-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    position: relative;
    background: var(--blue-soft);
}
.nav-icon::after { content: ""; width: 13px; height: 13px; display: block; background: var(--blue); mask-size: contain; mask-repeat: no-repeat; mask-position: center; }
.nav-icon.home::after { mask-image: linear-gradient(#000, #000); border-radius: 3px 3px 2px 2px; transform: rotate(45deg); }
.nav-icon.ball { background: #f7f7f8; }
.nav-icon.ball::after { width: 18px; height: 18px; border-radius: 50%; background: #111827; mask-image: none; box-shadow: inset 0 0 0 5px #fff; }
.nav-icon.receipt { background: var(--amber-soft); }
.nav-icon.receipt::after { background: var(--amber); mask-image: linear-gradient(#000, #000); border-radius: 2px; }
.nav-icon.box { background: #fff6ed; }
.nav-icon.box::after { background: #ea580c; mask-image: linear-gradient(#000, #000); clip-path: polygon(50% 0, 100% 22%, 100% 78%, 50% 100%, 0 78%, 0 22%); }
.nav-icon.cash { background: var(--green-soft); }
.nav-icon.cash::after { background: var(--green); mask-image: linear-gradient(#000, #000); border-radius: 50%; }
.nav-icon.chart { background: var(--blue-soft); }
.nav-icon.chart::after { background: var(--blue); mask-image: linear-gradient(#000, #000); clip-path: polygon(0 100%, 0 45%, 22% 45%, 22% 100%, 38% 100%, 38% 18%, 60% 18%, 60% 100%, 76% 100%, 76% 0, 100% 0, 100% 100%); }
.nav-icon.gear { background: var(--red-soft); }
.nav-icon.gear::after { background: var(--red); mask-image: linear-gradient(#000, #000); border-radius: 50%; box-shadow: 0 0 0 4px var(--red); transform: scale(.45); }
.sidebar-user { margin-top: auto; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fafafa; display: grid; gap: 3px; }
.sidebar-user span { color: var(--muted); font-size: 13px; }
.sidebar-user a { margin-top: 8px; color: var(--red); font-weight: 800; }
.content { padding: 28px; max-width: 1500px; width: 100%; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 18% 15%, rgba(15,159,110,.08), transparent 28%),
        radial-gradient(circle at 82% 88%, rgba(37,99,235,.08), transparent 26%),
        #fff;
}
.auth-card { width: min(920px, calc(100vw - 32px)); background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 34px; }
.auth-logo { width: 96px; height: auto; display: block; margin-bottom: 18px; }

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(28px, 4vw, 46px); margin-bottom: 8px; }
h2 { font-size: 20px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.eyebrow { color: var(--green); font-weight: 900; text-transform: uppercase; font-size: 12px; margin-bottom: 8px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.hero-panel {
    display: grid;
    grid-template-columns: 1fr minmax(240px, 380px);
    align-items: center;
    gap: 22px;
    padding: 28px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    margin-bottom: 22px;
    overflow: hidden;
}
.hero-panel img { width: 100%; animation: floatCue 5s ease-in-out infinite; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; display: grid; gap: 8px; box-shadow: 0 10px 28px rgba(16,24,39,.05); }
.metric span { width: 34px; height: 34px; border-radius: 50%; display: block; position: relative; }
.metric span::after { content: ""; position: absolute; inset: 9px; background: #fff; border-radius: 50%; }
.metric strong { font-size: 26px; }
.metric small { color: var(--muted); font-weight: 800; }
.metric.green span { background: var(--green); }
.metric.red span { background: var(--red); }
.metric.amber span { background: var(--amber); }
.metric.blue span { background: var(--blue); }
.metric.black span { background: #111827; }

.split { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr); gap: 18px; margin-bottom: 22px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel, .list-panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 28px rgba(16,24,39,.05); padding: 18px; }
.list-row { display: flex; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row small { display: block; color: var(--muted); }

.btn {
    border: 0;
    border-radius: 8px;
    padding: 11px 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 900;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(16,24,39,.12); }
.btn.primary { background: var(--green); color: #fff; }
.btn.success { background: #111827; color: #fff; }
.btn.danger { background: var(--red); color: #fff; }
.btn.amber { background: var(--amber); color: #111827; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.wide { width: 100%; }
.btn.mini { padding: 8px 10px; font-size: 13px; }
.icon-btn { border: 0; background: var(--red-soft); color: var(--red); width: 28px; height: 28px; border-radius: 50%; font-size: 18px; cursor: pointer; }

.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.table-grid.compact { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.pool-card {
    position: relative;
    display: grid;
    gap: 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    min-height: 240px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(16,24,39,.06);
    transition: .2s ease;
}
.pool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.pool-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--green); }
.pool-card.occupied::before { background: var(--red); }
.pool-card.pending_payment::before { background: var(--amber); }
.pool-card-top { display: flex; justify-content: space-between; gap: 12px; position: relative; z-index: 1; }
.pool-card-top strong { display: block; font-size: 20px; }
.pool-card-top span { color: var(--muted); font-size: 13px; font-weight: 800; }
.status-pill { padding: 6px 10px; background: #f1f5f9; border-radius: 999px; text-transform: capitalize; }
.pool-visual {
    min-height: 88px;
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(255,255,255,.22), transparent),
        linear-gradient(145deg, #15805a, #0f9f6e);
    border: 8px solid #7a4a28;
    position: relative;
    overflow: hidden;
}
.pool-visual::before { content: ""; position: absolute; inset: 10px; border: 1px solid rgba(255,255,255,.28); border-radius: 6px; }
.ball {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #111827;
    font-size: 12px;
    font-weight: 1000;
    position: absolute;
    box-shadow: inset -5px -5px 10px rgba(0,0,0,.18), 0 7px 12px rgba(0,0,0,.18);
}
.ball::before { content: ""; position: absolute; width: 15px; height: 15px; background: #fff; border-radius: 50%; z-index: 0; }
.ball-1 { background: #facc15; left: 25%; top: 24px; }
.ball-2 { background: #2563eb; color: #fff; left: 45%; top: 40px; }
.ball-8 { background: #111827; color: #fff; right: 24%; top: 30px; }
.cue-line { position: absolute; width: 112px; height: 4px; background: #ead2a7; left: 12px; bottom: 18px; transform: rotate(-14deg); transform-origin: left center; border-radius: 99px; }
.timer { font-size: 32px; font-weight: 1000; padding: 12px; background: var(--red-soft); color: var(--red); border-radius: 8px; text-align: center; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
.calc-box { display: flex; justify-content: space-between; align-items: center; padding: 14px; background: var(--amber-soft); border-radius: 8px; }
.calc-box strong { font-size: 24px; }

.pos-layout { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 18px; align-items: start; }
.category-strip { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 9px 14px; cursor: pointer; font-weight: 900; color: #334155; }
.chip.active, .chip:hover { background: var(--chip, var(--green)); color: #fff; border-color: transparent; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.product-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 8px; box-shadow: 0 10px 26px rgba(16,24,39,.05); transition: .18s ease; }
.product-card:hover { transform: translateY(-2px); }
.product-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 16%, white); color: var(--accent); font-weight: 1000; }
.product-card span, .product-card small { color: var(--muted); font-size: 12px; }
.product-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stock-low { color: var(--red) !important; font-weight: 900; animation: blinkSoft 1.8s ease-in-out infinite; }
.qty { width: 72px; }
.cart-panel { position: sticky; top: 18px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: var(--shadow); }
.cart-items { display: grid; gap: 10px; max-height: 50vh; overflow: auto; padding-right: 4px; }
.cart-item { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 12px; background: #f8fafc; border-radius: 8px; }
.cart-item small { color: var(--muted); display: block; margin-top: 3px; }
.cart-item > div:last-child { text-align: right; display: grid; gap: 6px; justify-items: end; }
.totals { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 8px; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { font-size: 22px; color: var(--green); }
.charge-form { display: grid; gap: 12px; margin-top: 16px; }

label { display: grid; gap: 6px; color: #334155; font-weight: 850; }
input, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    background: #fff;
    color: var(--ink);
    outline: none;
}
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(15,159,110,.12); }
.stack-form, .form-grid { display: grid; gap: 14px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid section { display: grid; gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.rate-row { display: grid; grid-template-columns: 1fr 130px 58px auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.inline-filter { display: flex; gap: 8px; align-items: center; }

.data-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: #475569; font-size: 13px; text-transform: uppercase; }
.row-alert { background: #fff7f7; }
.dot { width: 10px; height: 10px; background: var(--dot); border-radius: 50%; display: inline-block; margin-right: 8px; }
.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { border-radius: 8px; padding: 12px 14px; font-weight: 850; border: 1px solid var(--line); background: #fff; }
.flash.success { background: var(--green-soft); border-color: #a8efd2; color: #06704d; }
.flash.error { background: var(--red-soft); border-color: #fecaca; color: #b91c1c; }
.success-panel { background: var(--green-soft); }

.ticket-body { background: #fff; }
.ticket { width: 320px; margin: 20px auto; color: #111; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.ticket-head { text-align: center; border-bottom: 1px dashed #111; padding-bottom: 10px; }
.ticket-head img { width: 58px; }
.ticket-head h1 { font-size: 18px; margin: 5px 0; }
.ticket-meta { display: grid; gap: 3px; padding: 9px 0; font-size: 12px; border-bottom: 1px dashed #111; }
.ticket table th, .ticket table td { font-size: 12px; padding: 6px 0; white-space: normal; }
.ticket-total { padding: 8px 0; border-top: 1px dashed #111; display: grid; gap: 4px; }
.ticket-total div { display: flex; justify-content: space-between; }
.thanks { text-align: center; font-weight: 900; margin-top: 12px; }
.ticket-actions { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }

@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.22); } 50% { box-shadow: 0 0 0 9px rgba(239,68,68,0); } }
@keyframes floatCue { 0%,100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-8px) rotate(1deg); } }
@keyframes blinkSoft { 0%,100% { opacity: 1; } 50% { opacity: .58; } }

@media (max-width: 1050px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .sidebar nav { grid-template-columns: repeat(3, 1fr); }
    .pos-layout, .split, .hero-panel { grid-template-columns: 1fr; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cart-panel { position: static; }
}

@media (max-width: 650px) {
    .content { padding: 16px; }
    .sidebar { padding: 16px; }
    .sidebar nav { grid-template-columns: 1fr; }
    .page-head, .inline-filter { align-items: stretch; flex-direction: column; }
    .form-grid { grid-template-columns: 1fr; }
    .metric-grid { grid-template-columns: 1fr; }
    .rate-row { grid-template-columns: 1fr; }
    .hero-panel { padding: 18px; }
}

@media print {
    body { background: #fff; }
    .no-print { display: none !important; }
    .ticket { margin: 0; width: 72mm; }
}
