/* ダッシュボード専用スタイル */
:root {
  --primary-color: #1469a8;
  --primary-hover: #0f5d96;
  --secondary-color: #64748b;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --border-color: #e2e8f0;
  --bg-light: #f8fafc;
  --bg-white: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.10), 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 18px -10px rgba(15, 23, 42, 0.28), 0 4px 10px -6px rgba(15, 23, 42, 0.18);
  --shadow-lg: 0 18px 40px -18px rgba(15, 23, 42, 0.40), 0 10px 22px -12px rgba(15, 23, 42, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg-light);
  color: var(--text-primary);
  line-height: 1.6;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 24px 24px;
}

body.dashboard-page {
  height: 100vh;
  overflow: hidden;
}

body.dashboard-page .container {
  height: 100vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 左固定サイドメニュー + 右メインスクロール */
body.dashboard-page .dashboard-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

body.dashboard-page .dashboard-sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--bg-white);
  border-right: 1px solid var(--border-color);
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

body.dashboard-page .dashboard-sidebar-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0 0 10px 8px;
}

body.dashboard-page .dashboard-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

body.dashboard-page .dashboard-sidebar-link {
  display: block;
  padding: 10px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  line-height: 1.2;
}

body.dashboard-page .dashboard-sidebar-link:hover {
  background: var(--bg-light);
  border-color: var(--border-color);
}

body.dashboard-page .dashboard-main {
  flex: 1 1 auto;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-padding-top: 96px;
}

body.dashboard-page .dashboard-main .container {
  height: auto;
  overflow: visible;
}

body.dashboard-page [id^="sec-"] {
  scroll-margin-top: 96px;
}

/* ヘッダー */
header {
  background: var(--surface-titlebar, var(--surface-header, var(--bg-white)));
  padding: 20px 24px;
  margin: 0 -24px 24px -24px;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

header h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--titlebar-text, var(--text-primary));
  margin: 0;
}

.header-nav {
  display: flex;
  gap: 12px;
}

.nav-link {
  padding: 8px 16px;
  background: var(--titlebar-link-bg, var(--bg-light));
  color: var(--titlebar-text, var(--text-primary));
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  border: 1px solid var(--titlebar-link-border, var(--border-color));
}

.nav-link:hover {
  background: var(--titlebar-link-hover-bg, var(--primary-color));
  color: var(--titlebar-text, white);
  border-color: var(--titlebar-link-border, var(--primary-color));
}

.header-subtitle {
  font-size: 14px;
  color: var(--titlebar-muted, var(--text-secondary));
  margin: 0;
}

.header-filter-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0 0;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--titlebar-link-border, var(--border-color));
  background: var(--titlebar-link-bg, rgba(0, 0, 0, 0.04));
  color: var(--titlebar-text, var(--text-secondary));
  font-size: 12px;
  font-weight: 600;
}

/* セクション */
.section {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  padding: 24px;
  margin-bottom: 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 16px 0;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary-color);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header .section-title {
  margin: 0;
  padding: 0;
  border: none;
}

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

/* フィルターエリア */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.filter-input,
.filter-select {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  background: var(--surface-input, var(--bg-white));
  transition: all 0.2s;
}

.filter-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: var(--focus-ring);
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.filter-info {
  padding: 12px;
  background: var(--surface-display, var(--bg-light));
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ボタン */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-light);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-export {
  background: var(--success-color);
  color: white;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-export:hover {
  background: #059669;
}

.export-icon {
  font-size: 16px;
}

/* サマリーカード */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--surface-display, var(--bg-white));
  border-radius: 8px;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.summary-card:nth-child(2) {
  border-left-color: var(--success-color);
}

.summary-card:nth-child(3) {
  border-left-color: var(--warning-color);
}

.summary-card:nth-child(4) {
  border-left-color: var(--secondary-color);
}

.summary-icon {
  font-size: 36px;
  opacity: 0.85;
}

.summary-content {
  flex: 1;
}

.summary-label {
  font-size: 13px;
  opacity: 0.9;
  margin-bottom: 4px;
}

.summary-value {
  font-size: 28px;
  font-weight: 700;
  font-family: -apple-system-ui-monospaced, 'SF Mono', 'Segoe UI Mono', 'Roboto Mono', 'Ubuntu Mono', 'Menlo', 'Courier New', monospace;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

/* テーブル */
.table-wrapper {
  max-height: 500px;
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-white);
}

.table {
  width: 100%;
  min-width: 800px;
  border-collapse: separate;
  border-spacing: 0;
}

.table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-white);
}

.table thead th {
  background: linear-gradient(to bottom, #f8fafc 0%, #f1f5f9 100%);
  font-weight: 600;
  text-align: left;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.table thead th.number-header {
  text-align: right;
  padding-right: 20px;
}

.table thead th:hover {
  background: linear-gradient(to bottom, #f1f5f9 0%, #e2e8f0 100%);
}

.sort-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  color: var(--text-secondary);
  opacity: 0.5;
  min-width: 12px;
  text-align: center;
}

.sort-icon.active {
  color: var(--primary-color);
  opacity: 1;
  font-weight: bold;
}

.table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.15s;
}

.table tbody tr:hover {
  background: var(--bg-light);
}

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

.table td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
}

