/* ==========================================
   月次推移損益計算書 スタイルシート
   27インチモニター・1画面完結レイアウト
   ========================================== */

/* -- Reset & Base -------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  /* 27インチ(2560×1440想定)でスクロールなしに収まる全体縮尺 */
  font-size: 11px;
}

body {
  font-family: 'Noto Sans JP', 'Meiryo', 'Yu Gothic', sans-serif;
  font-size: 11px;
  background: #f0f2f5;
  color: #222;
  height: 100vh;
  overflow: hidden; /* body自体はスクロールなし */
}

.hidden { display: none !important; }

/* -- App Layout ---------------------------------------------------- */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* -- Toolbar ------------------------------------------------------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #1a3a5c 0%, #2563a8 100%);
  color: #fff;
  padding: 4px 14px;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
  z-index: 200;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

.app-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
}
.app-title i { margin-right: 5px; opacity: .85; }

.toolbar-right {
  display: flex;
  gap: 5px;
  flex-wrap: nowrap;
}

.auth-status {
  font-size: 10px;
  font-weight: 600;
  color: #ffffff;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 4px;
  padding: 3px 8px;
  white-space: nowrap;
}

.tenant-select {
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 4px;
  background: rgba(255,255,255,.15);
  color: #fff;
  padding: 2px 6px;
  font-size: 10px;
  min-width: 130px;
  font-family: inherit;
}
.tenant-select option {
  color: #222;
}

.btn-tool {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s;
  white-space: nowrap;
}
.btn-tool:hover { background: rgba(255,255,255,.28); }
.btn-tool i { margin-right: 3px; }

/* -- Report Header ------------------------------------------------- */
.report-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  background: #fff;
  padding: 4px 14px 3px;
  border-bottom: 2px solid #2563a8;
  gap: 4px;
  flex-shrink: 0;
}

.report-company {
  font-size: 11px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
}

.report-title-center { text-align: center; }
.report-title {
  font-size: 14px;
  font-weight: 700;
  color: #1a3a5c;
  white-space: nowrap;
}
.report-elapsed {
  font-size: 10px;
  color: #555;
  margin-top: 1px;
}

.report-meta {
  text-align: right;
  font-size: 10px;
  color: #444;
  line-height: 1.5;
}

/* -- Table Wrapper ------------------------------------------------- */
.table-outer {
  flex: 1;
  padding: 4px 6px 2px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.table-scroll-wrapper {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  border-radius: 4px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
  border: 1px solid #d0d7e2;
  background: #fff;
  min-height: 0;
}

/* -- PL Table ----------------------------------------------------- */
.pl-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 10.5px;
  table-layout: fixed;
}

/* 列幅 — 16列合計 ≒ 1240px → 27インチでちょうど収まる */
.pl-table col.col-account { width: 130px; }
.pl-table col.col-prev    { width: 52px;  }
.pl-table col.col-month   { width: 56px;  }
.pl-table col.col-cumul   { width: 64px;  }

/* -- Head ---------------------------------------------------------- */
.pl-table thead tr {
  background: #1a3a5c;
  color: #fff;
  font-size: 10px;
}
.pl-table thead th {
  padding: 4px 2px;
  text-align: center;
  font-weight: 600;
  border-right: 1px solid rgba(255,255,255,.2);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 50;
  background: #1a3a5c;
}
.pl-table thead th:first-child {
  text-align: left;
  padding-left: 8px;
  position: sticky;
  left: 0;
  z-index: 60;
}
.pl-table thead th.th-cumul {
  background: #14305a;
  border-left: 2px solid #5b9bd5;
}
.pl-table thead th.th-current {
  background: #c0392b !important;
  color: #fff;
}

/* sub-header row */
.pl-table thead tr.tr-sub-head th {
  background: #2563a8;
  font-size: 9px;
  padding: 2px 2px;
  font-weight: 400;
}
.pl-table thead tr.tr-sub-head th:first-child {
  background: #2563a8;
  left: 0;
  position: sticky;
  z-index: 60;
}
.pl-table thead tr.tr-sub-head th.th-current-sub {
  background: #c0392b !important;
  color: #fff;
  font-weight: 700;
}
.pl-table thead tr.tr-sub-head th.th-cumul {
  background: #1a4e8a;
}

