/* Prompt, served from this site (no trip to Google Fonts on each page): Thai and Latin, 400/500/600. */
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/prompt-thai-400.woff2') format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/prompt-latin-400.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/prompt-thai-500.woff2') format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/prompt-latin-500.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/prompt-thai-600.woff2') format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/prompt-latin-600.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* Theme from the baked.n.bar logo: cream, white, brown. */
:root {
  --cream: #FAF4EA;
  --cream-dark: #EEDFC4;
  --bread: #E6CEA2;
  --white: #FFFFFF;
  --brown: #633D1C;
  --brown-dark: #3F2611;
  --brown-light: #C4A982;
  --text: #3F2611;
  --muted: #8A6E55;
  --danger: #A33A2B;
  --ok: #4F7A3A;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--text);
  font-family: "Prompt", "Sarabun", "Noto Sans Thai", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--brown); }

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--cream-dark);
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--brown-dark);
  font-weight: 600;
  font-size: 18px;
}
.brand img { width: 40px; height: 40px; object-fit: contain; }
.shop-chip-logo { width: 28px; height: 28px; border-radius: 50%; object-fit: contain; background: var(--white); }
.logo-fallback.shop-chip-logo { font-size: 14px; }

.page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.page-narrow { max-width: 480px; }

h1 { font-size: 24px; margin: 0 0 16px; color: var(--brown-dark); }
h2 { font-size: 18px; margin: 0 0 12px; color: var(--brown-dark); }

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(62, 42, 30, 0.08);
  margin-bottom: 16px;
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--white); border-radius: var(--radius); padding: 16px; text-decoration: none; color: inherit; }
.stat .label { color: var(--muted); font-size: 14px; }
.stat .value { font-size: 32px; font-weight: 600; color: var(--brown); }

label { display: block; font-weight: 500; margin: 12px 0 4px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }
input[type=text], input[type=tel], input[type=date], input[type=password], input[type=search], input[type=url], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--cream-dark);
  border-radius: 10px;
  background: var(--white);
  font: inherit;
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--brown-light); outline-offset: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 12px 0; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--brown); }

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--brown);
  background: var(--brown);
  color: var(--white);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--brown-dark); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-light { background: var(--white); color: var(--brown); }
.btn-light:hover { background: var(--cream); }
.btn-danger { background: var(--white); color: var(--danger); border-color: var(--danger); }
.btn-block { width: 100%; text-align: center; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.alert-error { background: #F8E1DD; color: var(--danger); }
.alert-ok { background: #E3EEDB; color: var(--ok); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1 1 220px; width: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 12px; border-radius: 999px; background: var(--white); text-decoration: none; color: var(--brown); border: 1px solid var(--cream-dark); font-size: 14px; }
.chip.active { background: var(--brown); color: var(--white); border-color: var(--brown); }

.table-wrap { overflow-x: auto; padding-bottom: 2px; }
/* Scrollbars: thin, rounded, in the theme's brown, with no arrow buttons. Chrome, Edge and Safari take the
   ::-webkit-scrollbar rules (Chrome ignores them once scrollbar-color is set, so that is kept for Firefox only). */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--brown-light); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--brown); }
::-webkit-scrollbar-button, ::-webkit-scrollbar-corner { display: none; background: transparent; }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--brown-light) transparent; }
}
table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--cream); white-space: nowrap; }
th { background: var(--cream-dark); color: var(--brown-dark); font-weight: 600; font-size: 14px; }
tr:last-child td { border-bottom: 0; }
td a { font-weight: 500; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--cream); color: var(--brown); font-size: 12px; }
.muted { color: var(--muted); }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 16px; align-items: center; }

dl.details { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; }

.center { text-align: center; }
.spinner { margin: 48px auto; width: 36px; height: 36px; border: 4px solid var(--cream-dark); border-top-color: var(--brown); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
[hidden] { display: none !important; }

@media (max-width: 600px) {
  dl.details { grid-template-columns: 1fr; }
  dl.details dt { margin-top: 8px; }
}

.hero-logo { display: block; width: 220px; max-width: 70%; margin: 0 auto 16px; }

/* Shop logo placeholder: first letter of the shop name */
.logo-fallback {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--brown); color: var(--white); font-weight: 600; font-size: 20px;
}
.logo-fallback.hero-logo { display: flex; width: 96px; height: 96px; max-width: none; font-size: 44px; }

/* Settings */
.section-title { margin-top: 24px; }
.color-row { display: flex; flex-wrap: wrap; gap: 16px; }
.color-row label { display: flex; align-items: center; gap: 8px; margin: 0; }
.color-row input[type=color] { width: 48px; height: 36px; padding: 2px; border: 1px solid var(--cream-dark); border-radius: 8px; background: var(--white); }
code.copy { user-select: all; word-break: break-all; background: var(--cream); padding: 2px 6px; border-radius: 6px; }

/* Logo editor: preview on the left, picker and buttons on the right (stacked on phones) */
.logo-editor { display: flex; gap: 20px; align-items: stretch; flex-wrap: wrap; }
.logo-preview {
  flex: none; width: 160px; height: 160px; padding: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--white); border: 1px solid var(--cream-dark); border-radius: var(--radius);
}
.logo-preview.is-new { border-color: var(--brown-light); box-shadow: 0 0 0 3px var(--cream); }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview .logo-fallback { width: 96px; height: 96px; font-size: 44px; }
.logo-side { flex: 1 1 260px; display: flex; flex-direction: column; justify-content: center; }
.logo-side .actions { margin-top: 12px; }
.logo-side .alert { margin: 12px 0 0; }
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  margin: 0; padding: 22px 16px; text-align: center; cursor: pointer;
  background: var(--cream); border: 2px dashed var(--brown-light); border-radius: var(--radius);
  transition: background .15s, border-color .15s;
}
.dropzone:hover, .dropzone.dragging { background: var(--cream-dark); border-color: var(--brown); }
.dropzone.has-file { border-style: solid; }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-title { font-weight: 500; color: var(--brown); word-break: break-all; }
.dropzone:focus-within { outline: 2px solid var(--brown-light); outline-offset: 2px; }

/* Points: the green "new points" banner and history */
:root { --green: #2E9E4F; --green-dark: #1F7A3A; --green-light: #E3F5E8; }
.earned {
  background: var(--green); color: var(--white); border-radius: 20px; padding: 16px 20px; margin-bottom: 16px;
  text-align: center; box-shadow: 0 6px 18px rgba(46, 158, 79, 0.35); cursor: pointer;
}
.earned-points { font-size: 34px; font-weight: 600; line-height: 1.2; }
.earned.pop { animation: earned-pop .5s ease-out; }
@keyframes earned-pop { 0% { transform: scale(.8); opacity: 0; } 70% { transform: scale(1.04); opacity: 1; } 100% { transform: scale(1); } }

ul.history { list-style: none; margin: 0; padding: 0; }
ul.history li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--cream); }
ul.history li:last-child { border-bottom: 0; }
ul.history .h-icon { flex: none; width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--green-light); color: var(--green-dark); }
ul.history .h-icon.spent { background: var(--spent-light); color: var(--spent); }
ul.history .h-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
ul.history li.voided .h-icon { opacity: .45; }
ul.history .h-info { flex: 1; min-width: 0; }
ul.history .h-amount { font-weight: 500; }
ul.history .h-when { font-size: 12px; color: var(--muted); }
ul.history .h-points { font-weight: 600; color: var(--green-dark); font-size: 17px; }
ul.history li.is-new { background: var(--green-light); margin: 0 -12px; padding: 10px 12px; border-radius: 10px; }
ul.history li.voided .h-points, ul.history li.voided .h-amount { text-decoration: line-through; color: var(--muted); }

/* Staff page */
.staff-hello { margin: 0 0 12px; }
.scan-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 22px; font-size: 20px; border-radius: 18px; }
.scan-btn svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.inline-field { display: flex; gap: 8px; }
.inline-field input { flex: 1; text-transform: uppercase; letter-spacing: 2px; }
.staff-member { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--cream); }
.staff-member img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 2px solid var(--brown-light); }
.staff-member .name { font-size: 20px; font-weight: 600; }
input.amount-input { font-size: 32px; font-weight: 600; text-align: right; padding: 12px 16px; }
.points-preview { display: flex; justify-content: center; align-items: baseline; gap: 8px; margin-top: 16px; color: var(--muted); }
.points-preview b { font-size: 40px; color: var(--green); }
.points-preview b.zero { color: var(--brown-light); }
.done-check {
  width: 72px; height: 72px; margin: 4px auto 12px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--green); color: var(--white); font-size: 40px; animation: earned-pop .4s ease-out;
}
.points-new { color: var(--green); font-size: 32px; margin-bottom: 4px; }
.text-green { color: var(--green-dark); font-weight: 600; }
.text-void { text-decoration: line-through; color: var(--muted); }
.rate-row { display: flex; flex-wrap: wrap; gap: 16px; }
.rate-row label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; }
.rate-row input[type=number] { width: 120px; }
input[type=number] { padding: 10px 12px; border: 1px solid var(--cream-dark); border-radius: 10px; background: var(--white); font: inherit; color: var(--text); }
th.num, td.num { text-align: right; }
.btn-sm { padding: 4px 12px; font-size: 14px; }
.points-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.points-total { font-size: 28px; font-weight: 600; color: var(--brown); }
.points-total small { font-size: 14px; color: var(--muted); font-weight: 400; }
.staff-cell { display: flex; align-items: center; gap: 10px; }

