/* ==================================================
   精算表 練習システム  style.css
================================================== */

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

/* ===== カラー変数 ===== */
:root {
  /* ヘッダー */
  --clr-header-bg:    #1e3a6e;
  --clr-header-text:  #ffffff;

  /* 精算表 */
  --clr-acc-hd:       #8b6914;   /* 最上段ヘッダー */
  --clr-acc-group:    #c49a20;   /* グループヘッダー */
  --clr-acc-sub:      #f0cc70;   /* 借方／貸方ヘッダー */
  --clr-acc-subject:  #fffde7;   /* 勘定科目列背景 */
  --clr-acc-foot:     #f5e6b0;   /* 合計行背景 */

  /* 貸借対照表 */
  --clr-bs-hd:        #5c2d8e;
  --clr-bs-sub:       #d4b8ec;
  --clr-bs-foot:      #ede0f8;

  /* 損益計算書 */
  --clr-pl-hd:        #145080;
  --clr-pl-sub:       #b0cce8;
  --clr-pl-foot:      #daeaf8;

  /* 共通 */
  --clr-border:       #999;
  --clr-row-even:     #fafafa;
  --clr-focus:        #e0eeff;

  /* ボタン */
  --clr-btn-save:     #2e7d32;
  --clr-btn-clear:    #c62828;

  /* フォント */
  --font-ui:  "Meiryo", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  --font-num: "Courier New", "Lucida Console", monospace;

  /* セル高さ */
  --cell-h: 24px;
  --th-h:   26px;
}

/* ===== ベース ===== */
body {
  font-family: var(--font-ui);
  font-size: 12px;
  background: #dde2ea;
  color: #111;
  min-height: 100vh;
}

/* ===== ヘッダー ===== */
.site-header {
  background: var(--clr-header-bg);
  color: var(--clr-header-text);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

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

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-badge {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 3px;
  padding: 2px 8px;
  font-size: 11px;
  letter-spacing: 1px;
}

.header-title {
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ===== ローカル保存トグル ===== */
.save-label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 12px;
  user-select: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  padding: 4px 10px;
  transition: background 0.15s;
}

.save-label:hover {
  background: rgba(255, 255, 255, 0.1);
}

.save-check {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: #90caf9;
}

/* ===== ボタン ===== */
.btn {
  padding: 5px 14px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-ui);
  font-weight: bold;
  transition: filter 0.15s;
}

.btn:hover  { filter: brightness(1.2); }
.btn:active { filter: brightness(0.9); }

.btn-save  { background: var(--clr-btn-save);  color: #fff; }
.btn-clear { background: var(--clr-btn-clear); color: #fff; }

.btn-guide {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  text-decoration: none;
  display: inline-block;
}

/* ===== お知らせバー ===== */
.notice-bar {
  background: #fffbe6;
  border-bottom: 2px solid #f5c842;
  padding: 5px 16px;
  font-size: 11px;
  color: #555;
}

/* ===== メインレイアウト ===== */
.main {
  padding: 12px 16px;
  max-width: 1600px;
  margin: 0 auto;
}

.layout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

/* ===== 精算表 ラッパー ===== */
.wrap-accounting {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

/* ===== 共通テーブル ===== */
.ws-tbl {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.18);
}

.ws-tbl th,
.ws-tbl td {
  border: 1px solid var(--clr-border);
  text-align: center;
  padding: 0;
}

.ws-tbl th {
  height: var(--th-h);
  font-weight: bold;
  white-space: nowrap;
}

.ws-tbl td {
  height: var(--cell-h);
}

/* ===== 精算表ヘッダー ===== */
.tbl-accounting .th-subject {
  background: var(--clr-acc-hd);
  color: #fff;
  width: 115px;
  font-size: 13px;
}

.tbl-accounting .th-group {
  background: var(--clr-acc-group);
  color: #fff;
  font-size: 12px;
}

.tbl-accounting .th-dr,
.tbl-accounting .th-cr {
  background: var(--clr-acc-sub);
  font-size: 11px;
  min-width: 76px;
}

/* ===== 精算表 tbody ===== */
.tbl-accounting tbody tr:nth-child(even) td {
  background: var(--clr-row-even);
}

.tbl-accounting tbody td.td-subject {
  background: var(--clr-acc-subject);
  text-align: left;
}

/* ===== 精算表 合計行 ===== */
.tbl-accounting tfoot td {
  background: var(--clr-acc-foot);
  font-weight: bold;
}

.tbl-accounting tfoot td.td-foot-label {
  background: var(--clr-acc-group);
  color: #fff;
  text-align: left;
  padding: 0 5px;
}

/* ===== 右パネル ===== */
.side-panels {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex-shrink: 0;
  width: 250px;
}

/* ===== BS / PL 共通ヘッダー ===== */
.side-title {
  font-size: 13px;
  font-weight: bold;
  color: #fff;
  height: var(--th-h);
}

.bs-title { background: var(--clr-bs-hd); }
.pl-title { background: var(--clr-pl-hd); }

/* BS サブヘッダー */
.tbl-bs .side-th-sub,
.tbl-bs .side-th-amt {
  background: var(--clr-bs-sub);
  font-size: 11px;
}

/* PL サブヘッダー */
.tbl-pl .side-th-sub,
.tbl-pl .side-th-amt {
  background: var(--clr-pl-sub);
  font-size: 11px;
}

.side-th-sub { min-width: 72px; }
.side-th-amt { min-width: 78px; }

/* BS / PL tbody */
.tbl-bs tbody tr:nth-child(even) td,
.tbl-pl tbody tr:nth-child(even) td {
  background: var(--clr-row-even);
}

.tbl-bs tbody td.td-side-sub,
.tbl-pl tbody td.td-side-sub {
  text-align: left;
}

/* BS 合計行 */
.tbl-bs tfoot td {
  background: var(--clr-bs-foot);
  font-weight: bold;
}

.tbl-bs tfoot td.td-foot-label {
  background: var(--clr-bs-hd);
  color: #fff;
  text-align: left;
  padding: 0 4px;
  font-size: 11px;
}

/* PL 合計行 */
.tbl-pl tfoot td {
  background: var(--clr-pl-foot);
  font-weight: bold;
}

.tbl-pl tfoot td.td-foot-label {
  background: var(--clr-pl-hd);
  color: #fff;
  text-align: left;
  padding: 0 4px;
  font-size: 11px;
}

/* ===== 入力フィールド共通 ===== */
.ws-tbl input {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
  font-family: var(--font-ui);
  padding: 0 4px;
}

.ws-tbl input.inp-text {
  text-align: left;
}

.ws-tbl input.inp-num {
  text-align: right;
  font-family: var(--font-num);
  font-size: 11px;
}

/* フォーカス時のセルハイライト */
.ws-tbl td:focus-within {
  background: var(--clr-focus) !important;
  box-shadow: inset 0 0 0 2px #4a90e2;
}

/* ===== トースト通知 ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: rgba(20, 20, 20, 0.88);
  color: #fff;
  padding: 8px 24px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 500;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== フッター ===== */
.site-footer {
  text-align: center;
  margin-top: 28px;
  padding: 16px;
  border-top: 1px solid #d0ddd8;
  font-size: 12px;
  color: #999;
  line-height: 1.9;
}

.site-footer a {
  color: #999;
  text-decoration: none;
}

.site-footer a:hover {
  color: #555;
  text-decoration: underline;
}

/* ===== 印刷用 ===== */
@media print {
  .site-header,
  .notice-bar,
  .site-footer { display: none; }
  body { background: #fff; }
  .main { padding: 0; }
  .ws-tbl { box-shadow: none; }
}
