:root {
  --ink: #16343a;
  --muted: #4d6a6e;
  --line: #cfdedb;
  --teal: #073e40;
  --teal-2: #08675f;
  --paper: #f2f7f6;
  --white: #fff;
  --alert-bg: #ffeded;
  --alert-line: #e28f8f;
  --alert-ink: #8a1f1f;
  --warn-bg: #fff6dc;
  --warn-line: #e0b968;
  --warn-ink: #6a4a06;
  --ok-bg: #e8f3ef;
  --radius: 12px;
}

* { box-sizing: border-box; }

/* .store-bar / .tabs は display:flex を持つため、hidden 属性だけでは消えない */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 1rem;
}

.app-header {
  background: var(--teal);
  color: #fff;
  padding: 1.1rem 0 1.2rem;
}
.app-header .brand {
  margin: 0;
  font-size: .85rem;
  letter-spacing: .04em;
  color: #bfe4df;
}
.app-header h1 {
  margin: .1rem 0 0;
  font-size: 1.6rem;
  line-height: 1.3;
}

main { padding-top: 1rem; padding-bottom: 2rem; }

/* ---- 店舗選択 ---- */
.store-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1rem;
  align-items: end;
  background: #e4efed;
  border-radius: var(--radius);
  padding: .8rem 1rem;
  margin-bottom: 1rem;
}
.store-field {
  display: grid;
  gap: .2rem;
  font-size: .82rem;
  font-weight: 700;
  color: var(--muted);
}
.store-note {
  margin: 0 0 .35rem;
  font-size: .85rem;
  color: var(--muted);
}

/* ---- 入力部品（片手でも押しやすい大きさ） ---- */
select,
input,
button,
textarea {
  font: inherit;
  color: inherit;
  min-height: 46px;
  padding: .45rem .7rem;
  border: 1px solid #a4bdb9;
  border-radius: 9px;
  background: var(--white);
  max-width: 100%;
}

button {
  cursor: pointer;
  font-weight: 700;
}
button:disabled { opacity: .5; cursor: not-allowed; }

select:focus-visible,
input:focus-visible,
button:focus-visible,
textarea:focus-visible {
  outline: 3px solid #3376be;
  outline-offset: 2px;
}

/* ---- タブ ---- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .8rem;
}
.tabs button {
  background: var(--white);
  border-color: #a4bdb9;
}
.tabs button[aria-pressed="true"] {
  background: var(--teal-2);
  border-color: var(--teal-2);
  color: #fff;
}

/* ---- メッセージ ---- */
.message {
  min-height: 1.5em;
  margin: .2rem 0 .6rem;
  font-weight: 700;
  color: var(--teal-2);
}
.message.error { color: var(--alert-ink); }

/* ---- 利用方法の選択（お客様／店員） ---- */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: .8rem;
  margin: .6rem 0 1rem;
}
.mode-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 5px solid var(--teal-2);
  border-radius: var(--radius);
  padding: 1.1rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.mode-card.is-staff { border-top-color: var(--teal); }
.mode-card h3 {
  margin: 0;
  font-size: 1.15rem;
}
.mode-card .hint {
  margin: 0 0 auto;
  font-size: .85rem;
  line-height: 1.6;
  min-height: 2.6em;
}
.mode-card button {
  margin-top: .6rem;
  width: 100%;
}

.back-btn {
  background: var(--white);
  border-color: #a4bdb9;
  font-weight: 700;
  color: var(--muted);
  min-height: 42px;
  padding: .3rem .7rem;
}

.done-card h2 { margin-top: 0; color: var(--teal-2); }

/* ---- 件数タイル ---- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .7rem;
  margin: .4rem 0 1rem;
}
.tile {
  text-align: left;
  padding: .9rem 1rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: .15rem;
}
.tile .tile-label {
  font-size: .86rem;
  font-weight: 700;
  color: var(--muted);
}
.tile .tile-count {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.2;
}
.tile .tile-unit { font-size: .9rem; font-weight: 700; }
.tile.is-alert {
  background: var(--alert-bg);
  border-color: var(--alert-line);
  color: var(--alert-ink);
}
.tile.is-alert .tile-label { color: var(--alert-ink); }
.tile.is-warn {
  background: var(--warn-bg);
  border-color: var(--warn-line);
  color: var(--warn-ink);
}
.tile.is-warn .tile-label { color: var(--warn-ink); }

/* ---- 見出し ---- */
h2 {
  font-size: 1.1rem;
  margin: 1.4rem 0 .6rem;
}
h2 .count {
  font-size: .85rem;
  font-weight: 700;
  color: var(--muted);
  margin-left: .4rem;
}