.badge-pending { background: #FFF1D6; color: #9A6200; }
.badge-active { background: var(--green-light); color: var(--green-dark); }
.badge-disabled { background: #EEE; color: #777; }
/* Redemption history: filter bar, struck-through voided rows, and the per-reward tally with bars. */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filter-bar input[type=search] { flex: 1 1 220px; width: auto; }
.filter-bar select, .filter-bar input[type=date] { width: auto; }
.filter-field { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; color: var(--muted); white-space: nowrap; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--muted); }
td.nowrap { white-space: nowrap; }
@media (max-width: 600px) { .app .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
tr.is-voided td { background: #FAFAF8; }
ul.tally { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.tally-head { display: flex; justify-content: space-between; gap: 8px; }
.tally-head b { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tally-head span { flex: none; color: var(--brown); font-weight: 500; }
.tally-bar { height: 8px; margin: 6px 0 4px; border-radius: 999px; background: var(--cream); overflow: hidden; }
.tally-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--bread), var(--spent)); }
/* All shops: name, code and type in one cell, status as badges, so the table fits beside the new-shop form. */
.shop-table td { vertical-align: middle; }
.shop-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.shop-cell .shop-chip-logo { width: 36px; height: 36px; flex: none; border: 1px solid var(--cream-dark); }
.shop-cell-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.shop-cell-text b { font-weight: 600; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badges .badge { white-space: nowrap; }
.shop-table tr.is-current td { background: #FFFBF4; }
.shop-table td.num .badge { white-space: nowrap; }
.row-actions { display: flex; gap: 6px; }

/* LINE profile pictures; the first letter shows when there is no picture */
.avatar {
  position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; overflow: hidden; background: var(--bread); color: var(--brown-dark); font-weight: 600;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: 14px; }
.avatar-md { width: 40px; height: 40px; font-size: 17px; }
.avatar-lg { width: 72px; height: 72px; font-size: 30px; border: 3px solid var(--white); box-shadow: 0 1px 3px rgba(62, 42, 30, 0.2); }
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.profile-head h1 { margin: 0; }

/* Settings: shop links, one panel per LIFF page */
.link-groups { display: grid; gap: 14px; margin-top: 12px; }
.link-group { border: 1px solid var(--cream-dark); border-radius: var(--radius); padding: 16px; background: linear-gradient(var(--white), var(--cream) 260%); }
.link-group header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.link-group h3 { margin: 0; font-size: 16px; color: var(--brown-dark); }
.link-row { margin-top: 12px; }
.link-label { font-weight: 500; font-size: 14px; margin-bottom: 6px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.copy-field {
  display: flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 4px 4px 4px 12px; background: var(--white); border: 1px solid var(--cream-dark); border-radius: 10px;
}
.copy-field code { flex: 1; min-width: 0; font-size: 14px; overflow-x: auto; white-space: nowrap; user-select: all; color: var(--brown-dark); }
.copy-field.is-empty { padding: 10px 12px; border-style: dashed; color: var(--muted); font-size: 14px; background: transparent; }
.copy-btn {
  flex: none; padding: 6px 14px; border-radius: 8px; border: 0; cursor: pointer;
  background: var(--cream); color: var(--brown); font: inherit; font-size: 14px; font-weight: 500;
}
.copy-btn:hover { background: var(--cream-dark); }
.copy-btn.done { background: var(--green-light); color: var(--green-dark); }
.test-link { display: inline-block; margin-top: 12px; font-size: 14px; }
.link-group, .copy-field { min-width: 0; }
@media (max-width: 600px) {
  .link-group { padding: 12px; }
  .copy-field code { font-size: 13px; }
}
.nember-hero { display: block; width: 120px; height: 120px; margin: 4px auto 16px; filter: drop-shadow(0 8px 18px rgba(200, 100, 42, 0.35)); }

/* Rewards: list on the member card (grey until affordable), the coupon, staff confirm, back office list */
:root { --spent: #B4532A; --spent-light: #FBE9DC; }
ul.rewards, ul.reward-admin-list { list-style: none; margin: 8px 0 0; padding: 0; }
.reward, .reward-admin-list li {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--cream);
}
.reward:last-child, .reward-admin-list li:last-child { border-bottom: 0; }
.reward-thumb {
  flex: none; width: 56px; height: 56px; border-radius: 12px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; background: var(--cream); font-size: 26px;
}
.reward-thumb img { width: 100%; height: 100%; object-fit: cover; }
.reward-info { flex: 1; min-width: 0; }
.reward-name { font-weight: 600; }
.reward .reward-cost { color: var(--brown); font-weight: 500; font-size: 14px; }
.reward .btn { flex: none; min-width: 72px; text-align: center; }
.reward.locked .reward-thumb { filter: grayscale(1); opacity: .5; }
.reward.locked .reward-name, .reward.locked .reward-cost { color: var(--muted); }
.reward.locked .btn:disabled { background: var(--cream); border-color: var(--cream-dark); color: var(--muted); opacity: 1; font-size: 13px; }
.reward-admin-list .reward-cost { flex: none; color: var(--brown); white-space: nowrap; }
.reward-admin-list li.is-off .reward-thumb, .reward-admin-list li.is-off .reward-info { opacity: .55; }
@media (max-width: 600px) { .reward-admin-list li { flex-wrap: wrap; } .reward-admin-list .row-actions { width: 100%; justify-content: flex-end; } }

.coupon { border: 2px dashed var(--brown-light); text-align: center; }
.lp .coupon { border-radius: 20px; }
.coupon-head h2 { margin: 2px 0; }
.coupon-cost { color: var(--brown); }
.coupon .qr { background: var(--white); border-radius: 14px; padding: 12px; margin: 12px auto 8px; width: 220px; }
.coupon .qr svg { width: 100%; height: auto; display: block; }
.coupon .code { letter-spacing: 3px; font-size: 18px; font-weight: 600; }
.coupon-timer { margin: 8px 0 0; font-size: 18px; }
.earned.redeemed { background: var(--spent); box-shadow: 0 6px 18px rgba(180, 83, 42, 0.35); }
.earned.redeemed .earned-points { font-size: 26px; }
ul.history .h-points.spent { color: var(--spent); }
ul.history li.is-new-spent { background: var(--spent-light); margin: 0 -12px; padding: 10px 12px; border-radius: 10px; }
.text-spent { color: var(--spent); font-weight: 600; }
.coupon-reward { display: flex; align-items: center; gap: 14px; margin: 16px 0; padding: 14px; border-radius: 14px; background: var(--spent-light); }
.coupon-reward .reward-thumb { width: 64px; height: 64px; background: var(--white); }
.coupon-reward .reward-name { font-size: 20px; }
.reward-image-editor { margin-top: 2px; }
.reward-image-editor .logo-preview { width: 120px; height: 120px; padding: 0; overflow: hidden; }
.reward-image-editor .logo-preview img { width: 100%; height: 100%; object-fit: cover; }
.reward-image-empty { font-size: 48px; filter: grayscale(.3); opacity: .7; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--brown); text-decoration: underline; cursor: pointer; }

/* Dashboard: section heads, KPI tiles, the points trend chart, most redeemed rewards and the latest redemptions. */
:root { --given: #7A9E5A; }
.dash-section { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 20px 0 10px; }
.page > .dash-section:first-of-type { margin-top: 4px; }
.dash-section h2 { margin: 0; font-size: 16px; }
.dash-section .period { font-size: 12px; color: var(--muted); padding: 2px 10px; border: 1px solid var(--cream-dark); border-radius: 999px; background: var(--white); }
.dash-section-end { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.dash-section .live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #9A6200; background: #FFF1D6; padding: 3px 10px; border-radius: 999px; }
.dash-section .live i { width: 7px; height: 7px; border-radius: 50%; background: #E29A1B; box-shadow: 0 0 0 3px rgba(226, 154, 27, 0.2); }
.dash-section .more { font-size: 13px; }
.kpi .value { display: flex; align-items: baseline; gap: 4px; }
.kpi .delta { margin-top: 4px; font-size: 12px; color: var(--muted); }
.kpi .delta b { color: var(--green-dark); font-weight: 600; }
.kpi .delta b.down { color: var(--spent); }
.kpi .meter { height: 6px; border-radius: 999px; background: var(--cream); margin-top: 8px; overflow: hidden; }
.kpi .meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--bread), var(--spent)); }
.chart-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px 12px; margin-bottom: 6px; }
.chart-head h2 { margin: 0 0 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.legend span, .trend-tip span { display: inline-flex; align-items: center; gap: 6px; }
.sw-given, .sw-redeemed { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--given); }
.sw-redeemed { background: var(--spent); }
.trend { position: relative; touch-action: pan-y; }
.trend svg { display: block; overflow: visible; }
.trend .grid { stroke: #EFE6D8; stroke-width: 1; }
.trend .tick { font-size: 11px; fill: var(--muted); }
.trend .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend .line.given { stroke: var(--given); }
.trend .line.redeemed { stroke: var(--spent); }
.trend .area.given { fill: var(--given); opacity: .1; }
.trend .area.redeemed { fill: var(--spent); opacity: .1; }
.trend .cross { stroke: #C9B49A; stroke-dasharray: 3 3; }
.trend .dot { stroke: var(--white); stroke-width: 2; }
.trend .dot.given { fill: var(--given); }
.trend .dot.redeemed { fill: var(--spent); }
.trend-tip { position: absolute; top: 4px; min-width: 140px; display: grid; gap: 4px; padding: 8px 12px; border-radius: 10px; background: var(--white); border: 1px solid var(--cream-dark); box-shadow: 0 6px 18px rgba(62, 42, 30, 0.12); font-size: 12px; pointer-events: none; }
.trend-tip b { font-weight: 600; color: var(--brown-dark); }
.trend-tip em { margin-left: auto; padding-left: 12px; font-style: normal; font-weight: 600; color: var(--brown-dark); }
.chart-table { margin-top: 8px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--muted); width: fit-content; }
.chart-table .table-wrap { max-height: 260px; overflow-y: auto; margin-top: 8px; }
ul.toplist { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.toplist li { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; }
.toplist .reward-thumb { grid-row: span 2; width: 40px; height: 40px; border-radius: 10px; font-size: 18px; }
.toplist b { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toplist .n { color: var(--brown); font-weight: 500; font-size: 13px; white-space: nowrap; }
.toplist .bar { grid-column: 2 / 4; height: 6px; background: var(--cream); border-radius: 999px; overflow: hidden; }
.toplist .bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--bread), var(--spent)); }
ul.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--cream); }
.feed li:last-child { border-bottom: 0; }
.feed .who { flex: 1; min-width: 0; line-height: 1.35; }
.feed .who a { text-decoration: none; color: var(--brown-dark); }
.feed .who b { font-weight: 600; }
.feed .pts { color: var(--spent); font-weight: 600; white-space: nowrap; }

/* Back office shell: sidebar on the left, a slim bar on top, pages to the right. On phones the sidebar is a drawer. */
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.app { display: flex; min-height: 100vh; }
/* The menu: a dark rail of groups (icons) on the far left, and beside it a panel with the pages of one group.
   The panel folds away to leave just the rail (.sb-mini). */
.sidebar { position: sticky; top: 0; height: 100vh; flex: none; display: flex; z-index: 10; }
.rail {
  width: 76px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 0 12px;
  background: linear-gradient(180deg, var(--brown) 0%, var(--brown-dark) 100%); color: var(--cream);
}
/* The logo sits inside a white tile with room around it, so the rounded corners never cut into it. */
.rail-brand { display: flex; width: 56px; height: 56px; margin-bottom: 12px; padding: 5px; border-radius: 14px; background: var(--white); }
.rail-brand img { width: 100%; height: 100%; object-fit: contain; border-radius: 0; }
.rail-brand .logo-fallback { width: 100%; height: 100%; border-radius: 10px; }
.rail-item {
  position: relative; width: 100%; padding: 10px 0 8px; border: 0; background: none; color: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; font: inherit; font-size: 11.5px; line-height: 1.2; opacity: .78;
}
.rail-item .icon { width: 24px; height: 24px; stroke-width: 1.9; }
.rail-item:hover { opacity: 1; background: rgba(255, 255, 255, 0.06); }
.rail-item.active { opacity: 1; background: rgba(255, 255, 255, 0.16); }
.rail-item.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--bread); }
.rail-item:focus-visible { outline: 2px solid var(--bread); outline-offset: -2px; }
.rail-badge {
  position: absolute; top: 4px; right: 14px; min-width: 18px; padding: 0 5px; border-radius: 999px; font-style: normal;
  background: var(--danger); color: var(--white); font-size: 11px; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--brown);
}
.rail-badge-warn { background: #E0A100; color: var(--brown-dark); }
.rail-sep { width: 40px; margin: 8px 0; border: 0; border-top: 1px solid rgba(255, 255, 255, 0.2); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.rail-avatar {
  width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--bread); color: var(--brown-dark); font-weight: 600; text-decoration: none; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}
.rail-avatar:hover, .rail-avatar.active { box-shadow: 0 0 0 3px var(--bread); }
.rail-foot form { width: 100%; }
.rail-logout { padding: 8px 0; }
.rail-logout:hover { color: #FFD3CC; }

.sb-panel {
  position: relative; width: 236px; flex: none; display: flex; flex-direction: column; padding: 22px 12px 14px;
  background: var(--white); border-right: 1px solid var(--cream-dark);
}
.sb-collapse {
  position: absolute; top: 26px; right: -15px; z-index: 2; width: 30px; height: 30px; border-radius: 50%; padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; background: var(--white); color: var(--brown-dark);
  border: 1px solid var(--cream-dark); box-shadow: 0 2px 6px rgba(62, 42, 30, 0.12);
}
.sb-collapse .icon { width: 16px; height: 16px; }
.sb-collapse:hover { background: var(--cream); }
.app.sb-mini .sb-panel { display: none; }
.sb-section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sb-section h2 { margin: 0 10px 14px; font-size: 24px; font-weight: 500; color: var(--brown-dark); }
.sb-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; }
.sb-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  text-decoration: none; color: var(--brown-dark); font-weight: 400; position: relative; white-space: nowrap;
}
.sb-nav a .icon { color: var(--muted); }
.sb-nav a:hover { background: var(--cream); }
.sb-nav a.active { background: var(--cream); font-weight: 600; }
.sb-nav a.active .icon { color: var(--brown); }
/* Record count at the right of a menu item; a pending badge, when shown, sits just before it. */
.sb-count { margin-left: auto; min-width: 24px; padding: 0 7px; border-radius: 999px; background: var(--cream); color: var(--muted); font-size: 12px; font-weight: 500; line-height: 22px; text-align: center; }
.sb-nav a.active .sb-count { background: var(--cream-dark); color: var(--brown-dark); }
.sb-badge + .sb-count { margin-left: 6px; }
.sb-badge { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--danger); color: var(--white); font-size: 12px; line-height: 22px; text-align: center; }
.sb-panel-foot { flex: none; display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--cream-dark); }
.sb-shop {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 12px; background: var(--cream); border: 1px solid var(--cream-dark); text-decoration: none; color: var(--brown-dark);
}
.sb-shop:hover { border-color: var(--brown-light); }
.sb-shop-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sb-shop-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-shop-text .hint { font-size: 12px; }
.sb-shop .icon { width: 16px; height: 16px; color: var(--muted); }
/* A round initial for a person without a picture (account page, staff list). */
.sb-avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--bread); color: var(--brown-dark); font-weight: 600; }
.sb-who { text-align: center; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-who b { color: var(--brown-dark); font-weight: 500; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  margin: 14px 24px 0; padding: 10px 16px; border-radius: var(--radius);
  background: var(--white); box-shadow: 0 1px 4px rgba(62, 42, 30, 0.08);
}
.app-crumb { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.app-crumb b { color: var(--brown-dark); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.app-crumb .sep { color: var(--cream-dark); }
.app-top-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--cream-dark); text-decoration: none; font-size: 14px; white-space: nowrap; }
.app-top-link .icon { width: 16px; height: 16px; }
.app-top-link:hover { background: var(--cream); }
/* Branch picker: a pill like the top links, with the select itself inside it. */
.app-top .branch-pick { margin: 0; }
.app-top .branch-pick label, .app-top .branch-pick .branch-fixed {
  position: relative; display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 0 10px; height: 32px;
  border-radius: 999px; border: 1px solid var(--cream-dark); background: var(--cream); color: var(--brown-dark);
  font-size: 13px; font-weight: 500; cursor: pointer;
}
.app-top .branch-pick label:hover { border-color: var(--brown-light); }
.app-top .branch-pick .branch-fixed { cursor: default; white-space: nowrap; }
.app-top .branch-pick .icon { width: 16px; height: 16px; flex: none; }
.app-top .branch-pick select {
  appearance: none; -webkit-appearance: none; width: auto; max-width: 180px; margin: 0; padding: 0 18px 0 0; border: 0;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b4f3a' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right center / 12px;
  font: inherit; color: inherit; cursor: pointer; text-overflow: ellipsis; box-shadow: none; height: auto; min-height: 0;
}
.app-top .branch-pick select:focus { outline: none; }
.app-top .branch-pick label:focus-within { outline: 2px solid var(--brown); outline-offset: 2px; }
@media (max-width: 600px) {
  .app-top .branch-pick select { max-width: 120px; }
  /* Room for the page title beside the picker: the shop name goes. */
  .app-top:has(.branch-pick) .app-crumb > span { display: none; }
}
.sb-toggle { display: none; width: 38px; height: 38px; border: 0; border-radius: 10px; background: var(--cream); color: var(--brown-dark); cursor: pointer; align-items: center; justify-content: center; }
.app-main .page { margin: 0; padding: 24px 24px 48px; }
/* Back office pages use the whole width. On wide screens a page splits into a main column and a side column
   (.cols), or two equal halves (.cols-even); narrower screens stack them. */
.app-main .page { max-width: none; width: 100%; }
.cols { display: grid; gap: 0 16px; align-items: start; }
.cols > * { min-width: 0; }
.account-card { display: flex; align-items: center; gap: 12px; }
@media (min-width: 1100px) {
  .cols { grid-template-columns: minmax(0, 1fr) minmax(340px, 400px); }
  .cols.cols-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols.cols-wide { grid-template-columns: minmax(0, 1fr); }
  .app .link-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Wide tables sit side by side only when both still fit. */
@media (min-width: 1500px) {
  .cols.cols-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1600px) {
  .cols { grid-template-columns: minmax(0, 1fr) minmax(380px, 460px); }
}
.sb-backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; }
  .sb-collapse { display: none; }
  .sb-panel { width: min(250px, calc(100vw - 76px - 48px)); }
  .app.sb-mini .sb-panel { display: flex; }
  .app.sb-open .sidebar { transform: none; box-shadow: 0 0 30px rgba(0, 0, 0, 0.15); }
  .app.sb-open .sb-backdrop { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(40, 25, 12, 0.35); }
  .sb-toggle { display: inline-flex; }
  .app-top { margin: 10px 12px 0; padding: 8px 10px; }
  .app-top-link span { display: none; }
  .app-main .page { padding: 20px 16px 40px; }
}

