:root {
  --rose: #a8325e;
  --rose-dark: #84244a;
  --rose-soft: #fbeef3;
  --ink: #2b2228;
  --muted: #6d6068;
  --line: #e6dde1;
  --bg: #faf7f8;
  --white: #ffffff;
  --red: #c62828;
  --red-soft: #fdecea;
  --green: #2e7d32;
  --green-soft: #e8f5e9;
  --yellow: #8a6500;
  --yellow-soft: #fff6d6;
}

* { box-sizing: border-box; }

html { font-size: 18px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  line-height: 1.6;
}

h1, h2, h3 { line-height: 1.35; margin: 0 0 .6rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 .8rem; }

.loading { padding: 3rem 1rem; text-align: center; color: var(--muted); }

/* ログイン画面 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card { width: 100%; max-width: 26rem; }
.login-card h1 { text-align: center; color: var(--rose-dark); }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 1.4rem; }
.login-note { margin: 1rem 0 0; font-size: .9rem; color: var(--muted); }

/* 全体の枠 */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
}
.topbar .shop { font-weight: 700; color: var(--rose-dark); }
.topbar .who { font-size: .9rem; color: var(--muted); text-align: right; }

.nav {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  display: flex;
  overflow-x: auto;
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav a {
  flex: 0 0 auto;
  padding: .85rem 1rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.nav a[aria-current="page"] { color: var(--rose-dark); border-bottom-color: var(--rose); }

.main { max-width: 68rem; margin: 0 auto; padding: 1.2rem 1rem 3rem; }

/* 部品 */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.2rem;
  margin-bottom: 1rem;
}

label.field { display: block; margin-bottom: 1rem; font-weight: 600; }
label.field input, label.field select, label.field textarea {
  display: block;
  width: 100%;
  margin-top: .3rem;
  font: inherit;
  font-weight: 400;
  padding: .7rem .8rem;
  min-height: 3rem;
  border: 1px solid #b9adb3;
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
}

.check-field { display: flex; align-items: center; gap: .5rem; margin: -.4rem 0 1rem; min-height: 2.5rem; cursor: pointer; }
.check-field input { width: 1.3rem; height: 1.3rem; margin: 0; }

button, .button {
  font: inherit;
  font-weight: 700;
  min-height: 3rem;
  padding: .55rem 1.2rem;
  border-radius: 8px;
  border: 1px solid var(--rose);
  background: var(--rose);
  color: var(--white);
  cursor: pointer;
}
button:hover { background: var(--rose-dark); }
button:disabled { opacity: .55; cursor: wait; }
button.secondary { background: var(--white); color: var(--rose-dark); }
button.secondary:hover { background: var(--rose-soft); }
button.danger { background: var(--white); border-color: var(--red); color: var(--red); }
button.danger:hover { background: var(--red-soft); }
button.small { min-height: 2.5rem; padding: .3rem .8rem; font-size: .9rem; }
button.block { display: block; width: 100%; }

:focus-visible { outline: 3px solid #e58aab; outline-offset: 2px; }

.message { padding: .75rem .9rem; border-radius: 8px; margin-bottom: 1rem; }
.message.error { background: var(--red-soft); color: var(--red); }
.message.info { background: var(--rose-soft); color: var(--rose-dark); }
.message.ok { background: var(--green-soft); color: var(--green); }

.message.warn { background: var(--yellow-soft); color: #6b4e00; }
.message a { color: inherit; font-weight: 700; }

/* シフト希望 */
.month-tabs { display: flex; flex-wrap: wrap; gap: .4rem; }
.wish-list { list-style: none; margin: 0; padding: 0; }
.wish-day { padding: .9rem 0; border-top: 1px solid var(--line); }
.wish-day.is-closed { background: #f3eff1; padding: .9rem .6rem; }
.wish-day.has-error { background: var(--red-soft); padding: .9rem .6rem; }
.wish-date { font-weight: 700; margin-bottom: .4rem; }
.wish-date.sun { color: var(--red); }
.wish-date.sat { color: #1565c0; }
.wish-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem; }
.wish-option { position: relative; cursor: pointer; }
.wish-option input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.wish-option span {
  display: flex; align-items: center; justify-content: center;
  min-height: 3rem; padding: .3rem; text-align: center;
  border: 1px solid #b9adb3; border-radius: 8px; background: var(--white);
}
.wish-option input:checked + span { font-weight: 700; border-width: 2px; }
.wish-option.can input:checked + span { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.wish-option.cannot input:checked + span { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.wish-option input:focus-visible + span { outline: 3px solid #e58aab; outline-offset: 2px; }
.wish-option input:disabled + span { opacity: .75; cursor: not-allowed; }
.wish-times { margin-top: .5rem; }
.wish-times select {
  width: 100%; font: inherit; min-height: 3rem; padding: .4rem .5rem;
  border: 1px solid #b9adb3; border-radius: 8px; background: var(--white); color: var(--ink);
}
.wish-time-row { display: flex; align-items: center; gap: .5rem; margin-top: .4rem; }
.wish-time-row[hidden] { display: none; }
.wish-time-row select { flex: 1 1 0; min-width: 0; width: auto; }
.time-pair { display: flex; align-items: center; gap: .6rem; }
.time-pair .field { flex: 1 1 0; min-width: 0; }

/* パソコンでは1日を横1行にまとめます */
@media (min-width: 760px) {
  .wish-day[data-date] {
    display: grid; grid-template-columns: 9rem 14rem minmax(0, 1fr); align-items: center; gap: .8rem;
  }
  .wish-day .wish-date { margin: 0; }
  .wish-times { margin: 0; }
}
.sticky-submit { position: sticky; bottom: 0; padding: .6rem 0; background: var(--bg); }
.plain-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.plain-list li {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .6rem; padding: .5rem 0; border-top: 1px solid var(--line);
}
.plain-list li:first-child { border-top: 0; }

.deadline-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.extend-quick { margin-bottom: .8rem; }

/* 集計 */
.kpi-grid { display: grid; grid-template-columns: 1fr; gap: .6rem; margin-bottom: 1rem; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; }
.kpi-label { font-size: .85rem; color: var(--muted); }
.kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.kpi-compare { font-size: .82rem; color: var(--muted); }
.chart { margin: 0 0 1.2rem; }
.chart figcaption { font-weight: 700; margin-bottom: .2rem; }
.chart-box { position: relative; }
.chart-box svg { display: block; width: 100%; height: auto; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-grid.base { stroke: #b9adb3; }
.chart-axis { font-size: 12px; fill: var(--muted); }
.chart-bar { fill: var(--rose); pointer-events: none; }
.chart-hit { fill: transparent; cursor: pointer; }
.chart-hit.is-active { fill: rgba(168, 50, 94, .1); }
.chart-hit:focus { outline: none; }
.chart-tip {
  position: absolute; top: 0; padding: .2rem .55rem; border-radius: 6px; background: var(--ink); color: var(--white);
  font-size: .85rem; white-space: nowrap; pointer-events: none;
}
.data-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.data-table th, .data-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.data-table tbody th { text-align: left; font-weight: 700; }
.data-table thead th:first-child { text-align: left; }
.data-table tbody tr:last-child th, .data-table tbody tr:last-child td { border-bottom: 0; }
.weekday-table th.sun { color: var(--red); }
.weekday-table th.sat { color: #1565c0; }
.avg-cell { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; min-width: 8rem; }
.avg-bar { display: block; height: .4rem; border-radius: 4px; background: var(--rose); }

@media (min-width: 760px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 売上・客数 */
.sales-list, .log-list { list-style: none; margin: 0; padding: 0; }
.sales-row { padding: .8rem 0; border-top: 1px solid var(--line); }
.sales-row:first-child, .log-list li:first-child { border-top: 0; }
.sales-row.is-today { background: var(--rose-soft); margin: 0 -.6rem; padding: .8rem .6rem; border-radius: 8px; }
.sales-date { font-weight: 700; margin-bottom: .3rem; }
.sales-date.sun { color: var(--red); }
.sales-date.sat { color: #1565c0; }
.sales-figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .3rem .8rem; margin: 0 0 .4rem; }
.sales-figures dt { font-size: .78rem; color: var(--muted); }
.sales-figures dd { margin: 0; font-weight: 700; }
.sales-empty { margin-bottom: .3rem; }
.month-total { background: var(--rose-soft); border-color: #eccbd8; }
.month-total .sales-figures { margin: 0; }
.month-total dd { font-size: 1.2rem; color: var(--rose-dark); }
.sales-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.log-list li { padding: .7rem 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.cal-sales {
  display: flex; flex-wrap: wrap; gap: 0 .5rem; margin-top: .25rem; padding-top: .2rem;
  border-top: 1px dashed rgba(43, 34, 40, .25); font-size: .75rem; line-height: 1.35;
}

@media (min-width: 760px) {
  .sales-row { display: grid; grid-template-columns: 10rem minmax(0, 1fr) 9.5rem; align-items: center; gap: .8rem; }
  .sales-date, .sales-figures, .sales-empty { margin-bottom: 0; }
  .sales-figures { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sales-actions { justify-content: flex-end; }
}

/* 人手不足の表示 */
.cal-day.state-short { background: var(--red-soft); border-color: #e9a7a2; }
.cal-day.state-good { background: var(--green-soft); border-color: #a7d2aa; }
.cal-day.state-over { background: var(--yellow-soft); border-color: #e6cf7f; }
.cal-day.state-closed { background: #efeaec; }
button.cal-day.state-short:hover { background: #fbdcd8; }
button.cal-day.state-good:hover { background: #d6edd8; }
button.cal-day.state-over:hover { background: #ffedb0; }
.staff-status { font-size: .8rem; font-weight: 700; margin-bottom: .2rem; line-height: 1.3; }
.staff-status.short { color: var(--red); }
.staff-status.good { color: var(--green); }
.staff-status.over { color: #6b4e00; }
.legend { display: flex; flex-wrap: wrap; gap: .9rem; margin-bottom: .5rem; font-size: .85rem; }
.legend span { display: inline-flex; align-items: center; gap: .3rem; }
.legend-box { display: inline-block; width: 1rem; height: 1rem; border-radius: 3px; border: 1px solid; }
.legend-box.short { background: var(--red-soft); border-color: #e9a7a2; }
.legend-box.good { background: var(--green-soft); border-color: #a7d2aa; }
.legend-box.over { background: var(--yellow-soft); border-color: #e6cf7f; }
.shortage-card summary { cursor: pointer; min-height: 2rem; }
.shortage-card .plain-list { margin: .5rem 0 0; }
.day-settings { background: var(--rose-soft); border-radius: 8px; padding: .7rem; margin-bottom: .6rem; }
.day-settings .check-field { margin: 0 0 .3rem; }
.day-settings .field { margin-bottom: 0; }
.need-grid { display: grid; grid-template-columns: minmax(5rem, 1fr) minmax(0, 6rem) minmax(0, 6rem); gap: .4rem .6rem; align-items: center; margin-bottom: 1rem; }
.need-grid input { width: 100%; font: inherit; min-height: 3rem; padding: .4rem .6rem; border: 1px solid #b9adb3; border-radius: 8px; }
.need-day.sun { color: var(--red); }
.need-day.sat { color: #1565c0; }

/* シフト作成・確認 */
.badge.ok { background: var(--green); }
.badge.warn { background: var(--yellow); }
.text-red { color: var(--red); }
.name-dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; margin-right: .35rem; }
.memo { margin-top: .3rem; padding: .4rem .6rem; background: var(--rose-soft); border-radius: 6px; font-size: .9rem; overflow-wrap: anywhere; }
.button-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.view-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.month-now { padding: 0 .4rem; align-self: center; }
.change-list { margin: .3rem 0 .6rem; padding-left: 1.2rem; }
.totals-card { margin-top: 1rem; }

.cal { display: block; }
.cal-head, .cal-blank { display: none; }
.cal-day {
  display: block; width: 100%; text-align: left; font: inherit; font-weight: 400; color: var(--ink);
  background: var(--white); border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem; margin-bottom: .4rem; min-height: 3rem;
}
button.cal-day:hover { background: var(--rose-soft); }
.cal-day.is-clickable { cursor: pointer; }
.cal-date { font-weight: 700; margin-bottom: .25rem; }
.cal-date.sun, .cal-head.sun, .staff-table th.sun { color: var(--red); }
.cal-date.sat, .cal-head.sat, .staff-table th.sat { color: #1565c0; }
.chip {
  display: flex; flex-wrap: wrap; gap: 0 .4rem; color: var(--white); border-radius: 5px;
  padding: .1rem .4rem; margin-bottom: .2rem; font-size: .85rem; line-height: 1.35;
}
.chip-name { font-weight: 700; overflow-wrap: anywhere; }
.cal-can { margin-top: .3rem; overflow-wrap: anywhere; }
.cal-can-title { font-size: .75rem; font-weight: 700; color: var(--muted); }
.can-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0 .3rem; font-size: .9rem; line-height: 1.35; margin-bottom: .2rem; }
.can-row .name-dot { margin-right: 0; flex: 0 0 auto; }
.can-name { font-weight: 600; }
.can-time { color: var(--muted); }

@media (min-width: 760px) {
  .cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
  .cal-head { display: block; text-align: center; font-weight: 700; padding: .2rem 0; }
  .cal-blank { display: block; }
  .cal-day { margin: 0; padding: .35rem; min-height: 6.5rem; border-radius: 6px; }
  .cal-week { display: none; }
  .cal-date { font-size: 1.05rem; }
  .chip { display: block; font-size: .85rem; padding: .2rem .4rem; }
  .chip-name, .chip-time { display: block; }
  .chip-time { font-weight: 400; font-size: .78rem; }
  .can-row { display: block; font-size: .85rem; }
  .can-name { display: inline; }
  .can-time { display: block; font-size: .78rem; padding-left: 1.1rem; }
}

.table-scroll { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: 8px; }
.staff-table { border-collapse: collapse; font-size: .85rem; white-space: nowrap; }
.staff-table th, .staff-table td { border: 1px solid var(--line); padding: .3rem .35rem; text-align: center; min-width: 2.6rem; }
.staff-table .sticky-col { position: sticky; left: 0; background: var(--white); text-align: left; min-width: 6.5rem; z-index: 1; }
.staff-table .tail { font-weight: 700; }
.wish-mark { font-weight: 700; display: block; }
.wish-mark.on { color: var(--green); }
.wish-mark.off { color: var(--red); }
.wish-mark.none { color: #b9adb3; }
.wish-mark-time { display: block; line-height: 1.15; font-size: .72rem; }

.assign-row { padding: .7rem 0; border-top: 1px solid var(--line); }
.assign-check { display: flex; align-items: center; gap: .4rem; cursor: pointer; min-height: 2.75rem; }
.assign-check input { width: 1.4rem; height: 1.4rem; margin: 0 .3rem 0 0; flex: 0 0 auto; }
.assign-times { margin-top: .4rem; }
.assign-times select { width: 100%; font: inherit; min-height: 3rem; padding: .4rem .5rem; border: 1px solid #b9adb3; border-radius: 8px; background: var(--white); color: var(--ink); }
.assign-times .wish-time-row select { flex: 1 1 0; min-width: 0; width: auto; }

.note { font-size: .9rem; color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.page-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .6rem; margin-bottom: 1rem;
}
.page-head h1 { margin: 0; }

.badge {
  display: inline-block; font-size: .75rem; font-weight: 700; padding: .05rem .5rem;
  border-radius: 999px; background: var(--rose); color: var(--white); vertical-align: middle;
}
.badge.soft { background: var(--rose-soft); color: var(--rose-dark); }

/* スタッフ管理 */
.staff-list { list-style: none; margin: 0; padding: 0; }
.staff-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: .8rem;
  padding: .9rem 0; border-top: 1px solid var(--line);
}
.staff-row:first-child { border-top: 0; }
.staff-row.is-hidden { opacity: .7; }
.staff-color { flex: 0 0 auto; width: 1.6rem; height: 1.6rem; border-radius: 50%; }
.staff-info { flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; }
.staff-name { font-weight: 700; }
.staff-sub { font-size: .9rem; color: var(--muted); }
.staff-actions { display: flex; flex-wrap: wrap; gap: .4rem; }

/* 入力用の小さな画面 */
dialog {
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  border: 0;
  border-radius: 12px;
  padding: 1.2rem;
  color: var(--ink);
}
dialog::backdrop { background: rgba(43, 34, 40, .5); }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }

.assign-times[hidden] { display: none; }
.color-field { border: 0; margin: 0; padding: 0; }
.color-field legend { font-weight: 600; padding: 0; margin-bottom: .4rem; }
.color-options { display: flex; flex-wrap: wrap; gap: .6rem; }
.color-option {
  position: relative; width: 2.75rem; height: 2.75rem; border-radius: 50%; cursor: pointer;
  border: 3px solid transparent;
}
.color-option input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.color-option:has(input:checked) { box-shadow: 0 0 0 3px var(--white), 0 0 0 6px var(--ink); }
.color-option:has(input:checked)::after {
  content: "✓"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--white); font-weight: 700;
}
.color-option:has(input:focus-visible) { outline: 3px solid #e58aab; outline-offset: 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  padding: .7rem 1.1rem;
  border-radius: 8px;
  z-index: 50;
  max-width: calc(100vw - 2rem);
}
