:root {
  --brand: #e85d04;
  --brand-ink: #fff;
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e7e5e0;
  --ok: #1f9d55;
  --warn: #c98a00;
  --bad: #d64545;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Sinhala", "Hiragino Sans", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: .55em 1em; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none !important; white-space: nowrap; transition: transform .05s, box-shadow .15s;
}
.btn:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-danger { color: var(--bad); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-sm { padding: .3em .7em; font-size: .85rem; border-radius: 8px; }
.btn-lg { padding: .8em 1.4em; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--bad); font: inherit; cursor: pointer; }

label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 .3em; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], input[type=tel], select, textarea {
  width: 100%; padding: .6em .75em; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
input[type=color] { width: 56px; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 2px; background: #fff; }
.check { display: flex; align-items: center; gap: .5em; font-weight: 500; }
.check input { width: 18px; height: 18px; }
.field { margin-bottom: 1em; }
.row { display: flex; gap: 1em; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }
.inline-form { display: flex; gap: .5em; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; }

/* ---------- Cards / tables ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2em; box-shadow: var(--shadow); margin-bottom: 1.2em; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1em; margin-bottom: .8em; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 1em; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1em 1.2em; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.5rem; font-weight: 750; margin-top: .2em; font-variant-numeric: tabular-nums; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: .6em .5em; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
table.list tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.badge { display: inline-block; padding: .15em .6em; border-radius: 99px; font-size: .78rem; font-weight: 700; background: #eee; color: #444; text-transform: capitalize; }
.badge-new { background: #fff1e6; color: #c2410c; }
.badge-preparing { background: #fff7d6; color: #8a6100; }
.badge-served, .badge-paid, .badge-active, .badge-approved { background: #e3f6ea; color: #17733f; }
.badge-cancelled, .badge-rejected, .badge-suspended, .badge-expired { background: #fde8e8; color: #b42318; }
.badge-trial, .badge-pending, .badge-open { background: #e8f0fe; color: #1a56db; }
.empty { text-align: center; color: var(--muted); padding: 2em 1em; }

.flash { padding: .8em 1em; border-radius: 10px; margin-bottom: 1em; font-weight: 600; }
.flash-success { background: #e3f6ea; color: #17733f; }
.flash-error { background: #fde8e8; color: #b42318; }

/* ---------- Admin layout ---------- */
.admin { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: #17181c; color: #cfd0d4; padding: 1.2em .8em; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .6em; padding: 0 .5em 1em; color: #fff; font-weight: 750; }
.brand img, .brand .logo-dot { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; background: var(--brand); flex: none; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a { display: flex; align-items: center; gap: .6em; padding: .6em .8em; color: #cfd0d4; border-radius: 10px; margin-bottom: 2px; font-weight: 550; }
.nav a:hover { background: #24262c; text-decoration: none; color: #fff; }
.nav a.active { background: var(--brand); color: var(--brand-ink); }
.nav .count { margin-left: auto; background: var(--bad); color: #fff; font-size: .75rem; padding: 0 .5em; border-radius: 99px; }
.nav-sep { height: 1px; background: #2b2d33; margin: .8em .5em; }
.sidebar form button { width: 100%; text-align: left; background: none; border: 0; color: #9a9ba1; padding: .6em .8em; font: inherit; cursor: pointer; }
.main { padding: 1.6em 2em; max-width: 1280px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1em; margin-bottom: 1.2em; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.trial-bar { background: #fff7d6; color: #6b4d00; padding: .6em 1em; border-radius: 10px; margin-bottom: 1em; font-size: .9rem; }

@media (max-width: 860px) {
  .admin { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 20; height: auto; padding: .5em; display: flex; align-items: center; gap: .5em; overflow-x: auto; }
  .brand { padding: 0 .3em; }
  .brand span { display: none; }
  .nav { display: flex; gap: .2em; }
  .nav a { white-space: nowrap; margin: 0; padding: .5em .7em; }
  .nav-sep { display: none; }
  .sidebar form button { white-space: nowrap; }
  .main { padding: 1em; }
}

/* ---------- Live order board ---------- */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1em; align-items: start; }
.col h2 { display: flex; align-items: center; gap: .5em; }
.col h2 .n { background: #e9e7e2; border-radius: 99px; padding: 0 .55em; font-size: .85rem; }
.order { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: 12px; padding: .9em; margin-bottom: .8em; box-shadow: var(--shadow); }
.order.st-new { border-left-color: #f97316; }
.order.st-preparing { border-left-color: #eab308; }
.order.st-served { border-left-color: var(--ok); opacity: .85; }
.order.flash-in { animation: pop 1.2s ease 2; }
@keyframes pop { 0%,100% { box-shadow: var(--shadow); } 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 45%, transparent); } }
.order-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5em; }
.order-head .tbl { font-size: 1.15rem; font-weight: 800; }
.order ul { margin: .5em 0; padding-left: 0; list-style: none; }
.order li { padding: .15em 0; }
.order li b { display: inline-block; min-width: 2em; }
.order .note { background: #fff7d6; padding: .3em .5em; border-radius: 6px; font-size: .9rem; margin-bottom: .5em; }
.order .actions { display: flex; gap: .4em; flex-wrap: wrap; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: #bbb; display: inline-block; }
.live-dot.on { background: var(--ok); box-shadow: 0 0 0 4px #1f9d5533; }
@media (max-width: 980px) { .board { grid-template-columns: 1fr; } }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: 1fr 340px; gap: 1em; align-items: start; }
.pos-cart { position: sticky; top: 1em; }
.pos-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6em; }
.pos-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .7em; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.pos-item:hover { border-color: var(--brand); }
.pos-item[disabled] { opacity: .45; cursor: not-allowed; }
.pos-item .p { color: var(--muted); font-size: .9rem; }
.chips { display: flex; gap: .4em; overflow-x: auto; padding-bottom: .4em; margin-bottom: .8em; scrollbar-width: none; }
.chip { border: 1px solid var(--line); background: var(--card); padding: .4em .9em; border-radius: 99px; white-space: nowrap; cursor: pointer; font: inherit; font-weight: 600; color: var(--ink); }
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.qty { display: inline-flex; align-items: center; gap: .3em; }
.qty button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 1.1rem; font-weight: 700; cursor: pointer; color: var(--ink); }
.qty span { min-width: 1.6em; text-align: center; font-weight: 700; }
.cart-line { display: flex; justify-content: space-between; align-items: center; gap: .5em; padding: .5em 0; border-bottom: 1px solid var(--line); }
@media (max-width: 900px) { .pos { grid-template-columns: 1fr; } .pos-cart { position: static; } }

/* ---------- Tables / QR ---------- */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1em; }
.qr-card { text-align: center; }
.qr-card img { width: 170px; height: 170px; border-radius: 8px; }

/* ---------- Bars ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 1em; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar .fill { width: 100%; background: var(--brand); border-radius: 6px 6px 0 0; min-height: 2px; }
.bar .lbl { font-size: .7rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.bar.current .fill { background: color-mix(in srgb, var(--brand) 100%, #000 15%); }

/* ---------- Public / auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5em; }
.auth .card { width: 100%; max-width: 440px; padding: 2em; }
.auth .logo { font-weight: 800; font-size: 1.3rem; margin-bottom: 1em; display: block; color: var(--ink); }
.site-nav { display: flex; justify-content: space-between; align-items: center; padding: 1em 1.5em; max-width: 1100px; margin: 0 auto; }
.site-nav .logo { font-weight: 800; font-size: 1.2rem; color: var(--ink); }
.hero { max-width: 1100px; margin: 0 auto; padding: 3em 1.5em 2em; display: grid; grid-template-columns: 1.1fr .9fr; gap: 2em; align-items: center; }
.hero h1 { font-size: clamp(2rem, 4.5vw, 3.1rem); letter-spacing: -.02em; }
.hero p.lead { font-size: 1.15rem; color: var(--muted); }
.phone-mock { background: #17181c; border-radius: 34px; padding: 12px; max-width: 300px; margin: 0 auto; box-shadow: 0 30px 60px rgba(0,0,0,.18); }
.phone-mock .screen { background: #fff; border-radius: 24px; overflow: hidden; }
.section { max-width: 1100px; margin: 0 auto; padding: 2em 1.5em; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1em; }
.feature .icon { font-size: 1.6rem; }
.price { font-size: 2rem; font-weight: 800; }
footer.site { text-align: center; color: var(--muted); padding: 2em; font-size: .9rem; }
@media (max-width: 800px) { .hero { grid-template-columns: 1fr; } }

/* ---------- Customer menu ---------- */
.cust { max-width: 640px; margin: 0 auto; padding-bottom: 110px; background: var(--bg); min-height: 100vh; }
.cust-head { background: var(--brand); color: var(--brand-ink); padding: 1.2em 1.1em 1.4em; border-radius: 0 0 22px 22px; }
.cust-head .top { display: flex; align-items: center; gap: .8em; }
.cust-head img { width: 54px; height: 54px; border-radius: 14px; object-fit: cover; background: #fff; }
.cust-head h1 { font-size: 1.35rem; margin: 0; }
.cust-head .tbl { display: inline-block; margin-top: .3em; background: rgba(255,255,255,.22); padding: .15em .7em; border-radius: 99px; font-weight: 700; font-size: .9rem; }
.tabs { display: flex; gap: .4em; margin: 1em 1em .6em; background: #ebe9e4; padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; border: 0; background: none; padding: .6em; border-radius: 9px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.cust .chips { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: .6em 1em; margin: 0; }
.search { margin: 0 1em .4em; }
.cat-title { margin: 1.2em 1em .5em; font-size: 1.1rem; }
.item { display: flex; gap: .8em; background: var(--card); margin: 0 1em .7em; padding: .8em; border-radius: var(--radius); border: 1px solid var(--line); }
.item .img { width: 88px; height: 88px; border-radius: 12px; object-fit: cover; flex: none; background: #f0eee9; display: grid; place-items: center; font-size: 2rem; }
.item .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item .name { font-weight: 700; }
.item .desc { color: var(--muted); font-size: .85rem; margin: .15em 0 .4em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; }
.item .price { font-size: 1rem; font-weight: 800; }
.item.na { opacity: .55; }
.add-btn { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 10px; padding: .45em 1em; font: inherit; font-weight: 700; cursor: pointer; }
.cart-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: .8em 1em calc(.8em + env(safe-area-inset-bottom)); z-index: 30; }
.cart-bar button { max-width: 608px; margin: 0 auto; display: flex; width: 100%; justify-content: space-between; align-items: center; background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 14px; padding: 1em 1.2em; font: inherit; font-weight: 750; font-size: 1.02rem; box-shadow: 0 8px 24px rgba(0,0,0,.2); cursor: pointer; }
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto; background: #fff; border-radius: 22px 22px 0 0; z-index: 41; max-height: 88vh; overflow-y: auto; padding: 1.2em 1.2em calc(1.2em + env(safe-area-inset-bottom)); }
.sheet h2 { display: flex; justify-content: space-between; align-items: center; }
.sheet .close { background: #f0eee9; border: 0; border-radius: 50%; width: 34px; height: 34px; font-size: 1.1rem; cursor: pointer; }
.bill-order { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9em; margin: 0 1em .8em; }
.bill-total { background: var(--card); border-radius: var(--radius); margin: 0 1em; padding: 1em; border: 1px solid var(--line); }
.bill-total .line { display: flex; justify-content: space-between; padding: .2em 0; }
.bill-total .grand { font-size: 1.25rem; font-weight: 800; border-top: 1px dashed var(--line); margin-top: .4em; padding-top: .5em; }
.toast { position: fixed; top: 1em; left: 50%; transform: translateX(-50%); background: #17181c; color: #fff; padding: .7em 1.2em; border-radius: 12px; z-index: 60; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90vw; }
.toast.error { background: var(--bad); }
.success-box { text-align: center; padding: 2em 1em; }
.success-box .tick { width: 72px; height: 72px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 2.4rem; display: grid; place-items: center; margin: 0 auto 1em; }
