/* ==========================================================================
   RestoFlow UI
   --------------------------------------------------------------------------
   Design notes (deliberate, not defaults):
   - No web fonts. A restaurant tablet on shaky wifi should never wait on a
     font download before a waiter can punch an order. System stack only.
   - Money is set in tabular figures everywhere. A POS lives on columns of
     numbers lining up; that is the signature of this interface.
   - The veg / non-veg square marker is the real vernacular of an Indian menu
     card, so it is the item identity marker here too — not a colour chip.
   - Touch targets are 44px minimum. Thumbs, not mice.
   ========================================================================== */

:root {
    --ink:        #10141C;
    --ink-2:      #38414F;
    --ink-3:      #6B7686;
    --line:       #DDE2E9;
    --line-soft:  #EDF0F4;
    --canvas:     #F2F4F7;
    --surface:    #FFFFFF;

    --brand:      #14574A;   /* deep tea-leaf green */
    --brand-ink:  #0C3A31;
    --brand-soft: #E4F0EC;

    --accent:     #C97B12;   /* turmeric */
    --accent-soft:#FDF2DF;

    --danger:     #B3261E;
    --danger-soft:#FCEAE8;
    --warn:       #8A6100;
    --warn-soft:  #FFF6E0;
    --ok:         #1C6B3C;
    --ok-soft:    #E3F3E9;

    --veg:        #1C7A3E;
    --nonveg:     #A32B21;
    --egg:        #B8860B;

    --r-sm: 6px;
    --r:    10px;
    --r-lg: 16px;

    --shadow:    0 1px 2px rgba(16,20,28,.06), 0 4px 14px rgba(16,20,28,.06);
    --shadow-lg: 0 8px 30px rgba(16,20,28,.14);

    --sidebar-w: 232px;
    --topbar-h:  56px;

    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
            "Noto Sans", "Noto Sans Bengali", "Noto Sans Devanagari", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 .75rem; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

/* Numbers. The whole point. */
.num, .money, td.num, th.num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    text-align: right;
    white-space: nowrap;
}

/* ---------- layout ---------- */

.shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--ink);
    color: #C9D1DC;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform .18s ease;
    z-index: 60;
    overflow-y: auto;
}
.sidebar.open { transform: none; }

