/* =========================================================
   会計中継システム
   style.css
   画面表示・印刷レイアウト
========================================================= */

/* ---------------------------------------------------------
   基本設定
--------------------------------------------------------- */

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  background: #f5f7fa;
  color: #1f2937;
  font-family:
    "Yu Gothic",
    "YuGothic",
    "Meiryo",
    "Hiragino Kaku Gothic ProN",
    sans-serif;
  line-height: 1.6;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}


/* ---------------------------------------------------------
   ヘッダー
--------------------------------------------------------- */

.app-header {
  background: #ffffff;
  border-bottom: 1px solid #d9dee7;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.header-inner h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
}

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


/* ---------------------------------------------------------
   共通ボタン
--------------------------------------------------------- */

button,
.file-button {
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #ffffff;
  color: #1f2937;
  padding: 8px 14px;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

button:hover,
.file-button:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

button:focus-visible,
.file-button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.25);
  outline-offset: 1px;
}

.primary-button {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  font-weight: 700;
}

.primary-button:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}


/* ---------------------------------------------------------
   メインナビゲーション
--------------------------------------------------------- */

.main-nav {
  max-width: 1600px;
  margin: 0 auto;
  padding: 14px 24px 4px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.nav-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 7px;
  background: #ffffff;
  border: 1px solid #d9dee7;
  border-radius: 9px;
}

.nav-group-title {
  font-weight: 700;
  color: #374151;
  padding: 0 7px;
  white-space: nowrap;
}

.nav-button {
  padding: 7px 11px;
  border-radius: 6px;
  background: #f8fafc;
  font-size: 0.92rem;
}

.nav-button.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}


/* ---------------------------------------------------------
   メインコンテンツ
--------------------------------------------------------- */

.main-content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 18px 24px 40px;
}

.screen {
  display: none;
}

.screen.active-screen {
  display: block;
}


/* ---------------------------------------------------------
   画面ヘッダー
--------------------------------------------------------- */

.screen-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.screen-header h2 {
  margin: 0 0 3px;
  font-size: 1.45rem;
  color: #111827;
}

.screen-header p {
  margin: 0;
  color: #64748b;
  font-size: 0.92rem;
}

.screen-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}


/* ---------------------------------------------------------
   フィルター・期間指定
--------------------------------------------------------- */

.filter-area,
.date-range {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: #ffffff;
  border: 1px solid #d9dee7;
  border-radius: 8px;
}

.filter-area label,
.date-range label,
.month-control label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}

input[type="date"],
input[type="month"],
input[type="number"],
input[type="text"],
select,
textarea {
  min-height: 38px;
  padding: 6px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
}

input[type="date"],
input[type="month"] {
  min-width: 150px;
}

input[type="number"] {
  width: 130px;
  text-align: right;
}

.date-range span {
  font-weight: 700;
  color: #64748b;
}


/* ---------------------------------------------------------
   サマリーカード
--------------------------------------------------------- */

.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-card {
  background: #ffffff;
  border: 1px solid #d9dee7;
  border-radius: 9px;
  padding: 13px 16px;
}

.summary-card span {
  display: block;
  color: #64748b;
  font-size: 0.85rem;
  margin-bottom: 2px;
}

.summary-card strong {
  display: block;
  font-size: 1.25rem;
  color: #111827;
}


/* ---------------------------------------------------------
   テーブル
--------------------------------------------------------- */

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  background: #ffffff;
  border: 1px solid #d9dee7;
  border-radius: 9px;
}

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

th,
td {
  border-bottom: 1px solid #e2e8f0;
  padding: 9px 10px;
  vertical-align: middle;
  text-align: left;
  white-space: nowrap;
}

thead th {
  background: #f1f5f9;
  color: #374151;
  font-weight: 700;
  border-bottom: 2px solid #cbd5e1;
}

tbody tr:hover {
  background: #f8fafc;
}

tbody tr:last-child td {
  border-bottom: none;
}

td.amount,
th.amount {
  text-align: right;
}

td.center,
th.center {
  text-align: center;
}


/* ---------------------------------------------------------
   入力対象表示
--------------------------------------------------------- */

.input-target {
  background: #ffffff;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  padding: 12px 15px;
  margin-bottom: 16px;
  font-weight: 700;
}

.receipt-entry-area,
.payment-entry-area {
  background: #ffffff;
  border: 1px solid #d9dee7;
  border-radius: 9px;
  padding: 16px;
}

.receipt-details-header,
.payment-details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.receipt-details-header h3,
.payment-details-header h3 {
  margin: 0;
  font-size: 1.1rem;
}


/* ---------------------------------------------------------
   入金・支払明細表
--------------------------------------------------------- */

#receiptDetailTable,
#paymentDetailTable {
  min-width: 1100px;
}

#receiptDetailTable input,
#receiptDetailTable select,
#paymentDetailTable input,
#paymentDetailTable select {
  width: 100%;
}

#receiptDetailTable input[type="number"],
#paymentDetailTable input[type="number"] {
  min-width: 120px;
  text-align: right;
}

#receiptDetailTable textarea,
#paymentDetailTable textarea {
  min-width: 180px;
  min-height: 38px;
  resize: vertical;
}


/* ---------------------------------------------------------
   入力欄の幅
--------------------------------------------------------- */

.detail-date {
  min-width: 145px;
}

.detail-type {
  min-width: 150px;
}

