/* 共通の見た目（管理画面・注文画面・運営画面）。決まりは DESIGN.md */
:root {
  /* 色：オレンジは主ボタン・新着/未読の印だけ。選ばれている状態は黒 */
  --accent: #f25a00;
  --accent-hover: #d94f00;
  --ink: #222;
  --ink-2: #555;
  --sub: #767676;
  --line: #e4e4e4;
  --line-2: #cfcfcf;
  --bg: #f4f4f2;
  --tint: #f2f2f0;
  --card: #fff;
  --blue: #1f5fbf;
  --green: #1e7a46;
  --gray: #8a8a8a;
  --danger: #c8321e;
  --danger-bg: #fdf1ef;
  --warn-ink: #7a5200;
  --warn-bg: #fbf4e4;
  /* 前の名前（画面のコードが使っている）を新しい色に向ける */
  --brand: var(--accent);
  --brand-ink: var(--ink);
  --brand-weak: var(--tint);
  --brand-line: var(--line-2);
  --new: var(--accent);
  --acc: var(--blue);
  --done: var(--green);
  /* 形：0（一覧）・4px（部品）・8px（小窓・1件の物） */
  --r: 4px;
  --r-lg: 8px;
  /* 文字：12/13/14/16/20/24px、太さ 400/600/700 */
  --f12: .75rem; --f13: .8125rem; --f14: .875rem; --f16: 1rem; --f20: 1.25rem; --f24: 1.5rem;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "BIZ UDPGothic", Meiryo, sans-serif;
  --latin: "Helvetica Neue", Arial, var(--font);
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: 16px; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--f16);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.4; font-weight: 700; }
b, strong { font-weight: 700; }
p { margin: 0; }
a { color: var(--ink); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.num { font-family: var(--latin); font-variant-numeric: tabular-nums; }
.sub { color: var(--sub); }
.small { font-size: var(--f13); }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 名前（字だけ） */
.brandmark { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; flex: none; }
.brandmark b { font-family: var(--latin); font-size: var(--f16); font-weight: 700; letter-spacing: .16em; white-space: nowrap; }

/* ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: #fff; color: var(--ink);
  font-weight: 600; font-size: var(--f14); line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .1s, border-color .1s;
}
.btn:hover { background: #f6f6f5; border-color: #b8b8b8; }
.btn:active { background: #eeeeec; }
.btn:focus-visible, .input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 1px;
}
.btn:disabled { cursor: not-allowed; color: #a3a3a3; background: #f6f6f5; border-color: #e2e2e2; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.primary:disabled { background: #e6e6e4; border-color: #e6e6e4; color: #9a9a9a; }
.btn.outline { border-color: var(--ink); color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); border-color: #e7b3aa; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: var(--f13); }
.btn.lg { min-height: 48px; font-size: var(--f16); padding: 0 20px; }
.btn.block { display: flex; width: 100%; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* 入力 */
.field { display: block; }
.field > span { display: block; font-size: var(--f13); font-weight: 600; margin-bottom: 6px; color: var(--ink-2); }
.field > span em { color: var(--danger); font-style: normal; font-weight: 400; margin-left: 6px; font-size: var(--f12); }
.hint, .field .hint { display: block; font-size: var(--f12); color: var(--sub); margin-top: 4px; font-weight: 400; }
.input, .select, .textarea {
  display: block; width: 100%;
  min-height: 40px; padding: 8px 10px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: #fff; font-size: var(--f16);
}
.input:hover, .select:hover, .textarea:hover { border-color: #b0b0b0; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--ink); outline: none; }
.input::placeholder, .textarea::placeholder { color: #a8a8a8; }
.textarea { min-height: 80px; resize: vertical; line-height: 1.55; }
.select { padding-right: 30px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 8px center; background-size: 14px; background-repeat: no-repeat; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 32px; font-size: var(--f14); }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }

/* 1件の物 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card.pad { padding: 16px; }

/* 状態の札：背景を塗るのは新着だけ */
.pill {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px;
  border-radius: var(--r); font-size: var(--f12); font-weight: 600; white-space: nowrap;
  border: 1px solid currentColor; line-height: 1;
}
.pill.new { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill.accepted { color: var(--blue); border-color: #b6c9e8; }
.pill.delivered { color: var(--green); border-color: #b5d6c3; }
.pill.cancelled { color: var(--gray); border-color: #dcdcdc; }
.pill.stop { color: var(--gray); border-color: #dcdcdc; }
.pill.wait { color: var(--ink-2); border-color: var(--line-2); }
.pill.grp { color: var(--ink-2); background: var(--tint); border-color: var(--tint); font-weight: 400; }

/* 知らせ（囲みの線は付けない） */
.note { border-radius: var(--r); padding: 10px 12px; font-size: var(--f14); line-height: 1.6; }
.note.warn { background: var(--warn-bg); color: var(--warn-ink); }
.note.info { background: var(--tint); color: var(--ink-2); }
.note.err { background: var(--danger-bg); color: var(--danger); }
.note.ok { background: #edf5f0; color: var(--green); }

.demo-banner { background: var(--ink); color: #fff; font-size: var(--f12); text-align: center; padding: 4px 12px; }

/* 小さな知らせ */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1000;
  display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r); font-size: var(--f14);
  box-shadow: 0 2px 8px rgba(0,0,0,.2); pointer-events: auto; width: 100%; }
.toast.err { background: var(--danger); }
@media (max-width: 600px) { .toasts { bottom: auto; top: max(10px, env(safe-area-inset-top)); } }

/* 小窓 */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 900;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.sheet { background: #fff; border-radius: var(--r-lg); width: 100%; max-width: 540px; margin: auto 0;
  display: flex; flex-direction: column; max-height: none; box-shadow: 0 8px 32px rgba(0,0,0,.2); }
.sheet.wide { max-width: 820px; }
.sheet > header { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet > header h2 { font-size: var(--f16); flex: 1; min-width: 0; }
.sheet > .body { padding: 16px; }
.sheet > footer { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  padding: 12px 16px; border-top: 1px solid var(--line); background: #fff; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.sheet > footer .left { margin-right: auto; }
.x-btn { width: 32px; height: 32px; border: 0; background: transparent; border-radius: var(--r); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); margin-right: -6px; }
.x-btn svg { width: 18px; height: 18px; }
.x-btn:hover { background: #f0f0ee; }
@media (max-width: 600px) {
  .overlay { padding: 0; align-items: flex-end; }
  .sheet, .sheet.wide { border-radius: var(--r-lg) var(--r-lg) 0 0; margin: 0; max-height: 94vh; overflow-y: auto; }
  .sheet > header { position: sticky; top: 0; background: #fff; z-index: 1; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .sheet > footer { position: sticky; bottom: 0; border-radius: 0; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .sheet > footer .btn { flex: 1; }
  .sheet > footer .left { flex: 0 0 auto; }
}

/* 空の一覧：1行の灰色の文 */
.empty { color: var(--sub); padding: 20px 16px; font-size: var(--f14); }
.empty b { font-weight: 400; }
.empty .btn { margin-left: 8px; }

.spinner { width: 18px; height: 18px; border: 2px solid #e2e2e0; border-top-color: var(--ink);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px 16px; color: var(--sub); font-size: var(--f14); }

/* 請求書の紙面（画面でも印刷でも同じ。紙の決まりなので上の尺度とは別） */
.invdoc { background: #fff; color: #111; font-size: .9rem; line-height: 1.55; }
.invdoc .nowrap { white-space: nowrap; }
.invdoc .r { text-align: right; white-space: nowrap; }
.invdoc .small { font-size: .78rem; color: #444; }
.invdoc-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border-bottom: 2px solid #111; padding-bottom: 6px; }
.invdoc-h h1 { font-size: 1.5rem; letter-spacing: .4em; white-space: nowrap; }
.invdoc-no { text-align: right; font-size: .82rem; }
.invdoc-top { display: flex; justify-content: space-between; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.invdoc-to { flex: 1 1 280px; }
.invdoc-to .addr { font-size: .82rem; color: #333; }
.invdoc-to .name { font-size: 1.2rem; font-weight: 700; border-bottom: 1px solid #111; padding-bottom: 2px; display: inline-block; min-width: 60%; }
.invdoc-to .lead { margin: 8px 0; font-size: .85rem; }
.invdoc-to .amount { display: flex; align-items: baseline; gap: 10px; border: 2px solid #111; padding: 6px 12px; margin-top: 6px; width: fit-content; }
.invdoc-to .amount b { font-size: 1.45rem; }
.invdoc-to .due { margin-top: 6px; font-weight: 600; }
.invdoc-from { flex: 0 1 260px; font-size: .85rem; text-align: right; }
.invdoc-period { margin: 12px 0 6px; font-size: .85rem; }
.invdoc-tbl, .invdoc-sum table { width: 100%; border-collapse: collapse; }
.invdoc-tbl th, .invdoc-tbl td { border: 1px solid #999; padding: 4px 6px; vertical-align: top; }
.invdoc-tbl th { background: #f0f0f0; font-size: .8rem; text-align: left; }
.invdoc-sum { margin-top: 8px; display: flex; flex-direction: column; align-items: flex-end; }
.invdoc-sum table { width: auto; min-width: 60%; }
.invdoc-sum td { border: 1px solid #999; padding: 4px 8px; }
.invdoc-sum tr.total td { font-weight: 700; font-size: 1.05rem; background: #f5f5f5; }
.invdoc-bank { margin-top: 12px; border: 1px solid #999; padding: 8px 10px; font-size: .85rem; }
@media (max-width: 600px) {
  .invdoc { font-size: .82rem; }
  .invdoc-from { text-align: left; }
  .invdoc-tbl th:nth-child(2), .invdoc-tbl td:nth-child(2) { display: none; }
}

/* 印刷 */
#print { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; }
  body > *:not(#print) { display: none !important; }
  #print { display: block; color: #000; font-size: 10.5pt; }
}
