:root {
  --ink: #213a32;
  --muted: #586c62;
  --paper: #f7f7f1;
  --green: #286044;
  --line: #d6ded5;
  --accent: #e8efdc;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font:
    18px/1.7 -apple-system,
    BlinkMacSystemFont,
    "Noto Sans TC",
    sans-serif;
}
::selection {
  background: #d1e5ba;
}
button,
input,
textarea,
select {
  font: inherit;
}
button {
  cursor: pointer;
  border: 0;
  background: var(--green);
  color: white;
  padding: 11px 20px;
  border-radius: 7px;
  font-weight: 600;
}
button:hover {
  background: #194b32;
}
/* Disabled on purpose: grey with dark text, and the page shows why next to it. */
button:disabled:not([data-busy]),
button:disabled:not([data-busy]):hover {
  background: #d9ddd8;
  color: #3d4a43;
  border-color: #c3c9c2;
  cursor: not-allowed;
}
/* Briefly locked while a request runs (see act()). */
button[data-busy]:disabled {
  opacity: 0.6;
  cursor: wait;
}
button.secondary,
.link {
  background: transparent;
  color: var(--green);
  border: 2px solid var(--green);
}
button.danger {
  background: #a33c31;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #b78b26;
  outline-offset: 3px;
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid #7a8a7e;
  border-radius: 6px;
  padding: 11px;
  background: #fff;
  color: var(--ink);
  caret-color: var(--green);
}
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
label {
  display: block;
  font-size: 16px;
  font-weight: 600;
  margin: 16px 0;
}
label input,
label textarea,
label select {
  display: block;
  margin-top: 6px;
}
h1 {
  font-size: 34px;
  line-height: 1.35;
  margin: 0 0 12px;
  letter-spacing: -0.025em;
}
h2 {
  font-size: 23px;
  margin: 26px 0 12px;
}
p {
  color: var(--muted);
}
header {
  height: 86px;
  border-bottom: 1px solid var(--line);
  padding: 20px 36px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
}
.brand {
  font-size: 25px;
  font-weight: 750;
  letter-spacing: -0.025em;
}
.brand span {
  font-size: 15px;
  margin-left: 12px;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 86px);
}
nav {
  padding: 32px 20px;
  border-right: 1px solid var(--line);
}
nav button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--muted);
  margin-bottom: 8px;
}
nav button.active {
  background: var(--accent);
  color: var(--ink);
}
nav p {
  font-size: 15px;
  margin-top: 64px;
}
main {
  padding: 44px 48px;
  max-width: 1300px;
  width: 100%;
  min-width: 0;
}
.heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 28px;
}
.heading p {
  margin: 0;
}
.empty {
  border-block: 1px solid var(--line);
  padding: 64px 16px;
  text-align: center;
}
.empty h2 {
  margin-top: 0;
}
.form {
  max-width: 650px;
  background: white;
  padding: 24px 32px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 22px;
}
.table-wrap {
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
}
table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
  font-size: 16px;
}
th {
  font-size: 15px;
  color: var(--muted);
  background: #edf1e9;
}
td,
th {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}
td {
  font-variant-numeric: tabular-nums;
}
tr:last-child td {
  border: 0;
}
td button {
  padding: 6px 12px;
  font-size: 15px;
  white-space: nowrap;
}
.badge {
  display: inline-block;
  font-size: 15px;
  background: var(--accent);
  padding: 3px 10px;
  border-radius: 30px;
  white-space: nowrap;
}
.badge.closed {
  background: #edf0ec;
  color: var(--muted);
}
.banner {
  padding: 14px 20px;
  background: #f7ebcd;
  border: 1px solid #dbcda8;
  border-radius: 8px;
  margin-bottom: 24px;
  color: #65501d;
  font-size: 16px;
}
.detail {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 28px;
}
.summary {
  background: #eaf0e3;
  padding: 22px;
  border-radius: 12px;
  align-self: start;
}
.summary p {
  white-space: pre-wrap;
}
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login > div {
  max-width: 520px;
  width: 100%;
  margin: auto;
  padding: 48px;
}
.login .brand {
  display: block;
  margin-bottom: 64px;
}
.login h1 {
  font-size: 38px;
}
.login form button {
  width: 100%;
  margin: 10px 0;
}
.login .link {
  border: 0;
  font-size: 15px;
  padding-left: 0;
}
.login aside {
  background: #dce5d2;
  display: grid;
  place-items: center;
  padding: 48px;
}
.paper {
  background: #fafbf6;
  padding: 52px;
  transform: rotate(-3deg);
  max-width: 430px;
  width: 100%;
}
.paper h2 {
  font-size: 42px;
  line-height: 1.4;
}
.paper hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 36px 0;
}
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #213a32;
  color: white;
  padding: 14px 24px;
  border-radius: 8px;
  max-width: 90%;
  z-index: 9;
}
[hidden] {
  display: none !important;
}
.small {
  font-size: 15px;
  color: var(--muted);
}
pre {
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
  background: #edf1e9;
  padding: 20px;
}
a {
  color: var(--green);
  text-underline-offset: 3px;
}
@media (max-width: 900px), (orientation: landscape) and (max-height: 500px) {
  header {
    padding: 18px;
    height: 72px;
  }
  .brand span {
    display: none;
  }
  .layout {
    display: block;
  }
  nav {
    display: flex;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: auto;
    gap: 4px;
  }
  nav button {
    white-space: nowrap;
    width: auto;
    font-size: 15px;
    padding: 9px 12px;
    margin: 0;
    min-height: 44px;
  }
  nav p {
    display: none;
  }
  main {
    padding: 26px 18px;
  }
  h1 {
    font-size: 28px;
  }
  .heading {
    align-items: start;
  }
  .heading button {
    white-space: nowrap;
  }
  .heading > .subnav {
    width: 100%;
  }
  .detail {
    grid-template-columns: 1fr;
  }
  .form {
    padding: 20px;
  }
  .login {
    display: block;
  }
  .login > div {
    padding: 28px;
  }
  .login aside {
    display: none;
  }
  .login .brand {
    margin-bottom: 48px;
  }
  .login h1 {
    font-size: 34px;
  }
  td,
  th {
    padding: 14px;
  }
  table {
    min-width: 560px;
  }
}
button.secondary:hover,
.link:hover,
nav button:hover {
  background: #e0e9d8;
  color: #213a32;
}
.filters {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  align-items: end;
}
.filters label {
  flex: 1;
  min-width: 160px;
  margin: 0;
}
.order-strip {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
  padding: 18px 0;
  border-block: 1px solid var(--line);
  margin-bottom: 24px;
}
.pickup-qr {
  display: block;
  max-width: 100%;
  width: 280px;
  height: auto;
  margin: 24px 0;
  background: white;
}
#scan-video {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  margin-top: 20px;
  border-radius: 8px;
}
#scan-result {
  margin-top: 24px;
}
#content {
  overflow-wrap: anywhere;
}
@media (max-width: 900px), (orientation: landscape) and (max-height: 500px) {
  .heading {
    flex-wrap: wrap;
  }
  .filters {
    gap: 12px;
  }
  .filters label {
    min-width: 135px;
  }
  .order-strip {
    gap: 12px;
  }
  header #actor {
    max-width: 140px;
    font-size: 15px;
  }
  header #logout {
    padding: 8px 12px;
  }
  #order-list table {
    min-width: 780px;
  }
}