/* -- Body general -------------------------------------------------- */
.pl-table tbody tr { transition: background .1s; }
.pl-table tbody td {
  padding: 2px 3px;
  border-bottom: 1px solid #e8ecf0;
  border-right: 1px solid #e8ecf0;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

/* 科目名セル (sticky) */
.pl-table tbody td.td-account {
  text-align: left;
  font-size: 10.5px;
  position: sticky;
  left: 0;
  z-index: 10;
  background: inherit;
  min-width: 130px;
  max-width: 130px;
  padding-left: 6px;
  border-right: 2px solid #c8d0d8;
}

/* インデント */
.indent-1 .td-account { padding-left: 14px; }
.indent-2 .td-account { padding-left: 22px; }
.indent-3 .td-account { padding-left: 30px; }

/* -- Row types ----------------------------------------------------- */
.row-header td {
  background: #d6e4f0 !important;
  font-weight: 700;
  font-size: 10.5px;
  color: #1a3a5c;
}
.row-total td {
  background: #c7dff7 !important;
  font-weight: 700;
  border-top: 1.5px solid #2563a8;
  border-bottom: 1.5px solid #2563a8;
}
.row-subtotal td {
  background: #e8f4e8 !important;
  font-weight: 600;
}
.row-ratio td {
  background: #f7f7e0 !important;
  font-style: italic;
  font-size: 10px;
  color: #c0392b;
}
.row-data td { background: #fff; }
.row-data:hover td { background: #f0f7ff; }
.row-spacer td { height: 3px; background: #f0f2f5 !important; border: none; }

/* -- Current month highlight --------------------------------------- */
.col-current {
  border-left: 1.5px solid #e74c3c !important;
  border-right: 1.5px solid #e74c3c !important;
}
.row-header   td.col-current,
.row-total    td.col-current,
.row-subtotal td.col-current { background: #fdd0cc !important; }
.row-data     td.col-current { background: #fff5f4 !important; }
.row-ratio    td.col-current { background: #fff0ef !important; }
.row-data:hover td.col-current { background: #ffe8e6 !important; }

/* -- Cumulative column --------------------------------------------- */
td.td-cumul {
  border-left: 2px solid #2563a8 !important;
  background: #f0f6ff !important;
  font-weight: 600;
  color: #1a3a5c;
}
.row-total    td.td-cumul,
.row-subtotal td.td-cumul { background: #d0e8ff !important; }
.row-ratio    td.td-cumul { background: #e8f2ff !important; }
.row-header   td.td-cumul { background: #d0e8ff !important; }

/* -- Editable input ------------------------------------------------ */
.cell-input {
  width: 100%;
  text-align: right;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 10.5px;
  color: inherit;
  padding: 0 1px;
  outline: none;
  cursor: text;
}
.cell-input:focus {
  background: #fffbe6;
  border-bottom: 1.5px solid #f39c12;
}

/* -- Negative / zero values --------------------------------------- */
.val-negative { color: #c0392b; }
.val-zero     { color: #bbb; }

/* -- Modal -------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 22px 26px;
  min-width: 340px;
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
}
.modal-wide { max-width: 820px; }

.modal-box h2 {
  font-size: 14px;
  font-weight: 700;
  color: #1a3a5c;
  margin-bottom: 14px;
  border-bottom: 2px solid #2563a8;
  padding-bottom: 6px;
}
.modal-box h2 i { margin-right: 6px; }

.modal-hint {
  font-size: 11px;
  color: #666;
  margin-bottom: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #444;
}
.form-grid input,
.form-grid select {
  border: 1px solid #c8d0d8;
  border-radius: 4px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 12px;
  outline: none;
  background: #fafbfc;
  transition: border .2s;
}
.form-grid input:focus,
.form-grid select:focus { border-color: #2563a8; background: #fff; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.btn-primary {
  background: #2563a8;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 7px 18px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.btn-primary:hover { background: #1a4f8e; }
.btn-primary i { margin-right: 4px; }

.btn-secondary {
  background: #e8ecf0;
  color: #333;
  border: none;
  border-radius: 4px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background .2s;
}
.btn-secondary:hover { background: #d0d7e0; }

/* -- Account management ------------------------------------------- */
.account-table-editor {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-top: 6px;
}
.account-table-editor th {
  background: #f0f4f8;
  padding: 5px 6px;
  border: 1px solid #ddd;
  font-weight: 600;
  text-align: left;
  color: #1a3a5c;
  white-space: nowrap;
}
.account-table-editor td {
  padding: 3px 4px;
  border: 1px solid #e8ecf0;
  vertical-align: middle;
}
.account-table-editor input,
.account-table-editor select {
  width: 100%;
  border: 1px solid #d0d7e2;
  border-radius: 3px;
  padding: 3px 5px;
  font-family: inherit;
  font-size: 11px;
  outline: none;
  background: #fafbfc;
}
.account-table-editor input:focus,
.account-table-editor select:focus { border-color: #2563a8; background: #fff; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.btn-icon.delete { color: #e74c3c; }
.btn-icon.delete:hover { background: #fdd0cc; }
.btn-icon.up, .btn-icon.down { color: #2563a8; }
.btn-icon.up:hover, .btn-icon.down:hover { background: #d0e8ff; }

.btn-add-account {
  margin-top: 8px;
  background: #e8f0f8;
  border: 1px dashed #2563a8;
  color: #2563a8;
  border-radius: 4px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  width: 100%;
  transition: background .2s;
}
.btn-add-account:hover { background: #d0e8ff; }
.btn-add-account i { margin-right: 4px; }

/* -- Report Panel（P/L / B/S 共通ラッパー） ----------------------- */
.report-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.report-panel.hidden { display: none !important; }

/* -- Tab Footer --------------------------------------------------- */
.tab-footer {
  display: flex;
  flex-shrink: 0;
  background: #fff;
  border-top: 2px solid #2563a8;
  box-shadow: 0 -2px 8px rgba(0,0,0,.1);
  z-index: 100;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  border: none;
  background: #fff;
  color: #666;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s, color .2s;
  border-right: 1px solid #e8ecf0;
  gap: 1px;
  position: relative;
}
.tab-btn:last-child { border-right: none; }
.tab-btn i   { font-size: 16px; }
.tab-btn span { font-size: 10px; font-weight: 600; }
.tab-btn small { font-size: 9px; color: #aaa; letter-spacing: .05em; }

.tab-btn:hover {
  background: #f0f6ff;
  color: #2563a8;
}
.tab-btn.active {
  background: #f0f6ff;
  color: #2563a8;
  border-top: 3px solid #2563a8;
}
.tab-btn.active small { color: #2563a8; }
.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 40%; height: 2px;
  background: #2563a8;
  border-radius: 2px 2px 0 0;
}

/* =====================================================
   B/S スタイル
   ===================================================== */

/* B/S レイアウト（左右2列） */
.bs-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-width: 900px;
}

.bs-side {
  border: 1px solid #d0d7e2;
}
.bs-side + .bs-side {
  border-left: 2px solid #2563a8;
}

/* サイドタイトル帯 */
.bs-side-title {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  text-align: center;
  letter-spacing: .1em;
}
.bs-assets-title {
  background: linear-gradient(90deg, #1a3a5c, #2563a8);
  color: #fff;
}
.bs-liab-title {
  background: linear-gradient(90deg, #145a2c, #27ae60);
  color: #fff;
}
.bs-side-title i { margin-right: 6px; }

/* B/S テーブル本体 */
.bs-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 10.5px;
  table-layout: fixed;
}

.bs-table col.bs-col-name { width: auto; }
.bs-table col.bs-col-num  { width: 70px; }

.bs-table thead th {
  padding: 3px 4px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  border-bottom: 2px solid;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 30;
}
.bs-assets .bs-table thead th {
  background: #1a3a5c;
  color: #fff;
  border-bottom-color: #5b9bd5;
}
.bs-liabilities .bs-table thead th {
  background: #145a2c;
  color: #fff;
  border-bottom-color: #58d68d;
}
.bs-th-name { text-align: left !important; padding-left: 8px !important; }
.bs-th-cur  { background: rgba(255,255,255,.12) !important; }

/* B/S 行共通 */
.bs-table tbody td {
  padding: 2px 4px;
  border-bottom: 1px solid #e8ecf0;
  line-height: 1.4;
}

.bs-td-name {
  text-align: left;
  font-size: 10.5px;
  padding-left: 8px;
  border-right: 1px solid #e8ecf0;
}
.bs-td-num {
  text-align: right;
  white-space: nowrap;
  width: 70px;
  border-right: 1px solid #e8ecf0;
}
.bs-td-cur  { background: #fafeff; }
.bs-td-diff { background: #fafff8; font-size: 10px; }

/* インデント */
.bs-indent-1 .bs-td-name { padding-left: 16px; }
.bs-indent-2 .bs-td-name { padding-left: 26px; }

/* 行タイプ */
.bs-row-header td {
  background: #d6e4f0 !important;
  font-weight: 700;
  color: #1a3a5c;
  font-size: 10.5px;
}
.bs-liabilities .bs-row-header td {
  background: #d0eedd !important;
  color: #145a2c;
}
.bs-row-total td {
  background: #c7dff7 !important;
  font-weight: 700;
  border-top: 1.5px solid #2563a8;
  border-bottom: 1.5px solid #2563a8;
}
.bs-liabilities .bs-row-total td {
  background: #c3f0d4 !important;
  border-top-color: #27ae60;
  border-bottom-color: #27ae60;
}
.bs-row-subtotal td {
  background: #eaf4fb !important;
  font-weight: 600;
}
.bs-liabilities .bs-row-subtotal td {
  background: #e8f8ee !important;
}
.bs-row-data:hover td { background: #f0f7ff; }
.bs-liabilities .bs-row-data:hover td { background: #f0fff5; }
.bs-row-spacer td { height: 4px; background: #f5f7fa !important; border: none; }

/* 増減値の色 */
.bs-diff-plus  { color: #1a7a3c; font-weight: 600; }
.bs-diff-minus { color: #c0392b; font-weight: 600; }

/* 貸借チェックバー */
.bs-check-bar {
  padding: 5px 16px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  border-top: 2px solid;
}
.bs-check-ok {
  background: #eafaf1;
  color: #1a7a3c;
  border-color: #27ae60;
}
.bs-check-ng {
  background: #fdf2f2;
  color: #c0392b;
  border-color: #e74c3c;
}
.bs-check-bar i { margin-right: 6px; }

/* -- Print -------------------------------------------------------- */
@media print {
  html, body { height: auto; overflow: visible; font-size: 9px; }
  .toolbar, .tab-footer { display: none !important; }
  .table-outer { padding: 0; flex: none; overflow: visible; }
  .table-scroll-wrapper { overflow: visible; flex: none; box-shadow: none; border: none; }
  .pl-table thead th {
    background: #2a4a7a !important; color: #fff !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .report-header { border-bottom: 2px solid #000; }
  @page { size: A3 landscape; margin: 8mm; }
}