/* ---- 予約カード ---- */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 6px solid var(--line);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-bottom: .7rem;
}
.card.is-alert { border-left-color: var(--alert-line); background: #fffafa; }
.card.is-warn { border-left-color: var(--warn-line); }
.card.is-closed { border-left-color: #b9cbc7; background: #f8fbfa; }

.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .6rem;
  align-items: baseline;
}
.card-head h3 {
  margin: 0;
  font-size: 1.08rem;
}
.card-qty {
  font-weight: 800;
  color: var(--teal-2);
}

.badge {
  display: inline-block;
  padding: .12rem .5rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 800;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.alert { background: var(--alert-bg); border-color: var(--alert-line); color: var(--alert-ink); }
.badge.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.badge.info { background: var(--ok-bg); border-color: #b6d8ce; color: #0c5a52; }
.badge.closed { background: #eef2f1; border-color: #c9d8d5; color: #4b6663; }

.card-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .1rem .7rem;
  margin: .5rem 0 0;
  font-size: .92rem;
}
.card-meta dt { color: var(--muted); font-weight: 700; }
.card-meta dd { margin: 0; overflow-wrap: anywhere; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .7rem;
}
.card-actions button { flex: 1 1 auto; min-width: 128px; }
.btn-primary { background: var(--teal-2); border-color: var(--teal-2); color: #fff; }
.btn-danger { background: #fff; border-color: #d9a1a1; color: #8a1f1f; }

/* ---- ツールバー（絞り込み） ---- */
.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .6rem;
  background: #e9f2f0;
  border-radius: var(--radius);
  padding: .8rem 1rem;
  margin-bottom: .8rem;
}
.toolbar label {
  display: grid;
  gap: .2rem;
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
}
.toolbar button { align-self: end; }

/* ---- フォーム ---- */
.form-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: .75rem;
}
.form-grid label {
  display: grid;
  gap: .2rem;
  font-size: .82rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 0;
}
.form-grid input,
.form-grid select { width: 100%; min-width: 0; }
.form-grid .span-2 { grid-column: 1 / -1; }

.total-line {
  margin: .9rem 0 0;
  background: var(--ok-bg);
  border-radius: 9px;
  padding: .6rem .8rem;
  font-weight: 800;
}

.form-error {
  margin: .6rem 0 0;
  color: var(--alert-ink);
  font-weight: 700;
  min-height: 1.3em;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .8rem;
}
.form-actions button { flex: 1 1 auto; min-width: 140px; }

.hint { font-size: .8rem; color: var(--muted); margin: .3rem 0 0; }

.empty {
  background: var(--white);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  color: var(--muted);
}

.notice {
  border-radius: var(--radius);
  padding: .7rem .9rem;
  margin: .2rem 0 .8rem;
  font-weight: 700;
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn-ink);
}
.notice.is-alert {
  border-color: var(--alert-line);
  background: var(--alert-bg);
  color: var(--alert-ink);
}

/* ---- ログアウトボタン ---- */
.logout-btn {
  margin: 0 0 .35rem auto;
  background: var(--white);
  border-color: #a4bdb9;
}
.logout-btn[hidden] { display: none; }

/* ---- ログイン（暗証番号） ---- */
.login-card { max-width: 460px; margin: 1rem auto; }
.login-card h2 { margin-top: 0; }
.pin-input {
  font-size: 1.6rem;
  letter-spacing: .5em;
  text-align: center;
  font-weight: 800;
  min-height: 58px;
}

@media (max-width: 600px) {
  .app-header h1 { font-size: 1.35rem; }
  main { padding-top: .7rem; }
  .card-actions button { flex: 1 1 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .card-meta { grid-template-columns: 1fr; gap: 0; }
  .card-meta dt { margin-top: .3rem; }
}
