:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --card: #ffffff;
  --line: #e2ddd2;
  --ink: #2c2a26;
  --ink-sub: #6f6a60;
  --accent: #2f5d62;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

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

.back-to-front {
  position: sticky; top: 0; z-index: 50;
  display: block; padding: 12px 18px;
  background: #3a2417; color: #f3e6d2;
  font-size: 15px; text-decoration: none; letter-spacing: .04em;
  border-bottom: 1px solid rgba(226,183,132,.28);
}
.back-to-front:active { background: #4a2f1e; }

.app-header {
  padding: 22px 18px 10px;
  text-align: center;
}
.app-header h1 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--accent);
  letter-spacing: .05em;
}
.header-sub {
  color: var(--ink-sub);
  font-size: .9rem;
  margin-top: 4px;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 16px;
}
.card-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  color: var(--accent);
}
.note {
  color: var(--ink-sub);
  font-size: .88rem;
  margin: 0 0 12px;
}

/* ---------- 送り先情報 ---------- */
.head-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}
.head-item { display: flex; flex-direction: column; gap: 2px; }
.head-label { font-size: .78rem; color: var(--ink-sub); }
.head-value { font-size: 1.02rem; font-weight: 600; }

/* ---------- 日付選択 ---------- */
.date-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(90px, 1fr));
  gap: 8px;
  overflow-x: auto;
}
.date-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 4px;
}
.date-cell .wd {
  font-weight: 700;
  color: var(--accent);
}
.date-cell input[type="date"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 2px;
  font-size: .82rem;
  text-align: center;
}

/* ---------- 数量テーブル ---------- */
.table-scroll { overflow-x: auto; }
.order-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 720px;
}
.order-table th, .order-table td {
  border: 1px solid var(--line);
  padding: 8px 6px;
  text-align: center;
  font-size: .9rem;
}
.order-table th { background: #f0ede4; color: var(--ink-sub); font-weight: 600; }
.order-table td.item-name { text-align: left; font-weight: 600; white-space: nowrap; }
.order-table td.base-num { color: var(--ink-sub); }
.order-table select {
  width: 64px;
  padding: 5px 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: .95rem;
  text-align: center;
}

/* ---------- ボタン ---------- */
.action-row {
  display: flex;
  gap: 10px;
  margin: 4px 0 6px;
  flex-wrap: wrap;
}
.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px 22px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.primary-btn:active { opacity: .85; }
.ghost-btn {
  background: #fff;
  color: var(--ink-sub);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 18px;
  font-size: .95rem;
  cursor: pointer;
}
.pdf-help {
  background: #fdf3e2;
  border: 1px solid #e0b26a;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

/* ---------- 履歴 ---------- */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfaf6;
  cursor: pointer;
  font-size: .92rem;
}
.history-item:active { background: #f0ede4; }
.history-range { font-weight: 600; }
.history-meta { color: var(--ink-sub); font-size: .8rem; }

/* ---------- 印刷用ビュー(画面では隠す) ---------- */
.print-area { display: none; }

@media print {
  .back-to-front, .app-header, main { display: none !important; }
  body { padding: 0; background: #fff; }
  .print-area {
    display: block;
    font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
    color: #000;
    padding: 10mm;
  }
  .p-title {
    text-align: center;
    font-size: 22pt;
    letter-spacing: .3em;
    margin-bottom: 6mm;
  }
  .p-headline {
    text-align: right;
    font-size: 10pt;
    margin-bottom: 4mm;
  }
  .p-head-grid {
    display: flex;
    gap: 6mm;
    align-items: stretch;
    margin-bottom: 6mm;
    font-size: 10.5pt;
  }
  .p-fax { flex: 1; line-height: 1.5; }
  .p-box {
    border: 1px solid #000;
    display: flex;
    flex-direction: column;
    min-width: 40mm;
  }
  .p-box-label {
    border-bottom: 1px solid #000;
    padding: 1.5mm 3mm;
    font-size: 8.5pt;
    background: #f2f2f2;
  }
  .p-box-value {
    padding: 2.5mm 3mm;
    font-size: 12pt;
    font-weight: 700;
    text-align: center;
  }
  .p-route { min-width: 22mm; }
  .p-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9.5pt;
  }
  .p-table th, .p-table td {
    border: 1px solid #000;
    padding: 2mm 1.5mm;
    text-align: center;
  }
  .p-table td.p-item-name { text-align: left; white-space: nowrap; }
}
