/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', sans-serif; background: #f5f7fa; color: #1a1a2e; line-height: 1.6; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }

/* ===== Layout ===== */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: #1a1a2e; color: #e0e0e0; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; }
.main-content { flex: 1; margin-left: 240px; padding: 24px 32px; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar-header { padding: 20px; border-bottom: 1px solid #2d2d4a; }
.sidebar-header h1 { font-size: 1.1rem; font-weight: 700; color: #fff; }
.sidebar-header .version { font-size: 0.75rem; color: #888; }
.nav-menu { list-style: none; padding: 12px 0; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: #b0b0c8; transition: all 0.15s; font-size: 0.95rem; }
.nav-link:hover { background: #2d2d4a; color: #fff; }
.nav-link.active { background: #3a3a5c; color: #fff; border-left: 3px solid #4dabf7; padding-left: 17px; }
.nav-icon { font-size: 1.1rem; }
.sidebar-footer { padding: 16px; border-top: 1px solid #2d2d4a; }
.run-selector { display: flex; flex-direction: column; gap: 6px; }
.run-selector label { font-size: 0.75rem; color: #888; }
.run-selector select { background: #2d2d4a; color: #fff; border: 1px solid #3a3a5c; border-radius: 4px; padding: 6px 8px; font-size: 0.8rem; }
.run-selector .btn-sm { margin-top: 4px; }

/* ===== Pages ===== */
.page { display: none; }
.page.active { display: block; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h2 { font-size: 1.5rem; font-weight: 700; }

/* ===== Buttons ===== */
.btn { padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer; font-size: 0.85rem; font-weight: 500; transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: #4dabf7; color: #fff; }
.btn-primary:hover { background: #339af0; }
.btn-outline { background: transparent; border: 1px solid #dee2e6; color: #495057; }
.btn-outline:hover { background: #f1f3f5; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; border-radius: 4px; background: #4dabf7; color: #fff; border: none; cursor: pointer; }
.btn-sm:hover { background: #339af0; }
.btn-danger { background: #ff6b6b; color: #fff; }
.btn-danger:hover { background: #f03e3e; }

/* ===== Badges ===== */
.badge { padding: 3px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.badge-info { background: #e7f5ff; color: #1971c2; }
.badge-ok { background: #d3f9d8; color: #2b8a3e; }
.badge-ng { background: #ffe3e3; color: #c92a2a; }
.badge-skip { background: #fff3bf; color: #e67700; }
.badge-pending { background: #f1f3f5; color: #868e96; }
.badge-p0 { background: #ffe3e3; color: #c92a2a; font-weight: 700; }
.badge-p1 { background: #fff3bf; color: #e67700; }
.badge-p2 { background: #e7f5ff; color: #1971c2; }

/* ===== Select ===== */
.select-sm { padding: 6px 10px; border: 1px solid #dee2e6; border-radius: 6px; font-size: 0.85rem; background: #fff; }

/* ===== Stats Grid ===== */
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 10px; padding: 20px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.08); border-left: 4px solid #dee2e6; }
.stat-card.stat-ok { border-left-color: #40c057; }
.stat-card.stat-ng { border-left-color: #ff6b6b; }
.stat-card.stat-skip { border-left-color: #fcc419; }
.stat-card.stat-pending { border-left-color: #adb5bd; }
.stat-number { font-size: 2rem; font-weight: 700; }
.stat-ok .stat-number { color: #2b8a3e; }
.stat-ng .stat-number { color: #c92a2a; }
.stat-skip .stat-number { color: #e67700; }
.stat-pending .stat-number { color: #868e96; }
.stat-label { font-size: 0.8rem; color: #868e96; margin-top: 4px; }

/* ===== Progress Bar ===== */
.progress-section { background: #fff; border-radius: 10px; padding: 20px; margin-bottom: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.progress-bar-container { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.progress-bar { flex: 1; height: 24px; background: #f1f3f5; border-radius: 12px; overflow: hidden; display: flex; }
.progress-segment { height: 100%; transition: width 0.3s ease; }
.progress-ok { background: #40c057; }
.progress-ng { background: #ff6b6b; }
.progress-skip { background: #fcc419; }
.progress-text { font-weight: 700; font-size: 1rem; min-width: 48px; }

/* ===== Category Progress ===== */
.category-progress { background: #fff; border-radius: 10px; padding: 20px; margin-bottom: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.category-progress h3 { margin-bottom: 16px; }
.cat-bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.cat-bar-label { width: 160px; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-bar-track { flex: 1; height: 16px; background: #f1f3f5; border-radius: 8px; overflow: hidden; display: flex; }
.cat-bar-count { font-size: 0.8rem; color: #868e96; min-width: 60px; text-align: right; }

/* ===== Tables ===== */
.table { width: 100%; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.table thead { background: #f8f9fa; }
.table th { padding: 10px 14px; text-align: left; font-weight: 600; font-size: 0.8rem; color: #495057; border-bottom: 2px solid #e9ecef; }
.table td { padding: 10px 14px; font-size: 0.85rem; border-bottom: 1px solid #f1f3f5; }
.table tbody tr:hover { background: #f8f9fa; }

/* ===== Recent Section ===== */
.recent-section { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.recent-section h3 { margin-bottom: 16px; }

/* ===== Test Runner ===== */
.test-runner-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.test-runner-layout { display: flex; gap: 20px; }
.test-category-sidebar { width: 200px; flex-shrink: 0; }
.test-cases-list { flex: 1; min-width: 0; }

.cat-nav-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 0.85rem; margin-bottom: 4px; transition: background 0.15s; }
.cat-nav-item:hover { background: #e9ecef; }
.cat-nav-item.active { background: #e7f5ff; color: #1971c2; font-weight: 600; }
.cat-nav-count { font-size: 0.75rem; color: #868e96; }

/* ===== Test Case Card ===== */
.test-card { background: #fff; border-radius: 10px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); overflow: hidden; border-left: 4px solid #dee2e6; }
.test-card.status-ok { border-left-color: #40c057; }
.test-card.status-ng { border-left-color: #ff6b6b; }
.test-card.status-skip { border-left-color: #fcc419; }
.test-card.status-pending { border-left-color: #adb5bd; }

.test-card-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; cursor: pointer; user-select: none; }
.test-card-header:hover { background: #f8f9fa; }
.test-card-title { display: flex; align-items: center; gap: 10px; }
.test-card-title .case-id { font-weight: 700; color: #495057; font-size: 0.85rem; }
.test-card-title .case-name { font-weight: 500; }
.test-card-actions { display: flex; align-items: center; gap: 8px; }

.test-card-body { display: none; padding: 0 18px 18px; }
.test-card.expanded .test-card-body { display: block; }

.precondition { background: #fff9db; padding: 8px 12px; border-radius: 6px; font-size: 0.85rem; margin-bottom: 12px; }
.precondition strong { color: #e67700; }

.step-table { width: 100%; margin-bottom: 12px; }
.step-table th { padding: 8px 10px; background: #f8f9fa; font-size: 0.8rem; text-align: left; border-bottom: 1px solid #e9ecef; }
.step-table td { padding: 8px 10px; font-size: 0.85rem; border-bottom: 1px solid #f1f3f5; vertical-align: top; }
.step-table td:first-child { width: 36px; text-align: center; color: #868e96; }

.test-card-footer { display: flex; align-items: flex-start; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #f1f3f5; }
.test-card-footer textarea { flex: 1; padding: 8px 12px; border: 1px solid #dee2e6; border-radius: 6px; font-size: 0.85rem; resize: vertical; min-height: 60px; font-family: inherit; }
.status-buttons { display: flex; gap: 6px; flex-shrink: 0; flex-direction: column; }
.status-btn { padding: 6px 14px; border: 2px solid transparent; border-radius: 6px; cursor: pointer; font-size: 0.8rem; font-weight: 600; background: #f1f3f5; color: #495057; transition: all 0.15s; }
.status-btn:hover { transform: translateY(-1px); }
.status-btn.selected { color: #fff; }
.status-btn[data-status="ok"].selected { background: #40c057; border-color: #2b8a3e; }
.status-btn[data-status="ng"].selected { background: #ff6b6b; border-color: #c92a2a; }
.status-btn[data-status="skip"].selected { background: #fcc419; border-color: #e67700; color: #1a1a2e; }
.save-indicator { font-size: 0.75rem; color: #40c057; opacity: 0; transition: opacity 0.3s; }
.save-indicator.visible { opacity: 1; }

/* ===== Manual ===== */
.manual-layout { display: flex; gap: 24px; }
.manual-toc { width: 240px; flex-shrink: 0; position: sticky; top: 24px; align-self: flex-start; max-height: calc(100vh - 120px); overflow-y: auto; background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.manual-toc h4 { font-size: 0.85rem; margin-bottom: 12px; color: #495057; }
.manual-toc a { display: block; padding: 4px 8px; font-size: 0.8rem; color: #495057; border-radius: 4px; margin-bottom: 2px; }
.manual-toc a:hover { background: #e7f5ff; color: #1971c2; }
.manual-toc a.indent { padding-left: 20px; font-size: 0.78rem; }
.manual-content { flex: 1; background: #fff; border-radius: 10px; padding: 32px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); min-width: 0; }
.manual-content h1, .manual-content h2, .manual-content h3 { margin-top: 1.5em; margin-bottom: 0.5em; }
.manual-content h1 { font-size: 1.6rem; border-bottom: 2px solid #e9ecef; padding-bottom: 8px; }
.manual-content h2 { font-size: 1.3rem; border-bottom: 1px solid #f1f3f5; padding-bottom: 6px; }
.manual-content h3 { font-size: 1.1rem; }
.manual-content table { border: 1px solid #e9ecef; margin: 12px 0; }
.manual-content th, .manual-content td { padding: 8px 12px; border: 1px solid #e9ecef; font-size: 0.85rem; }
.manual-content th { background: #f8f9fa; }
.manual-content code { background: #f1f3f5; padding: 2px 6px; border-radius: 3px; font-size: 0.85em; }
.manual-content pre { background: #1a1a2e; color: #e0e0e0; padding: 16px; border-radius: 8px; overflow-x: auto; margin: 12px 0; }
.manual-content pre code { background: transparent; padding: 0; color: inherit; }
.manual-content blockquote { border-left: 4px solid #4dabf7; padding: 8px 16px; background: #e7f5ff; margin: 12px 0; border-radius: 0 6px 6px 0; }
.manual-content img { max-width: 360px; border-radius: 8px; border: 1px solid #e2e8f0; box-shadow: 0 2px 12px rgba(0,0,0,0.10); margin: 16px 0; cursor: zoom-in; transition: opacity 0.15s; }
.manual-content img:hover { opacity: 0.85; }
.img-modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 9999; padding: 24px; }
.img-modal-overlay.visible { display: flex; justify-content: center; align-items: flex-start; }
.img-modal-overlay .img-modal-scroll { overflow: auto; max-width: 95vw; max-height: 95vh; border-radius: 8px; }
.img-modal-overlay .img-modal-scroll img { display: block; max-width: none; width: auto; height: auto; border-radius: 8px; box-shadow: 0 4px 32px rgba(0,0,0,0.4); cursor: grab; }
.img-modal-overlay .img-modal-close { position: fixed; top: 16px; right: 24px; background: rgba(255,255,255,0.15); color: #fff; border: none; font-size: 24px; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; z-index: 10000; }
.img-modal-overlay .img-modal-close:hover { background: rgba(255,255,255,0.3); }
.manual-content hr { border: none; border-top: 1px solid #e9ecef; margin: 24px 0; }

/* ===== Reports ===== */
.report-filters { display: flex; gap: 12px; margin-bottom: 16px; }
.report-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.report-summary .stat-card { padding: 14px; }
.export-controls { display: flex; gap: 8px; }

/* ===== Modal ===== */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 400px; max-width: 90vw; }
.modal h3 { margin-bottom: 16px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 4px; }
.form-group input { width: 100%; padding: 8px 12px; border: 1px solid #dee2e6; border-radius: 6px; font-size: 0.9rem; }
.form-group input:focus { outline: none; border-color: #4dabf7; box-shadow: 0 0 0 3px rgba(77,171,247,0.2); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ===== Utility ===== */
.loading { color: #868e96; font-style: italic; }
.empty-state { text-align: center; padding: 40px; color: #868e96; }

/* ===== Responsive ===== */
/* ===== Test History ===== */
.th-round { background: #fff; border-radius: 10px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.th-round-header h3 { font-size: 1.1rem; margin-bottom: 8px; }
.th-round-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.8rem; color: #666; margin-bottom: 16px; }
.th-phase { border: 1px solid #e9ecef; border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.th-phase-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; cursor: pointer; background: #f8f9fa; transition: background 0.15s; }
.th-phase-header:hover { background: #e9ecef; }
.th-phase-title { font-weight: 600; font-size: 0.9rem; }
.th-phase-stats { display: flex; gap: 6px; align-items: center; }
.th-phase-body { display: none; padding: 0; }
.th-phase.expanded .th-phase-body { display: block; }
.th-phase-body .table { margin: 0; font-size: 0.8rem; }
.th-phase-body .table td, .th-phase-body .table th { padding: 6px 10px; }

@media (max-width: 1024px) {
  .sidebar { width: 200px; }
  .main-content { margin-left: 200px; padding: 16px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .test-category-sidebar { width: 160px; }
}
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-header h1, .nav-link span:not(.nav-icon), .sidebar-footer label, .version { display: none; }
  .nav-link { justify-content: center; padding: 12px; }
  .main-content { margin-left: 60px; padding: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .test-runner-layout { flex-direction: column; }
  .test-category-sidebar { width: 100%; }
  .manual-layout { flex-direction: column; }
  .manual-toc { width: 100%; position: static; }
}
