@font-face {
    font-family: Vazirmatn;
    src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: Vazirmatn;
    src: url("../fonts/Vazirmatn-Medium.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: Vazirmatn;
    src: url("../fonts/Vazirmatn-Bold.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}

:root {
    --zinc: #E4EAE8;
    --paper: #F3F6F5;
    --ink: #14211E;
    --muted: #3E524C;
    --line: #B7C7C1;
    --tile: #0F6E62;
    --tile-press: #0A564C;
    --action: #0F6E62;
    --action-press: #0A564C;
    --on-action: #F4FBF8;
    --chart: #1A8A78;
    --rail: #0F6E62;
    --rail-text: #F4FBF8;
    --on-tile: #F4FBF8;
    --focus: #0F6E62;
    --success: #1F7A4D;
    --warning: #8A5A00;
    --danger: #9B2335;
    --info: #1D5C78;
    --sidebar: 272px;
    --radius: 8px;
    --brand: var(--tile);
    --brand-dark: var(--tile-press);
    --brand-soft: var(--paper);
    --bg: var(--zinc);
    color-scheme: light;
}

[data-theme="dark"] {
    --zinc: #101816;
    --paper: #182421;
    --ink: #E7F0EC;
    --muted: #9FB0AA;
    --line: #2C3C37;
    --tile: #8FD9CE;
    --tile-press: #B7EBE3;
    --action: #146E64;
    --action-press: #0F6E62;
    --on-action: #F4FBF8;
    --chart: #8FD9CE;
    --rail: #146E64;
    --rail-text: #F4FBF8;
    --on-tile: #10211E;
    --focus: #5ED0C2;
    --success: #8FD9B0;
    --warning: #E2C07A;
    --danger: #F0A8B2;
    --info: #9FD0E4;
    color-scheme: dark;
}

* { font-family: Vazirmatn, Tahoma, sans-serif; }
html {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    scroll-padding-top: 80px;
    font-feature-settings: "ss01";
}
input, textarea, select, button, table, canvas {
    font-feature-settings: "ss01";
}
@media (pointer: fine) {
    html { overscroll-behavior: none; }
}
body {
    background: var(--zinc);
    color: var(--ink);
    font-size: 16px;
    line-height: 24px;
}
h1, h2, h3 { text-wrap: balance; scroll-margin-top: 80px; }
a { color: var(--tile); text-decoration: none; }
a:hover { color: var(--tile-press); }
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible,
.side-link:focus-visible,
.dropdown-item:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    inset-inline-start: 16px;
    top: 8px;
    z-index: 50;
    transform: translateY(-160%);
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px 16px;
}
.skip-link:focus { transform: none; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: var(--sidebar);
    background: var(--rail);
    color: var(--rail-text);
    z-index: 40;
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom);
    overscroll-behavior: contain;
    transition: transform 200ms ease-out;
}
.brand-block {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    padding: 24px 16px 16px;
}
.brand-mark, .stamp {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: var(--rail-text);
    color: var(--rail);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 20px;
    line-height: 28px;
    flex: 0 0 auto;
}
.brand-name { font-weight: 700; font-size: 20px; line-height: 28px; }
.brand-copy { min-width: 0; }
.brand-copy small { color: rgba(244, 251, 248, .78); font-size: 12px; line-height: 16px; }
.side-nav { overflow: auto; padding: 8px; flex: 1; }
.side-group {
    color: rgba(244, 251, 248, .72);
    font-size: 12px;
    line-height: 16px;
    padding: 16px 8px 8px;
}
.side-link {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    min-width: 0;
    padding: 8px;
    border-radius: var(--radius);
    color: var(--rail-text);
    margin-bottom: 4px;
}
.side-link span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.side-ico {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
}
.side-link:hover { background: rgba(244, 251, 248, .1); color: #fff; }
.side-link:active { background: rgba(244, 251, 248, .16); }
.side-link.active {
    background: rgba(244, 251, 248, .14);
    color: #fff;
    box-shadow: inset -3px 0 0 var(--rail-text);
}
.side-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin: 8px;
    padding: 16px 8px;
    border-top: 1px solid rgba(244, 251, 248, .2);
}
.min-w-0 { min-width: 0; }
.side-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: var(--rail-text);
    color: var(--rail);
    font-weight: 700;
    font-size: 14px;
    flex: 0 0 auto;
}
.side-user { min-width: 0; }
.side-user-name, .side-user-role { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-name { font-weight: 600; font-size: 14px; line-height: 20px; }
.side-user-role { color: rgba(244, 251, 248, .72); font-size: 12px; line-height: 16px; }
.sidebar-scrim {
    display: none;
    border: 0;
    padding: 0;
    background: transparent;
}

.workspace { margin-inline-start: var(--sidebar); min-height: 100vh; min-width: 0; }
.topbar {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    min-height: 64px;
    padding: 8px 16px;
    padding-top: max(8px, env(safe-area-inset-top));
    position: sticky;
    top: 0;
    z-index: 20;
}
.cafe-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date-chip { color: var(--muted); font-size: 14px; line-height: 20px; display: inline-flex; align-items: center; gap: 8px; }
.icon-btn, .user-btn {
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    border-radius: var(--radius);
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
}
.user-btn { padding-inline: 8px 16px; }
.user-btn .side-avatar { background: var(--rail); color: var(--rail-text); }
.icon-btn:hover, .user-btn:hover { border-color: var(--tile); color: var(--tile); }
.icon-btn:active, .user-btn:active { transform: translateY(1px); }
.icon-btn[aria-pressed="true"] { background: var(--rail); color: var(--rail-text); border-color: var(--rail); }
.dropdown-menu {
    z-index: 10;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink);
    box-shadow: none;
    padding: 4px;
}
.dropdown-item { border-radius: var(--radius); color: var(--ink); min-height: 44px; display: flex; align-items: center; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--zinc); color: var(--ink); }
.content { padding: 24px 24px 48px; }
.page-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-head h1 { font-size: 30px; line-height: 36px; margin: 0; font-weight: 700; }
.crumb { font-size: 14px; line-height: 20px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--tile); }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.stat-box {
    background: var(--paper);
    border: 1px solid var(--line);
    border-top: 3px solid var(--rail);
    border-radius: var(--radius);
    padding: 16px;
    min-width: 0;
}
.stat-box h2 {
    margin: 0;
    font-size: 14px;
    line-height: 20px;
    font-weight: 600;
    color: var(--muted);
}
.stat-box p {
    margin: 8px 0 0;
    font-size: 24px;
    line-height: 32px;
    font-weight: 700;
}
.takings { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.takings-label { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; color: var(--muted); }
.takings-value { margin: 8px 0 0; font-size: 36px; line-height: 40px; font-weight: 700; }
.takings-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px 24px;
    margin: 24px 0 0;
}
.takings-strip div { min-width: 0; }
.takings-strip dt { font-size: 12px; line-height: 16px; color: var(--muted); font-weight: 400; }
.takings-strip dd { margin: 4px 0 0; font-size: 18px; line-height: 28px; font-weight: 600; }