/* Desktop back office: tighter type and spacing, like a work tool. Phones keep the larger sizes. */
@media (min-width: 901px) {
  .app { font-size: 14px; }
  .app h1 { font-size: 20px; margin-bottom: 12px; }
  .app h2 { font-size: 15px; margin-bottom: 10px; }
  .app .hint { font-size: 12px; }
  .sb-panel { width: 220px; padding: 18px 10px 12px; }
  .sb-section h2 { font-size: 21px; margin: 0 10px 12px; }
  .sb-shop { padding: 6px 8px; }
  .sb-shop .shop-chip-logo { width: 24px; height: 24px; }
  .sb-nav a { padding: 8px 10px; gap: 10px; font-size: 14px; border-radius: 8px; }
  .sb-nav .icon { width: 18px; height: 18px; }
  .sb-badge { min-width: 20px; line-height: 20px; font-size: 11px; }
  .sb-count { min-width: 22px; line-height: 20px; font-size: 11px; }
  .app-top { margin: 12px 20px 0; padding: 7px 14px; font-size: 13px; }
  .app-top-link { padding: 4px 10px; font-size: 13px; }
  .app-main .page { padding: 18px 20px 40px; }
  .app .card { padding: 16px 18px; margin-bottom: 12px; }
  .app .stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 12px; }
  .app .stat { padding: 12px 14px; }
  .app .stat .label { font-size: 12px; }
  .app .stat .value { font-size: 24px; }
  .app th, .app td { padding: 7px 10px; }
  .app th { font-size: 12px; }
  .app label { margin: 10px 0 3px; font-size: 13px; }
  .app input[type=text], .app input[type=tel], .app input[type=date], .app input[type=password], .app input[type=search],
  .app input[type=url], .app input[type=number], .app select, .app textarea { padding: 7px 10px; font-size: 14px; }
  .app .btn { padding: 7px 14px; font-size: 14px; }
  .app .btn-sm { padding: 3px 10px; font-size: 12px; }
  .app .chip { padding: 3px 10px; font-size: 12px; }
  .app .avatar-md { width: 32px; height: 32px; font-size: 14px; }
  .app .avatar-sm { width: 26px; height: 26px; font-size: 12px; }
  .app .avatar-lg { width: 56px; height: 56px; font-size: 24px; }
  .app .points-total { font-size: 22px; }
  .app .reward-thumb { width: 44px; height: 44px; font-size: 20px; }
  .app .reward-admin-list li { padding: 9px 0; }
}

