:root {
    --bg: #f3efe6;
    --card: #fffdf9;
    --ink: #1d1a16;
    --muted: #5e564c;
    --line: #e3d9cc;
    --accent: #8d2d32;
    --accent-soft: #f8ebe8;
    --ok: #1d6b45;
    --ok-soft: #e7f4ec;
    --warn: #8a5a12;
    --warn-soft: #fbf3e4;
  }
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Yu Gothic", "YuGothic", Meiryo, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  button, input, select { font: inherit; color: inherit; }
  button { cursor: pointer; }
  input, select { font-size: 16px; }
  h1 { margin: 0; font-size: 22px; }
  h2 { margin: 0 0 10px; font-size: 16px; }
  .wrap { max-width: 480px; margin: 0 auto; padding: 12px; }
  .lead { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
  .steps { margin: 8px 0 0; padding-left: 1.2em; color: var(--muted); font-size: 14px; }
  .results {
    position: sticky;
    top: 0;
    z-index: 4;
    width: 100%;
    margin: 12px 0 8px;
    padding: 0;
    border: 0;
    background: transparent;
    perspective: 900px;
    text-align: left;
  }
  .results-inner {
    display: grid;
    transform-style: preserve-3d;
    transition: transform 0.55s ease;
  }
  .results.is-open .results-inner { transform: rotateX(180deg); }
  .results-face {
    grid-area: 1 / 1;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(40, 24, 12, 0.06);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }
  .results-front {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 74px;
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-size: 22px;
    font-weight: 700;
  }
  .results-back {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 10px;
    background: #fff;
    transform: rotateX(180deg);
  }
  @media (prefers-reduced-motion: reduce) {
    .results-inner { transition: none; }
  }
  .metric { padding: 2px; min-width: 0; }
  .metric span { display: block; color: var(--muted); font-size: 12px; }
  .metric strong { display: block; font-size: 16px; letter-spacing: 0; word-break: break-all; }
  .day-pay { margin: 0; }
  .confirm-pop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(29, 26, 22, 0.35);
  }
  .confirm-card {
    width: min(100%, 360px);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
  }
  .confirm-card p { margin: 0 0 14px; }
  .metric em { font-style: normal; color: var(--muted); font-size: 12px; }
  #result-more { margin: 0 0 12px; }
  .badges { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
  .badge {
    border-radius: 999px;
    padding: 4px 10px;
    background: var(--warn-soft);
    color: var(--warn);
    font-size: 13px;
  }
  .badge.on { background: var(--ok-soft); color: var(--ok); }
  .card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
  }
  .card.editing { background: #e7f0f8; }
  #customer-card, #customer-register, #day-box { scroll-margin-top: 120px; }
  .visit-row { display: flex; align-items: center; gap: 8px; }
  .visit-row .lines { flex: 1; min-width: 0; }
  .visit-row .lines p {
    margin: 0;
    height: 1.5em;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .visit-row > .btn { width: auto; flex: 0 0 auto; }
  .fold-list summary {
    list-style: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 16px;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .fold-list summary::-webkit-details-marker { display: none; }
  .fold-list summary::after { content: "▼"; font-weight: 400; }
  .fold-list[open] summary::after { content: "▲"; }
  .customer-row { display: flex; align-items: center; gap: 8px; }
  .customer-row .lines { flex: 1; min-width: 0; }
  .customer-row .lines p {
    margin: 0;
    height: 1.5em;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .customer-row > .btn { width: auto; flex: 0 0 auto; }
  .grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .grid.pair { grid-template-columns: 1fr 1fr; }
  .grid.visit-people { grid-template-columns: minmax(0, 7fr) minmax(0, 3fr); }
  .grid.visit-people select { min-width: 0; }
  .span-all { grid-column: 1 / -1; }
  label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
  input, select {
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid #d9d0c3;
    border-radius: 8px;
    background: #fff;
    font-size: 16px;
  }
  .layout { display: grid; grid-template-columns: 1fr; gap: 14px; }
  .row-btns { display: flex; gap: 8px; margin-top: 10px; }
  .row-btns[hidden] { display: none; }
  #customer-card .row-btns { margin-bottom: 22px; }
  .row-btns .btn { flex: 1; }
  .btn {
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    padding: 10px 12px;
    min-height: 44px;
  }
  a.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
  }
  .btn.ghost { background: #fff; color: var(--ink); border-color: #d9d0c3; }
  .btn:disabled { opacity: 0.4; }
  .btn.small { padding: 10px 12px; font-size: 16px; min-height: 44px; }
  .person { border-top: 1px solid var(--line); padding: 10px 0; }
  .person header { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
  .person .who {
    flex: 1;
    min-width: 0;
    text-align: left;
    background: transparent;
    border: 0;
    font-weight: 700;
    min-height: 44px;
    padding: 0;
  }
  .person .meta { margin: 0; color: var(--muted); font-size: 13px; }
  .person .detail { display: none; margin: 4px 0 0; color: var(--muted); font-size: 13px; }
  .person.open .detail { display: block; }
  .cal-head, .cal {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
  }
  .cal-head { margin-bottom: 6px; color: var(--muted); font-size: 12px; text-align: center; }
  .nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
  .nav .btn { min-width: 88px; }
  button.day, a.day {
    min-height: 52px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 2px;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: inherit;
  }
  button.day.work, a.day.work { border-color: #e3b4b4; background: var(--accent-soft); }
  button.day.today, a.day.today { outline: 2px solid #c4a574; }
  a.day.on { outline: 2px solid var(--accent); }
  button.day .num, a.day .num { font-weight: 700; font-size: 16px; line-height: 1.1; }
  a.day.punched .num, button.day.punched .num { color: var(--ok); }
  .day .punch { font-size: 11px; line-height: 1.1; color: var(--ok); }
  button.day .mark, a.day .mark { min-height: 14px; font-size: 10px; line-height: 1.2; color: var(--accent); white-space: nowrap; }
  .slot a.num { color: var(--ink); font-size: 16px; font-weight: 700; }
  .day-pad { visibility: hidden; }
  .day-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .day-kinds { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
  .day-kinds .check { gap: 4px; }
  select.staff-select { width: auto; min-width: 7.2em; flex: 0 0 auto; }
  .pick-name { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  select.champ-select { width: auto; min-width: 7.5em; max-width: 46%; flex: 0 0 auto; }
  .pick-menus { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
  select.share-select { width: auto; min-width: 4.8em; flex: 0 0 auto; }
  .check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 16px; min-height: 44px; }
  .check input { width: 22px; height: 22px; min-height: 22px; }
  .chip {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    align-items: center;
    margin-top: 4px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #f3efe7;
    font-size: 12px;
  }
  .chip.companion { background: #f0d2d2; }
  .muted { color: var(--muted); }
  .icon-btn {
    border: 0;
    background: transparent;
    color: var(--accent);
    font-weight: 700;
  }
  table { width: 100%; border-collapse: collapse; font-size: 14px; }
  th, td { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: right; }
  th:first-child, td:first-child { text-align: left; }
  .overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 22, 16, 0.35);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    z-index: 10;
  }
  .overlay[hidden] { display: none; }
  .panel {
    width: min(480px, 100%);
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px 16px 0 0;
    padding: 0;
  }
  .sheet-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 8px 8px 16px;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }
  .sheet-date { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 18px; font-weight: 700; }
  .sheet-close {
    width: 44px;
    height: 44px;
    border: 0;
    background: transparent;
    font-size: 28px;
    line-height: 1;
  }
  .sheet-scroll {
    overflow: auto;
    flex: 1 1 auto;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  }
  .pick { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .pick.booked { background: var(--accent-soft); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 10px; }
  .pick-line { display: flex; gap: 8px; align-items: flex-end; }
  .pick-line .btn { flex: 1; }
  .people-field { width: 88px; flex: 0 0 88px; }
  .find { margin: 0 0 8px; }
  .note { color: var(--muted); font-size: 13px; }
  .saved { color: var(--ok); font-size: 13px; min-height: 1.2em; }
  .fold > summary {
    list-style: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  table.stack tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 2px 0; text-align: left; }
  table.stack td::before { content: attr(data-label); color: var(--muted); }
  .fold > summary::-webkit-details-marker { display: none; }
  .fold > summary::after { content: " ▼"; }
  .fold[open] > summary { margin-bottom: 10px; }
  .fold[open] > summary::after { content: " ▲"; }

.wrap.wide { max-width: 960px; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 16px 0; }
.bar > span { display: flex; gap: 20px; align-items: center; }
.bar > .name-line { gap: 0; flex-wrap: nowrap; min-width: 0; }
.name-line .pokepara {
  flex: 0 0 auto;
  width: auto;
  min-height: 32px;
  padding: 4px 10px;
  white-space: nowrap;
  border-color: #fc0fc0;
  background: #fc0fc0;
  color: #fff;
  font-weight: 700;
}
.bar form { margin: 0 0 0 12px; }
.bottle-find { position: relative; z-index: 30; margin: 12px 0 0; }
.bottle-find-row { display: flex; gap: 8px; align-items: center; }
.bottle-find-field { position: relative; flex: 1 1 auto; min-width: 0; }
.bottle-find-field input { padding-right: 36px; }
.bottle-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  width: 32px;
  height: 32px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}
.bottle-find-row > .btn { flex: 0 0 auto; white-space: nowrap; }
.bottle-lookup-list {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 40;
  margin-top: 4px;
  box-shadow: 0 10px 24px rgba(40, 24, 12, 0.16);
}
.error { color: var(--accent); font-size: 14px; }
.tag { color: var(--muted); font-size: 13px; }
.slot {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 4px;
}
.slot.work { border-color: #e3b4b4; background: var(--accent-soft); }
.slot .num { font-weight: 700; text-align: center; }
.slot .crew { text-align: center; font-size: 12px; line-height: 1.35; }
.slot a { display: block; color: var(--accent); font-size: 12px; line-height: 1.35; text-align: center; text-decoration: none; }
.person a { color: var(--accent); font-weight: 700; text-decoration: none; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.wrap.wide .card { padding: 12px 16px; }
.pay-head {
  background: var(--ok-soft);
  margin: -12px -16px 0;
  padding: 12px 16px 18px;
  border-bottom: 1px solid var(--line);
  border-radius: 11px 11px 0 0;
}
.pay-name { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pay-name h2 { margin: 0; min-width: 0; }
.pay-plus, .pay-minus {
  flex: 0 0 auto;
  width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  font-weight: 700;
}
.sale-side { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.sale-side .meta { white-space: nowrap; }
.pay-head + .person { border-top: 0; }
.pay-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.owner-foot { display: flex; gap: 8px; margin: 18px 0 8px; }
.owner-foot form { flex: 1; margin: 0; }
.owner-foot .btn { width: 100%; }
.wrap.wide h2 { margin-bottom: 8px; }
.wrap.wide .sheet { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.wrap.wide .sheet.self { grid-template-columns: 1fr 1fr 1.3fr auto; }
.wrap.wide .sheet.pair-end { grid-template-columns: 1fr 1fr auto; }
.wrap.wide .row-btns.end { justify-content: flex-end; }
.wrap.wide .row-btns.end .btn { flex: 0 0 auto; min-width: 8em; }
.field-btn { display: flex; align-items: end; }
.field-btn .btn { white-space: nowrap; }
.issued-line { margin: 0; }
.account {
  display: grid;
  grid-template-columns: 7.2em max-content max-content auto minmax(11em, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.account-who strong { display: block; font-size: 15px; line-height: 1.3; }
.account .cred { font-size: 13px; white-space: nowrap; }
.account form { margin: 0; }
.account .btn { min-height: 36px; padding: 4px 10px; white-space: nowrap; }
.account input { min-height: 36px; }
.account-reset { display: flex; gap: 6px; align-items: center; }
#staff-lists > .row-btns .btn { flex: 1 1 0; min-width: 0; }
#staff-lists .staff-picks { margin-top: 18px; }
#staff-lists .staff-tools { margin-top: 18px; }
.rate-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.rate-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; }
.rate-table th, .rate-table td { background: var(--card); white-space: nowrap; padding: 8px 10px; }
.rate-table th:first-child, .rate-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 6.5em;
  box-shadow: 1px 0 0 var(--line);
}
.security-next { margin-top: 18px; }
.access-list { display: flex; flex-direction: column; }
.access-row { border-top: 1px solid var(--line); padding: 10px 0; }
.access-row p { margin: 0; font-size: 14px; }
.access-row .when { font-weight: 700; }
.staff-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.staff-picks .note { flex-basis: 100%; margin: 0; }
.pick-link {
  display: inline-flex;
  gap: 8px;
  align-items: baseline;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.pick-link span { color: var(--muted); font-size: 12px; font-weight: 400; }
.day-plans { margin-top: 12px; padding-top: 4px; border-top: 1px solid var(--line); }
.day-plans h2 { margin-top: 8px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.day-crew { font-size: 14px; font-weight: 400; text-align: right; }
.manager-work { margin-top: 12px; }
.page-foot { display: flex; justify-content: flex-end; align-items: center; gap: 20px; margin: 28px 0 12px; }
.page-foot form { margin: 0; }
.bottle-list { max-height: 240px; overflow: auto; border: 1px solid #d9d0c3; border-radius: 8px; background: #fff; }
.bottle-pick {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
  min-height: 44px;
}
.bottle-pick.on { background: var(--accent-soft); }
.bottle-pick strong { font-size: 16px; }
.bottle-pick span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (max-width: 800px) {
  .grid.pair { grid-template-columns: 1fr; }
  .wrap.wide .sheet,
  .wrap.wide .sheet.self,
  .wrap.wide .sheet.pair-end { grid-template-columns: 1fr 1fr; }
  .account { grid-template-columns: 1fr 1fr; }
  .account-who,
  .account-reset { grid-column: 1 / -1; }
}