.card, .sheet {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: none;
    color: var(--ink);
}
.card .card-body { padding: 16px; }
.card .h6, .card h2, .sheet h2 {
    font-size: 16px;
    line-height: 24px;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--ink);
}
.btn {
    border-radius: var(--radius);
    font-weight: 600;
    min-height: 44px;
    padding: 8px 16px;
    transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out, transform 150ms ease-out;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-brand {
    background: var(--action);
    border-color: var(--action);
    color: var(--on-action);
}
.btn-brand:hover, .btn-brand:focus { background: var(--action-press); border-color: var(--action-press); color: var(--on-action); }
.btn-outline-brand { color: var(--tile); border-color: var(--tile); background: transparent; }
.btn-outline-brand:hover { background: var(--tile); border-color: var(--tile); color: var(--on-tile); }
.btn-light, .btn-dark {
    background: var(--paper);
    border-color: var(--line);
    color: var(--ink);
}
.btn-light:hover, .btn-dark:hover { background: var(--zinc); color: var(--ink); border-color: var(--tile); }
.btn-sm { min-height: 44px; }
.form-control, .form-select {
    border-radius: var(--radius);
    border-color: var(--line);
    background: var(--paper);
    color: var(--ink);
    min-height: 44px;
    font-size: 16px;
    line-height: 24px;
}
.form-control:hover, .form-select:hover { border-color: var(--tile); }
.form-control:focus, .form-select:focus {
    border-color: var(--tile);
    background: var(--paper);
    color: var(--ink);
    box-shadow: none;
}
.form-control:disabled, .form-select:disabled { opacity: .45; cursor: not-allowed; }
.form-label { font-size: 14px; line-height: 20px; font-weight: 600; margin-bottom: 8px; }
.form-check { min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0; }
.form-check .form-check-input { float: none; margin: 0; width: 20px; height: 20px; }
.form-check .form-check-label { min-height: 44px; display: inline-flex; align-items: center; }
.filter-row, .filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.filter-row label, .filters label { display: grid; gap: 4px; font-size: 12px; line-height: 16px; color: var(--muted); font-weight: 600; }
.filter-row .form-control, .filters .form-control { width: 240px; }
.filter-row .form-select, .filters .form-select { width: 180px; }
.nav-tabs { border-bottom-color: var(--line); gap: 8px; }
.nav-tabs .nav-link {
    border: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    color: var(--muted);
    min-height: 44px;
}
.nav-tabs .nav-link:hover { color: var(--ink); }
.nav-tabs .nav-link.active { color: var(--ink); background: var(--paper); box-shadow: inset 0 -2px 0 var(--tile); }
.table { --bs-table-bg: transparent; --bs-table-color: var(--ink); color: var(--ink); }
.table thead th {
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    line-height: 16px;
    white-space: nowrap;
    background: var(--zinc);
    border-bottom-color: var(--line);
}
.table tbody td { vertical-align: middle; border-color: var(--line); }
.table tbody tr:hover { background: color-mix(in srgb, var(--zinc) 65%, transparent); }
.badge { border-radius: 8px; font-weight: 600; }
.badge-soft { background: color-mix(in srgb, var(--tile) 14%, var(--paper)); color: var(--ink); }
.alert { border: 1px solid var(--line); border-radius: var(--radius); border-inline-start-width: 4px; }
.alert-success { border-inline-start-color: var(--success); }
.alert-danger { border-inline-start-color: var(--danger); }
.alert-warning { border-inline-start-color: var(--warning); }
.pagination { gap: 8px; }
.page-link {
    border-radius: var(--radius) !important;
    color: var(--tile);
    background: var(--paper);
    border-color: var(--line);
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.page-link:hover { background: var(--zinc); color: var(--tile-press); }
.page-item.active .page-link { background: var(--rail); border-color: var(--rail); color: var(--rail-text); }
.page-item.disabled .page-link { opacity: .45; }
.empty-state { text-align: start; padding: 32px 0; color: var(--muted); }
.empty-state i { font-size: 24px; color: var(--tile); display: block; margin-bottom: 8px; }
.empty-state p { margin-bottom: 16px; }

.guest-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background: var(--zinc);
}
.slip, .guest-card {
    width: min(440px, 100%);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 32px 24px;
    color: var(--ink);
}
.stamp { margin-bottom: 16px; background: var(--rail); color: var(--rail-text); }
.slip-brand { margin: 0 0 8px; font-size: 14px; line-height: 20px; color: var(--muted); }
.slip h1, .guest-card h1, .guest-body h1 { font-size: 30px; line-height: 36px; font-weight: 700; margin: 0 0 24px; }
.theme-float {
    position: fixed;
    top: 16px;
    inset-inline-end: 16px;
    z-index: 20;
}

.menu-body { background: var(--zinc); }
.menu-head { padding: 48px 16px 24px; max-width: 760px; margin: 0 auto; }
.menu-head h1 { font-size: 36px; line-height: 40px; font-weight: 700; margin: 8px 0; }
.menu-head p { color: var(--muted); margin: 0; max-width: 62ch; }
.menu-logo { width: 64px; height: 64px; object-fit: contain; border-radius: var(--radius); background: var(--paper); }
.menu-sheet { max-width: 760px; margin: 0 auto; padding: 0 16px 64px; }
.menu-cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.menu-cats a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink);
}
.menu-cats a:hover { border-color: var(--tile); color: var(--tile); }
.menu-sheet h2 { font-size: 20px; line-height: 28px; margin: 32px 0 8px; }
.menu-list { list-style: none; margin: 0; padding: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.menu-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
    min-width: 0;
}
.menu-list li:last-child { border-bottom: 0; }
.menu-list li > div { min-width: 0; flex: 1; }
.menu-list p { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 20px; }
.menu-price { font-weight: 700; white-space: nowrap; }
.menu-photo {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: var(--radius);
    flex: none;
    background: var(--zinc);
}
.menu-out { color: var(--muted); }
.menu-out .menu-price { font-weight: 600; font-size: 14px; }

