/* ===== Theme Summary ===== */
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 12px;
}
.theme-summary {
  margin-bottom: 20px;
}
.theme-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.theme-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.theme-card:hover { box-shadow: var(--shadow-md); border-color: var(--c-blue); }
.theme-card-warn  { border-left: 3px solid var(--c-amber); }
.theme-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}
.theme-name { font-weight: 700; font-size: 14px; }
.theme-pending-badge {
  font-size: 11px;
  background: var(--c-amber-lt);
  color: var(--c-amber);
  border-radius: 20px;
  padding: 2px 8px;
  white-space: nowrap;
  font-weight: 600;
}
.theme-ok-badge {
  font-size: 11px;
  background: var(--c-green-lt);
  color: var(--c-green);
  border-radius: 20px;
  padding: 2px 8px;
  white-space: nowrap;
  font-weight: 600;
}
.theme-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.theme-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 42px;
}
.ts-val { font-size: 18px; font-weight: 700; color: var(--c-text); }
.ts-lbl { font-size: 10px; color: var(--c-muted); }
.theme-empty { color: var(--c-muted); font-size: 13px; padding: 8px 0; }

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

:root {
  --c-bg:        #f1f5f9;
  --c-surface:   #ffffff;
  --c-border:    #e2e8f0;
  --c-text:      #1e293b;
  --c-muted:     #64748b;
  --c-blue:      #2563eb;
  --c-blue-lt:   #dbeafe;
  --c-green:     #16a34a;
  --c-green-lt:  #dcfce7;
  --c-red:       #dc2626;
  --c-red-lt:    #fee2e2;
  --c-amber:     #d97706;
  --c-amber-lt:  #fef3c7;
  --c-purple:    #7c3aed;
  --c-purple-lt: #ede9fe;
  --c-gray-lt:   #f8fafc;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 12px rgba(0,0,0,.12);
  --radius:      8px;
  --radius-sm:   4px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
               "Noto Sans JP", sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.5;
}

/* ===== Header ===== */
header {
  background: var(--c-blue);
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.header-inner { display: flex; align-items: center; gap: 16px; width: 100%; }
header h1 { font-size: 18px; font-weight: 700; white-space: nowrap; }
.meta-info { font-size: 12px; opacity: .8; margin-left: auto; }

/* ===== Main ===== */
main { max-width: 1400px; margin: 0 auto; padding: 24px 16px 48px; }

/* ===== Summary Cards ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  cursor: default;
  transition: box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-value { font-size: 28px; font-weight: 700; color: var(--c-text); }
.card-label { font-size: 11px; color: var(--c-muted); margin-top: 2px; }
.card-blue .card-value  { color: var(--c-blue); }
.card-green .card-value { color: var(--c-green); }
.card-red .card-value   { color: var(--c-red); }

/* ===== Filters ===== */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.filters input[type="text"],
.filters select {
  padding: 7px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--c-bg);
  color: var(--c-text);
  outline: none;
  transition: border-color .15s;
}
.filters input[type="text"] { flex: 1; min-width: 200px; }
.filters input[type="text"]:focus,
.filters select:focus { border-color: var(--c-blue); }
.toggle-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--c-muted); cursor: pointer;
  user-select: none;
}
.toggle-label input { accent-color: var(--c-red); }
.btn-reset {
  padding: 7px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-gray-lt);
  font-size: 13px;
  cursor: pointer;
  color: var(--c-muted);
  transition: background .15s;
}
.btn-reset:hover { background: var(--c-border); color: var(--c-text); }

/* ===== Table ===== */
.table-wrapper {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  padding: 10px 12px;
  background: var(--c-gray-lt);
  border-bottom: 2px solid var(--c-border);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
}
thead th[data-sort] {
  cursor: pointer;
  user-select: none;
}
thead th[data-sort]:hover { background: var(--c-blue-lt); }
thead th.col-step {
  text-align: center;
  padding: 10px 6px;
  font-size: 12px;
  color: var(--c-muted);
}
tbody tr {
  border-bottom: 1px solid var(--c-border);
  cursor: pointer;
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8faff; }
tbody td {
  padding: 9px 12px;
  vertical-align: middle;
}
tbody td.col-step { text-align: center; padding: 9px 6px; font-size: 15px; }

.col-year  { text-align: right; width: 52px; }
.col-step  { width: 36px; }
.col-date  { white-space: nowrap; color: var(--c-muted); }
.col-error { text-align: center; width: 40px; }

.title-cell { display: flex; flex-direction: column; gap: 2px; }
.title-main { font-weight: 600; color: var(--c-text); }
.title-sub  { font-size: 11px; color: var(--c-muted); }

.society-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--c-blue-lt);
  color: var(--c-blue);
}

