:root {
  --bg: #f6f7f9; --fg: #1b1f24; --muted: #4b5563; --card: #ffffff; --line: #cfd5dd;
  --brand: #0b4f9c; --brand-fg: #ffffff; --alert: #b3261e; --ok-bg: #e6f4ea; --ok-fg: #14532d;
  --bad-bg: #fdecea; --bad-fg: #7a1710; --warn-bg: #fff4d6; --warn-fg: #5c4400; --focus: #1a73e8;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.6 -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.bar { max-width: 1100px; margin: 0 auto; padding: .5rem 16px; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; }
.brand { font-weight: 700; color: var(--fg); text-decoration: none; }
.brand-sub { font-weight: 400; color: var(--muted, #5b6472); font-size: .85em; margin-left: .35rem; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; list-style: none; margin: 0; padding: 0; }
.nav a { display: inline-block; padding: .5rem .25rem; }
.nav a[aria-current="page"] { font-weight: 700; border-bottom: 3px solid var(--brand); }
.logout { margin-left: auto; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; overflow-wrap: anywhere; }
h1 { font-size: 1.5rem; margin: .5rem 0 1rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin: 16px 0; }
.narrow { max-width: 460px; margin: 32px auto; }
.field { margin: 0 0 14px; display: flex; flex-direction: column; gap: 4px; }
label { font-weight: 600; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], select, textarea, input[type=file] {
  font: inherit; padding: .55rem .6rem; border: 1px solid #6b7280; border-radius: 6px; background: #fff; color: var(--fg); max-width: 100%; }
input.qty { width: 6.5rem; }
.btn { font: inherit; font-weight: 600; display: inline-block; padding: .6rem 1.1rem; border-radius: 6px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-fg); cursor: pointer; text-decoration: none; min-height: 44px; }
.btn:hover { filter: brightness(1.1); }
.btn-secondary { background: #fff; color: var(--brand); }
.btn-quiet { background: transparent; color: var(--fg); border-color: var(--line); }
.btn-small { padding: .4rem .7rem; min-height: 36px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-block { display: inline-block; margin-right: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.filters .field { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.table-wrap { position: relative; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--card); }
th, td { border-bottom: 1px solid var(--line); padding: .5rem .6rem; text-align: left; vertical-align: top; }
th { background: #eef1f5; font-weight: 700; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.totals { max-width: 560px; margin-left: auto; margin-top: 12px; }
.totals .grand th, .totals .grand td { font-size: 1.1rem; border-top: 2px solid var(--fg); }
.notice { padding: .7rem 1rem; border-radius: 6px; margin: 12px 0; border: 1px solid transparent; }
.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: #9bd1ac; }
.bad { background: var(--bad-bg); color: var(--bad-fg); border-color: #f0a9a3; }
.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: #e6c46a; }
.hint { color: var(--muted); font-size: .9rem; }
.badge { display: inline-block; min-width: 1.6rem; text-align: center; padding: 0 .5rem; border-radius: 999px; background: #e5e7eb; color: var(--fg); font-size: .9rem; }
.badge-alert { background: var(--alert); color: #fff; }
.status { font-weight: 700; }
.stock-in_stock { color: #14532d; } .stock-low { color: #7a4b00; } .stock-out { color: var(--alert); }
.plain { list-style: none; margin: 0; padding: 0; } .plain li { padding: .25rem 0; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; }
.meta dt { font-weight: 700; color: var(--muted); } .meta dd { margin: 0; }
.pre { white-space: pre-wrap; }
.est { font-size: 1.05rem; }
.invoice { position: relative; }
.sample-banner { background: var(--warn-bg); color: var(--warn-fg); border: 2px dashed #c79100; padding: .6rem 1rem; }
.sample-mark { color: var(--alert); border: 2px solid var(--alert); border-radius: 4px; padding: 0 .5rem; font-size: 1rem; margin-left: .5rem; }
.badge-new { background: var(--brand); color: var(--brand-fg); font-weight: 700; }
.tag { display: inline-block; border: 1px solid var(--line); border-radius: 4px; padding: 0 .4rem; font-size: .85rem; background: #eef1f5; }
.thread { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.msg { border: 1px solid var(--line); border-left-width: 6px; border-radius: 8px; padding: .6rem .9rem; max-width: 46rem; min-width: 0; }
.msg-own { border-left-color: var(--brand); background: #f1f6fd; margin-left: auto; }
.msg-staff { border-left-color: #6b7280; background: #f4f4f5; margin-right: auto; border-left-style: double; }
.msg-head { margin: 0 0 .25rem; display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline; }
.msg-body { margin: 0; overflow-wrap: anywhere; word-break: break-word; }
.msg-lines { margin-top: .4rem; }
.revise-lines { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.revise-lines legend { font-weight: 600; padding: 0; }
.revise-row { display: flex; flex-direction: column; gap: 4px; padding: .6rem 0; border-bottom: 1px solid var(--line); }
input[aria-invalid="true"] { border-color: var(--alert); border-width: 2px; }
@media (max-width: 640px) {
  .msg { max-width: none; }
  .meta { grid-template-columns: 1fr; } .meta dd { margin-bottom: .5rem; overflow-wrap: anywhere; }
  .logout { margin-left: 0; }
  .brand { display: inline-block; padding: .6rem 0; min-height: 44px; }
  .nav a { padding: .7rem .5rem; min-height: 44px; }
  .btn-small { min-height: 44px; padding: .5rem .9rem; }
  input.qty { width: 5.5rem; min-height: 44px; }
  input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], select, textarea { min-height: 44px; width: 100%; }
  .filters .field { flex: 1 1 100%; }
  .filters .btn, .actions .btn { flex: 1 1 100%; text-align: center; }
  input[type=checkbox] { width: 24px; height: 24px; }
  td, th { overflow-wrap: anywhere; }
  /* stacked cards: one row = one card, each cell labelled by its column header */
  .stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .stack, .stack tbody, .stack tr, .stack td { display: block; width: 100%; }
  .stack tr { border: 1px solid var(--line); border-radius: 8px; padding: .25rem .75rem; margin: 0 0 12px; background: var(--card); }
  .stack td { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: .45rem 0; text-align: right; min-height: 36px; }
  .stack td:last-child { border-bottom: 0; }
  .stack td::before { content: attr(data-label); font-weight: 700; color: var(--muted); text-align: left; flex: 0 0 38%; }
  .stack td.num { white-space: normal; }
  .stack td:not([data-label])::before { content: none; }
  .stack td > * { min-width: 0; }
  .stack td a { display: inline-flex; align-items: center; min-height: 44px; }
  .stack .hint { display: block; }
  .totals, .totals tbody, .totals tr { display: block; width: 100%; max-width: none; }
  .totals tr { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
  .totals th, .totals td { border-bottom: 0; flex: 1 1 auto; }
  .totals th { flex: 1 1 55%; } .totals td.num { flex: 0 0 auto; margin-left: auto; }
  .totals .grand th { flex: 1 1 55%; }
}
@media print {
  .noprint { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  main { max-width: none; padding: 0; }
  .card, table { border: 0; }
  th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit; text-decoration: none; }
  .sample-banner, .sample-mark { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
