body {
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #f5f5f5;
  margin: 0;
  padding: 24px;
  color: #333;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.page-wide {
  max-width: 960px;
  margin: 0 auto;
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.header-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.header-row > div {
  flex: 1;
  min-width: 200px;
}

.table-scroll {
  overflow-x: auto;
  margin-top: 20px;
}

table.items {
  border-collapse: collapse;
  width: 100%;
  min-width: 900px;
}

table.items th,
table.items td {
  border: 1px solid #ddd;
  padding: 6px;
  font-size: 14px;
}

table.items th {
  background: #edf2f7;
}

table.items input,
table.items select {
  width: 100%;
  padding: 6px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}

table.items input[type="number"] {
  text-align: right;
}

table.items input.f-amount[readonly] {
  background: #f5f5f5;
  color: #666;
}

.amount-cell {
  text-align: right;
  white-space: nowrap;
}

.small-button {
  width: auto;
  margin-top: 0;
  padding: 6px 10px;
  font-size: 13px;
  background: #c53030;
}

.small-button:hover {
  background: #9b2c2c;
}

.add-row-button {
  width: auto;
  margin-top: 12px;
  padding: 8px 16px;
}

.voice-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.voice-button {
  background: #c05621;
}

.voice-button:hover {
  background: #9c4221;
}

.voice-button.listening {
  background: #e53e3e;
}

.field-with-mic {
  display: flex;
  gap: 6px;
  align-items: center;
}

.field-with-mic input {
  flex: 1;
}

.mic-button {
  flex: none;
  width: 40px;
  margin-top: 0;
  padding: 8px 0;
  font-size: 15px;
  background: #c05621;
}

.mic-button:hover {
  background: #9c4221;
}

.mic-button.listening {
  background: #e53e3e;
}

.mic-button:disabled {
  background: #cbd5e0;
  cursor: not-allowed;
}

.voice-status {
  margin-top: 8px;
  font-size: 13px;
  color: #666;
}

.voice-confirm {
  margin-top: 16px;
  padding: 16px;
  background: #fffaf0;
  border: 1px solid #f6ad55;
  border-radius: 8px;
}

.voice-confirm-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: bold;
  color: #7b341e;
}

.voice-confirm-fields {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.voice-confirm-fields > div {
  flex: 1;
  min-width: 140px;
}

.voice-confirm-fields label {
  margin-top: 0;
}

.voice-confirm-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.voice-confirm-actions .add-row-button,
.voice-confirm-actions .small-button {
  margin-top: 0;
}

.totals {
  margin-top: 24px;
  margin-left: auto;
  max-width: 320px;
}

.totals div {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 15px;
}

.totals .grand-total {
  border-top: 2px solid #333;
  margin-top: 6px;
  padding-top: 8px;
  font-weight: bold;
  font-size: 17px;
}

h1 {
  font-size: 20px;
  margin-bottom: 20px;
}

label {
  display: block;
  margin-top: 14px;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: bold;
}

input[type="text"],
select {
  width: 100%;
  padding: 8px;
  font-size: 15px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}

button {
  margin-top: 24px;
  width: 100%;
  padding: 12px;
  font-size: 16px;
  background: #2b6cb0;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background: #2c5282;
}

.big-button {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 28px;
  margin-top: 20px;
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  text-decoration: none;
  color: #fff;
  background: #2b6cb0;
  border-radius: 8px;
}

.big-button:hover {
  background: #2c5282;
}

.big-button.secondary {
  background: #718096;
}

.big-button.secondary:hover {
  background: #4a5568;
}

#saveMessage {
  margin-top: 12px;
  color: #2f855a;
  font-size: 14px;
  text-align: center;
  display: none;
}

/* ===== トップ画面の選択肢 ===== */
.top-choices {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}

.settings-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.settings-link {
  display: block;
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: #718096;
  text-decoration: none;
}

.settings-link:hover {
  text-decoration: underline;
}