.sidebar__brand {
    display: flex; align-items: center; gap: .55rem;
    padding: 1rem 1.1rem;
    color: #fff; font-weight: 700; letter-spacing: -.02em; font-size: 1.05rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar__mark {
    width: 26px; height: 26px; border-radius: 7px;
    background: var(--accent);
    display: grid; place-items: center;
    color: var(--ink); font-weight: 800; font-size: .8rem;
}
.sidebar__tenant {
    padding: .6rem 1.1rem .9rem;
    font-size: .78rem; color: #8592A3;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar nav { padding: .5rem; flex: 1; }
.sidebar nav a {
    display: flex; align-items: center; gap: .6rem;
    padding: .7rem .75rem;
    min-height: 44px;
    color: #C9D1DC; border-radius: var(--r-sm);
    font-size: .93rem; text-decoration: none;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.is-active { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar nav a .ico { width: 18px; text-align: center; opacity: .9; }

.sidebar__foot {
    padding: .85rem 1.1rem;
    font-size: .72rem; color: #6C7889;
    border-top: 1px solid rgba(255,255,255,.08);
}

.topbar {
    position: sticky; top: 0; z-index: 40;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: .6rem;
    padding: 0 .9rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.topbar__title { font-weight: 650; font-size: 1rem; flex: 1; }

.iconbtn {
    display: inline-grid; place-items: center;
    width: 40px; height: 40px;
    border: 1px solid var(--line); background: var(--surface);
    border-radius: var(--r-sm); cursor: pointer;
    font-size: 1.05rem; color: var(--ink-2);
}
.iconbtn:hover { background: var(--line-soft); }

.main { padding: 1rem .9rem 3rem; }

.scrim {
    position: fixed; inset: 0; background: rgba(16,20,28,.45);
    z-index: 50; display: none;
}
.scrim.show { display: block; }

@media (min-width: 900px) {
    .sidebar { transform: none; }
    .topbar, .main { margin-left: var(--sidebar-w); }
    .main { padding: 1.4rem 1.6rem 4rem; }
    .menu-toggle { display: none; }
    .scrim { display: none !important; }
}

/* ---------- cards, grids ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow);
}
.card__head {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--line-soft);
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
}
.card__head h2, .card__head h3 { margin: 0; }
.card__body { padding: 1rem; }
.card__body--flush { padding: 0; }

.grid { display: grid; gap: 1rem; }
.grid--2 { grid-template-columns: 1fr; }
.grid--3 { grid-template-columns: 1fr; }
.grid--metrics { grid-template-columns: repeat(2, minmax(0,1fr)); gap: .7rem; }

@media (min-width: 700px) {
    .grid--metrics { grid-template-columns: repeat(4, minmax(0,1fr)); }
    .grid--2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (min-width: 1100px) {
    .grid--3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

/* ---------- metric tile ---------- */

.metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: .85rem .9rem;
}
.metric__label {
    font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--ink-3); font-weight: 600;
}
.metric__value {
    font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em;
    font-variant-numeric: tabular-nums; margin-top: .2rem;
}
.metric__delta { font-size: .78rem; font-weight: 600; margin-top: .1rem; }
.metric__delta.up   { color: var(--ok); }
.metric__delta.down { color: var(--danger); }
.metric--accent { border-left: 4px solid var(--accent); }
.metric--brand  { border-left: 4px solid var(--brand); }

/* ---------- buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 44px; padding: .55rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit; font-weight: 600; font-size: .92rem;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--line-soft); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-ink); }
.btn--accent  { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--danger  { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--ghost   { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--sm      { min-height: 34px; padding: .3rem .6rem; font-size: .82rem; }
.btn--block   { width: 100%; }
.btn--lg      { min-height: 54px; font-size: 1.02rem; }

.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- forms ---------- */

.field { margin-bottom: .9rem; }
.field > label {
    display: block; font-size: .82rem; font-weight: 600;
    color: var(--ink-2); margin-bottom: .3rem;
}
.field .hint { font-size: .78rem; color: var(--ink-3); margin-top: .25rem; }

.input, select.input, textarea.input {
    width: 100%;
    min-height: 44px;
    padding: .55rem .7rem;
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
}
.input:focus { border-color: var(--brand); outline: 2px solid var(--brand-soft); outline-offset: 0; }
textarea.input { min-height: 84px; resize: vertical; }
.input--num { font-variant-numeric: tabular-nums; text-align: right; }

.check { display: flex; align-items: center; gap: .55rem; font-size: .92rem; }
.check input { width: 20px; height: 20px; }

.form-row { display: grid; gap: .9rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-row--2 { grid-template-columns: 1fr 1fr; } }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
table.data {
    width: 100%; border-collapse: collapse; font-size: .9rem;
}
table.data th, table.data td {
    padding: .65rem .75rem;
    border-bottom: 1px solid var(--line-soft);
    text-align: left;
    vertical-align: middle;
}
table.data th {
    font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--ink-3); font-weight: 700; white-space: nowrap;
    background: var(--line-soft);
}
table.data tbody tr:hover { background: #FAFBFC; }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--line); }

/* ---------- badges / markers ---------- */

.badge {
    display: inline-block; padding: .18rem .5rem;
    font-size: .74rem; font-weight: 700; letter-spacing: .02em;
    border-radius: 999px; white-space: nowrap;
    background: var(--line-soft); color: var(--ink-2);
}
.badge--ok     { background: var(--ok-soft); color: var(--ok); }
.badge--warn   { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--brand  { background: var(--brand-soft); color: var(--brand-ink); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }

/* The FSSAI-style square marker every Indian menu card uses. */
.foodmark {
    display: inline-block; width: 13px; height: 13px;
    border: 1.5px solid var(--veg); border-radius: 2px;
    position: relative; flex: 0 0 auto;
}
.foodmark::after {
    content: ""; position: absolute; inset: 2px;
    border-radius: 50%; background: var(--veg);
}
.foodmark--nonveg { border-color: var(--nonveg); }
.foodmark--nonveg::after { background: var(--nonveg); }
.foodmark--egg { border-color: var(--egg); }
.foodmark--egg::after { background: var(--egg); }

/* ---------- flash ---------- */

.flash-stack { display: grid; gap: .5rem; margin-bottom: 1rem; }
.flash {
    padding: .7rem .9rem; border-radius: var(--r-sm);
    font-size: .9rem; font-weight: 550;
    border-left: 4px solid;
}
.flash--success { background: var(--ok-soft);     border-color: var(--ok);     color: #14522E; }
.flash--error   { background: var(--danger-soft); border-color: var(--danger); color: #8A1C16; }
.flash--info    { background: var(--brand-soft);  border-color: var(--brand);  color: var(--brand-ink); }

/* ---------- empty state ---------- */

.empty {
    padding: 2.4rem 1rem; text-align: center; color: var(--ink-3);
}
.empty h3 { color: var(--ink-2); }

/* ---------- auth pages ---------- */

.auth {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: 1.2rem;
    background:
        radial-gradient(900px 380px at 12% -8%, #1B6B5B 0%, transparent 62%),
        linear-gradient(160deg, #10141C 0%, #17202B 100%);
}
.auth__box {
    width: 100%; max-width: 420px;
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem 1.3rem;
}
.auth__box--wide { max-width: 620px; }
.auth__brand {
    display: flex; align-items: center; gap: .6rem;
    font-size: 1.25rem; font-weight: 750; letter-spacing: -.02em;
    margin-bottom: .15rem;
}
.auth__sub { color: var(--ink-3); font-size: .88rem; margin-bottom: 1.1rem; }
.auth__alt { margin-top: 1rem; font-size: .88rem; color: var(--ink-3); text-align: center; }
.auth__langs { margin-top: 1.1rem; text-align: center; font-size: .82rem; }
.auth__langs a { margin: 0 .35rem; color: #9AA6B4; }

/* ---------- POS ---------- */

.pos {
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100vh;
    background: var(--canvas);
}
.pos__bar {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem .8rem;
    background: var(--ink); color: #fff;
}
.pos__bar a { color: #fff; }
.pos__bar .grow { flex: 1; }

.pos__body {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 0;
}
@media (min-width: 980px) {
    .pos__body { grid-template-columns: 1fr 390px; }
}

.pos__menu { overflow-y: auto; padding: .8rem; min-height: 0; }
.pos__cart {
    background: var(--surface);
    border-top: 1px solid var(--line);
    display: flex; flex-direction: column;
    min-height: 0;
}
@media (min-width: 980px) {
    .pos__cart { border-top: 0; border-left: 1px solid var(--line); }
}

.cat-strip {
    display: flex; gap: .4rem; overflow-x: auto;
    padding-bottom: .6rem; margin-bottom: .6rem;
    scrollbar-width: thin;
}
.cat-chip {
    flex: 0 0 auto; min-height: 40px;
    padding: .45rem .85rem;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); font-size: .88rem; font-weight: 600;
    cursor: pointer; white-space: nowrap;
}
.cat-chip.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

.dish-grid {
    display: grid; gap: .55rem;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
}
.dish {
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: .6rem .65rem;
    min-height: 84px;
    display: flex; flex-direction: column; justify-content: space-between;
    cursor: pointer; font: inherit;
}
.dish:hover { border-color: var(--brand); }
.dish:active { transform: scale(.98); }
.dish__name { font-weight: 600; font-size: .9rem; line-height: 1.25; }
.dish__top { display: flex; gap: .4rem; align-items: flex-start; }
.dish__price { font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .4rem; }
.dish__variants { font-size: .74rem; color: var(--ink-3); }

.cart__lines { flex: 1; overflow-y: auto; padding: .6rem .8rem; min-height: 120px; }
.cart__line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .3rem .6rem;
    padding: .5rem 0;
    border-bottom: 1px solid var(--line-soft);
}
.cart__name { font-weight: 600; font-size: .9rem; }
.cart__meta { font-size: .76rem; color: var(--ink-3); }
.qty { display: flex; align-items: center; gap: .3rem; }
.qty button {
    width: 32px; height: 32px; border-radius: var(--r-sm);
    border: 1px solid var(--line); background: var(--surface);
    font-size: 1.05rem; line-height: 1; cursor: pointer;
}
.qty span { min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 650; }

.cart__totals { padding: .7rem .8rem; border-top: 1px solid var(--line); background: #FAFBFC; }
.cart__row { display: flex; justify-content: space-between; font-size: .88rem; padding: .15rem 0; }
.cart__row span:last-child { font-variant-numeric: tabular-nums; }
.cart__row--grand {
    font-size: 1.15rem; font-weight: 750;
    border-top: 1px dashed var(--line); margin-top: .4rem; padding-top: .5rem;
}
.cart__actions { padding: .7rem .8rem 1rem; display: grid; gap: .5rem; }

.seg { display: flex; gap: .3rem; }
.seg button {
    flex: 1; min-height: 40px;
    border: 1px solid var(--line); background: var(--surface);
    border-radius: var(--r-sm); font: inherit; font-weight: 600; font-size: .85rem;
    cursor: pointer;
}
.seg button.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- tables floor ---------- */

.floor-area { margin-bottom: 1.4rem; }
.floor-grid {
    display: grid; gap: .6rem;
    grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
}
.tablecard {
    border: 1px solid var(--line);
    border-left: 5px solid var(--ink-3);
    border-radius: var(--r);
    background: var(--surface);
    padding: .7rem;
    display: block; color: inherit; text-decoration: none;
}
.tablecard:hover { text-decoration: none; box-shadow: var(--shadow); }
.tablecard__name { font-weight: 750; font-size: 1.05rem; }
.tablecard__meta { font-size: .76rem; color: var(--ink-3); }
.tablecard--free     { border-left-color: var(--ok); }
.tablecard--occupied { border-left-color: var(--danger); }
.tablecard--reserved { border-left-color: var(--accent); }
.tablecard--cleaning { border-left-color: var(--ink-3); }

/* ---------- KDS ---------- */

.kds { background: #0C1016; min-height: 100vh; color: #E7ECF3; padding: .8rem; }
.kds__bar {
    display: flex; align-items: center; gap: .6rem;
    margin-bottom: .8rem; color: #fff;
}
.kds__bar .grow { flex: 1; }
.kds__bar a { color: #9FB0C4; }
.kds-grid {
    display: grid; gap: .7rem;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.ticket {
    background: #161C25; border: 1px solid #262F3C;
    border-top: 4px solid var(--accent);
    border-radius: var(--r);
    display: flex; flex-direction: column;
}
.ticket--late { border-top-color: var(--danger); }
.ticket__head {
    padding: .6rem .7rem; border-bottom: 1px solid #262F3C;
    display: flex; justify-content: space-between; align-items: baseline; gap: .5rem;
}
.ticket__no { font-weight: 750; font-variant-numeric: tabular-nums; }
.ticket__age { font-size: .78rem; color: #9FB0C4; }
.ticket__items { padding: .5rem .7rem; flex: 1; }
.ticket__item {
    display: flex; gap: .5rem; align-items: baseline;
    padding: .35rem 0; border-bottom: 1px solid #1E2733;
}
.ticket__item:last-child { border-bottom: 0; }
.ticket__qty {
    font-weight: 750; font-variant-numeric: tabular-nums;
    min-width: 30px; color: var(--accent);
}
.ticket__note { font-size: .78rem; color: #E0A93F; display: block; }
.ticket__item.done .ticket__name { text-decoration: line-through; opacity: .5; }
.ticket__foot { padding: .5rem .7rem .7rem; display: flex; gap: .4rem; }
.ticket__foot .btn { flex: 1; min-height: 40px; }

/* ---------- print (80mm thermal) ---------- */

.print-sheet {
    width: 78mm; margin: 0 auto; padding: 4mm 3mm;
    font-family: var(--mono); font-size: 11.5px; color: #000; background: #fff;
}
.print-sheet h1 { font-size: 15px; text-align: center; margin: 0 0 2px; font-family: var(--font); }
.print-sheet .center { text-align: center; }
.print-sheet .rule { border-top: 1px dashed #000; margin: 5px 0; }
.print-sheet table { width: 100%; border-collapse: collapse; }
.print-sheet td, .print-sheet th { padding: 1px 0; vertical-align: top; }
.print-sheet .r { text-align: right; font-variant-numeric: tabular-nums; }
.print-sheet .big { font-size: 14px; font-weight: 700; }
.print-actions { text-align: center; padding: 12px; display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; align-items: center; }
.paper-pick { display: inline-flex; gap: .25rem; }
.print-sheet th.r, .print-sheet td.r { padding-left: 5px; white-space: nowrap; }
/* 58 mm: drop the Rate column of the item table (3rd of 4) to keep names readable */
.paper-58 .print-sheet thead + tbody tr > :nth-child(3),
.paper-58 .print-sheet thead tr > :nth-child(3) { display: none; }

/* 58 mm thermal roll: ~48 mm printable. Narrower type, tighter rows. */
.paper-58 .print-sheet { width: 54mm; padding: 3mm 2mm; font-size: 10px; }
.paper-58 .print-sheet h1 { font-size: 13px; }
.paper-58 .print-sheet .big { font-size: 12px; }
.paper-58 .print-sheet canvas { width: 120px !important; height: 120px !important; }

@media print {
    .print-actions, .no-print { display: none !important; }
    body { background: #fff; }
    .print-sheet { width: auto; }
    .paper-58 .print-sheet { width: 54mm; margin: 0; }
    .paper-80 .print-sheet { width: 76mm; margin: 0; }
}

/* ---------- misc ---------- */

.muted { color: var(--ink-3); }
.small { font-size: .82rem; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.stack { display: grid; gap: .75rem; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin-bottom: 0; }
.token-box {
    font-family: var(--mono); font-size: .82rem; word-break: break-all;
    background: var(--ink); color: #7BE0B4; padding: .7rem; border-radius: var(--r-sm);
}

.chart-box { position: relative; height: 260px; }
.js-only { display: none; }
.has-js .js-only { display: block; }
.has-js .no-js-only { display: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}


/* ---------- subscription / view-as banners ---------- */
.viewas-bar, .sub-warn {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
    padding: .6rem .9rem; border-radius: var(--r-sm); margin-bottom: 1rem; font-size: .9rem;
}
.viewas-bar { background: #3a2a05; color: #ffd37a; border: 1px solid #7a5a12; }
.sub-warn { background: var(--warn-soft); color: var(--warn); }
.viewas-bar form { margin: 0; }
