:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1a1d29;
  --text-sub: #6b7280;
  --primary: #6366f1;
  --border: #e5e7eb;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.container {
  max-width: 500px;
  margin: 0 auto;
  padding: 20px 16px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.header h1 { font-size: 24px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}

.card h3 { font-size: 14px; font-weight: 600; }

.primary-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 14px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.primary-btn:disabled { opacity: 0.6; }

.text-btn {
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-size: 14px;
  font-family: inherit;
  padding: 8px;
  cursor: pointer;
}

.empty {
  color: var(--text-sub);
  text-align: center;
  padding: 32px 0;
}

[hidden] { display: none !important; }

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

.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-sub); }

.form label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 15px; color: var(--text); }

.form input:not([type="checkbox"]), .form select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
}

.form-error { color: #ef4444; font-size: 13px; }

.nav { display: flex; gap: 8px; margin-bottom: 16px; }

.nav a {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  background: var(--card);
  color: var(--text-sub);
  font-size: 14px;
  text-decoration: none;
}

.nav a[aria-current="page"] { background: var(--primary); color: white; }

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  margin-bottom: 8px;
}

.row-title { font-weight: 600; }

.row-sub { color: var(--text-sub); font-size: 13px; }

.link-row { color: inherit; text-decoration: none; }

.link-btn { display: block; text-align: center; text-decoration: none; margin-bottom: 16px; }

.period-form { margin-bottom: 16px; }

.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.field-label { font-size: 13px; color: var(--text-sub); }

.form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
}

.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }

.seg button { border: none; padding: 10px 4px; background: transparent; color: var(--text-sub); font-size: 14px; font-family: inherit; cursor: pointer; }

.seg button[aria-pressed="true"] { background: var(--primary); color: white; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chips button { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text); font-size: 14px; font-family: inherit; cursor: pointer; }

.chips button[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); font-weight: 600; }

#tripRegions { display: flex; flex-direction: column; gap: 8px; }

#tripRegions:empty { display: none; }

.region-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; gap: 6px; align-items: end; }

.form .region-row input:not([type="checkbox"]), .form .region-row select { padding: 10px 6px; }

.day-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }

.day-table th { color: var(--text-sub); font-size: 12px; font-weight: 500; text-align: left; }

.day-table th, .day-table td { padding: 6px 4px; border-bottom: 1px solid var(--border); }

.day-table th:nth-child(n + 3), .day-table td:nth-child(n + 3) { text-align: center; width: 3em; }

.day-table th:last-child, .day-table td:last-child { width: 4.8em; }

.day-table tbody tr:last-child td { background: var(--bg); }

.stay-btn { width: 4.2em; min-height: 36px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text-sub); font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer; }

.stay-btn[data-stay="定額"] { border-color: var(--primary); color: var(--primary); }

.stay-btn[data-stay="クレカ"] { border-color: var(--primary); background: var(--primary); color: white; }

.preview { display: flex; flex-direction: column; gap: 4px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; }

.preview-row { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }

.sheet-head { margin-bottom: 12px; }

.sheet-head h2 { font-size: 20px; }

.text-link { display: inline-block; color: var(--primary); font-size: 14px; margin-top: 4px; }

.sheet-warn { margin-bottom: 8px; }

.totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }

.totals div { background: var(--card); border-radius: 10px; padding: 10px; min-width: 0; }

.totals span { display: block; }

.totals strong { font-size: 16px; font-variant-numeric: tabular-nums; }

.sheet-list { padding: 4px 12px; }

.line { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; border-top: 1px solid var(--border); }

#sheetLines .line:first-child { border-top: none; }

.domestic-head { padding: 10px 0; }

.line-main { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 10px 0; border: none; background: none; color: var(--text); font-family: inherit; text-align: left; cursor: pointer; min-width: 0; }

.line-text { display: flex; flex-direction: column; min-width: 0; }

.pay { padding: 3px 7px; border: none; border-radius: 6px; font-size: 12px; font-weight: 600; font-family: inherit; }