/* Franchise: header store context, role badges, owner home, catalog switches. */
header {
  gap: 16px;
}
#store-bar,
.who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
#store-bar {
  flex: 1;
  justify-content: flex-start;
}
.store-name {
  font-size: 15px;
}
.store-switch {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.store-switch select {
  margin: 0;
  width: auto;
  max-width: 260px;
  padding: 8px 10px;
  font-size: 15px;
  font-weight: 600;
}
.badge.role {
  background: var(--ink);
  color: white;
}
.badge.role.staff {
  background: #dfe6f0;
  color: #2c3e57;
}
.badge.paid {
  background: #d4ead6;
  color: #1d5232;
  font-weight: 600;
}
.badge.stage,
.badge.job-simulated {
  background: #f7ebcd;
  color: #65501d;
}
.badge.job-failed {
  background: #f3d9d5;
  color: #7d2b22;
}
.badge.job-sent {
  background: #d4ead6;
  color: #1d5232;
}
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.tile {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
}
.tile span {
  display: block;
  font-size: 15px;
  color: var(--muted);
}
.tile strong {
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.row-link {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  font-weight: 400;
}
.row-link span {
  font-size: 16px;
  color: var(--muted);
}
.row-link:hover {
  background: #eef3e8;
}
.more-list {
  display: grid;
  gap: 10px;
}
.more-list button {
  text-align: left;
  background: white;
  min-height: 56px;
}
nav .more-tab {
  display: none;
}
.subnav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: -8px 0 24px;
}
.subnav button.active {
  background: var(--accent);
  color: var(--ink);
  border-color: #b9c9b2;
}
.catalog-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.catalog-bar p {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}
.switch-list {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.switch-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-weight: 400;
  font-size: 16px;
}
.switch-row:last-child {
  border: 0;
}
.switch-row input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.switch {
  flex: none;
  width: 48px;
  height: 28px;
  border-radius: 28px;
  background: #c7d0c6;
  position: relative;
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  transition: transform 0.15s;
}
.switch-row input:checked + .switch {
  background: var(--green);
}
.switch-row input:checked + .switch::after {
  transform: translateX(20px);
}
.switch-row input:focus-visible + .switch {
  outline: 3px solid #b78b26;
  outline-offset: 2px;
}
.switch-text small {
  display: block;
  color: var(--muted);
  font-size: 15px;
}
.member {
  display: block;
  white-space: nowrap;
}
.inline-select {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.inline-select select {
  width: auto;
  margin: 0;
  padding: 6px 8px;
}
.region h3 {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 17px;
  margin: 24px 0 10px;
}
.region h3 span {
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
}
meter {
  display: block;
  width: 100%;
  max-width: 260px;
  height: 8px;
  margin-top: 6px;
}
meter::-webkit-meter-bar {
  background: #edf1e9;
  border: 0;
  border-radius: 4px;
}
meter::-webkit-meter-optimum-value {
  background: var(--green);
  border-radius: 4px;
}
meter::-moz-meter-bar {
  background: var(--green);
}
a.button {
  display: inline-block;
  padding: 11px 20px;
  border-radius: 7px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--line);
}
a.button:hover {
  background: #e0e9d8;
}
.pay-link {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  margin-top: 12px;
}
.pay-link p {
  margin: 0;
  color: var(--ink);
}
.line-help {
  margin: 8px 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 0 16px;
  font-size: 15px;
}
.line-help summary {
  cursor: pointer;
  font-weight: 600;
  padding: 12px 0;
  min-height: 44px;
}
.line-help ol {
  padding-left: 20px;
  margin: 0 0 8px;
}
.line-help li {
  margin-bottom: 8px;
}
details pre {
  max-height: 320px;
  overflow: auto;
  font-size: 15px;
  font-family: ui-monospace, Menlo, monospace;
}

/* Phones: cards instead of tables, thumb-sized controls, bottom tabs for stores. */
@media (max-width: 900px), (orientation: landscape) and (max-height: 500px) {
  header {
    height: auto;
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 8px 12px;
  }
  .brand {
    font-size: 21px;
  }
  .who {
    margin-left: auto;
  }
  #store-bar {
    order: 3;
    flex-basis: 100%;
  }
  #store-bar:empty {
    display: none;
  }
  .store-switch {
    flex: 1;
  }
  .store-switch select {
    max-width: none;
    width: 100%;
    min-height: 44px;
  }
  header #actor {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  header #logout {
    min-height: 40px;
  }
  main {
    padding: 22px 16px 32px;
  }
  button,
  a.button,
  td button {
    min-height: 44px;
  }
  td button {
    padding: 8px 14px;
    font-size: 15px;
  }
  nav button {
    min-height: 44px;
  }
  .heading {
    margin-bottom: 20px;
  }
  .heading > button {
    width: 100%;
  }
  .table-wrap {
    overflow: visible;
    background: transparent;
    border: 0;
  }
  table,
  #order-list table {
    min-width: 0;
  }
  thead {
    display: none;
  }
  table,
  tbody,
  tr,
  td {
    display: block;
  }
  tr {
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 0;
    margin-bottom: 12px;
  }
  tr[hidden] {
    display: none;
  }
  td,
  tr:last-child td {
    display: grid;
    grid-template-columns: 6.5em minmax(0, 1fr);
    align-content: start;
    gap: 0 10px;
    border: 0;
    padding: 6px 16px;
  }
  td::before {
    content: attr(data-label);
    grid-row: 1 / span 30;
    font-size: 15px;
    color: var(--muted);
    padding-top: 2px;
    word-break: keep-all;
  }
  td[data-label=""] {
    display: block;
  }
  td[data-label=""]::before {
    display: none;
  }
  td:last-child:not([data-label=""]) {
    padding-bottom: 10px;
  }
  .tiles {
    gap: 8px;
  }
  .tile {
    padding: 12px;
  }
  .tile strong {
    font-size: 24px;
  }
  .catalog-bar {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--paper);
    padding: 10px 0;
    margin: 0 0 8px;
  }
  .switch-row {
    padding: 14px 16px;
    min-height: 64px;
  }
  #content > .form,
  #content > div > .form {
    max-width: none;
  }
  #scan-video {
    max-height: 60vh;
  }
  body.store-view nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 8;
    display: flex;
    gap: 0;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    background: white;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    overflow: visible;
  }
  body.store-view nav button {
    flex: 1;
    min-width: 0;
    min-height: 56px;
    padding: 6px 2px;
    font-size: 15px;
    text-align: center;
    white-space: normal;
    line-height: 1.25;
    border-radius: 8px;
  }
  body.store-view nav button.active {
    color: var(--green);
    background: var(--accent);
  }
  body.store-view nav .more-item {
    display: none;
  }
  body.store-view nav .more-tab {
    display: block;
  }
  body.store-view main {
    padding-bottom: 110px;
  }
  body.store-view #toast {
    bottom: 88px;
  }
}