/* Member page in LINE: big shop logo on top, the dark member card with a ticket-style QR half, soft cards below. */
.lp { padding-top: 20px; --line-soft: color-mix(in srgb, var(--cream-dark) 55%, #FFFFFF); }
body:has(.lp) { background: linear-gradient(180deg, color-mix(in srgb, var(--bread) 45%, var(--cream)) 0, var(--cream) 260px) no-repeat, var(--cream); }
.lp-hero { text-align: center; margin: 4px 0 18px; }
.lp-logo { display: block; width: 140px; height: 140px; margin: 0 auto; padding: 16px; object-fit: contain; border-radius: 30px; background: var(--white); box-shadow: 0 10px 30px color-mix(in srgb, var(--brown) 18%, transparent), 0 0 0 1px color-mix(in srgb, var(--brown) 6%, transparent); }
.logo-fallback.lp-logo { display: flex; font-size: 56px; background: var(--brown); }
.lp-tag { margin-top: 10px; font-size: 14px; color: var(--muted); }
.lp .card:not(.coupon) { border: 0; border-radius: 20px; box-shadow: 0 2px 10px color-mix(in srgb, var(--brown-dark) 6%, transparent); }
.lp .sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.lp .sec-head h2 { margin: 0; font-size: 17px; }
.lp-foot { text-align: center; font-size: 12px; color: var(--brown-light); margin: 8px 0 0; }

.member-card { border-radius: 24px; overflow: hidden; margin-bottom: 20px; background: var(--white); box-shadow: 0 18px 40px color-mix(in srgb, var(--brown-dark) 22%, transparent); }
.mc-top { position: relative; overflow: hidden; padding: 20px 22px 22px; color: var(--cream); background: radial-gradient(120% 140% at 100% 0, color-mix(in srgb, var(--brown), #FFFFFF 22%) 0, var(--brown) 45%, var(--brown-dark) 100%); }
.mc-top::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; border: 28px solid rgba(255, 255, 255, .05); pointer-events: none; }
.mc-row { display: flex; justify-content: space-between; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--bread); }
.member-card .who { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.member-card .who img, .avatar-initial { flex: none; width: 48px; height: 48px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .5); object-fit: cover; }
.avatar-initial { display: flex; align-items: center; justify-content: center; background: var(--bread); color: var(--brown); font-weight: 600; font-size: 20px; }
.member-card .name { font-size: 22px; font-weight: 600; line-height: 1.25; }
.member-card .since { font-size: 12px; color: var(--bread); }
.mc-points { display: flex; align-items: baseline; gap: 8px; margin-top: 18px; }
.mc-points .value { font-size: 48px; font-weight: 600; line-height: 1; color: var(--white); transition: color .3s; }
.mc-points .value.is-new { color: #A8E6B4; }
.mc-points .value.is-spent { color: #F6B892; }
.mc-points .label { color: var(--bread); }
.mc-next { margin-top: 12px; font-size: 13px; color: color-mix(in srgb, var(--bread), #FFFFFF 50%); }
.mc-next-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.mc-next-row b { font-weight: 600; color: var(--white); white-space: nowrap; }
.lp .bar { height: 8px; margin-top: 6px; border-radius: 99px; overflow: hidden; background: rgba(255, 255, 255, .18); }
.lp .bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--bread), var(--white)); transition: width .6s; }
/* The card's goal bar: a little thicker, and a dot of fill even at 0 so it reads as a bar to fill. */
.mc-next .bar { height: 10px; margin-top: 8px; background: rgba(255, 255, 255, .22); }
.mc-next .bar i { min-width: 10px; }
.mc-bottom { position: relative; padding: 22px 22px 18px; text-align: center; border-top: 2px dashed var(--cream-dark); }
.mc-bottom::before, .mc-bottom::after { content: ""; position: absolute; top: -12px; width: 22px; height: 22px; border-radius: 50%; background: var(--cream); }
.mc-bottom::before { left: -11px; }
.mc-bottom::after { right: -11px; }
.member-card .qr { width: 200px; margin: 0 auto; }
.member-card .qr svg { width: 100%; height: auto; display: block; }
.member-card .code { margin-top: 10px; letter-spacing: 4px; font-size: 18px; font-weight: 600; color: var(--brown-dark); }
.member-card .qr-hint { font-size: 13px; color: var(--muted); margin: 2px 0 0; }

.lp .reward { padding: 12px 0; border-bottom-color: var(--line-soft); }
.lp .reward-thumb { width: 64px; height: 64px; border-radius: 16px; }
.lp .reward-name { color: var(--brown-dark); }
.lp .reward .hint { font-size: 12px; }
.lp .reward .btn { border-radius: 99px; padding: 7px 16px; }
.lp .reward.locked .reward-thumb { filter: grayscale(.8); opacity: .6; }
.lp .reward.locked .reward-name { color: var(--brown-dark); }
.lp .reward.locked .btn:disabled { border-radius: 99px; padding: 5px 10px; font-size: 12px; }
.lp .reward .bar { height: 5px; margin-top: 6px; background: var(--line-soft); }
.lp .reward .bar i { min-width: 5px; background: var(--brown-light); }

dl.kv { margin: 0; }
dl.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
dl.kv > div:last-child { border-bottom: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; text-align: right; word-break: break-word; }
.kv-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.kv-actions .btn { border-radius: 99px; padding: 7px 18px; }
.link-danger { background: none; border: 0; padding: 4px 0; font: inherit; font-size: 13px; color: var(--danger); text-decoration: underline; cursor: pointer; }

/* Stock: page header with actions, level bars, the movement form's kind switch, and the count sheet. */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin-bottom: 4px; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-head-actions form { margin: 0; }
.page-form { max-width: 720px; }
.text-warn { color: #B26A00 !important; }
.text-danger { color: var(--danger) !important; }
.badge-danger { background: #F8E1DD; color: var(--danger); }
.sb-badge-warn { background: #D98A00; }
.stats-3 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stats-3 .value { font-size: 26px; }
.stock-table td { vertical-align: top; }
.stock-table tr.is-off td { color: var(--muted); }
.stock-name { display: inline-block; margin-bottom: 2px; }
.stock-table .badges { align-items: center; }
.level { width: 72px; height: 5px; margin: 6px 0 0 auto; border-radius: 99px; background: var(--cream); overflow: hidden; }
.level span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.level.is-low span { background: #D98A00; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.form-grid input[type=number] { width: 100%; }
.sub-box { border: 1px solid var(--cream-dark); border-radius: 12px; padding: 4px 16px 16px; margin: 16px 0 4px; }
.sub-box legend { padding: 0 6px; font-weight: 500; }
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 12px; background: var(--cream); }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 8px 4px; border-radius: 9px; text-align: center; font-size: 14px; color: var(--muted); cursor: pointer; }
.segmented input:checked + span { background: var(--white); color: var(--brown-dark); font-weight: 600; box-shadow: 0 1px 3px rgba(62, 42, 30, 0.15); }
.segmented input:focus-visible + span { outline: 2px solid var(--brown-light); }
.qty-field { display: flex; gap: 8px; align-items: center; }
.qty-field input { flex: 1; min-width: 0; width: 100%; }
.qty-field select { width: auto; flex: none; }
.qty-unit { flex: none; color: var(--muted); font-size: 14px; min-width: 40px; }
.move-form [hidden] { display: none !important; }
.badge.kind-receive { background: var(--green-light); color: var(--green-dark); }
.badge.kind-use { background: var(--cream); color: var(--brown); }
.badge.kind-waste { background: #F8E1DD; color: var(--danger); }
.badge.kind-count { background: #E6EEF8; color: #2F5A8A; }
.count-table .qty-field { justify-content: flex-end; }
.count-table input { max-width: 120px; text-align: right; padding: 6px 10px; }
.count-parts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 12px; }
.count-parts .qty-field { gap: 6px; }
.count-parts input { width: 84px; }
.count-parts .qty-unit { min-width: 0; }
/* Stock item form: sections in cards, a summary beside them on wide screens, a save bar at the bottom on small ones. */
.app-main .page.page-edit { max-width: 1180px; }
.page-sub { margin: 0; }
.edit-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.edit-main { display: grid; gap: 16px; min-width: 0; }
.edit-side { position: sticky; top: 16px; }
.form-section { padding: 22px 24px 24px; margin: 0; }
.fs-head { display: flex; gap: 14px; align-items: flex-start; padding-bottom: 14px; margin-bottom: 4px; border-bottom: 1px solid var(--cream); }
.fs-head h2 { margin: 0 0 2px; font-size: 17px; }
.fs-head p { margin: 0; }
.fs-icon { flex: none; width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--cream); color: var(--brown); }
.opt { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 4px; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-2 input, .form-grid-2 select { width: 100%; }

.type-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin: 16px 0 4px; }
.fs-head > div { flex: 1; min-width: 0; }
.fs-link { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--cream-dark); border-radius: 9px; font-size: 13px; text-decoration: none; color: var(--brown); white-space: nowrap; }
.fs-link:hover { background: var(--cream); }
.fs-link .icon { width: 16px; height: 16px; }
.type-card { margin: 0; cursor: pointer; }
.type-card input { position: absolute; opacity: 0; pointer-events: none; }
.type-card-body { display: flex; gap: 12px; align-items: center; height: 100%; padding: 14px; border: 1.5px solid var(--cream-dark); border-radius: 12px; background: var(--white); transition: border-color .15s, box-shadow .15s, background .15s; }
.type-card-body b { display: block; font-size: 15px; color: var(--brown-dark); }
.type-card-body small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; line-height: 1.4; }
.type-icon { flex: none; width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--cream); color: var(--muted); transition: background .15s, color .15s; }
.type-card:hover .type-card-body { border-color: var(--brown-light); }
.type-card input:checked + .type-card-body { border-color: var(--brown); background: color-mix(in srgb, var(--cream) 45%, var(--white)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brown) 10%, transparent); }
.type-card input:checked + .type-card-body .type-icon { background: var(--brown); color: var(--white); }
.type-card input:focus-visible + .type-card-body { outline: 2px solid var(--brown-light); outline-offset: 2px; }

.base-unit { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: end; margin-top: 4px; }
.base-unit-field input { width: 100%; }
.base-unit-note { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--cream); }
.ratio-pill { flex: none; padding: 3px 10px; border-radius: 999px; background: var(--brown); color: var(--white); font-size: 13px; font-weight: 600; letter-spacing: .5px; }

.unit-table { margin-top: 18px; border: 1px solid var(--cream-dark); border-radius: 12px; overflow: hidden; }
.unit-table-head, .unit-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 10px; align-items: center; padding: 10px 14px; }
.unit-table-head { background: var(--cream); color: var(--brown-dark); font-size: 13px; font-weight: 600; padding-top: 8px; padding-bottom: 8px; }
.unit-row { border-top: 1px solid var(--cream); }
.unit-row:first-child { border-top: 0; }
.unit-row input, .unit-row select { width: 100%; margin: 0; }
.unit-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.unit-one, .unit-eq { flex: none; width: 12px; color: var(--muted); text-align: center; }
.unit-size { color: var(--brown-dark); font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unit-size.is-bad { color: var(--danger); }
.icon-btn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.icon-btn .icon { width: 18px; height: 18px; }
.unit-empty { margin: 0; padding: 16px 14px 4px; text-align: center; }
.unit-table-head[hidden] { display: none; }
.add-row { display: flex; width: calc(100% - 28px); margin: 12px 14px 14px; align-items: center; justify-content: center; gap: 6px; padding: 10px; border: 1.5px dashed var(--brown-light); border-radius: 10px; background: transparent; color: var(--brown); font: inherit; font-weight: 500; cursor: pointer; }
.add-row:hover { background: var(--cream); border-color: var(--brown); }
.add-row .icon { width: 18px; height: 18px; }
.add-row[hidden] { display: none; }

.input-unit { position: relative; }
.input-unit input { width: 100%; padding-right: 72px; }
.input-unit span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }

.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 0; padding: 14px 0; border-bottom: 1px solid var(--cream); cursor: pointer; font-weight: 400; }
.switch-row:last-child { border-bottom: 0; padding-bottom: 0; }
.switch-row b { display: block; font-weight: 500; color: var(--brown-dark); }
.switch-row small { display: block; color: var(--muted); font-size: 13px; }
.switch { position: relative; flex: none; width: 44px; height: 26px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--cream-dark); transition: background .2s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 3px rgba(62, 42, 30, 0.25); transition: transform .2s; }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--brown-light); outline-offset: 2px; }

.summary { margin: 0; padding: 20px; }
.summary-label { font-size: 12px; font-weight: 600; letter-spacing: .4px; color: var(--muted); text-transform: uppercase; }
.summary-name { font-size: 20px; font-weight: 600; color: var(--brown-dark); margin: 6px 0 8px; word-break: break-word; }
.summary-list { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; margin: 16px 0; padding: 14px 0 0; border-top: 1px solid var(--cream); font-size: 14px; }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; text-align: right; color: var(--brown-dark); font-weight: 500; }
.summary-actions { display: grid; gap: 8px; }
.edit-bar { display: none; }

