* { box-sizing: border-box; }
:root {
  --bg: #faf7f1; --card: #ffffff; --ink: #232c3d; --muted: #6f7280;
  --accent: #b45309; --accent2: #1f3a5f; --warn: #dc2626; --warn-bg: #fef2f2;
  --line: #e7e1d4; --ok: #15803d; --muted-bg: #efe9df;
}
html, body { margin: 0; padding: 0; }
body { font-family: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif; background: var(--bg); color: var(--ink); padding-bottom: 96px; }
header { background: var(--accent2); color: #fff; padding: 12px 16px; position: sticky; top: 0; z-index: 20; border-bottom: 1px solid rgba(0,0,0,.15); }
.header-inner { max-width: 1024px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
header h1 { margin: 0; font-size: 18px; font-weight: 900; letter-spacing: .04em; }
.store-switch { display: flex; gap: 0; background: rgba(255,255,255,.15); border-radius: 999px; padding: 4px; }
.store-btn { padding: 7px 18px; border-radius: 999px; border: none; background: transparent; color: rgba(255,255,255,.85); font-size: 14px; font-weight: 700; cursor: pointer; transition: all .15s; }
.store-btn.active { background: #fff; color: var(--accent2); box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.alert-banner { background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid #fecaca; padding: 10px 16px; font-weight: 700; font-size: 14px; }
.hidden { display: none !important; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--muted-bg); border-radius: 12px; margin-bottom: 14px; }
.tab-btn { flex: 1; padding: 9px 2px; border: none; border-radius: 9px; background: transparent; font-size: 14px; font-weight: 700; color: var(--muted); cursor: pointer; position: relative; transition: all .15s; }
.tab-btn.active { color: var(--ink); background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.14); }
.badge { background: var(--warn); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 6px; margin-left: 3px; vertical-align: top; }
main { padding: 16px 12px 12px; max-width: 1024px; margin: 0 auto; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.stat-card.warn { background: var(--warn-bg); border-color: #fecaca; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-num { font-size: 24px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.card h2 { margin: 0 0 12px; font-size: 17px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-head h2 { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form-grid label.wide { grid-column: 1 / -1; }
input, select { font-size: 16px; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent2); outline-offset: 0; }
.input-with-mic { display: flex; gap: 6px; }
.input-with-mic input { flex: 1; }
.mic-btn { font-size: 18px; padding: 6px 12px; border-radius: 8px; border: 1px solid #d1d5db; background: #f9fafb; cursor: pointer; }
.mic-btn.listening, .voice-op-btn.listening { background: #fee2e2; border-color: var(--warn); }
.mic-btn:disabled { opacity: .4; }
.primary-btn { background: var(--accent2); color: #fff; border: none; border-radius: 10px; padding: 11px 18px; font-size: 15px; font-weight: 700; cursor: pointer; }
.primary-btn:active { opacity: .85; }
.list-title { margin: 0 0 12px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: #fff; border: 1px solid #d8d2c4; color: var(--muted); border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 700; cursor: pointer; }
.chip.active { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.filter-row #search { flex: 1; min-width: 150px; width: auto; margin: 0; }
.filter-row #supplier-filter { width: auto; flex: 0 1 170px; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.add-main-btn { font-size: 15px; padding: 11px 18px; border-radius: 10px; box-shadow: 0 2px 8px rgba(31,58,95,.35); white-space: nowrap; flex: 0 0 auto; }
.small-btn { padding: 7px 12px; font-size: 13px; }
.ghost-btn { background: #fff; color: var(--ink); border: 1px solid #d1d5db; border-radius: 10px; padding: 11px 16px; font-size: 15px; cursor: pointer; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0; line-height: 1.5; }
.voice-op-btn { background: #eef2ff; border: 1px solid #c7d2fe; color: var(--accent2); border-radius: 10px; padding: 9px 12px; font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.voice-op-btn:disabled { opacity: .4; }
.voice-status { background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 10px; font-size: 14px; margin: 8px 0; }
#search { margin: 6px 0 12px; }
.items-list { display: flex; flex-direction: column; gap: 10px; }
.item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.item.low { border-color: #fca5a5; background: var(--warn-bg); }
.item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.item-name { font-size: 16px; font-weight: 700; }
.item-qty { font-size: 16px; font-weight: 700; white-space: nowrap; }
.item-qty .unit { font-size: 12px; color: var(--muted); font-weight: 400; }
.low-badge { background: var(--warn); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.item-meta { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.item-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.item-actions input[type="number"] { width: 72px; padding: 7px 8px; font-size: 15px; }
.act-btn { border-radius: 8px; border: 1px solid #d1d5db; background: #f9fafb; padding: 8px 12px; font-size: 14px; font-weight: 700; cursor: pointer; }
.act-btn.in { background: #ecfdf5; border-color: #a7f3d0; color: var(--ok); }
.act-btn.out { background: #fff7ed; border-color: #fed7aa; color: var(--accent); }
.act-btn.small { font-size: 12px; padding: 7px 9px; font-weight: 400; }
.loading, .empty { color: var(--muted); text-align: center; padding: 18px 0; }
.proposal { border: 1px solid #fca5a5; background: var(--warn-bg); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.proposal .p-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.proposal .p-name { font-weight: 700; font-size: 16px; }
.proposal .p-meta { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.proposal .p-actions { display: flex; gap: 6px; margin-top: 10px; align-items: center; }
.proposal input[type="number"] { width: 80px; padding: 7px 8px; }
.order-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 14px; }
.order-row .o-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.status-chip { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; background: #e0e7ff; color: var(--accent2); }
.status-chip.done { background: #dcfce7; color: var(--ok); }
.move-row { display: flex; justify-content: space-between; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 14px; gap: 8px; }
.move-row:last-child { border-bottom: none; }
.move-delta { font-weight: 700; white-space: nowrap; }
.move-delta.plus { color: var(--ok); }
.move-delta.minus { color: var(--warn); }
.move-meta { font-size: 12px; color: var(--muted); }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.summary-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 14px 8px; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.summary-box.warn { background: var(--warn-bg); border-color: #fecaca; }
.summary-num { font-size: 20px; font-weight: 800; }
.summary-label { font-size: 12px; color: var(--muted); }
.consultant-head { display: flex; gap: 12px; align-items: flex-start; }
.consultant-head .avatar { flex-shrink: 0; width: 56px; height: 56px; border-radius: 50%; overflow: hidden; line-height: 0; background: #dbeafe; }
.consultant-head .avatar img { width: 56px; height: 56px; object-fit: cover; display: block; }
.who-avatar { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; vertical-align: -5px; margin-right: 5px; }
.consultant-name { margin: 0 0 4px !important; }
.consultant-intro { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 0; }
.unavailable { background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 10px; font-size: 13px; margin-top: 12px; }
.chat-log { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; max-height: 46vh; overflow-y: auto; padding: 4px 2px; }
.msg { max-width: 88%; padding: 10px 12px; border-radius: 14px; font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--accent2); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: #f1f5f9; border-bottom-left-radius: 4px; }
.msg.ai .who { display: block; font-size: 11px; font-weight: 700; color: var(--accent2); margin-bottom: 3px; }
.chat-input-row { display: flex; gap: 8px; margin-top: 12px; }
.chat-input-row input { flex: 1; }
.quick-questions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.quick-questions button { background: #fff; border: 1px solid #d1d5db; border-radius: 999px; padding: 7px 12px; font-size: 13px; cursor: pointer; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-box { background: #fff; border-radius: 16px; padding: 20px; max-width: 440px; width: 100%; max-height: 85vh; overflow-y: auto; }
.modal-box h3 { margin: 0 0 10px; font-size: 17px; }
.modal-box #modal-body { font-size: 14px; line-height: 1.7; }
.modal-box #modal-body table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.modal-box #modal-body td { padding: 4px 6px; border-bottom: 1px solid var(--line); font-size: 14px; }
.modal-box #modal-body td:first-child { color: var(--muted); width: 38%; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111827; color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; z-index: 60; box-shadow: 0 4px 16px rgba(0,0,0,.3); max-width: 90vw; text-align: center; }
@media (max-width: 480px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .stat-num { font-size: 18px; }
  .tab-btn { font-size: 13px; }
  .add-main-btn { flex: 1; text-align: center; }
}