.pay-現金 { background: #fdf0dc; color: #a85a00; }

.pay-クレカ { background: #e2eff9; color: #24639b; }

button.pay { cursor: pointer; }

.line-detail { padding: 0 0 10px; }

.line-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.backup-note { margin-bottom: 12px; }

.backup-note a { color: inherit; }

.table-scroll { overflow-x: auto; background: var(--card); border-radius: 10px; margin-bottom: 12px; }

.monthly-table { border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.monthly-table th, .monthly-table td { padding: 8px; border-bottom: 1px solid var(--border); text-align: right; }

.monthly-table th:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }

.sheet-links { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }

.sheet-btn { display: block; padding: 11px 2px; border: 1px solid var(--primary); border-radius: 8px; background: var(--card); color: var(--primary); font-size: 13px; font-weight: 600; text-align: center; text-decoration: none; }

.print-bar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

.print-bar .check { display: flex; align-items: center; gap: 8px; font-size: 14px; }

.paper { background: var(--card); padding: 16px; border-radius: 4px; font-size: 12px; overflow-wrap: anywhere; }

.paper-title { font-size: 18px; text-align: center; margin-bottom: 12px; }

.paper-section { margin-top: 14px; }

.paper-section h3 { font-size: 13px; margin-bottom: 4px; }

.paper-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }

.paper-table td, .paper-table th { border-bottom: 1px solid var(--border); padding: 4px 3px; text-align: left; vertical-align: top; }

.detail-table td:nth-child(1), .detail-table td:nth-child(3), .detail-table td:nth-child(4) { white-space: nowrap; overflow-wrap: normal; }

.paper-text { white-space: pre-wrap; min-height: 2em; }

.paper-note { font-size: 11px; color: var(--text-sub); margin-top: 6px; }

.tag { display: inline-block; margin: 0 4px; padding: 0 5px; border-radius: 4px; font-size: 10px; font-weight: 700; white-space: nowrap; }

.tag-domestic { background: #d7e8fb; color: #174a7c; }

.tag-overseas { background: #e7e7ee; color: #45465a; }

.tag-invoice { background: #fde2e4; color: #9f1239; }

.tag-cash { background: #fef3c7; color: #92400e; }

.row-domestic td { background: #edf4fd; }

.row-cash td { background: #fef3c7; }

.row-invoice td:first-child { border-left: 4px solid #e11d48; }

.attach-title { margin-top: 16px; }

.attach-section { background: var(--card); padding: 12px; margin-top: 12px; }

.attach-section h3 { font-size: 13px; margin-bottom: 6px; break-after: avoid; } /* 見出しだけがページの下に残らないようにする */

.attach-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.attach-item { break-inside: avoid; font-size: 11px; }

.attach-load { padding: 4px 0; border: none; background: transparent; color: var(--primary); font-size: 12px; font-family: inherit; text-align: left; text-decoration: underline; word-break: break-all; cursor: pointer; }

.attach-item img { display: block; width: 100%; max-height: 120mm; object-fit: contain; }

@page { size: A4 portrait; margin: 12mm; }

@media print {
  body { background: white; }
  .container { max-width: none; padding: 0; }
  .header, .nav, .no-print { display: none !important; }
  .paper, .attach-section { padding: 0; border-radius: 0; }
  .paper-table td, .paper-table th { border-color: #999; }
  .tag, .row-domestic td, .row-cash td, .row-invoice td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .attach-title { break-before: page; break-after: avoid; } /* 添付資料は新しいページから（本体と証拠を分けるため） */
  .attach-section { break-inside: auto; }
}

.wide-btn { width: 100%; margin-bottom: 16px; }

.file-btn { display: inline-block; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; cursor: pointer; }

.form label.file-btn { display: inline-block; color: var(--text); }

.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.file-links { display: flex; flex-wrap: wrap; gap: 4px 12px; flex-basis: 100%; }

.file-links:empty { display: none; }

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

.file-item .text-link { margin-top: 0; }

.invoice { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--text-sub); }

.attach-row { display: flex; flex-wrap: wrap; gap: 6px; }

#sheetPhotos .file-btn { margin-bottom: 10px; }

#sheetUpload, #sheetUploadError { margin-bottom: 8px; }

#sheetUpload:empty, #sheetUploadError:empty { display: none; }

.panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88%;
  overflow-y: auto;
  background: var(--card);
  border-top: 2px solid var(--primary);
  border-radius: 14px 14px 0 0;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
}

.panel-form { max-width: 468px; margin: 0 auto; }

.warn { color: #b3261e; font-size: 13px; font-weight: 600; }

.text-btn.danger { color: #b3261e; font-weight: 600; }

.back { display: inline-block; color: var(--primary); font-size: 14px; text-decoration: none; margin-bottom: 12px; }

.rate-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; }

.rate-table th, .rate-table td {
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-weight: 400;
}

.rate-table thead th { color: var(--text-sub); }

.rate-table thead th:first-child { width: 30%; }

.rate-table tbody th { font-weight: 600; word-break: keep-all; }

.rate-daily { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

.form .rate-table label { margin-bottom: 6px; font-size: 12px; }

.form .rate-table input { padding: 8px; }

/* 報告入力の日ごとの欄 */
.report-day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }

.report-date { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }

.report-state { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 1px 10px; background: #fef3c7; color: #92400e; }

.report-state[data-done="true"] { background: #eef0fe; color: var(--primary); }

.report-block { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; }

.report-block-title { font-size: 13px; font-weight: 600; }

.report-person { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }

.report-person label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-sub); }

.report-costs { font-size: 13px; color: var(--text-sub); border-top: 1px solid var(--border); padding-top: 8px; font-variant-numeric: tabular-nums; }

.report-block .chips button[aria-pressed="true"] { background: var(--primary); color: white; }

.report-block .file-btn { align-self: flex-start; }

/* 報告書の日ごとの記録 */
.report-print-days { display: flex; flex-direction: column; }

.report-print-day { padding: 6px 0; border-bottom: 1px solid var(--border); } /* 1日分が長いときはページの途中で分ける（丸ごと送ると大きな空白ができるため） */

.report-print-head { font-weight: 600; break-after: avoid; }

.report-print-sub { font-size: 12px; color: var(--text-sub); }

.report-ai { display: flex; flex-direction: column; gap: 4px; }

.report-ai .text-btn { align-self: flex-start; }

.report-ai textarea { font-size: 13px; }

.report-claude { align-self: flex-start; padding: 9px 16px; }

/* 会議費・交際費 */
.meeting-month { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.meeting-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; text-align: center; font-variant-numeric: tabular-nums; }

.meeting-totals div { background: var(--bg); border-radius: 8px; padding: 6px 2px; }

.meeting-totals span { display: block; font-size: 11px; color: var(--text-sub); }

.meeting-line { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 10px; padding: 10px 0; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; cursor: pointer; text-decoration: none; color: inherit; }

.meeting-line .amount { text-align: right; font-weight: 600; }

.meeting-line { padding-left: 8px; padding-right: 8px; }

.meeting-cash { background: #fef3c7; }

.meeting-cash .amount { color: #92400e; }

.meeting-line .detail { grid-column: 2 / 4; font-size: 12px; color: var(--text-sub); }

.meeting-tag { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 0 8px; margin-right: 4px; background: #eef0fe; color: var(--primary); }

.nav a { padding: 10px 2px; font-size: 13px; }

.meeting-sheet { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }

.meeting-sheet .row-cash td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

.meeting-sheet td { white-space: pre-line; }

/* 日付・科目・金額・支払は折り返さない */
.meeting-sheet th:nth-child(1), .meeting-sheet td:nth-child(1), .meeting-sheet th:nth-child(2), .meeting-sheet td:nth-child(2),
.meeting-sheet th:nth-child(6), .meeting-sheet td:nth-child(6), .meeting-sheet th:nth-child(7), .meeting-sheet td:nth-child(7) { white-space: nowrap; }

.meeting-sheet th, .meeting-sheet td { border-bottom: 1px solid var(--border); padding: 4px 3px; text-align: left; vertical-align: top; }

/* 現金の記帳を分かりやすくする表示（現金は会計ソフトに入れる分、クレカは直接計上済み） */
.trip-amounts { text-align: right; font-variant-numeric: tabular-nums; }

.trip-cash { font-weight: 700; font-size: 16px; color: #b45309; }

.trip-cash small { display: block; font-size: 11px; font-weight: 600; }

#meetingFilter { margin-bottom: 2px; }

.cash-box { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; font-variant-numeric: tabular-nums; }

.cash-label { font-size: 12px; font-weight: 700; color: #b45309; }

.cash-row { display: flex; justify-content: space-between; align-items: baseline; background: #fef3c7; color: #92400e; border-radius: 6px; padding: 5px 10px; font-size: 14px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

.cash-row strong { font-size: 18px; }

.cash-total { background: transparent; border: 2px solid #b45309; }

.cash-breakdown { font-size: 11px; color: var(--text-sub); padding-left: 10px; }

.cash-domestic { background: #dbeafe; color: #1e40af; }

.meeting-link { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 0 8px; margin-left: 4px; border: 1px solid var(--primary); color: var(--primary); text-decoration: none; }

.linked-card { border: 2px dashed var(--border); }


.report-linked { display: grid; gap: 4px; font-size: 13px; border: 2px dashed var(--border); border-radius: 8px; padding: 8px 10px; }

/* ===== 売上・在庫管理 ===== */
.container.wide { max-width: 1100px; }
.nav { flex-wrap: wrap; }
.note { margin-bottom: 8px; }
.section-title { font-size: 15px; margin: 20px 0 8px; }
.filter { flex-direction: row; flex-wrap: wrap; align-items: end; }
.filter label { min-width: 160px; }
.data-table { border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; width: 100%; }
.data-table th { color: var(--text-sub); font-size: 12px; font-weight: 500; text-align: left; }
.data-table th, .data-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
.data-table .num { text-align: right; }
.data-table .total-row td { font-weight: 700; background: var(--bg); }
.data-table .warn-row td { background: #fef9c3; }
.card .primary-btn { margin-top: 12px; width: 100%; }
.filter label.grow { flex: 1; }
.filter label.check { flex-direction: row; align-items: center; gap: 6px; min-width: 0; color: var(--text); }
.data-table .sub-row td { color: var(--text-sub); font-size: 12px; }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--primary); }
.primary-btn.small { padding: 10px 14px; font-size: 14px; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: #eef0ff; }
.move { display: inline-flex; gap: 2px; }
.icon-btn { border: 1px solid var(--border); background: var(--card); border-radius: 6px; width: 26px; height: 26px; cursor: pointer; color: var(--text-sub); font-family: inherit; }
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
dialog.editor { border: none; border-radius: var(--radius); padding: 20px; width: min(640px, 94vw); max-height: 90vh; margin: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.25); }
dialog.editor::backdrop { background: rgba(0,0,0,0.35); }
.sku-edit input, .sku-edit select { width: 100%; padding: 6px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.dialog-actions .primary-btn { width: auto; padding: 12px 24px; }
.filter-actions { display: flex; gap: 8px; margin-left: auto; }
.primary-btn.outline { background: var(--card); color: var(--primary); border: 1px solid var(--primary); }
#screen.editing .data-table { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 10px; }
.tabs { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; align-self: end; }
.tabs button { border: none; padding: 10px 18px; background: var(--card); color: var(--text-sub); font-size: 14px; font-family: inherit; cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--primary); color: white; font-weight: 600; }
.data-table .weekend-row td { background: #f5f7ff; }
dialog.wide-dialog { width: min(1100px, 96vw); }
.filter-inline { margin-bottom: 8px; max-width: 360px; }

/* 長い商品名などは折り返して全部見せる（省略しない） */
.data-table .wrap { white-space: normal; min-width: 16em; max-width: 30em; }

/* 仕入の登録：入力の表 */
.entry-table td { vertical-align: top; }
.entry-table input, .entry-table select { font: inherit; padding: 4px 6px; }
.entry-table .num-input { width: 6.5em; text-align: right; }