.table td.number {
  text-align: right;
  font-family: -apple-system-ui-monospaced, 'SF Mono', 'Segoe UI Mono', 'Roboto Mono', 'Ubuntu Mono', 'Menlo', 'Courier New', monospace;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  padding-right: 20px;
}

/* 計上基準 月別×担当部門集計 - 視認性強化 */
#posted-department-monthly-table th,
#posted-department-monthly-table td {
  border-right: 1px solid var(--border-color);
}

#posted-department-monthly-table th:last-child,
#posted-department-monthly-table td:last-child {
  border-right: none;
}

#posted-department-monthly-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

#posted-department-monthly-table th:first-child,
#posted-department-monthly-table td:first-child {
  min-width: 180px;
  width: 180px;
}

#posted-department-monthly-table th:nth-child(2),
#posted-department-monthly-table td:nth-child(2) {
  min-width: 90px;
  width: 90px;
}

#posted-department-monthly-table .posted-org,
#posted-department-monthly-table .posted-item {
  position: sticky;
  background: #fdfdfd;
  z-index: 8;
}

#posted-department-monthly-table .posted-org {
  left: 0;
  z-index: 9;
}

#posted-department-monthly-table .posted-item {
  left: 180px;
  background: #f7f8fb;
  z-index: 10;
  box-shadow: 1px 0 0 var(--border-color);
}

#posted-department-monthly-table thead .posted-org,
#posted-department-monthly-table thead .posted-item {
  z-index: 12;
}

#posted-department-monthly-table tbody tr:nth-child(even) td:first-child,
#posted-department-monthly-table tbody tr:nth-child(even) .posted-org {
  background: #f1f5f9;
}

#posted-department-monthly-table tbody tr:nth-child(even) td:nth-child(2),
#posted-department-monthly-table tbody tr:nth-child(even) .posted-item {
  background: #eef2f7;
}

.table td.positive {
  color: var(--success-color);
  font-weight: 600;
}

.table td.negative {
  color: var(--danger-color);
  font-weight: 600;
}

.no-data {
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
}

/* 空き社員フィルター */
.available-filter-section {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-light);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

 .member-assignment-filter-section {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-light);
  border-radius: 8px;
  border: 1px solid var(--border-color);
 }

 .filter-checkbox-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-white);
 }

 .checkbox-label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
 }

 .row-over-assigned td {
  background: rgba(239, 68, 68, 0.07);
 }

 .assignment-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
 }

 .assignment-item {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-white);
  font-size: 12px;
 }

 .assignment-effort {
  font-family: -apple-system-ui-monospaced, 'SF Mono', 'Segoe UI Mono', 'Roboto Mono', 'Ubuntu Mono', 'Menlo', 'Courier New', monospace;
  font-weight: 700;
 }

 .prob-b2 {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.10);
 }

 .prob-c2 {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.10);
 }

 .prob-mop {
  border-color: rgba(245, 158, 11, 0.40);
  background: rgba(245, 158, 11, 0.12);
 }

 .prob-op {
  border-color: rgba(168, 85, 247, 0.35);
  background: rgba(168, 85, 247, 0.10);
 }

 .prob-sop {
  border-color: rgba(20, 105, 168, 0.35);
  background: rgba(20, 105, 168, 0.10);
 }

/* フッター */
footer {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* レスポンシブ */
@media (max-width: 768px) {
  .container {
    padding: 0 16px 16px 16px;
  }

  header {
    margin: 0 -16px 16px -16px;
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

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

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* グラフ表示ボタン */
.btn-chart {
  background: var(--primary-color);
  color: white;
  border: 1px solid var(--primary-color);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--motion-fast, 0.2s);
  box-shadow: var(--shadow-sm);
}

.btn-chart:hover {
  background: var(--primary-hover);
  transform: translateY(var(--button-hover-translate-y, -1px));
  box-shadow: var(--button-hover-shadow, var(--shadow-md));
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--bg-white);
  border-radius: 16px;
  width: 90%;
  max-width: 1200px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-header, var(--bg-white));
  color: var(--text-primary);
  border-left: 4px solid var(--primary-color);
}

.modal-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.modal-close {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 32px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  line-height: 1;
}

.modal-close:hover {
  background: var(--bg-white);
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: rotate(90deg);
}

.modal-body {
  padding: 32px;
  overflow-y: auto;
  max-height: calc(90vh - 100px);
}

/* チャートタブ */
.chart-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0;
}

.chart-tab {
  background: transparent;
  border: none;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
  position: relative;
  bottom: -2px;
}

.chart-tab:hover {
  color: var(--primary-color);
  background: rgba(37, 99, 235, 0.05);
}

.chart-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  background: rgba(37, 99, 235, 0.05);
}

/* チャートコンテナ */
.chart-container-wrapper {
  position: relative;
}

.chart-tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.chart-tab-content.active {
  display: block;
}

.chart-tab-content h3 {
  margin: 0 0 20px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-container {
  position: relative;
  height: 400px;
  background: var(--bg-white);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    max-height: 95vh;
  }

  .modal-header {
    padding: 16px 20px;
  }

  .modal-header h2 {
    font-size: 20px;
  }

  .modal-body {
    padding: 20px;
  }

  .chart-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .chart-tab {
    white-space: nowrap;
    padding: 10px 16px;
    font-size: 13px;
  }

  .chart-container {
    height: 300px;
    padding: 12px;
  }
}