.product-card { height: 100%; transition: border-color 150ms ease-out, background-color 150ms ease-out; }
.product-card:hover { border-color: var(--tile); }
.pos-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; }
.cart-pane { position: sticky; top: 80px; }
.table-tile { border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper); padding: 16px; min-height: 112px; }
.table-tile.free { box-shadow: inset 0 4px 0 var(--success); }
.table-tile.reserved { box-shadow: inset 0 4px 0 var(--warning); }
.table-tile.occupied { box-shadow: inset 0 4px 0 var(--action); }
.table-tile.awaiting_payment { box-shadow: inset 0 4px 0 var(--danger); }
.kds-card { border-inline-start: 4px solid var(--tile); }
.impersonate {
    background: color-mix(in srgb, var(--action) 16%, var(--paper));
    color: var(--ink);
    border-bottom: 1px solid var(--action);
    padding: 8px 16px;
}
.toast-stack { position: fixed; top: 16px; inset-inline-start: 16px; z-index: 50; }
.num, .table td, .takings-value, .takings-strip dd, .menu-price, .stat-box p {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "ss01", "tnum";
}

[data-theme="dark"] .text-muted { color: var(--muted) !important; }
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .page-link { background-color: var(--paper); color: var(--ink); }
[data-theme="dark"] .table { color: var(--ink); }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(110%); pointer-events: none; }
    .sidebar.show { transform: none; pointer-events: auto; }
    .sidebar-scrim.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(16, 24, 22, .48);
        z-index: 30;
    }
    .workspace { margin-inline-start: 0; }
    .pos-grid { grid-template-columns: 1fr; }
    .cart-pane { position: static; }
    .content { padding: 16px 16px 32px; }
    .stat-grid, .takings-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .page-head h1, .slip h1 { font-size: 24px; line-height: 32px; }
    .takings-value, .menu-head h1 { font-size: 30px; line-height: 36px; }
    .filter-row .form-control, .filter-row .form-select { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
@media print {
    .sidebar, .topbar, .no-print, .sidebar-scrim, .skip-link, .theme-float { display: none !important; }
    .workspace { margin: 0; }
    .content { padding: 0; }
    body { background: #fff; color: #14211E; }
}