/* Store staff (often 60+): large text, thumb-sized targets, plain task flows. */
body.store-view button,
body.store-view a.button,
body.store-view summary,
body.store-view .choice {
  min-height: 52px;
}
body.store-view .badge,
body.store-view header #actor {
  font-size: 15px;
}
body.store-view nav button {
  font-size: 16px;
}
body.store-view h1 {
  font-size: 30px;
}
#toast {
  cursor: pointer;
  font-size: 17px;
}
#toast.error {
  background: #8f2c22;
}
dialog#ask {
  border: 0;
  border-radius: 16px;
  padding: 24px;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  color: var(--ink);
}
dialog#ask::backdrop {
  background: rgb(20 30 25 / 0.55);
}
#ask h2 {
  margin-top: 0;
  font-size: 22px;
  line-height: 1.45;
}
#ask p {
  color: var(--ink);
}
.ask-actions {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}
.ask-actions button {
  min-height: 56px;
  font-size: 19px;
}
pre.preview {
  font-size: 16px;
  border-radius: 8px;
  max-height: 40vh;
  overflow: auto;
}
.notice-bar {
  margin: -8px 0 16px;
  font-size: 15px;
}
.notice-bar summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 14px;
  background: #f7ebcd;
  color: #65501d;
  border-radius: 8px;
  cursor: pointer;
}
.notice-bar summary span {
  margin-left: 4px;
  text-decoration: underline;
}
.notice-bar[open] summary {
  margin-bottom: 8px;
}
.notice-bar .banner {
  margin-bottom: 8px;
}
.steps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}
.steps li {
  text-align: center;
  font-size: 15px;
  color: var(--muted);
  padding: 8px 2px;
  border-radius: 8px;
  background: #edf1e9;
}
.steps li span {
  display: block;
  font-size: 20px;
  line-height: 1.2;
}
.steps li.done {
  color: var(--green);
}
.steps li.done span::after {
  content: " ✓";
  font-size: 15px;
}
.steps li.now {
  background: var(--green);
  color: white;
  font-weight: 700;
}
.next-step button,
button.task,
button.wide {
  display: block;
  width: 100%;
  min-height: 64px;
  font-size: 20px;
  border-radius: 12px;
}
.next-step {
  margin-bottom: 20px;
}
button.tile {
  display: block;
  text-align: left;
  color: var(--ink);
  font-weight: 400;
  background: white;
  border: 2px solid var(--line);
}
button.tile:hover {
  background: #eef3e8;
  border-color: var(--green);
}
.tasks {
  display: grid;
  gap: 12px;
  margin-bottom: 28px;
}
.tasks .banner {
  margin: 0;
}
button.task.secondary {
  background: white;
}
.close-zone {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 2px dashed #d7b7b2;
}
.close-zone p {
  color: var(--ink);
}
.guide-card {
  background: white;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.guide-card h2 {
  margin-top: 0;
}
.guide-card button {
  width: 100%;
  font-size: 19px;
}
.why {
  color: #5a4a1d;
  background: #fbf4e2;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0;
}
details.advanced {
  margin: 20px 0;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 16px;
}
details.advanced > summary {
  cursor: pointer;
  font-weight: 700;
  padding: 14px 0;
  display: flex;
  align-items: center;
}
details.advanced[open] {
  padding-bottom: 16px;
}
details.advanced .form {
  border: 0;
  padding: 0;
}
.result {
  border-radius: 14px;
  padding: 20px;
  margin: 8px 0 20px;
  border: 3px solid;
}
.result p {
  color: inherit;
  margin: 6px 0;
}
.result .result-title {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.35;
}
.result.ok {
  background: #dcefdc;
  border-color: #2f7a45;
  color: #17432a;
}
.result.bad {
  background: #fbe3df;
  border-color: #b23b2e;
  color: #6e1f17;
}
.result.info {
  background: white;
  border-color: var(--green);
}
.result button {
  margin-top: 12px;
  width: 100%;
}
.result.ok button.secondary,
.result.bad button.secondary {
  background: white;
}
.big {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}
.order-head p {
  margin: 4px 0;
}
.order-head {
  margin-bottom: 16px;
}
.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin: 8px 0;
}
.choice {
  margin: 0;
  position: relative;
}
.choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.choice span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 2px solid var(--green);
  border-radius: 8px;
  color: var(--green);
  font-size: 17px;
  cursor: pointer;
  text-align: center;
  padding: 4px 8px;
}
.choice input:checked + span {
  background: var(--green);
  color: white;
}
.choice input:focus-visible + span {
  outline: 3px solid #b78b26;
  outline-offset: 2px;
}
fieldset.reason {
  border: 0;
  padding: 0;
  margin: 16px 0;
}
fieldset.reason legend {
  font-weight: 600;
  font-size: 16px;
}
.filter-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.filter-tabs button {
  font-size: 18px;
  min-height: 56px;
}
.filter-tabs button.secondary {
  background: white;
}
.order-cards {
  display: grid;
  gap: 10px;
}
.order-card {
  min-height: 52px;
  gap: 2px;
  padding: 14px 16px;
}
.order-card strong {
  font-size: 19px;
}
.order-card small {
  font-size: 15px;
  font-weight: 400;
  color: var(--muted);
}
.order-card .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
  margin-top: 4px;
}
.badge.unpaid {
  background: #fbe3df;
  color: #6e1f17;
}
.badge.st-ready {
  background: #2f7a45;
  color: white;
}
.scope-chip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--ink);
  font-weight: 600;
}
.scan-actions {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}
.scan-actions button {
  min-height: 72px;
  font-size: 20px;
  border-radius: 12px;
}
.scan-actions button.secondary {
  background: white;
}
.claim-line {
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  background: #edf1e9;
  padding: 12px 16px;
  border-radius: 8px;
  user-select: all;
}
@media (min-width: 901px) {
  .filter-tabs {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Phone-first polish for store staff: 16px floor, 48px targets, safe areas, no sideways scroll. */
html:has(body.store-view dialog[open]) {
  overflow: hidden;
}
@media (max-width: 900px), (orientation: landscape) and (max-height: 500px) {
  .login .line-help,
  .login .small {
    font-size: 16px;
  }
  .login .brand span {
    display: none;
  }
  #line-login {
    width: 100%;
  }
  body.store-view :is(small, .small, .badge, summary, .notice-bar, .steps li, .tile span, .store-name, .switch-text small, .order-card small, td button),
  body.store-view header #actor,
  body.store-view td::before,
  body.store-view .steps li.done span::after,
  .store-switch select {
    font-size: 16px;
  }
  header #actor {
    display: none;
  }
  .store-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #store-bar .badge.role {
    flex: none;
  }
  .store-switch select {
    min-height: 48px;
    text-overflow: ellipsis;
  }
  header #logout {
    min-height: 48px;
  }
  body.store-view main {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }
  body.store-view #toast {
    bottom: calc(84px + env(safe-area-inset-bottom));
    width: max-content;
  }
  body.store-view nav {
    padding-left: calc(4px + env(safe-area-inset-left));
    padding-right: calc(4px + env(safe-area-inset-right));
  }
  body.store-view nav button.active {
    font-weight: 800;
    box-shadow: inset 0 4px 0 var(--green);
  }
  body.store-view td button {
    min-height: 48px;
  }
  body.store-view td > .badge {
    justify-self: start;
  }
  body.store-view .tile {
    padding: 12px 8px;
  }
  body.store-view .pay-link a.button {
    background: var(--green);
    color: white;
  }
  body.store-view .actions {
    flex-direction: column;
    align-items: stretch;
  }
  body.store-view .actions > :is(button, a.button) {
    width: 100%;
    text-align: center;
  }
  body.store-view form button:not([type="button"]) {
    width: 100%;
    min-height: 56px;
    font-size: 19px;
  }
  body.store-view .filters :is(input, select) {
    height: 52px;
  }
  body.store-view .subnav[role="group"] {
    grid-auto-flow: row;
    grid-template-columns: 1fr 1fr;
  }
  body.store-view .scope-chip button {
    width: 100%;
  }
  body.store-view .row-link {
    padding: 14px 16px;
  }
  #scan-video {
    aspect-ratio: 1;
    max-height: 60vh;
  }
  dialog#ask {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  /* Keep the answer buttons in reach when the question is long. */
  .ask-actions {
    position: sticky;
    bottom: -24px;
    margin: 20px -24px -24px;
    padding: 12px 24px 24px;
    background: white;
  }
}
@media (hover: none) {
  body.store-view nav button:not(.active):hover {
    background: transparent;
    color: var(--muted);
  }
}
/* Landscape phones: keep the store bar inline and the bottom tabs short. */
@media (orientation: landscape) and (max-height: 500px) {
  #store-bar {
    order: 0;
    flex-basis: auto;
  }
  body.store-view nav button {
    min-height: 48px;
    padding: 2px;
  }
  body.store-view main {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }
  body.store-view #toast {
    bottom: calc(68px + env(safe-area-inset-bottom));
  }
  .ask-actions {
    grid-template-columns: 1fr 1fr;
  }
  body.store-view .subnav[role="group"] {
    grid-template-columns: repeat(4, 1fr);
  }
  .ask-actions button {
    min-height: 52px;
  }
  #scan-video {
    max-height: 70vh;
    aspect-ratio: auto;
  }
}