.detail-account {
  min-width: 180px;
}

.detail-amount {
  min-width: 130px;
}

.detail-tax {
  min-width: 100px;
}

.detail-summary {
  min-width: 220px;
}


/* ---------------------------------------------------------
   入金・支払集計
--------------------------------------------------------- */

.entry-summary {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 15px;
}

.entry-summary > div {
  min-width: 150px;
  background: #f8fafc;
  border: 1px solid #d9dee7;
  border-radius: 7px;
  padding: 9px 13px;
}

.entry-summary span {
  display: block;
  color: #64748b;
  font-size: 0.82rem;
}

.entry-summary strong {
  display: block;
  font-size: 1.05rem;
  text-align: right;
}

.entry-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}


/* ---------------------------------------------------------
   伝票メモ
--------------------------------------------------------- */

.voucher-note {
  margin-bottom: 16px;
  padding: 11px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #1e3a8a;
}


/* ---------------------------------------------------------
   データ管理
--------------------------------------------------------- */

.data-management-card {
  background: #ffffff;
  border: 1px solid #d9dee7;
  border-radius: 9px;
  padding: 20px;
  max-width: 900px;
}

.data-management-card h3 {
  margin: 0 0 9px;
  font-size: 1.1rem;
}

.data-management-card p {
  margin: 0 0 13px;
  color: #64748b;
}

.month-control {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.data-management-card hr {
  margin: 24px 0;
  border: 0;
  border-top: 1px solid #e2e8f0;
}


/* ---------------------------------------------------------
   メッセージ
--------------------------------------------------------- */

.message-area {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  max-width: 420px;
  pointer-events: none;
}

.message-area .message {
  margin-top: 8px;
  padding: 11px 15px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.12);
  color: #1f2937;
  pointer-events: auto;
}

.message-area .message.success {
  border-color: #86efac;
}

.message-area .message.error {
  border-color: #fca5a5;
}

.message-area .message.warning {
  border-color: #fcd34d;
}


/* ---------------------------------------------------------
   状態表示
--------------------------------------------------------- */

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.status-complete {
  background: #dcfce7;
  color: #166534;
}

.status-error {
  background: #fee2e2;
  color: #991b1b;
}

.status-partial {
  background: #dbeafe;
  color: #1e40af;
}


/* ---------------------------------------------------------
   仕訳表
--------------------------------------------------------- */

#receiptJournalTable,
#paymentJournalTable {
  min-width: 1050px;
}

#receiptJournalTable th,
#receiptJournalTable td,
#paymentJournalTable th,
#paymentJournalTable td {
  padding: 8px 9px;
}

.journal-edit-input {
  width: 100%;
  min-width: 180px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
}


/* ---------------------------------------------------------
   販売システム伝票表
--------------------------------------------------------- */

#receiptSalesVoucherTable,
#paymentSalesVoucherTable {
  min-width: 950px;
}


/* ---------------------------------------------------------
   空データ表示
--------------------------------------------------------- */

.empty-row td {
  padding: 30px 15px;
  text-align: center;
  color: #64748b;
  background: #ffffff;
}


/* ---------------------------------------------------------
   小さい画面への対応
--------------------------------------------------------- */

@media (max-width: 900px) {

  .header-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .main-nav {
    padding-left: 12px;
    padding-right: 12px;
  }

  .main-content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .summary-cards {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .screen-header {
    flex-direction: column;
  }

  .screen-actions {
    justify-content: flex-start;
  }

}


@media (max-width: 560px) {

  .summary-cards {
    grid-template-columns: 1fr;
  }

  .header-inner {
    padding: 13px 14px;
  }

  .main-content {
    padding: 12px 10px 30px;
  }

  .main-nav {
    padding: 10px;
  }

  .nav-group {
    width: 100%;
  }

  .nav-button {
    flex: 1 1 auto;
  }

}


/* =========================================================
   印刷設定
========================================================= */

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

@media print {

  html,
  body {
    background: #ffffff;
    color: #000000;
    margin: 0;
    padding: 0;
  }

  body {
    font-size: 10pt;
  }

  .app-header,
  .main-nav,
  .screen-header,
  .filter-area,
  .date-range,
  .summary-cards,
  .entry-summary,
  .entry-actions,
  .data-management-card,
  .message-area,
  .screen-actions,
  .file-button,
  button {
    display: none !important;
  }

  .main-content {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .screen {
    display: none !important;
  }

  .screen.active-screen {
    display: block !important;
  }

  .table-wrapper {
    width: 100%;
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  table {
    width: 100%;
    min-width: 0 !important;
    border-collapse: collapse;
  }

  th,
  td {
    padding: 4px 5px;
    border: 1px solid #000000;
    font-size: 9pt;
    color: #000000;
    white-space: normal;
  }

  thead th {
    background: #eeeeee !important;
    color: #000000 !important;
  }

  .journal-edit-input {
    border: 0;
    padding: 0;
    min-width: 0;
    background: transparent;
    color: #000000;
  }

  .voucher-note {
    margin-bottom: 8px;
    padding: 5px 7px;
    border: 1px solid #000000;
    background: #ffffff;
    color: #000000;
  }

  .empty-row td {
    padding: 15px;
  }

  /* 印刷時は上から詰めて配置 */
  .main-content,
  .screen.active-screen,
  .table-wrapper {
    position: static;
  }

}
