/* ARRIBA ユニフォーム申込システム。単一CSS + 最小限のJSで構成する。
   モバイルファースト。クラブカラー(ロゴの赤 #d81820)基調、絵文字は使わない。 */

:root {
  --brand: #d81820;
  --brand-dark: #b01018;
  --brand-light: #fdecec;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #dbe1e8;
  --text: #1f2933;
  --text-muted: #667080;
  --danger: #c0392b;
  --danger-bg: #fbe9e7;
  --success: #1f8a4c;
  --success-bg: #e4f6ec;
  --warning: #a3690f;
  --warning-bg: #fdf1de;
  --info-bg: #e2edfb;
  --info: #1a5fa8;
  --radius: 10px;
  --radius-small: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}

body.has-totalbar {
  padding-bottom: 92px;
}

img {
  max-width: 100%;
  display: block;
}

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

h1, h2, h3 {
  margin: 0 0 12px;
  font-weight: 700;
}

/* ---------------------------------------------------------------------- */
/* ヘッダー・ナビゲーション                                              */
/* ---------------------------------------------------------------------- */

.app-header {
  background: var(--surface);
  color: var(--text);
  border-bottom: 3px solid var(--brand);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.app-header-public {
  padding-bottom: 2px;
}

.app-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  max-width: 1100px;
  margin: 0 auto;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 0.98rem;
  text-decoration: none;
}

.app-brand img {
  height: 30px;
  width: auto;
}

.app-brand-sub {
  white-space: nowrap;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  border-left: 1px solid var(--border);
  padding-left: 10px;
}

.nav-toggle {
  white-space: nowrap;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-small);
  min-height: 40px;
  padding: 0 14px;
  font-size: 0.95rem;
}

.app-nav {
  display: none;
  flex-direction: column;
  padding: 0 16px 12px;
  max-width: 1100px;
  margin: 0 auto;
}

.app-nav.is-open {
  display: flex;
}

.app-nav a {
  color: var(--text);
  text-decoration: none;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.app-nav a.is-active {
  font-weight: 700;
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.nav-logout {
  margin-top: 8px;
}

@media (min-width: 860px) {
  .nav-toggle {
    display: none;
  }
  .app-nav {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 18px;
    padding: 0 16px 14px;
  }
  .nav-logout {
    margin-top: 0;
    margin-left: auto;
  }
  .app-nav a {
    border-bottom: none;
    padding: 4px 0;
  }
  .app-nav a.is-active {
    border-bottom: 2px solid var(--brand);
  }
}

/* ---------------------------------------------------------------------- */
/* レイアウト全般                                                        */
/* ---------------------------------------------------------------------- */

.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.app-main-center {
  display: flex;
  /* flashメッセージとパネルが横に並ばないよう縦積みにする */
  flex-direction: column;
  align-items: center;
  min-height: calc(100vh - 120px);
  padding-top: 48px;
}

.app-main-center .flash-list {
  width: 100%;
  max-width: 420px;
}

.flash-list {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flash {
  padding: 12px 14px;
  border-radius: var(--radius-small);
  font-size: 0.92rem;
}

.flash-success {
  background: var(--success-bg);
  color: var(--success);
}

.flash-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.flash-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.panel-narrow {
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.3rem;
  margin-bottom: 14px;
}

.section-title {
  font-size: 1.05rem;
  margin-bottom: 10px;
}

.danger-title {
  color: var(--danger);
}

.lead {
  color: var(--text-muted);
  margin: 0 0 14px;
}

.hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 6px 0 0;
}

.text-muted {
  color: var(--text-muted);
}

.required {
  color: var(--danger);
  font-size: 0.75rem;
  margin-left: 6px;
  border: 1px solid var(--danger);
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: middle;
}

/* ---------------------------------------------------------------------- */
/* ボタン                                                                */
/* ---------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-small);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--brand);
  color: var(--brand);
}

.btn-danger-outline {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-text {
  background: transparent;
  border-color: transparent;
  color: var(--brand);
  padding: 0 6px;
  min-height: 36px;
}

/* 一覧のバッジと次の操作。カード表示でも右側の領域内で折り返す。 */
.cell-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

@media (max-width: 720px) {
  .cell-actions {
    justify-content: flex-end;
    margin-left: auto;
  }
}

.btn-small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------------------------------------------------------------------- */
/* フォーム部品                                                          */
/* ---------------------------------------------------------------------- */

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* iOSのmonth/date入力は固有幅で親からはみ出すことがある */
.stack-form .field input,
.stack-form .field select,
.stack-form .field textarea {
  width: 100%;
  max-width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface);
}

input,
select,
textarea {
  max-width: 100%;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 10px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="month"],
input[type="search"],
input[type="file"],
select,
textarea {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

textarea {
  min-height: 100px;
  padding: 10px 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  min-height: 32px;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.filter-form .field {
  /* iOSのmonth入力は固有幅で隣とかぶることがあるため、
     フィールドを伸縮させて input を幅100%に収める */
  flex: 1 1 150px;
  min-width: 0;
}

.filter-form .field input {
  width: 100%;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface);
}

.download-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--brand-light);
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.current-image img {
  max-width: 200px;
  border-radius: var(--radius-small);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

/* ---------------------------------------------------------------------- */
/* バッジ                                                                */
/* ---------------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-small {
  padding: 1px 7px;
  font-size: 0.68rem;
  margin-top: 4px;
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-muted {
  background: #edf0f3;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------------- */
/* テーブル(スマホではカード型に崩す)                                    */
/* ---------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.9rem;
  vertical-align: middle;
}

.data-table thead th {
  background: #f0f2f5;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.8rem;
}

.data-table tbody tr:hover {
  background: #fafbfc;
}

.amount-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.col-select {
  width: 44px;
  text-align: center;
}

.col-narrow {
  width: 90px;
}

.action-cell {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.inline-form input[type="text"] {
  min-height: 36px;
  width: 90px;
}

.size-price-table input[type="number"] {
  min-height: 40px;
  width: 100px;
}

@media (max-width: 720px) {
  .data-table {
    border: none;
  }
  .data-table thead {
    display: none;
  }
  .data-table tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    margin-bottom: 12px;
  }
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #eef1f4;
    padding: 8px 0;
    text-align: right;
  }
  .data-table td:last-child {
    border-bottom: none;
  }
  .data-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-align: left;
    flex-shrink: 0;
  }
  .action-cell {
    justify-content: flex-end;
  }
}

/* ---------------------------------------------------------------------- */
/* 発注一覧 / 集計                                                       */
/* ---------------------------------------------------------------------- */

.export-actions {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.export-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 640px) {
  .summary-cards {
    grid-template-columns: repeat(4, 1fr);
  }
}

.summary-card {
  background: var(--brand-light);
  border-radius: var(--radius-small);
  padding: 12px;
}

.summary-card-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.summary-card-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--brand-dark);
}