/* LIFF (/liff inside LINE): LINE draws its own title bar, so the header keeps only store context. */
body.liff #login,
body.liff header .brand {
  display: none;
}
.liff-gate {
  max-width: 520px;
  margin: 0 auto;
  padding: 48px 16px;
}
.liff-gate .brand {
  display: block;
  margin-bottom: 32px;
}
.liff-gate button {
  width: 100%;
}
body.liff header {
  height: auto;
  padding: 8px 16px;
  flex-wrap: nowrap;
}
body.liff #store-bar {
  order: 0;
  flex: 1;
  flex-basis: auto;
}
body.liff .who {
  flex: none;
}
body.liff #logout {
  white-space: nowrap;
}
/* HQ: sidebar grouped by function, change arrows, compact role selects. */
.nav-group {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin: 24px 0 6px;
  padding-left: 20px;
}
.nav-group:first-child {
  margin-top: 0;
}
.delta {
  white-space: nowrap;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}
.delta.up {
  color: #1d5232;
}
.delta.down {
  color: #a33c31;
}
select.compact {
  width: auto;
  margin: 0;
  padding: 6px 8px;
}
@media (max-width: 900px), (orientation: landscape) and (max-height: 500px) {
  .nav-group {
    display: none;
  }
}
@media (max-width: 900px), (orientation: landscape) and (max-height: 500px) {
  select.compact {
    width: 100%;
  }
  td > .badge {
    justify-self: start;
  }
}
/* 出貨給分店: one card per store; the grid itself drops to one column on phones. */
.ship-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 12px;
}
.ship-card {
  display: flex;
  flex-direction: column;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
}
.ship-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 12px;
}
.ship-head h3 {
  margin: 0;
  font-size: 18px;
  overflow-wrap: anywhere;
}
.ship-card > p.small {
  margin: 4px 0 0;
}
.ship-items {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}
.ship-items li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.ship-items strong {
  flex: none;
  font-variant-numeric: tabular-nums;
}
/* Six HQ figures (counts and NT$ totals) sit 3 x 2 from tablets up, so 7-digit amounts
   fit and no row is left half empty; portrait phones keep the shared 2 x 3. */
