:root {
    --brand: #e23744;
    --brand-dark: #c01f2c;
    --brand-tint: #fdecef;
    --ink: #1c1c1e;
    --muted: #6b6b70;
    --line: #e6e6ea;
    --bg: #f6f6f8;
    --card: #ffffff;
    --ok: #1a8a4f;
    --ok-tint: #e6f4ec;
    --warn: #b8860b;
    --warn-tint: #fbf3df;
    --info: #2563c9;
    --info-tint: #e7eefb;
    --danger: #c01f2c;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 6px 18px rgba(0, 0, 0, .05);
    --maxw: 1080px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 16px;
}

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

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.page { padding: 24px 0 64px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------- top bar ---------- */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar .inner {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 60px;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 16px;
}
.brand {
    font-weight: 800;
    font-size: 1.3rem;
    color: var(--brand);
    letter-spacing: -.5px;
}
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.nav a {
    color: var(--ink);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--brand-tint); color: var(--brand-dark); }

/* ---------- cards ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.card-head h2, .card-head h3 { margin: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat .n { font-size: 2rem; font-weight: 800; }
.stat .l { color: var(--muted); font-size: .9rem; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    font-weight: 600;
    font-size: .95rem;
    cursor: pointer;
    transition: filter .12s ease, background .12s ease;
    text-decoration: none;
    line-height: 1.2;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); filter: none; }
.btn-ghost { background: transparent; }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- forms ---------- */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .92rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=tel], input[type=url], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-tint);
}
textarea { min-height: 90px; resize: vertical; }
.help { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.checkbox { display: flex; align-items: center; gap: 10px; }
.checkbox input { width: auto; }
.field-error { color: var(--danger); font-size: .85rem; margin-top: 4px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; margin: 0 0 16px; }
legend { font-weight: 700; padding: 0 8px; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge-new { background: var(--brand-tint); color: var(--brand-dark); }
.badge-received { background: var(--info-tint); color: var(--info); }
.badge-in_progress { background: var(--warn-tint); color: var(--warn); }
.badge-done { background: var(--ok-tint); color: var(--ok); }
.badge-delivered { background: var(--ok-tint); color: var(--ok); }
.badge-cancelled { background: #f0f0f2; color: var(--muted); }
.badge-paid { background: var(--ok-tint); color: var(--ok); }
.badge-pending { background: var(--warn-tint); color: var(--warn); }
.badge-failed { background: #fde8e8; color: var(--danger); }

/* ---------- flash / alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--ok-tint); color: var(--ok); border-color: #bfe2cd; }
.alert-error { background: #fde8e8; color: var(--danger); border-color: #f4c4c4; }
.alert-info { background: var(--info-tint); color: var(--info); border-color: #c5d8f5; }
.alert-warning { background: var(--warn-tint); color: var(--warn); border-color: #ecdcaf; }

/* ---------- auth ---------- */
.auth-wrap { max-width: 420px; margin: 48px auto; }
.auth-wrap .brand { display: block; text-align: center; font-size: 2rem; margin-bottom: 8px; }

/* ---------- restaurant listing ---------- */
.resto-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.resto-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .12s ease; }
.resto-card:hover { transform: translateY(-2px); text-decoration: none; }
.resto-cover { height: 130px; background: var(--brand-tint); background-size: cover; background-position: center; }
.resto-body { padding: 14px 16px; }
.resto-body h3 { margin: 0 0 4px; }

/* ---------- menu ---------- */
.menu-item { display: flex; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.menu-item:last-child { border-bottom: none; }
.menu-item .thumb { width: 84px; height: 84px; border-radius: var(--radius-sm); object-fit: cover; background: var(--bg); flex: 0 0 auto; }
.menu-item .info { flex: 1; }
.menu-item .price { font-weight: 700; white-space: nowrap; }

/* ---------- cart ---------- */
.cart-line { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.totals { margin-top: 12px; }
.totals .row { justify-content: space-between; padding: 4px 0; }
.totals .grand { font-weight: 800; font-size: 1.15rem; border-top: 2px solid var(--line); padding-top: 10px; margin-top: 6px; }

.logo-img { height: 40px; width: 40px; border-radius: 8px; object-fit: cover; }

/* ---------- order ticket (restaurant) ---------- */
.ticket { border-left: 4px solid var(--line); }
.ticket.is-new { border-left-color: var(--brand); }
.ticket.is-received { border-left-color: var(--info); }
.ticket.is-in_progress { border-left-color: var(--warn); }
.ticket.is-done { border-left-color: var(--ok); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
    .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    body { font-size: 15px; }
    .topbar .inner { height: 54px; gap: 8px; }
    .nav a { padding: 8px 9px; }
    .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
    .hide-mobile { display: none !important; }
    .card { padding: 16px; }
    h1 { font-size: 1.35rem; }
}
