:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #dfe4ea;
  --text: #1b2733;
  --muted: #6b7a8c;
  --brand: #14664a;
  --brand-soft: #e6f2ec;
  --accent: #b8541f;
  --danger: #b3261e;
  --warn: #8a6100;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 4px 14px rgba(16, 32, 48, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; }

/* ---------- Толгой хэсэг ---------- */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1rem;
  background: var(--brand); color: #fff;
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 700; letter-spacing: .01em; margin-right: .5rem; }
.topbar nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.topbar nav a {
  color: #d9ebe3; text-decoration: none; padding: .4rem .7rem;
  border-radius: var(--radius); font-weight: 600; font-size: .92rem;
}
.topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.topbar nav a[aria-current="page"] { background: rgba(255,255,255,.2); color: #fff; }
.topbar .who { font-size: .85rem; opacity: .9; }

/* Нарийн дэлгэц дээр цэсийг тусдаа мөрөнд, хэвтээ гүйдэг байдлаар харуулна. */
@media (max-width: 640px) {
  .topbar { gap: .5rem; padding: .6rem .75rem; }
  .topbar .brand { flex: 1 1 auto; margin-right: 0; }
  .topbar nav {
    order: 3; flex: 0 0 100%; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .topbar nav a { white-space: nowrap; }
  .topbar .who { font-size: .8rem; }
}

main { max-width: 1180px; margin: 0 auto; padding: 1rem; }

/* ---------- Ерөнхий бүрэлдэхүүн ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem;
}
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 880px) { .grid-2 { grid-template-columns: 1fr; } }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .55rem .9rem; border-radius: var(--radius); min-height: 40px;
}
button:hover:not(:disabled) { border-color: #c2cbd6; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #10553d; border-color: #10553d; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: #9c4718; border-color: #9c4718; }
.btn-danger { color: var(--danger); border-color: #e7c4c1; background: #fdf3f2; }
.btn-sm { padding: .3rem .55rem; min-height: 32px; font-size: .85rem; }
.btn-block { width: 100%; }

input, select {
  font: inherit; padding: .5rem .6rem; min-height: 40px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}
label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .25rem; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .5rem .55rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.empty { color: var(--muted); padding: 1.25rem; text-align: center; }
.row { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.row > .shrink { flex: 0 0 auto; }
.stack { display: flex; flex-direction: column; gap: 1rem; }

.badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; white-space: nowrap;
}
.badge-paid { background: var(--brand-soft); color: var(--brand); }
.badge-pending { background: #fdf4e0; color: var(--warn); }
.badge-void { background: #f1f3f5; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  background: #1b2733; color: #fff; padding: .6rem 1rem; border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 50; max-width: 90vw;
}
.toast.error { background: var(--danger); }

/* ---------- Кассын дэлгэц ---------- */
.menu-group + .menu-group { margin-top: 1rem; }
.menu-group h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: .6rem; }
.menu-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: .3rem;
  padding: .7rem; text-align: left; min-height: 72px;
}
.menu-btn .name { font-weight: 600; }
.menu-btn .price { color: var(--brand); font-weight: 700; font-variant-numeric: tabular-nums; }

.cart { position: sticky; top: 4.2rem; }
.cart-list { list-style: none; margin: 0 0 .75rem; padding: 0; max-height: 46vh; overflow-y: auto; }
.cart-list li {
  display: grid; grid-template-columns: 1fr auto; gap: .2rem .5rem;
  padding: .5rem 0; border-bottom: 1px solid var(--border);
}
.cart-list .line-name { font-weight: 600; }
.cart-list .line-total { font-variant-numeric: tabular-nums; font-weight: 600; }
.qty { display: flex; align-items: center; gap: .3rem; }
.qty button { min-height: 30px; padding: .1rem .5rem; line-height: 1; }
.qty .count { min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.total-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: .6rem 0; border-top: 2px solid var(--text); margin-bottom: .6rem;
}
.total-row .amount { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Төлбөрийн цонх ---------- */
dialog {
  border: none; border-radius: var(--radius); padding: 0;
  box-shadow: 0 10px 40px rgba(16,32,48,.25); max-width: 420px; width: 92vw;
}
dialog::backdrop { background: rgba(16,32,48,.45); }
.dialog-body { padding: 1.25rem; }
.pay-total { font-size: 2rem; font-weight: 700; text-align: center; margin: .25rem 0 1rem; font-variant-numeric: tabular-nums; }
.pay-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.pay-buttons button { min-height: 60px; font-size: 1rem; }

/* ---------- Тайлангийн хайрцгууд ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; }
.stat .label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .15rem; }
.stat.highlight { background: var(--brand-soft); border-color: #bcd9cc; }
.stat.highlight .value { color: var(--brand); }

/* ---------- Нэвтрэх хуудас: хоёр талт бүтэц ---------- */
.login-split { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }

/* Зүүн тал: брэнд */
.login-brand {
  background: linear-gradient(150deg, #14664a 0%, #0d4b36 55%, #0a3b2a 100%);
  color: #fff;
  padding: 3rem clamp(1.5rem, 5vw, 4rem);
  display: flex; flex-direction: column; justify-content: center; gap: 2rem;
  position: relative; overflow: hidden;
}
/* Далд чимэглэл */
.login-brand::after {
  content: ''; position: absolute; right: -18%; bottom: -25%;
  width: 26rem; height: 26rem; border-radius: 50%;
  background: rgba(255, 255, 255, .05);
}
.login-brand > * { position: relative; z-index: 1; }

.brand-mark { display: flex; align-items: center; gap: .85rem; }
.brand-mark svg { width: 2.75rem; height: 2.75rem; flex: none; }
.brand-mark .wordmark { display: flex; flex-direction: column; line-height: 1.15; }
.brand-mark .wordmark b { font-size: 1.6rem; font-weight: 800; letter-spacing: -.01em; }
.brand-mark .wordmark span { font-size: .9rem; color: #a9d2c0; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }

.login-brand h1 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); font-weight: 700; max-width: 22ch; }
.login-brand .lede { color: #c9e3d8; max-width: 38ch; margin: -1rem 0 0; }

.brand-points { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.brand-points li { display: flex; align-items: flex-start; gap: .6rem; color: #dcece5; font-size: .95rem; }
.brand-points li::before {
  content: '✓'; flex: none; width: 1.35rem; height: 1.35rem; border-radius: 50%;
  background: rgba(255, 255, 255, .14); color: #fff;
  display: grid; place-items: center; font-size: .75rem; font-weight: 700; margin-top: .1rem;
}

.login-brand footer { color: #8fbfaa; font-size: .8rem; margin-top: auto; }

/* Баруун тал: нэвтрэх маягт */
.login-panel { display: grid; place-items: center; padding: 2rem 1.25rem; background: var(--bg); }
.login-form { width: min(360px, 100%); }
.login-form h2 { font-size: 1.35rem; }
.login-form .hint { color: var(--muted); margin: 0 0 1.5rem; font-size: .92rem; }
.login-form .error { color: var(--danger); min-height: 1.2rem; margin: .5rem 0; font-size: .85rem; }

/* Нарийн дэлгэц дээр дээд/доод болгож хураана */
@media (max-width: 860px) {
  .login-split { grid-template-columns: 1fr; min-height: 100dvh; grid-template-rows: auto 1fr; }
  .login-brand { padding: 1.5rem 1.25rem; gap: 1rem; }
  .login-brand::after { display: none; }
  .login-brand h1, .login-brand .lede, .brand-points, .login-brand footer { display: none; }
  .login-panel { align-content: start; padding-top: 2.5rem; }
}