@media (min-width: 641px) {
  .tiles.three:not(.status) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* The button row sits at the card bottom so neighbouring cards line up. */
.ship-card > .actions {
  margin-top: auto;
  padding-top: 12px;
}
.form-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  align-items: start;
}
.form-pair,
#hq-account-form {
  margin-top: 20px;
}
@media (max-width: 900px), (orientation: landscape) and (max-height: 500px) {
  /* Status cards carry sentences, not numbers: one per row on phones. */
  .tiles.status {
    grid-template-columns: 1fr;
  }
}
/* AI helpers: owner review lists, announcement drafts, HQ block. */
.ai-box {
  background: white;
  border: 2px solid #dbcda8;
  border-radius: 12px;
  padding: 16px 20px;
  margin: 0 0 24px;
}
.ai-box h2 {
  margin: 0 0 4px;
}
.ai-item {
  border-top: 1px solid var(--line);
  padding: 14px 0 4px;
  margin-top: 12px;
}
.ai-item .actions {
  margin-top: 10px;
}
.ai-item p {
  margin: 4px 0;
}
.ai-quote {
  font-size: 19px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.ai-read {
  background: var(--accent);
  border-radius: 8px;
  padding: 8px 12px;
}
.ai-read span {
  display: block;
  font-size: 15px;
  color: var(--muted);
}
.ai-writer {
  margin: 16px 0;
}
.ai-writer .actions {
  margin-top: 0;
}
.ai-options {
  display: grid;
  gap: 12px;
  margin: 12px 0;
}
.ai-option {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  background: var(--paper);
}
.ai-option h3 {
  margin: 0;
  font-size: 17px;
}
.ai-text {
  white-space: pre-line;
  overflow-wrap: anywhere;
  margin: 6px 0 10px;
}
.badge.flag {
  background: #fbe3df;
  color: #6e1f17;
}
.ai-hq {
  margin-top: 40px;
}
.ai-hq .form {
  margin-top: 16px;
}
@media (max-width: 640px) {
  .ai-box {
    padding: 14px 16px;
  }
  .ai-item .actions button,
  .ai-option button {
    width: 100%;
  }
}

/* ---- Voice campaign (#9) and handwritten order photo (#12) ---- */
.voice-entry,
.photo-entry {
  margin: 0 0 24px;
}
.voice-entry p,
.photo-entry p {
  margin: 6px 0 0;
}
#campaign-form .voice-entry {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
button.voice-start {
  background: #8a5a14;
}
button.voice-start:hover {
  background: #6f480f;
}
dialog#voice {
  border: 0;
  border-radius: 16px;
  padding: 24px;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--ink);
}
dialog#voice::backdrop {
  background: rgb(20 30 25 / 0.55);
}
#voice h2 {
  margin: 0 0 12px;
  font-size: 22px;
}
#voice h3 {
  margin: 18px 0 8px;
  font-size: 19px;
}
button.voice-mic {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 150px;
  border-radius: 20px;
  font-size: 20px;
}
.voice-mic span {
  font-size: 52px;
  line-height: 1;
}
button.voice-mic.on {
  background: #a33c31;
}
.voice-hint,
.voice-said {
  color: var(--muted);
  font-size: 17px;
  overflow-wrap: anywhere;
}
.voice-status {
  min-height: 1.7em;
  font-weight: 700;
}
.voice-status:empty {
  min-height: 0;
  margin: 0;
}
.voice-form p {
  margin: 0;
}
.voice-form {
  display: grid;
  gap: 12px;
}
.voice-form label {
  font-size: 18px;
}
.voice-question {
  font-size: 26px;
  line-height: 1.45;
  font-weight: 800;
  margin: 8px 0;
  overflow-wrap: anywhere;
}
.voice-detail {
  font-size: 18px;
  color: var(--muted);
}
.voice-choices {
  display: grid;
  gap: 10px;
}
.voice-choices button {
  min-height: 56px;
  font-size: 19px;
  text-align: left;
  background: white;
}
.voice-choices button.active {
  background: var(--accent);
}
.voice-choices small {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 15px;
}
.voice-actions {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}
.voice-actions button {
  min-height: 56px;
  font-size: 19px;
}
label.photo-pick {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  border-radius: 12px;
  background: var(--green);
  color: white;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
}
label.photo-pick:hover {
  background: #194b32;
}
label.photo-pick:focus-within {
  outline: 3px solid #b78b26;
  outline-offset: 3px;
}
.photo-wait {
  font-weight: 700;
}
#photo-result h3 {
  margin: 20px 0 4px;
}
.photo-cell {
  display: grid;
  gap: 6px;
}
.photo-cell label {
  font-size: 15px;
  color: var(--muted);
}
.photo-cell input,
.photo-cell select {
  color: var(--ink);
}
#photo-result td input,
#photo-result td select {
  margin: 0;
  min-height: 48px;
}
#photo-result td.unsure input,
#photo-result td.unsure select {
  border: 2px solid #b3261e;
  background: #fdf1ef;
}
.unsure-note {
  color: #8f2c22;
  font-weight: 700;
  font-size: 15px;
}
#photo-result .actions button {
  flex: 1 1 100%;
}
@media (max-width: 640px) {
  #photo-result td:not([data-label=""]),
  #photo-result tr:last-child td:not([data-label=""]) {
    display: block;
  }
  #photo-result td:not([data-label=""])::before {
    display: block;
    margin-bottom: 4px;
  }
}
#photo-result td label {
  margin: 0;
}