/* ===== 請求書作成画面：保存・印刷ボタン ===== */
.invoice-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.add-row-button.secondary {
  background: #718096;
}

.add-row-button.secondary:hover {
  background: #4a5568;
}

.save-message {
  margin-top: 10px;
  color: #2f855a;
  font-size: 14px;
}

/* 印刷時のみ表示する請求元情報（画面上は非表示） */
.print-header {
  display: none;
}

/* ===== 過去の請求書を確認画面 ===== */
.month-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.month-row label {
  margin-top: 0;
}

.month-row input[type="month"] {
  width: auto;
  padding: 8px;
  font-size: 15px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.month-label {
  margin: 20px 0 0;
  font-size: 18px;
}

.stat-cards {
  display: flex;
  gap: 16px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 140px;
  background: #f7fafc;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.stat-card .stat-label {
  font-size: 13px;
  color: #666;
}

.stat-card .stat-value {
  font-size: 22px;
  font-weight: bold;
  margin-top: 4px;
}

.stat-card.paid .stat-value {
  color: #2f855a;
}

.stat-card.unpaid .stat-value {
  color: #c53030;
}

.filter-tabs {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.filter-tab {
  width: auto;
  margin-top: 0;
  padding: 8px 16px;
  font-size: 13px;
  background: #edf2f7;
  color: #333;
}

.filter-tab:hover {
  background: #e2e8f0;
}

.filter-tab.active {
  background: #2b6cb0;
  color: #fff;
}

.invoice-list {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.invoice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.invoice-row-main {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.invoice-client {
  font-weight: bold;
  min-width: 140px;
}

.invoice-amount {
  font-size: 16px;
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
}

.status-badge.paid {
  background: #c6f6d5;
  color: #276749;
}

.status-badge.unpaid {
  background: #fed7d7;
  color: #9b2c2c;
}

.pay-toggle-button {
  width: auto;
  margin-top: 0;
  padding: 6px 12px;
  font-size: 13px;
  background: #2b6cb0;
}

.pay-toggle-button:hover {
  background: #2c5282;
}

.pay-toggle-button.undo {
  background: transparent;
  color: #718096;
  text-decoration: underline;
  padding: 6px 4px;
}

.pay-toggle-button.undo:hover {
  background: transparent;
  color: #4a5568;
}

.empty-message {
  margin-top: 20px;
  color: #718096;
  font-size: 14px;
  text-align: center;
}

/* ===== PDF読み込み（確認パネル）===== */
.confirm-panel {
  margin-top: 20px;
  padding: 16px;
  background: #fffaf0;
  border: 1px solid #f6ad55;
  border-radius: 8px;
}

.import-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.import-status {
  margin-top: 8px;
  font-size: 13px;
  color: #666;
}

.import-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.import-items-table th,
.import-items-table td {
  border: 1px solid #ddd;
  padding: 6px;
  font-size: 13px;
}

.import-items-table th {
  background: #edf2f7;
}

.import-items-table input,
.import-items-table select {
  width: 100%;
  padding: 5px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}

/* ===== レスポンシブ（スマートフォン） ===== */
@media (max-width: 600px) {
  body {
    padding: 12px;
  }

  .page,
  .page-wide {
    padding: 16px;
  }

  .invoice-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .stat-cards {
    flex-direction: column;
  }
}

/* ===== 印刷（簡易PDF出力） ===== */
@media print {
  body {
    background: #fff;
    padding: 0;
  }

  .page-wide {
    box-shadow: none;
    max-width: 100%;
    padding: 0;
  }

  .no-print {
    display: none !important;
  }

  .print-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #333;
  }

  table.items th:last-child,
  table.items td:last-child {
    display: none;
  }

  table.items input,
  table.items select {
    border: none;
    background: transparent;
    padding: 2px;
  }

  .header-row input[type="text"] {
    border: none;
    padding: 2px;
    font-weight: bold;
  }
}
