* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  background: #f5f6f8;
  color: #222;
}

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

h1 {
  font-size: 20px;
  margin: 8px 0 16px;
}

.mode-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.mode-toggle label {
  font-size: 15px;
}

/* 種別セグメント（2026-07-19 種別拡大） */
.type-select {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: #fff;
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.type-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 2px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: #444;
  background: #f0f2f5;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
}

.type-button span {
  font-size: 10px;
  font-weight: 400;
  color: #888;
}

.type-button.active {
  background: #2b6cb0;
  color: #fff;
  border-color: #244f80;
}

.type-button.active span {
  color: #cfe0f5;
}

.cash-panel {
  background: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  margin: -8px 0 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.cash-panel .field {
  margin-bottom: 10px;
}

.cash-panel .field:last-child {
  margin-bottom: 0;
}

.cash-panel-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
}

.cash-panel-row select {
  padding: 8px;
  font-size: 15px;
  border: 1px solid #ccc;
  border-radius: 8px;
}

.cash-panel select,
.cash-panel input[type="text"] {
  width: 100%;
  padding: 10px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 8px;
  margin-top: 4px;
}

.capture-area {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.image-source-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.capture-button,
.library-button {
  display: inline-block;
  width: 100%;
  padding: 14px 8px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.capture-button {
  background: #2b6cb0;
  color: #fff;
  border: 1px solid #2b6cb0;
}

.library-button {
  background: #fff;
  color: #2b6cb0;
  border: 1px solid #2b6cb0;
}

.capture-button:active {
  background: #244f80;
}

.library-button:active {
  background: #ebf4ff;
}

#file-input,
#library-input {
  display: none;
}

.image-source-hint {
  margin: 9px 0 0;
  color: #777;
  font-size: 11px;
  line-height: 1.4;
}

.preview-img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 12px;
}

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

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 4px;
}

.field input,
.field select {
  width: 100%;
  padding: 10px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
}

.field input.error,
.field select.error {
  border-color: #e53e3e;
  background: #fff5f5;
}

.accounting-panel {
  margin: 18px -4px 16px;
  padding: 14px;
  border: 1px solid #b7dfc5;
  border-radius: 12px;
  background: #f4fbf6;
}

.accounting-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.accounting-heading h2 {
  margin: 0;
  font-size: 16px;
}

.accounting-heading span {
  color: #2f855a;
  font-size: 11px;
  font-weight: 600;
}

.choice-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.choice-buttons button {
  min-height: 42px;
  padding: 8px 4px;
  border: 1px solid #c8d1d8;
  border-radius: 9px;
  background: #fff;
  color: #444;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
}

.choice-buttons button.active {
  border-color: #2f855a;
  background: #38a169;
  color: #fff;
}

.tax-buttons {
  grid-template-columns: repeat(3, 1fr);
}

.field-hint {
  margin: 7px 0 0;
  color: #777;
  font-size: 11px;
  line-height: 1.45;
}

.tax-mixed-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.tax-mixed-fields .field {
  margin-bottom: 0;
}

.tax-mixed-fields .field label {
  min-height: 32px;
  font-size: 11px;
}

.tax-mixed-fields input {
  padding: 8px;
  font-size: 14px;
}

.tax-total-check {
  grid-column: 1 / -1;
  font-size: 12px;
  text-align: right;
}

.tax-total-check.ok {
  color: #2f855a;
}

.tax-total-check.error {
  color: #e53e3e;
  font-weight: 600;
}

.accounting-summary {
  padding: 9px 10px;
  border-radius: 8px;
  background: #e6f4ea;
  color: #276749;
  font-size: 12px;
  font-weight: 600;
}

.accounting-summary.warning {
  background: #fff8e1;
  color: #975a16;
}

.save-target {
  font-size: 13px;
  color: #555;
  margin-bottom: 12px;
}

.save-button {
  width: 100%;
  padding: 14px;
  background: #38a169;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.save-button:disabled {
  background: #a0aec0;
  cursor: not-allowed;
}

.status {
  margin-top: 10px;
  font-size: 14px;
  text-align: center;
}

/* 保存結果はフォームカードの外にあり、保存後も残り続ける（2026-07-27）。
   カード内の細い文字だと見落とすため、成功時だけ帯として目立たせる */
#save-status {
  margin: 0 0 16px;
}