/* AI CRM (owner「客戶」page, HQ segment mix). Kept in one block at the end of the file. */
.nowrap {
  white-space: nowrap;
}
.crm-sub {
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 10px;
}
.crm-insight {
  background: white;
  border: 2px solid #dbcda8;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 8px;
}
.crm-insight h2 {
  margin: 0 0 6px;
}
.crm-insight .crm-summary {
  color: var(--ink);
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 8px;
}
.crm-insight ol {
  margin: 0;
  padding-left: 1.4em;
}
.crm-insight li {
  margin: 6px 0;
}
.crm-insight-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-top: 12px;
}
.crm-segments {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.crm-seg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  background: white;
  color: var(--ink);
  border: 2px solid var(--line);
  border-left-width: 8px;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 400;
}
.crm-seg:hover {
  background: #eef3e8;
}
.crm-seg-name {
  font-size: 17px;
  font-weight: 700;
}
.crm-seg strong {
  font-size: 30px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.crm-seg strong small,
.crm-count .tile strong small {
  font-size: 16px;
  font-weight: 600;
}
.crm-at_risk {
  border-left-color: #c0612b;
}
.crm-sleeping {
  border-left-color: #7c8692;
}
.crm-new {
  border-left-color: #3b78b0;
}
.crm-high_value {
  border-left-color: #b78b26;
}
.crm-loyal {
  border-left-color: var(--green);
}
.crm-one_time,
.crm-regular {
  border-left-color: #b9c9b2;
}
.badge.crm-tag {
  font-weight: 600;
}
.badge.crm-at_risk {
  background: #f8dfcc;
  color: #6b2f0c;
}
.badge.crm-sleeping {
  background: #e4e7eb;
  color: #3a4350;
}
.badge.crm-new {
  background: #d9e7f4;
  color: #1f4566;
}
.badge.crm-high_value {
  background: #f7ebcd;
  color: #65501d;
}
.badge.crm-loyal {
  background: #d4ead6;
  color: #1d5232;
}
.crm-rules dl {
  margin: 0 0 8px;
}
.crm-rules dt {
  font-weight: 700;
  margin-top: 8px;
}
.crm-rules dd {
  margin: 0;
  color: var(--muted);
}
.crm-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.crm-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
}
.crm-card h3 {
  margin: 0;
  font-size: 19px;
}
.crm-card p {
  margin: 4px 0;
}
.crm-big {
  color: var(--ink);
  font-size: 18px;
}
.crm-big strong {
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.crm-rank {
  list-style-position: inside;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  margin: 0 0 8px;
}
.crm-rank li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.crm-rank li:last-child {
  border-bottom: 0;
}
.crm-rank li::marker {
  font-weight: 700;
}
.crm-rank.crm-plain {
  list-style: none;
}
.crm-num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.crm-filters label {
  margin: 0;
}
.crm-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  background: var(--accent);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
}
.crm-cta p {
  margin: 0;
  color: var(--ink);
}
.crm-person .tags > span:not(.badge) {
  color: var(--muted);
}
.crm-person-head h2 {
  margin: 0 0 6px;
}
.crm-person-head p {
  margin: 4px 0;
}
.crm-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.crm-facts div {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
}
.crm-facts dt {
  font-size: 15px;
  color: var(--muted);
}
.crm-facts dd {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.crm-offer {
  max-width: 760px;
}
.crm-offer fieldset {
  border: 0;
  padding: 0;
  margin: 16px 0;
}
.crm-offer legend {
  font-weight: 600;
  font-size: 16px;
}
.crm-count .tiles {
  margin: 8px 0 4px;
}
.crm-offer .choice small {
  white-space: nowrap;
  margin-left: 6px;
  font-size: 15px;
}
.crm-why p {
  margin: 2px 0;
  color: inherit;
}
.crm-result > summary {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.crm-result > summary > span:first-child {
  display: flex;
  flex-direction: column;
}
.crm-result > summary small {
  font-weight: 400;
  color: var(--muted);
  font-size: 15px;
}
.crm-back {
  white-space: nowrap;
  color: var(--green);
}
.crm-back strong {
  font-size: 22px;
}
#crm-hq {
  margin-top: 32px;
}
@media (max-width: 640px), (orientation: landscape) and (max-height: 500px) {
  .crm-segments {
    grid-template-columns: 1fr 1fr;
  }
  .crm-seg strong {
    font-size: 26px;
  }
  .crm-sub {
    display: block;
    margin: 2px 0 0;
  }
  body.store-view .crm-tabs button {
    font-size: 16px;
    padding: 8px 2px;
  }
  .crm-cta button,
  .crm-insight-foot button {
    width: 100%;
  }
  .crm-count .tiles {
    grid-template-columns: repeat(3, 1fr);
  }
  .crm-count .tile strong {
    font-size: 24px;
  }
}

/* HQ analytics (hq-ai.js): digest, reports, ask, anomalies, forecast, differences, voice. */
.nowrap {
  white-space: nowrap;
}
.digest,
.report-card,
.ask-box,
.alerts-box,
.issues-box,
.forecast,
.voice {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 22px;
  margin: 0 0 24px;
}
.forecast,
.voice {
  margin-top: 32px;
}
.digest {
  border: 2px solid #dbcda8;
  background: #fffdf6;
}
.digest-head,
.report-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 12px;
  flex-wrap: wrap;
}
.digest-head h2,
.report-head h2,
.report-head h3 {
  margin: 0;
}
.digest-text {
  font-size: 20px;
  font-weight: 600;
  margin: 10px 0;
  overflow-wrap: anywhere;
}
.digest-foot {
  display: flex;
  align-items: center;
  gap: 8px 14px;
  flex-wrap: wrap;
}
.digest-foot button,
.report-card .actions button,
.ask-form button,
.alert-item button,
.issues-box .heading button,
.forecast .heading button {
  white-space: nowrap;
}
.reports {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 0 20px;
}
.report-summary {
  margin: 10px 0 6px;
}
.report-facts {
  display: grid;
  grid-template-columns: 5.5em 1fr;
  gap: 6px 12px;
  margin: 12px 0;
  font-size: 16px;
}
.report-facts dt {
  color: var(--muted);
}
.report-facts dd {
  margin: 0;
  min-width: 0;
}
.report-facts ol,
.report-facts ul,
.report-tips {
  margin: 0;
  padding-left: 1.3em;
}
.report-card h3 {
  font-size: 17px;
  margin: 14px 0 4px;
}
.report-tips li {
  margin: 4px 0;
}
.ask-form {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-top: 8px;
}
.ask-form label {
  flex: 1;
  margin: 0;
  min-width: 0;
}
.ask-form input {
  margin: 0;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}
