/* Admin panel + restaurant staff portal */

:root {
  --bg: #F1F4EF;
  --surface: #FFFFFF;
  --ink: #1D2922;
  --muted: #5A665F;
  --faint: #8A958E;
  --line: #DBE2D9;
  --line-strong: #C3CDC2;
  --primary: #2F6B4F;
  --primary-hover: #255A41;
  --primary-soft: #E2EEE6;
  --danger: #B3261E;
  --danger-soft: #FBEAE8;
  --warn: #8A5A00;
  --warn-soft: #FDF3DC;
  --info-soft: #E6EEF9;
  --info: #21457F;
  --radius: 10px;
  --radius-sm: 7px;
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 0.75rem; }

:focus-visible { outline: 3px solid #F2B134; outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Layout ---------- */

.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; background: linear-gradient(90deg, var(--ink) 0 236px, var(--bg) 236px); }

.sidebar {
  background: var(--ink);
  color: #E8EEE9;
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: block;
  color: #fff; text-decoration: none;
  font-weight: 700; font-size: 1.05rem;
  padding: 4px 10px 2px;
}
.sidebar .brand-sub { color: #9DB0A4; font-size: 0.8rem; padding: 0 10px 18px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  color: #CFDAD2; text-decoration: none;
  padding: 9px 10px; border-radius: var(--radius-sm);
  font-weight: 500;
}
.sidebar nav a svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.sidebar nav a:hover { background: rgba(255,255,255,0.07); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar .sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.sidebar .sidebar-foot a { color: #9DB0A4; font-size: 0.9rem; text-decoration: none; padding: 7px 10px; border-radius: var(--radius-sm); }
.sidebar .sidebar-foot a:hover { color: #fff; background: rgba(255,255,255,0.07); }
.sidebar .who { color: #7F948A; font-size: 0.8rem; padding: 8px 10px 0; }

.main { padding: 28px 32px 60px; min-width: 0; max-width: 1180px; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 22px;
}
.page-head p { color: var(--muted); margin: 6px 0 0; max-width: 62ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.back-link { display: inline-block; margin-bottom: 10px; font-size: 0.92rem; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

/* ---------- Panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}
.panel > h2 { margin-bottom: 4px; }
.panel > .panel-intro { color: var(--muted); margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush .panel-head { padding: 18px 22px 0; }

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

/* ---------- Stats ---------- */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .num { font-size: 1.8rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }

.progress { height: 8px; background: #E8ECE6; border-radius: 99px; overflow: hidden; display: flex; }
.progress span { display: block; height: 100%; }
.progress .p-used { background: var(--ink); }
.progress .p-claimed { background: var(--primary); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }

/* ---------- Restaurant overview on dashboard ---------- */

.rest-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.rest-card .rest-top { display: flex; gap: 12px; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.rest-card .rest-top img, .thumb-fallback {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none;
}
.thumb-fallback {
  display: grid; place-items: center; background: var(--primary-soft); color: var(--primary);
  font-weight: 700; font-size: 1.1rem;
}
.rest-card .rest-top .sub { color: var(--muted); font-size: 0.85rem; }
.rest-card ul { list-style: none; margin: 0; padding: 6px 18px 14px; }
.rest-card li { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.rest-card li:last-child { border-bottom: 0; }
.rest-card li .row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 0.92rem; }
.rest-card li .row span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.data th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 0.82rem;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: #F8FAF7; white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.is-used td { color: var(--faint); }
table.data .code { font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data tr.is-used .code { text-decoration: line-through; text-decoration-thickness: 2px; }
table.data .muted { color: var(--muted); font-size: 0.85rem; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data .nowrap { white-space: nowrap; }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.78rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.available { background: #EEF1ED; color: #5A665F; }
.badge.claimed { background: var(--primary-soft); color: var(--primary); }
.badge.used { background: #E7E9EE; color: #3A3F4A; }
.badge.off { background: var(--warn-soft); color: var(--warn); }
.badge.expired { background: var(--danger-soft); color: var(--danger); }

.swatch-dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: 0.93rem;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  background: var(--primary); color: #fff; line-height: 1.3;
}
.btn:hover { background: var(--primary-hover); color: #fff; }
.btn svg { width: 16px; height: 16px; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: #F4F7F3; color: var(--ink); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: #E7B9B5; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 6px 11px; font-size: 0.85rem; }
.btn.big { padding: 13px 22px; font-size: 1rem; }
.btn.block { width: 100%; }
.btn.link { background: none; border: 0; color: var(--primary); padding: 6px 4px; }
.btn.link:hover { text-decoration: underline; background: none; color: var(--primary-hover); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

form.inline { display: inline; }

/* ---------- Forms ---------- */

.field { margin-bottom: 18px; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.93rem; }
.field .hint { color: var(--muted); font-size: 0.85rem; margin-top: 5px; }
.field .optional { color: var(--faint); font-weight: 400; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=search], input[type=tel], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 9px 11px; min-height: 41px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
input.short, select.short { max-width: 220px; }
input.tiny { max-width: 120px; }

.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.check, .field label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
.check small { display: block; color: var(--muted); font-weight: 400; font-size: 0.85rem; }

.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-top: 6px; }
.form-section { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 6px; }
.form-section > h3 { margin-bottom: 4px; }
.form-section > p { color: var(--muted); font-size: 0.9rem; }

.error-text { color: var(--danger); font-size: 0.85rem; margin-top: 5px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }

/* Colour swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches label {
  display: flex; align-items: center; gap: 8px; font-weight: 500;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 7px 12px 7px 8px; cursor: pointer; background: #fff; font-size: 0.9rem; margin: 0;
}
.swatches input { position: absolute; opacity: 0; pointer-events: none; }
.swatches .chip { width: 22px; height: 22px; border-radius: 5px; }
.swatches input:checked + .chip { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.swatches label:has(input:checked) { border-color: var(--ink); }
.swatches label:has(input:focus-visible) { outline: 3px solid #F2B134; outline-offset: 2px; }

/* Photo picker */
.photo-picker { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.photo-picker .preview {
  width: 140px; height: 92px; border-radius: 8px; background: var(--primary-soft) center/cover no-repeat;
  border: 1px solid var(--line); display: grid; place-items: center; color: var(--primary); font-size: 0.8rem; text-align: center;
}

/* Coupon preview inside the editor */
.mini-ticket {
  display: flex; border-radius: 10px; overflow: hidden; max-width: 380px;
  border: 1px solid var(--line-strong);
}
.mini-ticket .mt-main { flex: 1; padding: 16px 18px; color: #fff; }
.mini-ticket .mt-big { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.mini-ticket .mt-note { font-size: 0.85rem; opacity: 0.9; }
.mini-ticket .mt-title { font-weight: 700; margin-top: 10px; }
.mini-ticket .mt-time { font-size: 0.85rem; opacity: 0.9; }
.mini-ticket .mt-stub {
  width: 92px; background: #FBF8EE; border-left: 2px dashed var(--line-strong); font-weight: 600;
  display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 0.78rem; padding: 8px;
}

/* ---------- Alerts ---------- */

.alert {
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 18px;
  display: flex; gap: 10px; align-items: flex-start; font-weight: 500;
}
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert.success { background: var(--primary-soft); color: #1F4F38; }
.alert.error { background: var(--danger-soft); color: #7D1A14; }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.warn { background: var(--warn-soft); color: #6B4500; }

/* ---------- Filters + pagination ---------- */

.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  padding: 16px 22px; border-bottom: 1px solid var(--line); background: #FAFBF9;
}
.filters .f { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.filters .f.grow { flex: 1; min-width: 200px; }
.filters label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.filters select, .filters input { min-height: 38px; padding: 7px 10px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 14px 22px 0; }
.tabs a {
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.9rem;
  padding: 7px 12px; border-radius: 99px;
}
.tabs a:hover { background: #EEF2EC; color: var(--ink); }
.tabs a.active { background: var(--ink); color: #fff; }
.tabs a .n { font-weight: 500; opacity: 0.75; margin-left: 4px; font-variant-numeric: tabular-nums; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; flex-wrap: wrap; }
.pager .links { display: flex; gap: 6px; }

/* ---------- Empty states ---------- */

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; font-size: 1.05rem; }
.empty p { max-width: 46ch; margin: 0 auto 16px; }

/* ---------- Lists of restaurants/coupons on admin pages ---------- */

.item-list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; gap: 16px; align-items: center; padding: 16px 22px; border-top: 1px solid var(--line);
}
.item:first-child { border-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 650; }
.item .meta { color: var(--muted); font-size: 0.88rem; }
.item .item-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.item img.thumb { width: 64px; height: 48px; border-radius: 7px; object-fit: cover; flex: none; }
.item .thumb-fallback { width: 64px; height: 48px; }
.item .ticket-chip {
  width: 64px; height: 48px; border-radius: 7px; display: grid; place-items: center; flex: none;
  font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em;
}
.item .bar { width: 170px; flex: none; }
.item .bar .nums { font-size: 0.82rem; color: var(--muted); margin-bottom: 5px; font-variant-numeric: tabular-nums; }

.group-head { padding: 14px 22px; background: #F8FAF7; border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.group-head:first-child { border-top: 0; }

/* ---------- Login pages ---------- */

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 30px 28px;
}
.auth-card.wide { max-width: 620px; }
.auth-card h1 { font-size: 1.45rem; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: 22px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 0.9rem; color: var(--muted); }

/* ---------- Staff portal ---------- */

.staff-top {
  background: var(--ink); color: #fff; padding: 14px 24px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
.staff-top .name { font-weight: 700; font-size: 1.05rem; }
.staff-top .name small { display: block; font-weight: 400; color: #9DB0A4; font-size: 0.82rem; }
.staff-top a { color: #CFDAD2; text-decoration: none; font-size: 0.92rem; }
.staff-top a:hover { color: #fff; text-decoration: underline; }
.staff-main { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }

.redeem {
  background: var(--surface); border: 2px solid var(--ink); border-radius: 14px; padding: 22px; margin-bottom: 22px;
}
.redeem h1 { font-size: 1.3rem; margin-bottom: 4px; }
.redeem p { color: var(--muted); }
.redeem > form { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.redeem input[type=text]::placeholder { text-transform: none; letter-spacing: normal; font-weight: 500; }
.redeem input[type=text] {
  flex: 1; min-width: 220px; font-size: 1.35rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 12px 14px; min-height: 54px;
}
.redeem .btn { min-height: 54px; padding: 0 24px; font-size: 1.02rem; }
.redeem-result { margin-top: 16px; margin-bottom: 0; font-size: 1.02rem; }

input[type=file] { font: inherit; font-size: 0.88rem; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 600; color: var(--ink); background: #fff; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 7px 14px; margin-right: 10px; cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: #F4F7F3; }

.panel.narrow { max-width: 860px; }

/* ---------- Install ---------- */

.steps { margin: 0 0 22px; padding-left: 20px; color: var(--muted); }
.steps li { margin-bottom: 6px; }
pre.config { background: #F4F7F3; border: 1px solid var(--line); border-radius: 8px; padding: 14px; overflow-x: auto; font-size: 0.85rem; }

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
  .item .bar { display: none; }
}

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; background: var(--bg); }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    padding: 12px 14px; gap: 6px;
  }
  .sidebar .brand { padding: 4px 6px; }
  .sidebar .brand-sub, .sidebar .who { display: none; }
  .sidebar nav { flex-direction: row; overflow-x: auto; width: 100%; order: 3; gap: 4px; padding-bottom: 2px; }
  .sidebar nav a { white-space: nowrap; padding: 8px 10px; }
  .sidebar nav a svg { display: none; }
  .sidebar .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; }
  .main { padding: 20px 16px 50px; }
  .grid-2, .field-row, .field-row.three { grid-template-columns: 1fr; }
  .item { flex-wrap: wrap; padding: 14px 16px; }
  .item .item-actions { width: 100%; justify-content: flex-start; }
  .filters { padding: 14px 16px; }
  .filters .f { min-width: calc(50% - 5px); flex: 1; }
  .tabs { padding: 12px 16px 0; }
  .panel { padding: 18px 16px; }
  .panel.flush .panel-head { padding: 16px 16px 0; }
  .group-head { padding: 12px 16px; }
  .pager { padding: 12px 16px; }
}

@media (max-width: 560px) {
  h1 { font-size: 1.35rem; }
  .stats { gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .num { font-size: 1.45rem; }

  /* Code tables become stacked cards on phones */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.cards td { border: 0; padding: 2px 0; }
  table.cards td[data-label]::before { content: attr(data-label) ": "; color: var(--faint); font-size: 0.82rem; }
  table.cards td.code { font-size: 1.05rem; }
  table.cards td.actions { text-align: left; padding-top: 8px; }
  .redeem .btn { flex: 1; }
}

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