@media (max-width: 1099px) {
    .edit-layout { grid-template-columns: minmax(0, 1fr); }
    .edit-side { display: none; }
    .edit-bar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; margin-top: 4px; background: var(--white); border-radius: var(--radius); box-shadow: 0 -2px 12px rgba(62, 42, 30, 0.10); }
}
@media (max-width: 700px) {
    .form-section { padding: 18px 16px 20px; }
    .type-cards { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
    .fs-head { flex-wrap: wrap; }
    .fs-link { margin-left: 54px; }
    .type-card-body { flex-direction: column; gap: 6px; padding: 12px 6px; text-align: center; }
    .type-card-body b { font-size: 14px; }
    .type-card-body small { display: none; }
    .form-grid-2, .base-unit { grid-template-columns: minmax(0, 1fr); }
    .base-unit { gap: 10px; }
    .unit-table-head { display: none; }
    .unit-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; grid-template-areas: "name per remove" "of size size"; padding: 12px; }
    .unit-row > .unit-cell:nth-child(1) { grid-area: name; }
    .unit-row > .unit-cell:nth-child(2) { grid-area: per; }
    .unit-row > .unit-of { grid-area: of; }
    .unit-row > .unit-size { grid-area: size; }
    .unit-row > .unit-remove { grid-area: remove; }
    .edit-bar .btn { flex: 1; }
}
/* Phone: each counted line becomes a small card, the boxes for its units under the name. */
@media (max-width: 700px) {
    .count-table, .count-table tbody { display: block; }
    .count-table thead { display: none; }
    .count-table .group-row, .count-table .group-row td { display: block; }
    .count-table tr[data-onhand] { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 10px 12px; border-bottom: 1px solid var(--cream-dark); }
    .count-table tr[data-onhand] td { padding: 0; border: 0; }
    .count-table tr[data-onhand] td:nth-child(3), .count-table tr[data-onhand] td.diff { grid-column: 1 / -1; }
    .count-table .count-parts { justify-content: flex-start; }
    .count-parts input { width: 72px; }
}
.count-table .group-row td { background: var(--cream); color: var(--brown-dark); font-weight: 600; font-size: 13px; padding: 6px 12px; }
.count-bar { position: sticky; bottom: 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 12px; padding: 12px 16px; background: var(--white); border-radius: var(--radius); box-shadow: 0 -2px 12px rgba(62, 42, 30, 0.10); }
.count-bar input { flex: 1 1 240px; width: auto; }
.move-form input[type=number] { width: 100%; }
@media (max-width: 600px) {
  .app .stats-3 > :last-child { grid-column: span 2; }
}
@media (max-width: 1099px) {
  /* On a phone the stock form comes first, under the item's name: recording is what staff open it for. */
  .cols > .move-form { order: -1; }
}
.segmented-3 { grid-template-columns: repeat(3, 1fr); }
.chip-rows { display: grid; gap: 8px; margin-bottom: 12px; }
.chip-soft.active { background: var(--cream-dark); color: var(--brown-dark); border-color: var(--cream-dark); }
.stock-table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.stock-table .row-actions form { margin: 0; }
.branch-table .row-actions { flex-wrap: wrap; min-width: 150px; }
.app-main .page.page-form { max-width: 760px; }

/* Stock types and categories page. */
.app-main .page.page-types { max-width: 1180px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.type-panel { margin: 0; padding: 18px 20px 20px; }
.type-panel.is-off { background: color-mix(in srgb, var(--white) 70%, var(--cream)); }
.type-panel.is-off .tp-icon { background: var(--cream-dark); color: var(--muted); }
.tp-head { display: flex; gap: 12px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--cream); }
.tp-icon { flex: none; width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--brown); color: var(--white); }
.tp-title { flex: 1; min-width: 0; }
.tp-title h2 { margin: 0; font-size: 17px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tp-actions, .cat-actions { display: flex; align-items: center; gap: 2px; }
.tp-actions form, .cat-actions form { margin: 0; }
.icon-btn-plain:hover { background: var(--cream); color: var(--brown); }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > summary { background: var(--cream); color: var(--brown); }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 280px; padding: 14px; background: var(--white); border: 1px solid var(--cream-dark); border-radius: 12px; box-shadow: 0 12px 32px rgba(62, 42, 30, 0.16); }
.menu-panel label:first-child { margin-top: 0; }
.menu-panel input[type=text] { width: 100%; }
.menu-panel .btn { margin-top: 12px; }
.menu-sep { height: 1px; background: var(--cream); margin: 12px -14px 6px; }
.menu-item { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 6px; border: 0; border-radius: 8px; background: transparent; font: inherit; font-size: 14px; color: var(--brown-dark); cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--cream); }
.menu-item .icon { width: 17px; height: 17px; color: var(--muted); }
.menu-item.is-danger, .menu-item.is-danger .icon { color: var(--danger); }
.menu-note { margin: 6px 6px 0; }
.icon-pick { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.type-new .icon-pick { max-width: 360px; }
.icon-pick label { margin: 0; cursor: pointer; }
.icon-pick input { position: absolute; opacity: 0; pointer-events: none; }
.icon-pick span { display: flex; align-items: center; justify-content: center; height: 36px; border-radius: 9px; border: 1px solid var(--cream-dark); color: var(--muted); }
.icon-pick input:checked + span { background: var(--brown); border-color: var(--brown); color: var(--white); }
.icon-pick input:focus-visible + span { outline: 2px solid var(--brown-light); }
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0 6px 4px; border-bottom: 1px solid var(--cream); }
.cat-list li.is-off .cat-name { color: var(--muted); }
.cat-name { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--brown-dark); }
.cat-count { flex: none; color: var(--muted); font-size: 13px; }
.cat-empty { padding: 14px 4px !important; }
.cat-add { display: flex; gap: 8px; margin-top: 12px; }
.cat-add input { flex: 1; min-width: 0; width: auto; }
.cat-add .btn { display: inline-flex; align-items: center; gap: 4px; }
.cat-add .icon { width: 16px; height: 16px; }
.type-new { border: 1.5px dashed var(--brown-light); background: transparent; box-shadow: none; }
.type-new .tp-icon { background: var(--cream); color: var(--brown); }
.type-new form .btn { margin-top: 14px; }
.type-new input[type=text] { width: 100%; }
@media (max-width: 700px) {
    .type-grid { grid-template-columns: minmax(0, 1fr); }
    .menu-panel { width: min(280px, calc(100vw - 48px)); }
}