button.chip {
  min-height: 44px;
  padding: 5px 12px;
  font-size: 15px;
  font-weight: 500;
  border-width: 1px;
}
.ask-answer {
  background: var(--accent);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 14px 0;
}
.ask-answer p {
  margin: 6px 0;
}
.ask-q {
  font-weight: 700;
}
.figures {
  list-style: none;
  margin: 0;
  padding: 0;
}
.figures li {
  margin: 2px 0;
}
.figures span {
  color: var(--muted);
}
.alerts-box {
  border: 2px solid #e6b8b0;
}
.alerts-box h2 {
  margin-top: 0;
}
.alert-item {
  border-top: 1px solid var(--line);
  padding: 12px 0 4px;
}
.alert-head {
  display: flex;
  gap: 4px 10px;
  align-items: baseline;
  flex-wrap: wrap;
}
.alert-item ul {
  margin: 6px 0;
  padding: 0;
  list-style: none;
}
.alert-item li {
  margin: 4px 0;
}
.alert-item .actions {
  margin-top: 8px;
}
.coach .report-tips {
  margin-top: 6px;
}
.coach:not(:empty) {
  background: var(--accent);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 10px 0;
}
.issues-box .heading,
.forecast .heading {
  margin-bottom: 12px;
}
.issues-box > h3 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 17px;
  margin: 20px 0 0;
}
.issues-box > h3 span {
  flex: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
}
.issues-box .ai-box {
  margin: 0 0 12px;
}
.estimate {
  font-size: 18px;
}
.estimate strong {
  font-size: 26px;
}
#campaign-forecast:not(:empty) {
  border-bottom: 1px solid #cddac2;
  margin-bottom: 14px;
  padding-bottom: 6px;
}
#campaign-forecast h2 {
  margin-top: 0;
}
@media (max-width: 640px), (orientation: landscape) and (max-height: 500px) {
  .digest,
  .report-card,
  .ask-box,
  .alerts-box,
  .issues-box,
  .forecast,
  .voice {
    padding: 14px 16px;
  }
  .reports {
    grid-template-columns: 1fr;
  }
  .ask-form {
    flex-direction: column;
  }
  .report-card .actions button,
  .alert-item .actions button {
    flex: 1 1 auto;
  }
  .digest-foot button {
    flex: 1 1 100%;
  }
  /* Tables inside these cards become cards themselves: drop the double frame. */
  .issues-box tr,
  .forecast tr,
  .voice tr,
  .ask-box tr {
    border-color: #e3e8df;
  }
  .report-facts {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .report-facts dd {
    margin-bottom: 8px;
  }
  .ask-box td,
  .ask-box tr:last-child td {
    grid-template-columns: 3.5em 1fr;
  }
  .figures li {
    margin: 6px 0;
  }
  .figures span {
    display: block;
    font-size: 15px;
  }
}

/* Staff LINE notices (staff-notify.js): HQ announcement store picker. */
#announce-stores .choices {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
#announce-stores .choice span {
  flex-direction: column;
  line-height: 1.35;
}
#announce-stores .choice small {
  font-size: 15px;
  opacity: 0.85;
}
#staff-notify,
#staff-stats {
  margin-top: 20px;
}

/* RWD rules shared by HQ and store views.
   - Button groups: on phones every button in a group fills its row share, so a wrapped
     last button spans the full width instead of hanging alone.
   - Segmented filters (.subnav): one equal-width row; five options split 3 + 2 evenly.
   - Card tables: the label spans every row so all content stays in the value column;
     action cells become a full-width button row.
   - Long names wrap anywhere; badges, deltas, tile figures and money (NBSP) never break.
   - Tablets (641-900px) use the phone layout: top tabs, cards instead of squeezed tables. */
