/* 政治資金管理モジュール - ビジネスライクデザイン */
:root {
  --f-bg: #f7f8fa;
  --f-surface: #fff;
  --f-border: #dde1e6;
  --f-text: #21272a;
  --f-text-sub: #697077;
  --f-text-muted: #a2a9b0;
  --f-accent: #393f49;
  --f-accent-hover: #2d3239;
  --f-link: #4a6fa5;
  --f-success: #3a7d44;
  --f-warning: #8a6d3b;
  --f-danger: #a94442;
  --f-row-alt: #fafbfc;
}

.funds-module { background: var(--f-bg); min-height: 100vh; font-family: 'Yu Gothic UI', 'Meiryo', 'Segoe UI', sans-serif; color: var(--f-text); }

/* レイアウト */
.funds-layout { display: flex; min-height: calc(100vh - 56px); }
.funds-sidebar {
  width: 220px; background: var(--f-surface); border-right: 1px solid var(--f-border);
  padding: 12px 0; flex-shrink: 0;
}
.funds-main { flex: 1; padding: 24px 28px; overflow-y: auto; }

/* サイドバー */
.funds-sidebar-year { padding: 0 14px 12px; border-bottom: 1px solid var(--f-border); margin-bottom: 4px; }
.funds-sidebar-year label { display: block; font-size: 10px; color: var(--f-text-sub); margin-bottom: 3px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; }
.funds-year-select {
  width: 100%; padding: 5px 8px; border: 1px solid var(--f-border); border-radius: 4px;
  font-size: 13px; background: var(--f-surface); color: var(--f-text);
}
.funds-sidebar-section { margin-top: 2px; }
.funds-sidebar-heading {
  padding: 8px 14px 3px; font-size: 10px; font-weight: 700; color: var(--f-text-muted);
  letter-spacing: .5px; text-transform: uppercase;
}
.funds-sidebar-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 20px; color: var(--f-text-sub); text-decoration: none;
  font-size: 12px; font-weight: 500; transition: background .1s; border-left: 3px solid transparent;
}
.funds-sidebar-item:hover { background: var(--f-row-alt); color: var(--f-text); }
.funds-sidebar-item.active { background: var(--f-row-alt); color: var(--f-text); font-weight: 600; border-left-color: var(--f-accent); }

/* ダッシュボード */
.funds-dashboard h2 { font-size: 17px; font-weight: 600; color: var(--f-text); margin-bottom: 16px; letter-spacing: -.2px; }
.funds-stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; margin-bottom: 28px;
}
.funds-stat-card {
  background: var(--f-surface); border-radius: 6px; padding: 16px 18px;
  border: 1px solid var(--f-border);
}
.funds-stat-label { font-size: 11px; color: var(--f-text-sub); font-weight: 600; margin-bottom: 4px; letter-spacing: .3px; }
.funds-stat-value { font-size: 20px; font-weight: 700; color: var(--f-text); }

.funds-nav-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}
.funds-nav-card {
  background: var(--f-surface); border-radius: 6px; padding: 16px 18px; cursor: pointer;
  border: 1px solid var(--f-border); transition: border-color .15s;
}
.funds-nav-card:hover { border-color: var(--f-accent); }
.funds-nav-card-title { font-size: 14px; font-weight: 600; color: var(--f-text); margin-bottom: 3px; }
.funds-nav-card-desc { font-size: 11px; color: var(--f-text-sub); line-height: 1.5; }

/* パネル */
.funds-panel {
  background: var(--f-surface); border-radius: 6px; margin-bottom: 16px;
  border: 1px solid var(--f-border); overflow: hidden;
}
.funds-panel-header {
  padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--f-text);
  background: var(--f-row-alt); border-bottom: 1px solid var(--f-border);
}
.funds-panel-body { padding: 16px; }