#save-status.ok {
  background: #e6f4ea;
  border: 1px solid #9ad0ae;
  border-radius: 10px;
  padding: 12px;
  font-weight: 600;
  word-break: break-all;
}

#save-status.error {
  background: #fff5f5;
  border: 1px solid #f0b4b4;
  border-radius: 10px;
  padding: 12px;
  word-break: break-all;
}

.status.error {
  color: #e53e3e;
}

.status.ok {
  color: #2f855a;
}

.status.mock {
  color: #b7791f;
}

.history {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.history h2 {
  font-size: 15px;
  margin: 0;
}

.history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.export-link {
  font-size: 12px;
  color: #2b6cb0;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.history-period {
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #f5f8fc;
  border-radius: 10px;
}

.history-period label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: #555;
}

.history-period-row,
.history-month-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.history-period select {
  min-width: 76px;
  padding: 9px 28px 9px 9px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  border: 1px solid #b8c4d2;
  border-radius: 8px;
}

.history-department-row {
  margin-top: 10px;
}

.history-department-row select {
  width: 100%;
}

.history ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  color: #444;
}

.history li {
  padding: 4px 0;
  border-bottom: 1px solid #eee;
  word-break: break-all;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 2px;
  border: 0;
  background: transparent;
  color: #333;
  font-family: inherit;
  text-align: left;
}

.history-item-name {
  min-width: 0;
  word-break: break-all;
}

.history-department-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.history-department-badge.bokka {
  background: #e5effc;
  color: #24558d;
}

.history-department-badge.kanowa {
  background: #f3e8ff;
  color: #6b3b8f;
}

.history-department-badge.common {
  background: #e6f4ea;
  color: #276749;
}

.history-department-badge.unset {
  background: #eee;
  color: #666;
}

.history-detail {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #b8cbe0;
  border-radius: 10px;
  background: #f8fbff;
}

.history-detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.history-detail h3 {
  margin: 0;
  font-size: 15px;
}

.history-detail-close {
  padding: 6px 10px;
  border: 1px solid #b8c4d2;
  border-radius: 7px;
  background: #fff;
  color: #555;
}

.history-detail dl {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 7px 8px;
  margin: 0 0 14px;
  font-size: 12px;
}

.history-detail dt {
  color: #777;
}

.history-detail dd {
  min-width: 0;
  margin: 0;
  font-weight: 600;
  word-break: break-all;
}

.history-detail-editor > label {
  display: block;
  margin-bottom: 6px;
  color: #555;
  font-size: 12px;
}

.history-detail-save {
  width: 100%;
  margin-top: 10px;
  padding: 11px;
  border: 0;
  border-radius: 9px;
  background: #2b6cb0;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
}

.history-detail-save:disabled {
  background: #a0aec0;
}

/* 今保存した1枚。一覧のどれが自分の分か一目で分かるようにする（2026-07-27） */
.history li.just-saved {
  color: #2f855a;
  font-weight: 600;
}

.history li.just-saved::before {
  content: "✅ ";
}

.hidden {
  display: none !important;
}

/* 個人アカウント・月次締め */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 14px;
}

.app-header h1 {
  margin: 0 0 2px;
}

.current-user-label {
  margin: 0;
  color: #667085;
  font-size: 12px;
}

.text-button {
  padding: 7px 9px;
  border: 1px solid #c8d1d8;
  border-radius: 8px;
  background: #fff;
  color: #555;
  font-family: inherit;
  font-size: 12px;
}

.type-select.staff-mode {
  grid-template-columns: repeat(2, 1fr);
}

.staff-guide {
  margin-bottom: 16px;
  padding: 15px 16px;
  border: 1px solid #b8cbe0;
  border-radius: 12px;
  background: #f8fbff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.staff-guide h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.staff-guide ol {
  margin: 0;
  padding-left: 23px;
}

.staff-guide li {
  margin-bottom: 9px;
  padding-left: 2px;
  color: #24558d;
}

.staff-guide li strong,
.staff-guide li span {
  display: block;
}

.staff-guide li strong {
  color: #222;
  font-size: 13px;
}

.staff-guide li span,
.staff-guide > p,
.staff-monthly-hint {
  color: #667085;
  font-size: 11px;
  line-height: 1.5;
}

.staff-guide > p {
  margin: 10px 0 0;
  padding: 9px 10px;
  border-radius: 8px;
  background: #eaf3ff;
}

.staff-accounting-note {
  margin-bottom: 12px;
}