select {
  text-overflow: ellipsis;
}
p,
h1,
h2 {
  text-wrap: pretty;
}
td {
  text-wrap: balance;
}
.tile > p:last-child {
  margin-bottom: 0;
}
.form > :is(h2, h3):first-child {
  margin-top: 0;
}
/* Table columns size to whole words; long CJK names still wrap between characters. */
#content table {
  overflow-wrap: break-word;
}
th,
td code {
  white-space: nowrap;
}
/* Desktop tables: short cells (amounts, counts, dates) keep a readable minimum width. */
@media (min-width: 901px) {
  td:not(:first-child) {
    min-width: 6.5em;
  }
  td:has(> button + button) {
    white-space: nowrap;
  }
}
/* 44px tap floor for table buttons and every select/input, desktop included. */
td button,
select,
input:not([type="checkbox"]):not([type="radio"]) {
  min-height: 44px;
}
.heading > button,
.tile strong {
  flex: none;
  white-space: nowrap;
}
small,
code {
  font-size: 15px;
}
@media (max-width: 900px), (orientation: landscape) and (max-height: 500px) {
  .actions > :is(button, a.button) {
    flex: 1 1 auto;
    text-align: center;
  }
  .banner .actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(max(8.5em, 30%), 1fr));
  }
  .subnav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
  }
  .subnav button {
    padding: 8px 4px;
    white-space: nowrap;
  }
  .subnav:has(> :nth-child(5)) {
    grid-auto-flow: row;
    grid-template-columns: repeat(6, 1fr);
  }
  .subnav:has(> :nth-child(5)) > * {
    grid-column: span 2;
  }
  .subnav:has(> :nth-child(5)) > :nth-child(n + 4) {
    grid-column: span 3;
  }
  td > br {
    display: none;
  }
  tr:last-child td[data-label=""],
  td[data-label=""] {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-top: 10px;
  }
  td[data-label=""] > button {
    flex: 1 1 auto;
  }
  .tile,
  button.tile {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .tile strong {
    font-size: min(24px, 6.2vw);
  }
  /* Tiles: two per row, three when there are exactly three, an odd last tile spans the row. */
  .tiles:not(.status) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tiles:not(.status):has(> :nth-child(3):last-child) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .tiles:not(.status):not(:has(> :nth-child(3):last-child)) > :nth-child(odd):last-child {
    grid-column: 1 / -1;
  }
  .member {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 6px;
    white-space: normal;
  }
  .form > button:not([type="button"]) {
    width: 100%;
  }
}
/* Portrait phones: choice buttons two per row, an odd last one takes the whole row. */
@media (max-width: 640px) {
  .choices {
    grid-template-columns: 1fr 1fr;
  }
  .choices > :nth-child(odd):last-child {
    grid-column: 1 / -1;
  }
}
/* Portrait phones get full-width heading buttons; landscape phones and tablets have room
   for one row of tiles and a heading button beside the title. */
@media (min-width: 641px) and (max-width: 900px), (orientation: landscape) and (max-height: 500px) {
  .heading {
    flex-wrap: nowrap;
  }
  .heading > :is(button, .subnav) {
    width: auto;
  }
  .filter-tabs {
    grid-template-columns: repeat(4, 1fr);
  }
  .tiles:not(.status),
  .tiles:not(.status):has(> :nth-child(3):last-child) {
    grid-template-columns: repeat(auto-fit, minmax(10em, 1fr));
  }
  .tiles:not(.status):not(:has(> :nth-child(3):last-child)) > :nth-child(odd):last-child {
    grid-column: auto;
  }
}
/* Disclosure rows inside tables are tap targets too. */
td summary {
  min-height: 44px;
  padding-block: 9px;
  margin-top: -7px;
  cursor: pointer;
}
/* Round 2: the same shared rules extended to the AI, CRM and notice screens.
   - Two-line button labels split evenly instead of leaving one character behind.
   - Long dialogs (voice campaign pickers) keep their answer buttons in reach, like #ask.
   - Card grids (customer segments) fill rows without an orphan; store pickers with long
     names take one row each.
   - Tables inside a framed box (forecast, differences, voice, ask) give the cards more width. */
button {
  text-wrap: balance;
}
/* Choice cards in one row share the tallest card's height. */
.choices > .choice > span {
  height: 100%;
}
.form > label:first-child {
  margin-top: 0;
}
#voice .voice-actions {
  position: sticky;
  bottom: -24px;
  margin: 20px -24px -24px;
  padding: 12px 24px 24px;
  background: white;
}
/* Landscape phones: the answer buttons sit two per row, as in #ask. */
@media (orientation: landscape) and (max-height: 500px) {
  #voice .voice-actions {
    grid-template-columns: 1fr 1fr;
  }
  #voice .voice-actions > :nth-child(odd):last-child {
    grid-column: 1 / -1;
  }
  #voice .voice-actions button {
    min-height: 52px;
  }
}
@media (max-width: 640px) {
  .crm-segments > :nth-child(odd):last-child {
    grid-column: 1 / -1;
  }
  /* Four customer tabs sit 2 x 2 like the other store tabs; search and segment stack so
     the search hint is not cut off. */
  body.store-view .crm-tabs {
    grid-auto-flow: row;
    grid-template-columns: 1fr 1fr;
  }
  .crm-filters label {
    flex-basis: 100%;
  }
  #announce-stores .choices {
    grid-template-columns: 1fr;
  }
  .crm-result > summary {
    flex-direction: column;
    align-items: flex-start;
  }
  :is(.issues-box, .forecast, .voice, .ask-box) {
    padding-inline: 12px;
  }
  :is(.issues-box, .forecast, .voice, .ask-box) :is(td, tr:last-child td) {
    padding-inline: 12px;
  }
}
/* A phone number inside a sentence is still a tap target. */
.crm-person-head a[href^="tel:"] {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* LIFF rollouts: each row represents a branch/group, not an aggregate success. */
.rollout-row{border-top:1px solid var(--line);padding:20px 0;display:grid;grid-template-columns:minmax(0,1fr) minmax(180px,280px);gap:20px}.rollout-row h3{margin:0}.rollout-row p{margin:6px 0}.rollout-row .actions{align-content:start;align-items:start;margin-top:0}.rollout-row .actions button{width:100%}@media(max-width:640px){.rollout-row{grid-template-columns:1fr}.rollout-row .actions button{width:auto;flex:1}}
.rollout-roster{grid-column:1/-1}
.product-thumb{display:block;width:112px;height:84px;object-fit:cover;border-radius:8px;margin-bottom:8px}