/* グリッド */
.funds-grid { display: grid; gap: 12px; }
.funds-grid-2 { grid-template-columns: repeat(2, 1fr); }
.funds-grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 768px) {
  .funds-layout { flex-direction: column; }
  /* モバイル: サイドバー非表示、領収書管理のみ */
  .funds-sidebar { display: none; }
  .funds-main { padding: 12px; }
  .funds-grid-2, .funds-grid-4 { grid-template-columns: 1fr !important; }

  /* 領収書カード */
  .funds-receipt-grid { grid-template-columns: 1fr; gap: 10px; }
  .funds-receipt-card { display: flex; flex-direction: row; }
  .funds-receipt-thumb { width: 100px; height: auto; min-height: 80px; flex-shrink: 0; }
  .funds-receipt-body { flex: 1; }
  .funds-receipt-amount { font-size: 15px; }

  /* 月タブ横スクロール */
  .funds-month-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .funds-month-tab { flex-shrink: 0; }

  /* モーダル モバイル対応 */
  .funds-modal-overlay { align-items: stretch; justify-content: stretch; padding: 0; }
  .funds-modal {
    width: 100%; max-width: 100%; height: 100%; max-height: 100%;
    border-radius: 0; display: flex; flex-direction: column;
  }
  .funds-modal-cols {
    display: flex !important; flex-direction: column !important; flex: 1;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  .funds-modal-left {
    width: 100% !important; border-right: none !important;
    border-bottom: 1px solid var(--f-border);
    padding: 12px !important; flex-shrink: 0 !important; min-height: 0;
  }
  .funds-modal-right {
    width: 100% !important; padding: 12px !important; flex-shrink: 0;
  }
  .funds-modal-right h3 { font-size: 15px; margin-bottom: 10px; }
  .funds-modal-right .funds-grid { grid-template-columns: 1fr !important; gap: 8px !important; }
  .funds-modal-right .funds-field { margin-bottom: 0; }
  .funds-modal-right .funds-input { font-size: 16px; padding: 10px; }
  .funds-modal-right select.funds-input { font-size: 16px; padding: 10px; }
  .funds-modal-right .funds-actions { flex-direction: column; gap: 8px; margin-top: 12px; padding-bottom: 24px; }
  .funds-modal-right .funds-actions .funds-btn { width: 100%; text-align: center; padding: 14px; font-size: 15px; }
  /* モーダル内のスクロールを確実に */
  .funds-modal-right { padding-bottom: 40px !important; }
  .funds-modal-img { max-height: 200px; width: 100%; object-fit: contain; }
  .funds-dropzone {
    padding: 24px 16px; font-size: 14px; min-height: 120px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
  }
  .funds-dropzone p { margin: 4px 0; }
  .funds-spinner-overlay { border-radius: 0; }
  .funds-compliance-result { font-size: 12px; padding: 10px 12px; }
  .funds-address-source { font-size: 10px; }
  .funds-hint { font-size: 11px; padding: 8px 10px; }

  .funds-hide-mobile { display: none !important; }
  .funds-mobile-fab { display: block !important; }

  /* ボタン */
  .funds-actions { flex-wrap: wrap; }
  .funds-btn { padding: 10px 16px; font-size: 14px; }

  /* ビューヘッダー */
  .funds-view-header { flex-direction: column !important; align-items: flex-start !important; gap: 8px; }

  /* 新規アップロード: 画面最下部に固定 */
  .funds-mobile-fab {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: var(--f-surface); border-top: 1px solid var(--f-border);
    box-shadow: 0 -2px 8px rgba(0,0,0,.08);
  }
  .funds-mobile-fab .funds-btn { width: 100%; padding: 14px; font-size: 15px; font-weight: 600; }
  /* FABの分だけ下にパディング */
  .funds-main { padding-bottom: 80px !important; }

  /* 統計カード */
  .funds-stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .funds-stat-card { padding: 12px; }
  .funds-stat-value { font-size: 16px; }
}

/* フォーム */
.funds-field { display: flex; flex-direction: column; gap: 3px; }
.funds-label { font-size: 11px; font-weight: 600; color: var(--f-text-sub); }
.funds-label.required::after { content: ' *'; color: var(--f-danger); }
.funds-input {
  padding: 7px 10px; border: 1px solid var(--f-border); border-radius: 4px;
  font-size: 13px; background: var(--f-surface); color: var(--f-text); transition: border-color .1s;
}
.funds-input:focus { outline: none; border-color: #8da4bf; box-shadow: 0 0 0 2px rgba(74,111,165,.12); }
select.funds-input { appearance: auto; }

/* ボタン */
.funds-actions { margin-top: 20px; display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.funds-btn {
  padding: 8px 20px; border: 1px solid var(--f-border); border-radius: 4px; font-size: 13px;
  font-weight: 500; cursor: pointer; transition: background .1s; background: var(--f-surface); color: var(--f-text);
}
.funds-btn:hover { background: var(--f-row-alt); }
.funds-btn-primary { background: var(--f-accent); color: #fff; border-color: var(--f-accent); }
.funds-btn-primary:hover { background: var(--f-accent-hover); }
.funds-btn-danger { color: var(--f-danger); border-color: #d4a0a0; }
.funds-btn-danger:hover { background: #faf5f5; }

/* ビューヘッダ */
.funds-view-header h2 { font-size: 17px; font-weight: 600; color: var(--f-text); margin-bottom: 2px; }
.funds-desc { font-size: 12px; color: var(--f-text-sub); }
.funds-hint {
  background: #f9f6f0; border: 1px solid #e8e0d0; border-radius: 4px;
  padding: 8px 14px; font-size: 11px; color: var(--f-warning); margin-bottom: 16px;
}

/* month tabs */
.funds-month-tabs { display: flex; gap: 3px; flex-wrap: wrap; margin-bottom: 12px; }
.funds-month-tab {
  padding: 5px 10px; border: 1px solid var(--f-border); border-radius: 4px;
  background: var(--f-surface); font-size: 11px; cursor: pointer; color: var(--f-text-sub);
}
.funds-month-tab:hover { background: var(--f-row-alt); }
.funds-month-tab.active { background: var(--f-accent); color: #fff; border-color: var(--f-accent); }
.funds-receipt-summary { font-size: 12px; color: var(--f-text-sub); margin-bottom: 10px; }

/* receipt grid */
.funds-receipt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.funds-receipt-card {
  background: var(--f-surface); border-radius: 6px; overflow: hidden; cursor: pointer;
  border: 1px solid var(--f-border); transition: border-color .15s;
}
.funds-receipt-card:hover { border-color: #a0aab4; }
.funds-receipt-thumb { height: 220px; background: var(--f-row-alt); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.funds-receipt-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.funds-receipt-no-img { color: var(--f-text-muted); font-size: 12px; }
.funds-receipt-body { padding: 10px 12px; }
.funds-receipt-amount { font-size: 16px; font-weight: 700; color: var(--f-text); }
.funds-receipt-meta { font-size: 11px; color: var(--f-text-sub); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funds-compliance-badge { display: inline-block; font-size: 10px; font-weight: 600; margin-top: 3px; padding: 1px 6px; border-radius: 3px; background: var(--f-row-alt); }

/* modal */
.funds-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(33,39,42,.6); z-index: 9000;
  display: flex; align-items: center; justify-content: center;
}
.funds-modal {
  background: var(--f-surface); border-radius: 8px; width: 88vw; max-width: 880px;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.funds-modal-cols { display: flex; flex-direction: row; }
.funds-modal-left { width: 38%; padding: 18px; background: var(--f-row-alt); border-right: 1px solid var(--f-border); flex-shrink: 0; }
.funds-modal-right { width: 62%; padding: 18px; overflow-y: auto; flex: 1; min-width: 0; }
.funds-modal-img { width: 100%; border-radius: 4px; border: 1px solid var(--f-border); }
.funds-dropzone {
  border: 2px dashed var(--f-border); border-radius: 6px; padding: 36px;
  text-align: center; color: var(--f-text-muted); cursor: pointer; transition: border-color .15s;
  font-size: 13px;
}
.funds-dropzone:hover { border-color: #8da4bf; }
.funds-compliance-result {
  padding: 10px 14px; background: var(--f-row-alt); border-radius: 4px; margin-top: 10px;
  border-left: 3px solid var(--f-border); font-size: 13px;
}
/* モーダル responsive は上のメインmedia queryに統合済み */

/* table */
.funds-table { border-collapse: collapse; }
.funds-table th, .funds-table td { border: 1px solid var(--f-border); padding: 7px 10px; font-size: 13px; }
.funds-table th { background: var(--f-row-alt); font-weight: 600; color: var(--f-text-sub); font-size: 11px; text-transform: uppercase; letter-spacing: .3px; }
.funds-table-bold td { font-weight: 600; background: var(--f-row-alt); }
.funds-table tbody tr:nth-child(even) { background: var(--f-row-alt); }
.funds-table td .funds-input { width: 100%; box-sizing: border-box; }

/* placeholder */
.funds-placeholder { text-align: center; padding: 60px 20px; }
.funds-placeholder h2 { font-size: 18px; color: var(--f-text); margin-bottom: 6px; }
.funds-placeholder p { color: var(--f-text-sub); font-size: 13px; }

/* loading */
.funds-loading { text-align: center; padding: 48px; color: var(--f-text-sub); font-size: 13px; }
.funds-error { text-align: center; padding: 48px; color: var(--f-danger); font-size: 13px; }

/* カテゴリセレクト (収入/支出) */
.funds-category-bar {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px;
  max-width: 480px;
}
.funds-category-select {
  font-size: 14px !important; padding: 10px 12px !important;
}
.funds-category-select option[disabled] {
  font-weight: 700; color: var(--f-text); background: var(--f-row-alt);
  font-size: 12px;
}

/* 表紙 折りたたみ */
.funds-cover-collapse {
  margin-top: 20px; background: var(--f-surface); border: 1px solid var(--f-border);
  border-radius: 6px; overflow: hidden;
}
.funds-cover-toggle {
  padding: 12px 16px; font-size: 14px; font-weight: 600; color: var(--f-text);
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
  user-select: none;
}
.funds-cover-toggle::-webkit-details-marker { display: none; }
.funds-cover-toggle::before {
  content: '▶'; font-size: 10px; color: var(--f-text-muted); transition: transform .15s;
}
.funds-cover-collapse[open] > .funds-cover-toggle::before { transform: rotate(90deg); }
.funds-cover-collapse > .funds-cover-form { padding: 0 16px 16px; }

/* 収支総括表 */
.funds-summary-header {
  background: var(--f-surface); border: 1px solid var(--f-border); border-radius: 6px;
  padding: 14px 18px; margin-bottom: 12px;
}
.funds-summary-table { width: 100%; }
.funds-summary-table td { padding: 6px 10px; font-size: 13px; border-bottom: 1px solid var(--f-border); }
.funds-summary-label { color: var(--f-text); }
.funds-summary-amount { text-align: right; font-variant-numeric: tabular-nums; width: 130px; white-space: nowrap; }
.funds-summary-row.bold td { font-weight: 700; background: var(--f-row-alt); font-size: 14px; border-top: 2px solid var(--f-border); }
.funds-summary-row.sub td { font-weight: 600; background: var(--f-row-alt); }
.funds-summary-row.subsub td { padding-left: 28px; font-size: 12px; }
.funds-summary-row[style*="cursor"] td:first-child { color: var(--f-link); }
.funds-summary-row:hover td { background: #f0f4f8; }

/* mobile fab (PC非表示) */
.funds-mobile-fab { display: none; }

/* expense total bar */
.funds-expense-total {
  background: var(--f-surface); border: 1px solid var(--f-border); border-radius: 6px;
  padding: 12px 16px; margin-top: 12px; display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--f-text-sub);
}

/* spinner overlay */
.funds-spinner-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.85); display: flex; flex-direction: column;
  align-items: center; justify-content: center; border-radius: 4px; gap: 12px;
}
.funds-spinner {
  width: 36px; height: 36px; border: 3px solid var(--f-border);
  border-top-color: var(--f-accent); border-radius: 50%;
  animation: funds-spin .8s linear infinite;
}
@keyframes funds-spin { to { transform: rotate(360deg); } }
.funds-spinner-text { font-size: 13px; color: var(--f-text-sub); font-weight: 600; }

/* address source */
.funds-address-source {
  font-size: 11px; color: var(--f-text-sub); margin-top: 4px; margin-bottom: 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.funds-source-link {
  color: var(--f-link); text-decoration: none; font-size: 11px;
  word-break: break-all;
}
.funds-source-link:hover { text-decoration: underline; }

/* toast */
.funds-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--f-accent); color: #fff; padding: 10px 22px; border-radius: 4px;
  font-size: 13px; z-index: 10000; animation: funds-toast-in .25s; box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.funds-toast.error { background: var(--f-danger); }
@keyframes funds-toast-in { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%); } }