/* Step icons */
.step-completed { color: var(--c-green); }
.step-failed    { color: var(--c-red); }
.step-running   { color: var(--c-amber); }
.step-skipped   { color: var(--c-muted); font-size: 11px; }
.step-pending   { color: #cbd5e1; }

/* Status badge */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.status-LEARNED  { background: var(--c-blue-lt);   color: var(--c-blue); }
.status-CLINICAL { background: var(--c-blue-lt);   color: var(--c-blue); }
.status-COMPARED { background: var(--c-purple-lt); color: var(--c-purple); }
.status-READ     { background: var(--c-green-lt);  color: var(--c-green); }
.status-APPROVED { background: var(--c-amber-lt);  color: var(--c-amber); }
.status-FOUND    { background: #f1f5f9; color: var(--c-muted); }
.status-ERROR    { background: var(--c-red-lt);    color: var(--c-red); }

.error-icon { font-size: 14px; }

/* Loading / empty */
.loading, .empty-row {
  text-align: center;
  color: var(--c-muted);
  padding: 40px;
}
.row-count {
  font-size: 12px;
  color: var(--c-muted);
  padding: 8px 16px;
  text-align: right;
  border-top: 1px solid var(--c-border);
}

/* ===== Detail Panel ===== */
.detail-panel {
  position: fixed;
  top: 56px;
  right: 0;
  width: min(480px, 96vw);
  height: calc(100vh - 56px);
  background: var(--c-surface);
  border-left: 1px solid var(--c-border);
  box-shadow: -4px 0 16px rgba(0,0,0,.12);
  overflow-y: auto;
  z-index: 200;
  transition: transform .2s ease;
}
.detail-panel.hidden { transform: translateX(100%); }
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  background: var(--c-surface);
  z-index: 10;
}
.detail-header h2 { font-size: 15px; font-weight: 700; line-height: 1.4; }
.detail-close {
  flex-shrink: 0;
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--c-muted);
  padding: 2px 6px;
  border-radius: 4px;
}
.detail-close:hover { background: var(--c-border); }
#detail-body { padding: 20px; }

.detail-section { margin-bottom: 20px; }
.detail-section h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--c-muted);
  margin-bottom: 8px;
}
.detail-kv { display: flex; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.detail-kv .k { color: var(--c-muted); min-width: 80px; flex-shrink: 0; }
.detail-kv .v { color: var(--c-text); }

.step-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--c-border);
  font-size: 13px;
}
.step-row:last-child { border-bottom: none; }
.step-row .step-name { flex: 1; }
.step-row .step-date { font-size: 11px; color: var(--c-muted); }

.artifact-link {
  display: block;
  padding: 5px 0;
  color: var(--c-blue);
  text-decoration: none;
  font-size: 13px;
  word-break: break-all;
}
.artifact-link:hover { text-decoration: underline; }

.error-box {
  background: var(--c-red-lt);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
}
.error-box .err-code { font-weight: 700; color: var(--c-red); }
.error-box .err-msg  { margin-top: 4px; color: var(--c-text); }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--c-gray-lt);
  border: 1px solid var(--c-border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--c-muted);
}

.summary-text {
  font-size: 13px;
  color: var(--c-muted);
  line-height: 1.6;
  background: var(--c-gray-lt);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--c-muted);
  border-top: 1px solid var(--c-border);
  margin-top: 40px;
}
footer a { color: var(--c-blue); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ===== Settings button ===== */
.btn-settings {
  background: none;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 16px;
  cursor: pointer;
  color: var(--c-text);
  transition: background .15s;
  margin-left: 12px;
}
.btn-settings:hover { background: var(--c-surface); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 28px 32px;
  width: min(480px, 90vw);
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-desc { font-size: 13px; color: var(--c-muted); margin-bottom: 16px; line-height: 1.6; }
.modal-label { font-size: 12px; font-weight: 600; color: var(--c-muted); display: block; margin-bottom: 6px; }
.modal-input {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--c-border); border-radius: 6px;
  font-size: 14px; background: var(--c-bg); color: var(--c-text);
  box-sizing: border-box; margin-bottom: 12px;
}
.modal-actions { display: flex; gap: 10px; }
.key-status { font-size: 12px; color: var(--c-muted); margin-top: 8px; min-height: 18px; }

/* ===== Action buttons (detail panel) ===== */
.detail-actions { border-top: 2px solid var(--c-border); padding-top: 16px; }
.action-note { font-size: 12px; color: var(--c-muted); margin-bottom: 12px; }
.action-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-approve {
  padding: 8px 18px; border-radius: 6px; border: none;
  background: #16a34a; color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.btn-approve:hover { background: #15803d; }
.btn-skip {
  padding: 8px 18px; border-radius: 6px; border: none;
  background: #64748b; color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.btn-skip:hover { background: #475569; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 12px 24px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  z-index: 300; max-width: 90vw; text-align: center;
  animation: fadeIn .2s ease;
}
.toast.hidden { display: none; }
.toast-ok   { background: #16a34a; }
.toast-err  { background: #dc2626; }
.toast-warn { background: #d97706; }
.toast-info { background: #2563eb; }
@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ===== Local Required Notice ===== */
.local-notice {
  max-width: 1200px;
  margin: 24px auto 0;
  padding: 0 16px;
}
.local-notice details {
  border: 1px solid #d97706;
  border-radius: 8px;
  background: color-mix(in srgb, #fef3c7 80%, transparent);
  overflow: hidden;
}
@media (prefers-color-scheme: dark) {
  .local-notice details { background: color-mix(in srgb, #78350f 30%, transparent); }
}
.local-notice summary {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
@media (prefers-color-scheme: dark) {
  .local-notice summary { color: #fcd34d; }
}
.local-notice summary::-webkit-details-marker { display: none; }
.local-notice-body {
  padding: 0 16px 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--c-text);
}
.local-notice-body p { margin: 0 0 8px; }
.notice-table {
  width: 100%; border-collapse: collapse;
  font-size: 12px; margin-top: 8px;
}
.notice-table th, .notice-table td {
  border: 1px solid var(--c-border);
  padding: 6px 10px; text-align: left;
}
.notice-table th { background: var(--c-surface); font-weight: 600; }
.notice-table code { font-size: 11px; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .cards { grid-template-columns: repeat(4, 1fr); }
  .col-date, .col-error { display: none; }
}