/* Import from Excel */
.alert-warn { background: #FFF1D6; color: #8A5600; }
.import-result + .import-steps { margin-top: 30px; }
.page-head-actions .btn .icon, .import-step .btn .icon, .import-upload .btn .icon { width: 16px; height: 16px; vertical-align: -3px; margin-right: 2px; }
.import-steps { margin-top: 26px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.import-step { margin-bottom: 0; position: relative; padding-top: 22px; display: flex; flex-direction: column; gap: 6px; }
.import-step h2 { margin: 0; font-size: 17px; }
.import-step p { margin: 0 0 8px; }
.import-step > .btn { align-self: flex-start; margin-top: auto; }
.step-no { position: absolute; top: -12px; left: 18px; width: 28px; height: 28px; border-radius: 50%; background: var(--brown); color: var(--white); display: grid; place-items: center; font-weight: 600; font-size: 14px; }
.import-notes { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.import-notes li + li { margin-top: 4px; }
.import-upload { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.file-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 16px 12px; border: 1.5px dashed var(--brown-light); border-radius: 12px; background: var(--cream); cursor: pointer; text-align: center; }
.file-drop:hover, .file-drop:focus-within { border-color: var(--brown); }
.file-drop .icon { width: 28px; height: 28px; color: var(--brown); }
.file-drop .file-name { font-weight: 600; color: var(--brown-dark); word-break: break-all; }
.file-drop.has-file { border-style: solid; border-color: var(--ok); background: #EEF5E8; }
.file-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.import-upload .btn { align-self: stretch; }
.import-columns summary { cursor: pointer; font-weight: 600; color: var(--brown-dark); }
.import-columns table { margin-top: 12px; }
.import-columns .req { color: var(--danger); }
.import-result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.import-result-head h2 { margin: 0 0 6px; font-size: 18px; }
.import-result-head h2 .muted { font-size: 14px; font-weight: 400; }
.import-counts { display: flex; gap: 6px; flex-wrap: wrap; }
.import-save { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
.import-skip { margin: 4px 0; }
.import-only-errors { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; margin-bottom: 8px; cursor: pointer; }
.import-table td { white-space: nowrap; }
.import-table td:nth-child(2) { white-space: normal; min-width: 220px; }
.import-table tr.is-error td { background: #FCF1EF; }
.import-table.only-errors tbody tr:not(.is-error) { display: none; }
.import-error { color: var(--danger); font-size: 13px; margin-top: 2px; }
@media (max-width: 900px) {
    .import-steps { grid-template-columns: minmax(0, 1fr); gap: 22px; }
}

/* Settings: stock alerts in LINE */
.alert-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.alert-head h2 { margin: 0; }
.alert-kinds { margin-top: 8px; }
.alert-percent { display: flex; align-items: center; gap: 12px; padding-top: 10px; }
.alert-percent label { margin: 0; flex: 1; }
.alert-percent .input-unit { width: 120px; }
.alert-percent .input-unit input { padding-right: 32px; }
.alert-sub { margin: 18px 0 6px; font-size: 15px; }
.staff-picks { display: grid; gap: 6px; }
.staff-pick { display: flex; align-items: center; gap: 10px; margin: 0; padding: 8px 10px; border: 1px solid var(--cream-dark); border-radius: 10px; cursor: pointer; font-weight: 400; }
.staff-pick:has(input:checked) { border-color: var(--brown); background: var(--cream); }
.staff-pick input { width: 18px; height: 18px; flex: none; accent-color: var(--brown); }
.staff-pick img, .staff-pick .sb-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; }
.staff-pick b { display: block; font-weight: 500; color: var(--brown-dark); line-height: 1.2; }
.staff-pick small { display: block; color: var(--muted); font-size: 12px; }

/* Receive form: receipt photo */
.receipt-pick { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px dashed var(--brown-light); border-radius: 10px; background: var(--cream); cursor: pointer; position: relative; margin: 0; font-weight: 400; }
.receipt-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.receipt-pick .icon { color: var(--brown); }
.receipt-pick.has-file { border-style: solid; border-color: var(--ok); background: #EEF5E8; }
.receipt-thumb { display: none; width: 44px; height: 44px; border-radius: 8px; object-fit: cover; margin-left: auto; }
.receipt-pick.has-file .receipt-thumb { display: block; }
.receipt-link { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; white-space: nowrap; }
.receipt-link .icon { width: 15px; height: 15px; }

/* Page changes in the back office: fade between pages instead of a white flash; the menu and top bar stay put. */
@view-transition { navigation: auto; }
.sidebar { view-transition-name: sidebar; }
.app-top { view-transition-name: app-top; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }
::view-transition-group(sidebar), ::view-transition-group(app-top) { animation-duration: 0s; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* Loader while the next page takes a moment: the whole page fades back a little and treats take turns inside a ring that fills up. */
.page-loader {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(250, 244, 234, 0.55); opacity: 0; visibility: hidden; transition: opacity .18s ease, visibility 0s linear .18s;
}
.page-loader.on { opacity: 1; visibility: visible; transition: opacity .18s ease; cursor: progress; }
.pl-card { text-align: center; }
.pl-ring-wrap { position: relative; width: 120px; height: 120px; margin: 0 auto; }
.pl-ring { position: absolute; inset: 0; transform: rotate(-90deg); filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.9)); }
.pl-ring circle { fill: none; stroke-width: 6; }
.pl-track { stroke: var(--cream-dark); opacity: .7; }
.pl-progress { stroke: var(--brown); stroke-linecap: round; }
.pl-treats { position: absolute; inset: 22px; filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.95)); }
.pl-treat { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transform: scale(.7) rotate(-12deg); transition: opacity .25s ease, transform .35s cubic-bezier(.3,1.6,.5,1); }
.pl-treat.on { opacity: 1; transform: none; animation: pl-bob .7s ease-in-out infinite alternate; }
@keyframes pl-bob { to { transform: translateY(-4px); } }
.pl-name { margin-top: 8px; font-weight: 600; color: var(--brown); font-size: 15px; text-shadow: 0 0 4px #fff, 0 0 8px #fff, 0 0 12px #fff; }
@media (prefers-reduced-motion: reduce) { .pl-treat.on { animation: none; } }

/* The same treats while a LINE page (member card, staff) loads: CSS only, no overlay. */
.treat-loading { display: flex; flex-direction: column; align-items: center; margin: 56px auto; text-align: center; }
.treat-loading .pl-treat { animation: pl-turn 4.2s infinite; }
.treat-loading .pl-treat:nth-child(2) { animation-delay: .7s; }
.treat-loading .pl-treat:nth-child(3) { animation-delay: 1.4s; }
.treat-loading .pl-treat:nth-child(4) { animation-delay: 2.1s; }
.treat-loading .pl-treat:nth-child(5) { animation-delay: 2.8s; }
.treat-loading .pl-treat:nth-child(6) { animation-delay: 3.5s; }
@keyframes pl-turn {
  0% { opacity: 0; transform: scale(.7) rotate(-12deg); }
  4%, 14% { opacity: 1; transform: none; }
  18%, 100% { opacity: 0; transform: scale(.7) rotate(-12deg); }
}
.treat-loading .pl-progress { stroke-dasharray: 339.3; stroke-dashoffset: 339.3; animation: pl-fill 8s cubic-bezier(.1,.6,.3,1) forwards; }
@keyframes pl-fill { to { stroke-dashoffset: 33.9; } }
@media (prefers-reduced-motion: reduce) { .treat-loading .pl-treat { animation: none; } .treat-loading .pl-treat:first-child { opacity: 1; transform: none; } }

/* Menu items and recipes. */
.recipe-cell { display: flex; align-items: center; gap: 12px; }
.recipe-thumb { flex: none; width: 44px; height: 44px; border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--cream); color: var(--brown-light); }
.recipe-thumb img { width: 100%; height: 100%; object-fit: cover; }
.recipe-thumb .icon { width: 22px; height: 22px; }
.recipe-thumb-lg { width: 64px; height: 64px; border-radius: 12px; }
.recipe-thumb-lg .icon { width: 28px; height: 28px; }
.recipe-photo { display: flex; align-items: center; gap: 12px; }
.recipe-photo input[type=file] { width: 100%; font-size: 13px; }
.fc-level { width: 64px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-3 input { width: 100%; }
.yield-pair { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 8px; }
.yield-pair input { width: 100%; }
.input-unit span span { position: static; transform: none; }
.line-table { margin-top: 4px; border: 1px solid var(--cream-dark); border-radius: 12px; overflow: hidden; }
.line-table-head, .line-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, .9fr) minmax(0, 1.3fr) 104px 40px; gap: 10px; align-items: center; padding: 10px 14px; }
.line-table-head { background: var(--cream); color: var(--brown-dark); font-size: 13px; font-weight: 600; padding-top: 8px; padding-bottom: 8px; }
.line-table-head .num, .line-row .num { text-align: right; }
.line-row { border-top: 1px solid var(--cream); }
.line-row:first-child { border-top: 0; }
.line-row input, .line-row select { width: 100%; margin: 0; }
.line-row select:disabled { color: var(--muted); background: var(--cream); opacity: 1; }
.line-cost { color: var(--brown-dark); font-weight: 500; font-size: 14px; white-space: nowrap; }
.line-cost.is-bad { color: var(--danger); font-size: 12px; }
.line-foot { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--cream); }
.line-foot .add-row { flex: 1; width: auto; margin-right: 0; }
.line-total { padding-right: 68px; white-space: nowrap; color: var(--muted); font-size: 14px; }
.line-total b { color: var(--brown-dark); font-size: 16px; }
.cost-hero { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin: 12px 0 4px; }
.cost-hero .hint { width: 100%; }
.cost-hero b { font-size: 34px; font-weight: 600; color: var(--brown-dark); line-height: 1.1; }
.fc-meter { margin-top: 10px; }
.fc-meter[hidden] { display: none; }
.fc-meter-bar { position: relative; height: 8px; border-radius: 99px; background: var(--cream); }
.fc-meter-bar span { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width .2s ease; }
.fc-meter-bar i { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 1px; background: var(--brown-light); }
.fc-meter.is-high .fc-meter-bar span { background: #D98A00; }
.fc-meter-text { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 14px; }
.fc-meter.is-high #sum-fc { color: #B26A00; }
.summary-warn { margin: 0 0 14px; font-size: 13px; }
.side-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
@media (max-width: 1099px) { .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
    .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
    .line-table-head { display: none; }
    .line-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; grid-template-areas: "item item remove" "qty unit unit" "cost cost cost"; padding: 12px; }
    .line-row > .line-item { grid-area: item; }
    .line-row > .line-qty { grid-area: qty; }
    .line-row > .line-unit { grid-area: unit; }
    .line-row > .line-cost { grid-area: cost; text-align: right; }
    .line-row > .line-cost:empty { display: none; }
    .line-row > .line-remove { grid-area: remove; }
    .line-foot { flex-direction: column; align-items: stretch; gap: 0; }
    .line-foot .add-row { margin-right: 14px; }
    .line-total { padding: 0 14px 14px; text-align: right; }
}
.badge.kind-produce { background: #F3E8FB; color: #6B3D8F; }

/* Production page. */
.need-list { margin: 4px 0 14px; border: 1px solid var(--cream); border-radius: 10px; overflow: hidden; }
.need-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px 62px 84px; gap: 6px; align-items: baseline; padding: 8px 12px; font-size: 14px; border-top: 1px solid var(--cream); }
.need-row:first-child { border-top: 0; }
.need-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.need-row > b { text-align: right; font-variant-numeric: tabular-nums; }
.need-row > i { margin-right: 4px; font-style: normal; font-size: 13px; color: var(--muted); white-space: nowrap; }
.need-row > small { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.need-row.is-short { background: #FBEDEA; }
.need-row.is-short > b, .need-row.is-short > i, .need-row.is-short > small { color: var(--danger); }

/* Kitchen tab on the LINE staff page. */
.staff-tabs { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; margin-bottom: 12px; }
.staff-h2 { margin: 0 0 4px; font-size: 17px; }
.menu-pick { display: grid; gap: 8px; margin-top: 12px; }
.menu-pick-item { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; padding: 14px 16px; border: 1px solid var(--cream-dark); border-radius: 12px; background: var(--white); font: inherit; font-size: 16px; font-weight: 600; color: var(--brown-dark); text-align: left; cursor: pointer; }
.menu-pick-item small { font-weight: 400; font-size: 13px; color: var(--muted); white-space: nowrap; }
.menu-pick-item:active { background: var(--cream); }
.today-list { list-style: none; margin: 8px 0 0; padding: 0; }
.today-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--cream); }
.today-list li:first-child { border-top: 0; }
.today-list li > span:first-child { display: grid; }
.today-list small { color: var(--muted); font-size: 13px; }
.today-list li > span:last-child { white-space: nowrap; font-weight: 600; }
.produce-name { margin: 2px 0 14px; }
.stepper { display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; gap: 8px; }
.stepper .btn { padding: 0; font-size: 22px; }
.stepper input { text-align: center; font-size: 20px; font-weight: 600; }
.lot-no { font-size: 18px; margin: 4px 0; }
.stepper .btn { border-radius: 12px; }

/* Production history: one row a run, its ingredients folded under it. */
.run-list { background: var(--white); border-radius: var(--radius); overflow: hidden; container: runs / inline-size; }
.run-head, .run { display: grid; grid-template-columns: 52px minmax(0, 1fr) 76px 96px 64px; column-gap: 14px; padding: 14px 18px; }
.run-head { padding: 10px 18px; background: var(--cream-dark); color: var(--brown-dark); font-size: 12px; font-weight: 600; }
.run-head .num { text-align: right; }
.run { border-top: 1px solid var(--cream); align-items: start; }
.run:first-of-type { border-top: 0; }
.run:hover { background: #FFFCF7; }
.run-when { display: grid; gap: 0; line-height: 1.35; padding-top: 1px; }
.run-when b { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.run-when small { font-size: 12px; color: var(--muted); }
.run-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.run-name b { font-size: 15px; font-weight: 600; color: var(--brown-dark); }
.run-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.run-meta > span + span::before { content: "·"; margin: 0 7px; color: var(--brown-light); }
.run-meta em { font-style: normal; }
.lot-pill { padding: 0 7px; border-radius: 6px; background: var(--cream); color: var(--brown); font-size: 12px; font-variant-numeric: tabular-nums; letter-spacing: .02em; white-space: nowrap; }
.run-meta > .lot-pill + span::before { margin-left: 8px; }
.run-note { margin-top: 6px; padding-left: 8px; border-left: 2px solid var(--bread); font-size: 13px; color: var(--brown); }
.run-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.35; padding-top: 1px; }
.run-num b { font-size: 15px; font-weight: 600; }
.run-num > span { font-size: 12px; color: var(--muted); }
.run-num small { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.run-act { text-align: right; }
.run-act form { margin: 0; }
.btn-ghost-sm { padding: 2px 10px; border: 1px solid var(--cream-dark); border-radius: 999px; background: none; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; }
.btn-ghost-sm:hover { border-color: var(--danger); color: var(--danger); background: #FBEDEA; }
.run.is-off { background: #FCFAF7; }
.run.is-off .run-when, .run.is-off .run-num, .run.is-off .run-meta, .run.is-off .run-taken { opacity: .6; }
.run.is-off .run-name b { text-decoration: line-through; color: var(--muted); }
.run-taken { grid-column: 2 / -1; margin-top: 8px; font-size: 13px; }
.run-taken summary { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; color: var(--brown); font-size: 12.5px; list-style: none; }
.run-taken summary::-webkit-details-marker { display: none; }
.run-taken summary::before { content: ""; width: 5px; height: 5px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.run-taken[open] summary::before { transform: rotate(45deg) translate(-1px, -1px); }
.run-taken table { width: 100%; margin-top: 8px; border-collapse: collapse; background: var(--cream); border-radius: 10px; overflow: hidden; }
.run-taken td { padding: 6px 12px; border: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.run-taken td.num { text-align: right; width: 1%; }
.run-taken td.unit { width: 1%; padding-left: 0; color: var(--muted); white-space: nowrap; }
.run-taken tbody tr + tr td { border-top: 1px solid #F1E6D3; }
.run-taken tfoot td { border-top: 1px solid var(--cream-dark); font-weight: 600; color: var(--brown-dark); }
/* Narrow list (a phone, or a laptop with the form beside it): stack each run. */
@container runs (max-width: 560px) {
  .run-head { display: none; }
  .run { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; grid-template-areas: "when when act" "what what what" "qty cost cost" "taken taken taken"; row-gap: 8px; padding: 14px 16px; }
  .run-when { grid-area: when; display: flex; gap: 8px; align-items: baseline; }
  .run-what { grid-area: what; }
  .run-act { grid-area: act; }
  .run-qty { grid-area: qty; text-align: left; }
  .run-cost { grid-area: cost; }
  .run { column-gap: 0; }
  .run-qty, .run-cost { padding: 10px 0 0; border-top: 1px solid var(--cream); }
  .run-taken { grid-area: taken; margin-top: 0; }
  .run-qty::before, .run-cost::before { display: block; margin-bottom: 1px; font-size: 11.5px; color: var(--muted); }
  .run-qty::before { content: "ได้"; }
  .run-cost::before { content: "ต้นทุนวัตถุดิบ"; }
}
.run-exp { margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.run-exp em { font-style: normal; }
.run.is-off .run-exp { opacity: .6; }
/* On the LINE staff page (a phone), what is on hand goes under the name so the name has room. */
.staff-page .need-row { grid-template-columns: minmax(0, 1fr) 76px 66px; row-gap: 0; }
.staff-page .need-row > span { white-space: normal; }
.staff-page .need-row > small { grid-column: 1; grid-row: 2; text-align: left; font-size: 12px; }

/* Allergens: tick boxes on the item and recipe forms, and the tags they show as. */
.allergen-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-top: 12px; }
.allergen-pick .allergen-opt { position: relative; margin: 0; cursor: pointer; font-weight: 400; font-size: inherit; }
.allergen-opt input { position: absolute; opacity: 0; pointer-events: none; }
.allergen-opt span { display: grid; gap: 1px; height: 100%; padding: 9px 12px 9px 36px; border: 1px solid var(--cream-dark); border-radius: 10px; background: var(--white); transition: border-color .12s, background .12s; }
.allergen-opt span::before { content: ""; position: absolute; left: 12px; top: 12px; width: 16px; height: 16px; border: 1.5px solid var(--brown-light); border-radius: 5px; background: var(--white); }
.allergen-opt b { font-weight: 500; font-size: 14px; color: var(--brown-dark); }
.allergen-opt small { font-size: 12px; line-height: 1.35; color: var(--muted); }
.allergen-opt:hover span { border-color: var(--brown-light); }
.allergen-opt input:checked + span { border-color: #D9A441; background: #FFF6E3; }
.allergen-opt input:checked + span::before { border-color: #B26A00; background: #B26A00 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E") center / 12px no-repeat; }
.allergen-opt input:focus-visible + span { outline: 2px solid var(--brown-light); outline-offset: 1px; }
.allergen-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.allergen-tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: #FFF1D6; color: #8A5600; font-size: 12px; line-height: 20px; white-space: nowrap; }
.allergen-tag.may { background: transparent; color: var(--muted); border: 1px dashed var(--brown-light); line-height: 18px; }
.allergen-found { margin: 12px 0 18px; }
.allergen-found-label { margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--brown-dark); }
.allergen-from { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.allergen-from li { display: flex; align-items: baseline; gap: 10px; font-size: 13px; color: var(--muted); }
.allergen-from .allergen-tag { min-width: 72px; justify-content: center; }
#allergen-none { margin: 6px 0 0; font-size: 13px; }
.sum-allergens { margin: 12px 0 16px; padding-top: 12px; border-top: 1px solid var(--cream); }
.sum-allergens .summary-label { margin-bottom: 6px; }
.recipe-allergens { margin-top: 5px; }
.produce-allergens { margin: -8px 0 16px; }
.allergen-opt input:disabled + span { opacity: .5; cursor: default; background: var(--cream); }

/* Settings: one tab per topic. Without script every panel shows, one under another. */
.settings-tabs { display: flex; gap: 4px; margin: 0 0 18px; border-bottom: 1px solid var(--cream-dark); overflow-x: auto; scrollbar-width: none; }
.settings-tabs::-webkit-scrollbar { display: none; }
.settings-tabs a { position: relative; display: flex; align-items: center; gap: 6px; flex: none; padding: 10px 14px 12px; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.settings-tabs a:hover { color: var(--brown-dark); }
.settings-tabs a.active { color: var(--brown-dark); border-bottom-color: var(--brown); }
.tab-dot { width: 7px; height: 7px; border-radius: 50%; background: #D9922E; }
.settings-page.tabs-ready .settings-panel { display: none; }
.settings-page.tabs-ready .settings-panel.active { display: block; }
.settings-narrow { max-width: 720px; }
.settings-panel .feature-list { margin-top: 14px; border-top: 1px solid var(--cream); }
.settings-panel .color-row { margin-bottom: 4px; }
.alert-cols { margin-top: 6px; }
.alert-cols .alert-sub { margin-top: 0; }
@media (max-width: 1099px) { .alert-cols .alert-sub { margin-top: 18px; } }
@media (max-width: 600px) { .settings-tabs a { padding: 10px 10px 12px; } }

/* A branch picked right in a table row (accounts, staff). */
.inline-pick { margin: 0; }
.inline-pick select { width: auto; min-width: 140px; padding: 6px 30px 6px 10px; font-size: 14px; }

/* Transfers between branches. */
.badge.kind-xfer-out { background: #FBEBDD; color: #9A5214; }
.badge.kind-xfer-in { background: #E1F1EF; color: #23695F; }
.badge.kind-xfer-loss { background: #F8E1DD; color: var(--danger); }
.badge.xfer-draft { background: #EEE; color: #666; }
.badge.xfer-sent { background: #FFF1D6; color: #9A6200; }
.badge.xfer-received { background: var(--green-light); color: var(--green-dark); }
.badge.xfer-cancelled { background: #EEE; color: #888; text-decoration: line-through; }
.chip-count { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 5px; border-radius: 99px; background: #D9922E; color: var(--white); font-size: 11px; line-height: 18px; text-align: center; }
.xfer-table tr.is-waiting td { background: #FFF8EA; }
.xfer-route { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--brown-dark); }
.xfer-route .icon { width: 18px; height: 18px; color: var(--muted); }
.xfer-route .badge { margin-left: 4px; }
.xfer-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 14px; }
.xfer-step { display: grid; gap: 1px; padding: 10px 12px; border-radius: 12px; background: var(--white); border: 1px dashed var(--cream-dark); font-size: 14px; color: var(--muted); min-width: 0; }
.xfer-step b { color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xfer-step.is-done { border-style: solid; }
.xfer-step.is-done b { color: var(--brown-dark); }
.xfer-step.is-cancel { border-style: solid; border-color: #F0CFC9; }
.xfer-step .hint { font-size: 12px; }
.xfer-lots { font-size: 13px; color: var(--muted); }
.xfer-detail tfoot td { border-top: 2px solid var(--cream-dark); font-weight: 500; }
.xfer-detail .qty-field { justify-content: flex-end; }
.xfer-detail .qty-field input { width: 110px; text-align: right; }
.xfer-detail select { width: auto; min-width: 150px; margin: 0; }
.xfer-detail tr.is-short td { background: #FDF3F1; }
.xfer-receive { margin-top: 16px; max-width: 640px; }
.xfer-receive .actions { align-items: center; justify-content: flex-end; }
.xfer-switch { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.xfer-form { display: grid; gap: 16px; max-width: 980px; }
.xfer-actions { justify-content: flex-end; margin-top: 0; }
.xfer-lines .line-table-head, .xfer-lines .line-row { grid-template-columns: minmax(0, 2fr) minmax(0, .8fr) minmax(0, 1.2fr) minmax(0, 2fr) 40px; }
.xfer-lines .line-have { grid-column: 1 / -1; margin-top: -4px; }
.xfer-lines .line-have:empty { display: none; }
@media (max-width: 700px) {
    .xfer-step { padding: 8px 10px; font-size: 13px; }
    /* On phones each line of a transfer is a small card: name on top, then each figure with its label. */
    .xfer-detail thead { display: none; }
    .xfer-detail, .xfer-detail tbody, .xfer-detail tfoot, .xfer-detail tr { display: block; }
    .xfer-detail tbody tr { padding: 10px 12px; border-bottom: 1px solid var(--cream); }
    .xfer-detail tbody td { display: block; padding: 3px 0; border: 0; text-align: right; overflow: hidden; }
    .xfer-detail tbody td::before { content: attr(data-label); float: left; margin-right: 12px; color: var(--muted); font-size: 13px; line-height: 2; }
    .xfer-detail tbody td.xd-name { text-align: left; }
    .xfer-detail .qty-field { display: inline-flex; }
    .xfer-detail tbody td.xd-name { font-weight: 600; padding-bottom: 4px; }
    .xfer-detail tbody td.xd-name::before { content: none; }
    .xfer-detail tbody td.xfer-lots { text-align: right; }
    .xfer-detail tbody td .hint { display: inline; margin-left: 4px; }
    .xfer-detail tfoot tr { display: flex; justify-content: space-between; padding: 10px 12px; }
    .xfer-detail tfoot td { border: 0; padding: 0; }
    .xfer-detail tfoot td:empty { display: none; }
    .xfer-lines .line-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; grid-template-areas: "item item remove" "qty unit unit" "lot lot lot" "have have have"; }
    .xfer-lines .line-row > .line-lot { grid-area: lot; }
    .xfer-lines .line-row > .line-have { grid-area: have; margin-top: 0; }
}

/* All-branch overview and the expiry report. */
.level-table td.level-low { background: #FFF1D6; color: #8A5600; font-weight: 600; }
.level-table td.level-none { color: var(--brown-light); }
.expiry-branch { margin-top: 18px; }
.expiry-branch h2 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.expiry-branch h2 .hint { font-weight: 400; }
.expiry-table tr.is-past td { background: #FDF3F1; }
.expiry-table { table-layout: fixed; min-width: 640px; }

/* Login: the shop's brand on the left, the form on the right; on phones the form alone with a small logo above it. */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(360px, 5fr) 7fr; background: var(--white); }
.login-brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  padding: 40px 48px;
  background: linear-gradient(155deg, var(--brown) 0%, var(--brown-dark) 100%);
  color: var(--cream);
}
.login-brand::before, .login-brand::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(230, 206, 162, 0.22) 0%, rgba(230, 206, 162, 0) 70%);
}
.login-brand::before { width: 520px; height: 520px; right: -220px; top: -160px; }
.login-brand::after { width: 420px; height: 420px; left: -180px; bottom: -200px; }
.login-brand > * { position: relative; }
.login-brand-top { display: flex; align-items: center; gap: 14px; }
.login-logo {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 56px; height: 56px; border-radius: 16px; background: var(--white); overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.login-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.login-logo .logo-fallback { width: 100%; height: 100%; border-radius: 0; display: flex; align-items: center; justify-content: center; color: var(--white); font-size: 24px; font-weight: 600; }
.login-brand-name { font-size: 22px; font-weight: 600; color: var(--white); letter-spacing: 0.2px; }
.login-brand-body h2 { color: var(--white); font-size: 34px; line-height: 1.25; margin: 0 0 12px; font-weight: 600; }
.login-brand-body p { margin: 0 0 28px; color: var(--bread); font-size: 17px; max-width: 26em; }
.login-brand-body ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.login-brand-body li { display: flex; align-items: center; gap: 12px; color: var(--cream); }
.login-brand-body li .icon {
  width: 36px; height: 36px; padding: 8px; flex: none; border-radius: 10px;
  background: rgba(255, 255, 255, 0.1); stroke: var(--bread); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.login-brand-foot { margin: 0; font-size: 13px; color: var(--brown-light); }

.login-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--white); }
.login-form { width: 100%; max-width: 380px; }
.login-form h1 { font-size: 30px; margin: 0 0 6px; }
.login-sub { margin: 0 0 24px; color: var(--muted); }
.login-form label { margin: 16px 0 6px; font-size: 15px; }
.login-field { position: relative; }
.login-field > .icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; pointer-events: none;
  fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.login-field input[type=text], .login-field input[type=password] {
  height: 50px; padding: 0 14px 0 44px; border-radius: 12px; border-color: var(--cream-dark); background: #FDFBF7;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.login-field input:focus { outline: none; border-color: var(--brown); background: var(--white); box-shadow: 0 0 0 4px rgba(99, 61, 28, 0.12); }
.login-field input[type=password], .login-field input#Password { padding-right: 48px; }
.login-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.login-eye:hover { background: var(--cream); color: var(--brown); }
.login-eye:focus-visible { outline: 2px solid var(--brown-light); }
.login-eye span { display: inline-flex; }
.login-eye span[hidden] { display: none; }
.login-eye .icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.login-caps { margin: 8px 0 0; font-size: 13px; color: #9A6A12; }
.login-submit {
  margin-top: 28px; height: 52px; border-radius: 12px; font-size: 17px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 8px 20px rgba(99, 61, 28, 0.22); transition: transform .1s, box-shadow .15s, background .15s;
}
.login-submit:hover { box-shadow: 0 10px 24px rgba(99, 61, 28, 0.28); }
.login-submit:active { transform: translateY(1px); }
.login-spin { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: var(--white); animation: login-spin .7s linear infinite; }
.login-submit.busy .login-spin { display: inline-block; }
.login-submit.busy, .login-submit:disabled { opacity: 0.85; }
@keyframes login-spin { to { transform: rotate(360deg); } }
.login-help { margin: 20px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.login-form .alert { margin: 0 0 4px; }
.login-mobile-brand { display: none; }

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; background: var(--cream); }
  .login-brand { display: none; }
  .login-main { align-items: flex-start; padding: 32px 16px; background: var(--cream); }
  .login-form { max-width: 420px; margin: 0 auto; background: var(--white); border-radius: 20px; padding: 28px 22px; box-shadow: 0 10px 30px rgba(62, 42, 30, 0.08); }
  .login-mobile-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; font-weight: 600; font-size: 18px; color: var(--brown-dark); }
  .login-mobile-brand .login-logo { width: 46px; height: 46px; border-radius: 13px; box-shadow: 0 2px 8px rgba(62, 42, 30, 0.12); }
  .login-form h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { .login-spin { animation-duration: 2s; } .login-submit, .login-field input { transition: none; } }

/* Points by QR. Staff: pick the points, show the QR, wait for the customer. Member: take the points. */
.settings-sub { margin-top: 24px; }
.give-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 16px; }
.give-pick { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 72px; padding: 8px; border: 1.5px solid var(--cream-dark); border-radius: 14px; background: var(--white); color: var(--brown-dark); font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.give-pick b { font-size: 28px; line-height: 1; }
.give-pick small { font-size: 13px; opacity: .75; }
.give-pick.active { background: var(--brown-dark); border-color: var(--brown-dark); color: var(--white); }
.give-pick:active { transform: scale(.97); }
.give-stepper input { font-size: 30px; height: 56px; }
.give-stepper .btn { height: 56px; }
.give-title { margin: 4px 0 2px; font-size: 38px; }
.give-qr { width: min(260px, 80%); margin: 14px auto 10px; padding: 10px; background: var(--white); border-radius: 16px; border: 1px solid var(--cream-dark); }
.give-qr svg { width: 100%; height: auto; display: block; }
.give-qr.is-off { opacity: .2; filter: grayscale(1); }
.give-wait { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px 0 8px; color: var(--brown-dark); }
.give-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); animation: give-pulse 1.2s ease-in-out infinite; }
@keyframes give-pulse { 0%, 100% { transform: scale(.7); opacity: .5; } 50% { transform: scale(1.1); opacity: 1; } }

.claim-step { padding: 28px 22px; }
.claim-step h1 { font-size: 22px; margin: 8px 0 6px; }
.claim-points { margin: 6px 0 2px; font-size: 64px; font-weight: 600; line-height: 1.1; color: var(--green); }
.claim-points small { font-size: 22px; margin-left: 6px; color: var(--green-dark); font-weight: 500; }
.claim-btn { padding: 15px; font-size: 18px; border-radius: 14px; background: var(--green); border-color: var(--green); box-shadow: 0 8px 20px rgba(46, 158, 79, .3); }
.claim-btn:hover { background: var(--green-dark); }
.claim-badge { display: inline-block; padding: 6px 16px; border-radius: 99px; background: var(--green-light); color: var(--green-dark); font-weight: 600; }
.claim-banner { margin: -4px 0 14px; padding: 10px 14px; border-radius: 12px; background: var(--green-light); color: var(--green-dark); text-align: center; }

/* The card's lower part now says how to get points; no QR to show staff any more. */

/* Birthday: the same tall, left-aligned field with a calendar mark on iPhone and Android. iPhone draws an empty
   date as a short blank button, so the browser's own look is switched off and the hint is ours. */
.date-field { position: relative; }
.date-field input[type=date] {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; min-width: 0; min-height: 46px; margin: 0;
  text-align: left; line-height: 1.4; padding-right: 44px; background-color: var(--white);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A6E55' stroke-width='1.8' stroke-linecap='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 20px;
}
.date-field input[type=date]::-webkit-date-and-time-value { text-align: left; margin: 0; }
.date-field input[type=date]::-webkit-calendar-picker-indicator { position: absolute; right: 0; top: 0; width: 44px; height: 100%; opacity: 0; cursor: pointer; }
.date-field input[type=date].is-empty { color: transparent; }
.date-field input[type=date].is-empty::-webkit-datetime-edit { color: transparent; }
.date-ph { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; display: none; }
.date-field input.is-empty ~ .date-ph { display: block; }
.date-field input.is-empty:focus ~ .date-ph { display: none; }
.date-field input.is-empty:focus, .date-field input.is-empty:focus::-webkit-datetime-edit { color: var(--text); }
.scan-view { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 18px; background: #000; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }

/* Ready-to-sell products (สต๊อกสินค้าขาย) */
.case-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.case-item { display: flex; gap: 14px; padding: 14px; background: var(--white); border-radius: var(--radius); }
.case-item.is-empty { opacity: .65; }
.case-thumb { flex: none; width: 72px; height: 72px; border-radius: 14px; overflow: hidden; background: var(--cream); display: grid; place-items: center; color: var(--brown); }
.case-thumb img { width: 100%; height: 100%; object-fit: cover; }
.case-thumb .icon { width: 30px; height: 30px; }
.case-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.case-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.case-name { font-weight: 600; color: var(--brown-dark); text-decoration: none; }
a.case-name:hover { text-decoration: underline; }
.case-qty { text-align: right; white-space: nowrap; }
.case-qty b { font-size: 26px; line-height: 1; color: var(--brown); }
.case-qty span { font-size: 13px; color: var(--muted); }
.case-exp { margin: 0; font-size: 13px; font-weight: 600; }
.case-lots { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.case-lots li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.case-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 4px; }
/* End-of-day close (ปิดยอดสิ้นวัน) */
.close-table input { width: 84px; text-align: right; padding: 6px 10px; }
.close-table select { display: block; width: 100%; max-width: 120px; margin: 6px 0 0 auto; padding: 4px 8px; font-size: 13px; }
.close-table select[hidden] { display: none; }
.close-lots { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.badge.kind-sell { background: var(--green-light); color: var(--green-dark); }
.badge.kind-give { background: #FBEFD9; color: #8A5A00; }
.badge.kind-made { background: var(--cream); color: var(--brown-dark); }
/* Phone: each line becomes a card, its boxes in a grid under the name. */
@media (max-width: 700px) {
    .close-table, .close-table tbody { display: block; }
    .close-table thead { display: none; }
    .close-table tr[data-onhand] { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 12px; border-bottom: 1px solid var(--cream-dark); }
    .close-table tr[data-onhand] td { padding: 0; border: 0; text-align: left; }
    .close-table tr[data-onhand] td:first-child { grid-column: 1 / -1; }
    .close-table td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
    .close-table input { width: 100%; text-align: left; }
    .close-table select { margin-left: 0; max-width: none; }
}
.close-item { display: grid; gap: 8px; }
.close-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.close-head b { font-size: 16px; color: var(--brown-dark); }
.close-head span { white-space: nowrap; color: var(--muted); font-size: 14px; }
.close-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.close-grid label { display: grid; gap: 2px; margin: 0; font-size: 12px; color: var(--muted); }
.close-grid input { width: 100%; padding: 8px 10px; text-align: center; }
.close-reason { width: 100%; }
.close-sold { font-weight: 600; color: var(--green-dark); }
.close-sold.is-over { color: var(--danger); }
.close-total { font-weight: 600; margin-bottom: 8px; }
.close-sum { text-align: left; }
/* Reward tied to a stock item */
.reward-stock { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.reward-stock select { flex: 1 1 200px; width: auto; }
.reward-stock .qty-field input { width: 100px; }
.reward-stock .qty-field[hidden] { display: none; }
/* Sales report */
.report-table td, .report-table th { white-space: nowrap; }
.report-cols { align-items: start; }