.staff-accounting-note strong,
.staff-accounting-note span {
  display: block;
}

.staff-accounting-note strong {
  font-size: 15px;
}

.staff-accounting-note span {
  margin-top: 3px;
  color: #667085;
  font-size: 11px;
}

.staff-monthly-hint {
  margin: 10px 0 0;
  padding: 9px 10px;
  border-radius: 8px;
  background: #f5f8fc;
}

.payer-self {
  padding: 11px 12px;
  border: 1px solid #b7dfc5;
  border-radius: 8px;
  background: #f4fbf6;
  color: #276749;
  font-weight: 700;
}

.password-notice,
.monthly-card,
.admin-panel {
  margin-bottom: 16px;
  padding: 16px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.password-notice {
  border: 1px solid #f6c453;
  background: #fffaf0;
}

.password-change-row {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.password-change-row input,
.password-change-row button,
.admin-user-form input,
.admin-user-form select,
.admin-user-form button {
  width: 100%;
  padding: 10px;
  border: 1px solid #c8d1d8;
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
  font-size: 14px;
}

.password-change-row button,
.admin-user-form button {
  border-color: #2b6cb0;
  background: #2b6cb0;
  color: #fff;
  font-weight: 700;
}

.monthly-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.monthly-heading h2,
.admin-panel h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.monthly-heading p {
  margin: 0;
  color: #667085;
  font-size: 11px;
}

.history-period-row.compact select {
  width: 72px;
  padding: 7px 4px;
  border: 1px solid #b8c4d2;
  border-radius: 7px;
  background: #fff;
  font-size: 13px;
}

.monthly-summary-row {
  margin-top: 12px;
  padding: 11px;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: #fafbfc;
}

.monthly-summary-row.own {
  border-color: #b8cbe0;
  background: #f8fbff;
}

.monthly-person,
.monthly-totals,
.admin-user-row,
.admin-monthly-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.monthly-person strong {
  font-size: 14px;
}

.monthly-status-badge {
  padding: 3px 7px;
  border-radius: 999px;
  background: #edf2f7;
  color: #555;
  font-size: 10px;
  font-weight: 700;
}

.monthly-status-badge.submitted { background: #e5effc; color: #24558d; }
.monthly-status-badge.ready { background: #fff3cd; color: #8a6116; }
.monthly-status-badge.paid { background: #e6f4ea; color: #276749; }
.monthly-status-badge.late { background: #fff0f0; color: #b42318; }

.monthly-totals {
  align-items: flex-start;
  flex-direction: column;
  margin-top: 7px;
  color: #4a5568;
  font-size: 12px;
}

.monthly-late,
.legacy-note {
  margin-top: 7px;
  color: #b42318;
  font-size: 11px;
  font-weight: 700;
}

.monthly-submit-button {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border: 0;
  border-radius: 9px;
  background: #2b6cb0;
  color: #fff;
  font-family: inherit;
  font-weight: 700;
}

.monthly-submit-button:disabled {
  background: #a0aec0;
}

.admin-panel {
  margin-top: 14px;
  border: 1px solid #d6dee8;
  box-shadow: none;
}

.admin-panel h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.admin-monthly-row {
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.admin-monthly-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin: 7px 0 0 11px;
}

.admin-monthly-actions button,
.admin-user-row button {
  padding: 6px 8px;
  border: 1px solid #b8c4d2;
  border-radius: 7px;
  background: #fff;
  color: #345;
  font-family: inherit;
  font-size: 11px;
}

.admin-monthly-actions button:disabled {
  opacity: .45;
}

.admin-user-row {
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.admin-user-row > div {
  min-width: 0;
}

.admin-user-row strong,
.admin-user-row span {
  display: block;
}

.admin-user-row span {
  margin-top: 3px;
  color: #667085;
  font-size: 11px;
}

.admin-user-form {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.admin-user-form h3 {
  margin: 0;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(100%, 380px);
  padding: 24px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 30px rgba(34, 57, 80, .12);
}

.login-card h1 {
  margin: 8px 0 4px;
  font-size: 24px;
}

.login-card > p {
  margin: 0 0 22px;
  color: #667085;
  font-size: 13px;
}

.login-mark {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e5effc;
  color: #24558d;
  font-size: 11px;
  font-weight: 700;
}

@media (max-width: 420px) {
  .monthly-heading {
    flex-direction: column;
  }

  .history-period-row.compact {
    width: 100%;
  }
}
