* {
  box-sizing: border-box;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #f2f4f7;
  color: #1c2733;
  padding-bottom: 40px;
}

.app-header {
  background: #2f5d8a;
  color: #fff;
  padding: 12px 16px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header h1 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.date-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.date-row input[type="date"] {
  padding: 6px 8px;
  border-radius: 6px;
  border: none;
  font-size: 0.95rem;
}

.date-label {
  font-weight: bold;
  font-size: 1rem;
}

.header-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.header-btn {
  display: inline-block;
  background: #fff;
  color: #2f5d8a;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
  min-height: 40px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.header-btn.danger-btn {
  background: #ffe3e3;
  color: #a12626;
}

main {
  padding: 12px;
}

.table-scroll {
  overflow-x: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.sheet-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 800px;
  font-size: 0.9rem;
}

.sheet-table th,
.sheet-table td {
  border: 1px solid #d5dbe2;
  padding: 4px 6px;
  text-align: center;
  white-space: nowrap;
}

.sheet-table thead th {
  background: #e8eef5;
  position: sticky;
  top: 0;
  z-index: 10;
}

.sheet-table tfoot td {
  background: #eef3f8;
  font-weight: bold;
}

.tfoot-title-row th {
  background: #e8eef5;
  font-weight: bold;
}

.total-split-cell {
  white-space: normal;
  padding: 3px 3px;
}

.total-split-line {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  font-size: 0.78rem;
  line-height: 1.3;
}

.total-label {
  color: #57626d;
  font-weight: normal;
}

.col-num {
  width: 28px;
}

.col-check {
  width: 34px;
}

.col-name {
  min-width: 170px;
  text-align: left;
}

.col-name .name-input {
  width: 100px;
}

.col-name .name-picker {
  width: 56px;
  font-size: 0.75rem;
  margin-left: 4px;
}

.col-fee {
  width: 34px;
}

.col-fee select {
  width: 34px;
  padding: 2px 0;
  font-size: 0.85rem;
  text-align: center;
}

.col-withdrawal,
.col-chips,
.col-food {
  width: 90px;
}

.col-deposit {
  width: 124px;
  padding: 4px 3px;
}

.num-input {
  width: 80px;
  text-align: right;
}

.deposit-cell-btn {
  width: 100%;
  min-height: 40px;
  border: 1px solid #c4ccd6;
  border-radius: 4px;
  background: #fff;
  padding: 4px 3px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}

.deposit-cell-btn.empty {
  color: #8ba3bc;
  justify-content: center;
  align-items: center;
  font-size: 0.85rem;
}

.deposit-cell-line {
  display: block;
  text-align: right;
  font-size: 0.78rem;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.name-input,
.num-input,
select {
  border: 1px solid #c4ccd6;
  border-radius: 4px;
  padding: 5px 4px;
  font-size: 0.9rem;
  min-height: 30px;
}

.col-actions {
  width: 96px;
}

.icon-btn {
  border: none;
  background: #eef1f5;
  border-radius: 4px;
  min-width: 28px;
  min-height: 28px;
  margin: 1px;
  cursor: pointer;
  font-size: 0.85rem;
}

.icon-btn.danger-btn {
  background: #ffe3e3;
  color: #a12626;
}

.check-btn {
  min-width: 32px;
  min-height: 32px;
  border: 1px solid #c4ccd6;
  border-radius: 4px;
  background: #fff;
  color: #2f5d8a;
  font-weight: bold;
  cursor: pointer;
}

.check-btn.checked {
  background: #2f5d8a;
  color: #fff;
}

.add-row-btn {
  margin-top: 12px;
  width: 100%;
  padding: 12px;
  border: 1px dashed #8ba3bc;
  border-radius: 8px;
  background: #fff;
  color: #2f5d8a;
  font-size: 0.95rem;
  cursor: pointer;
}

.save-btn {
  margin-top: 10px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: #2f5d8a;
  color: #fff;
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
}

.summary-section {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.summary-box {
  flex: 1 1 140px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  padding: 10px 12px;
}

.summary-title {
  font-weight: bold;
  color: #2f5d8a;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 2px 0;
}

.summary-label {
  color: #57626d;
}

.summary-value {
  font-size: 1.2rem;
  font-weight: bold;
  color: #1c2733;
}

.summary-input {
  width: 100%;
  border: 1px solid #c4ccd6;
  border-radius: 4px;
  padding: 8px;
  font-size: 1rem;
  text-align: right;
  min-height: 40px;
}

/* モーダル共通 */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
}

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

.modal-header h2 {
  font-size: 1.05rem;
  margin: 0;
}

.modal-subtitle {
  font-size: 0.8rem;
  font-weight: normal;
  color: #57626d;
  margin-left: 6px;
}

.deposit-entries-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.deposit-entry-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.deposit-entry-method {
  width: 64px;
  flex-shrink: 0;
  border: 1px solid #c4ccd6;
  border-radius: 4px;
  padding: 8px 4px;
  font-size: 0.95rem;
  text-align: center;
}

.deposit-entry-amount {
  flex: 1;
  width: auto;
  border: 1px solid #c4ccd6;
  border-radius: 4px;
  padding: 8px;
  font-size: 0.95rem;
  text-align: right;
}

.deposit-empty-hint {
  color: #57626d;
  font-size: 0.9rem;
  text-align: center;
  margin: 8px 0;
}

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

.regular-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.regular-row input {
  flex: 1;
  border: 1px solid #c4ccd6;
  border-radius: 4px;
  padding: 8px;
  font-size: 0.95rem;
}

.danger-btn {
  background: #ffe3e3;
  color: #a12626;
  border: none;
  border-radius: 4px;
  min-width: 32px;
  min-height: 32px;
  cursor: pointer;
}

.add-regular-row {
  display: flex;
  gap: 8px;
}

.add-regular-row input {
  flex: 1;
  border: 1px solid #c4ccd6;
  border-radius: 4px;
  padding: 8px;
  font-size: 0.95rem;
}

.export-preview {
  width: 100%;
  border: 1px solid #d5dbe2;
  border-radius: 6px;
  margin-bottom: 10px;
}

.export-hint {
  font-size: 0.8rem;
  color: #57626d;
  margin-bottom: 12px;
}

#exportDownloadLink {
  width: 100%;
}

/* html2canvasキャプチャ用の非表示スナップショット */
.export-snapshot {
  background: #ffffff;
  padding: 16px;
  width: 720px;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
}

.export-title {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 10px;
}

.export-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}

.export-table th,
.export-table td {
  border: 1px solid #333;
  padding: 4px 6px;
  text-align: center;
}

.export-table tfoot td {
  font-weight: bold;
  background: #f0f0f0;
}

.export-deposit-cell div {
  font-size: 0.82em;
  line-height: 1.3;
}

.export-summary {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.export-summary-box {
  flex: 1;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 0.85rem;
}

.export-summary-title {
  font-weight: bold;
  margin-bottom: 4px;
}

@media (min-width: 640px) {
  .app-header h1 {
    font-size: 1.3rem;
  }
}