.summary-card-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stage-summary-cards {
  grid-template-columns: repeat(2, 1fr);
}

.select-all-bar {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 8px;
}

.select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}

.select-all-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.purge-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.move-buttons {
  display: flex;
  gap: 4px;
}

/* ---------------------------------------------------------------------- */
/* 申込詳細                                                              */
/* ---------------------------------------------------------------------- */

.summary-list {
  margin: 0 0 4px;
}

.summary-row {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #eef1f4;
  font-size: 0.92rem;
}

.summary-row dt {
  width: 120px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.summary-row dd {
  margin: 0;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.photo-thumb {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  overflow: hidden;
}

/* 画像は切り取らず、元の比率のまま表示する */
.photo-thumb img {
  width: 100%;
  height: 110px;
  object-fit: contain;
  background: #fff;
}

/* ---------------------------------------------------------------------- */
/* 保護者向けフォーム                                                    */
/* ---------------------------------------------------------------------- */

.size-guide {
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 10px 14px;
}

.size-guide summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--brand);
  padding: 6px 0;
}

.size-guide-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.size-guide-table th,
.size-guide-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: center;
  font-size: 0.88rem;
}

.size-guide-table thead th {
  background: #f0f2f5;
}

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.product-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

@media (min-width: 640px) {
  .product-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.product-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.product-card.is-selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.product-card-media {
  background: #fff;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

/* 商品写真は切り取らず全体を表示する(cover だとユニフォームの裾や袖が欠ける) */
.product-card-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-placeholder {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.product-card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.product-name-label {
  align-items: flex-start;
}

.product-name {
  font-weight: 700;
  font-size: 1rem;
}

.product-price {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.product-fields {
  display: none;
  flex-direction: column;
  gap: 10px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}

.product-card.is-selected .product-fields {
  display: flex;
}

.size-qty-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
}

.total-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.total-bar-info {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.total-bar-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.total-bar-amount {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--brand-dark);
}

.total-bar .btn {
  flex-shrink: 0;
}

/* ---------------------------------------------------------------------- */
/* 確認画面 / 完了画面                                                   */
/* ---------------------------------------------------------------------- */

.confirm-table th,
.confirm-table td {
  vertical-align: top;
}

.confirm-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 4px;
  border-top: 2px solid var(--brand);
  margin-top: 6px;
}

.confirm-total strong {
  font-size: 1.4rem;
  color: var(--brand-dark);
}

.confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

@media (min-width: 640px) {
  .confirm-actions {
    flex-direction: row;
    justify-content: flex-end;
  }
  .confirm-actions .btn-block {
    width: auto;
  }
  .confirm-actions form {
    display: inline-flex;
  }
}

.complete-panel {
  text-align: center;
}

.complete-panel .btn {
  margin-top: 12px;
}

@media (max-width: 480px) {
  .app-header:not(.app-header-public) .app-brand-sub {
    display: none;
  }
}

/* 発注ダイアログ */
.export-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.export-dialog::backdrop {
  background: rgba(31, 41, 51, 0.45);
}

.export-dialog h2 {
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.export-dialog .field {
  margin-top: 12px;
}

.export-dialog input[type="date"],
.export-dialog textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  font-size: 16px;
  font-family: inherit;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}


/* 発行直後の仕入金額内訳(注文書には金額を載せないため画面で見せる) */
.export-summary {
  margin: 0 0 20px;
  padding: 14px 16px;
  border: 1px solid #e3e3e3;
  border-radius: 8px;
  background: #fff;
}
.export-summary h2 {
  font-size: 1rem;
  margin: 0 0 6px;
}
.export-summary-table td.amount-cell,
.export-summary-table th:not(:first-child) {
  text-align: right;
}
.export-summary-total td {
  font-weight: 700;
  border-top: 2px solid #333;
}
.export-cost-line {
  margin: 0 0 8px;
  font-size: 0.95rem;
}
.export-cost-line strong {
  font-size: 1.15rem;
  margin: 0 4px;
}
.breakdown-detail-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}
.breakdown-detail-table th,
.breakdown-detail-table td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  font-size: 0.85rem;
  text-align: left;
}
.breakdown-detail-table thead th {
  background: #f5f5f5;
}
.hint-inline {
  color: #666;
  font-size: 0.85rem;
}

/* 管理一覧の状況チップ・到着待ちバッジ */
.stage-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.stage-chips .is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.badge-arrival { background: #ede9fe; color: #5b21b6; }
.edit-product.is-collapsed .field { display: none; }
