/* ===== Variables ===== */
:root {
  /* Theme A: ミニマル（デフォルト） */
  --bg:          #F9FAFB;
  --surface:     #FFFFFF;
  --surface-alt: #F3F4F6;
  --border:      #E2E8F0;
  --text:        #1A202C;
  --muted:       #718096;
  --accent:      #185FA5;
  --danger:      #b8002e;
  --success:     #1a7a4a;
  --warning:     #b45309;
  --held:        #5a3fb5;
  --radius:      12px;
  --shadow:      0 2px 8px rgba(0,0,0,.08);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.14);
}

html[data-theme="b"] {
  --bg:          #F5EDDD;
  --surface:     #FAF7F2;
  --surface-alt: #EDE4D0;
  --border:      #D5C4A8;
  --text:        #2D1A0A;
  --muted:       #8B6F4F;
  --accent:      #854F0B;
  --danger:      #9A2020;
  --success:     #2D6A1A;
  --warning:     #9A5000;
  --held:        #6B4FA8;
}

html[data-theme="c"] {
  --bg:          #0F1419;
  --surface:     #1A1F26;
  --surface-alt: #222831;
  --border:      #2E3744;
  --text:        #E2E8F0;
  --muted:       #8899AA;
  --accent:      #5DCAA5;
  --danger:      #F87171;
  --success:     #4ADE80;
  --warning:     #FBBF24;
  --held:        #A78BFA;
  --shadow:      0 2px 8px rgba(0,0,0,.3);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.5);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ===== Layout ===== */
.app-header {
  background: var(--accent);
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.app-header h1 { font-size: 17px; font-weight: 700; letter-spacing: .04em; }
.header-sub { font-size: 12px; opacity: .7; margin-left: auto; }

.main-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ===== Pending area (top of page) ===== */
#pending-area {
  margin-bottom: 20px;
}
.pending-area-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
}
.pending-quick-card {
  background: var(--surface);
  border: 2px solid #fde68a;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.pqc-meta { flex: 1; min-width: 0; }
.pqc-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 6px;
}
.pqc-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
@media (max-width: 480px) {
  .pending-quick-card { flex-direction: column; align-items: stretch; }
  .pqc-actions { justify-content: flex-end; }
}

/* ===== Stats bar ===== */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-card .num {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-card .label { font-size: 12px; color: var(--muted); }
.stat-card.pending     .num { color: var(--accent); }
.stat-card.in_progress .num { color: var(--success); }
.stat-card.completed   .num { color: var(--muted); }
.stat-card.failed      .num { color: var(--danger); }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-btn {
  padding: 6px 16px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  border: 2px solid var(--border);
  color: var(--muted);
  background: var(--surface);
  transition: all .15s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-divider { width: 1px; background: var(--border); margin: 4px 4px; align-self: stretch; }

/* ===== Todo cards ===== */
.todo-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.todo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow .15s;
}
.todo-card:hover { box-shadow: var(--shadow-lg); }

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px 12px;
}
.card-header .meta { flex: 1; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; line-height: 1.4; }
.card-id    { font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.card-desc  { font-size: 13px; color: var(--muted); line-height: 1.6; }
.card-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.card-status-info { margin-top: 8px; }
.status-info {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
}
.status-info.in-progress { background: #d1fae5; color: #065f46; }
.status-info.completed   { background: #f1f5f9; color: #475569; }
.status-info.failed      { background: #fee2e2; color: #991b1b; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.pending     { background: #fef3c7; color: #92400e; }
.badge.approved    { background: #dbeafe; color: #1e40af; }
.badge.in_progress { background: #d1fae5; color: #065f46; animation: pulse-badge 1.8s ease-in-out infinite; }
.badge.completed   { background: #f1f5f9; color: #64748b; }
.badge.failed      { background: #fee2e2; color: #991b1b; }
.badge.rejected    { background: #e5e7eb; color: #6b7280; }
.badge.held        { background: #ede9fe; color: #4c1d95; }
.badge.lock-waiting { background: #e2e8f0; color: #475569; }
.badge.urgent      { background: #fef3c7; color: #92400e; }
.badge.high        { background: #ffedd5; color: #9a3412; }
.badge.normal      { background: #f1f5f9; color: #475569; }
.badge.cat         { background: #e0f2fe; color: #0c4a6e; }
.badge.member      { background: #f0fdf4; color: #166534; font-size: 11px; }
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50%       { opacity: .55; }
}

/* ===== Judgment section ===== */
.card-judgment {
  padding: 0 20px 12px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.judgment-item { font-size: 12px; }
.judgment-item .j-label { color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.judgment-item .j-val   { font-weight: 600; }
.judgment-item.impact   .j-val { color: var(--danger); }
.judgment-item.approve  .j-val { color: var(--success); }
.judgment-item.reject   .j-val { color: var(--danger); }
.judgment-item.point    .j-val { color: var(--warning); }

/* ===== Actions ===== */
.card-actions {
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--surface-alt);
}
.card-actions .by { font-size: 12px; color: var(--muted); margin-right: auto; }

.btn {
  padding: 7px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  transition: opacity .15s, transform .1s;
}
.btn:hover   { opacity: .85; }
.btn:active  { transform: scale(.97); }
.btn.approve { background: var(--success); color: #fff; }
.btn.reject  { background: var(--danger);  color: #fff; }
.btn.hold    { background: var(--held);    color: #fff; }
.btn.comment { background: var(--surface); color: var(--accent); border: 2px solid var(--accent); }
.btn.show-history { background: transparent; color: var(--muted); font-size: 12px; border: 1px solid var(--border); padding: 5px 12px; }

.btn:disabled { opacity: .4; cursor: default; }

/* ===== Comments inline ===== */
.card-comments {
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  display: none;
}
.card-comments.open { display: block; }
.comment-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.comment-item { background: var(--bg); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.comment-item .c-time { font-size: 11px; color: var(--muted); margin-left: 8px; }
.comment-form { display: flex; gap: 8px; }
.comment-form input {
  flex: 1;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
}
.comment-form input:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* ===== History panel ===== */
.card-history {
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  display: none;
}
.card-history.open { display: block; }
.history-item { font-size: 12px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.history-item:last-child { border: none; }
.history-item .h-action { font-weight: 700; margin-right: 6px; }
.history-item .h-action.approved { color: var(--success); }
.history-item .h-action.rejected { color: var(--danger); }
.history-item .h-action.held     { color: var(--held); }

/* ===== Empty / loading ===== */
.empty { text-align: center; color: var(--muted); padding: 48px; font-size: 15px; }
.loading { text-align: center; padding: 32px; color: var(--muted); }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease;
  max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(60px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Collapsible cards ===== */
.todo-card.collapsed .card-desc { display: none; }
.todo-card.collapsed .card-judgment { display: none; }
.btn.toggle-details {
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--border);
  padding: 5px 12px;
}
.btn.toggle-details:hover { border-color: var(--accent); color: var(--accent); }

/* ===== 実行履歴タブ ===== */
.filter-btn.history-tab { border-color: #c7d2fe; color: #4338ca; }
.filter-btn.history-tab:hover { border-color: #4338ca; color: #4338ca; }
.filter-btn.history-tab.active { background: #4338ca; border-color: #4338ca; color: #fff; }

/* ===== 環境切り替え（検証/本番） ===== */
.staging-badge {
  font-size: 11px;
  font-weight: 700;
  background: rgba(255,255,255,.22);
  color: #fff;
  padding: 3px 10px;
  border-radius: 99px;
  letter-spacing: .03em;
  flex-shrink: 0;
}
.visual-link-btn {
  padding: 5px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid rgba(255,255,255,.5);
  color: #fff;
  background: rgba(255,255,255,.12);
  transition: background .15s, border-color .15s;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
}
.visual-link-btn:hover {
  background: rgba(255,255,255,.28);
  border-color: rgba(255,255,255,.9);
}

/* ===== Monitor Indicator ===== */
.monitor-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,.9);
  flex-shrink: 0;
}
.monitor-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.monitor-alive {
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74,222,128,.6);
  animation: monitor-pulse 2s infinite;
}
.monitor-dead  { background: #f87171; }
.monitor-unknown { background: rgba(255,255,255,.4); }
.monitor-time  { opacity: .7; font-weight: 400; }
@keyframes monitor-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(74,222,128,.6); }
  70%  { box-shadow: 0 0 0 6px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}

/* ===== WMS Hub link in schedule header ===== */
.sched-hub-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 4px 10px;
  border: 1.5px solid var(--accent);
  border-radius: 99px;
  transition: background .15s;
}
.sched-hub-link:hover { background: var(--accent); color: #fff; }

.env-btn {
  padding: 5px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid rgba(255,255,255,.5);
  color: #fff;
  background: rgba(255,255,255,.12);
  transition: background .15s, border-color .15s;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 6px;
}
.env-btn:hover {
  background: rgba(255,255,255,.28);
  border-color: rgba(255,255,255,.9);
}

/* staging 時: ヘッダーを鮮やかなオレンジ（注意色）に変更 */
body.is-staging { --accent: #9a3412; }
body.is-staging .app-header {
  background: #ea580c;
  background-image: repeating-linear-gradient(
    135deg,
    transparent,
    transparent 18px,
    rgba(0,0,0,.06) 18px,
    rgba(0,0,0,.06) 20px
  );
}
body.is-staging .filter-btn.active { background: #ea580c; border-color: #ea580c; }
body.is-staging .filter-btn:hover { border-color: #ea580c; color: #ea580c; }

/* ===== History stats bar ===== */
.history-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.hist-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
.hist-num {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--muted);
}
.hist-label { font-size: 11px; color: var(--muted); }
.completed-stat .hist-num { color: var(--success); }
.failed-stat    .hist-num { color: var(--danger); }
.today-stat     .hist-num { color: var(--accent); }
.avg-stat       .hist-num { color: var(--warning); }

/* ===== History cards ===== */
.hist-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hist-card-header {
  padding: 14px 16px 10px;
}
.hist-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

/* ===== Timestamps grid ===== */
.hist-timestamps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}
.hist-ts-item {
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hist-ts-label {
  font-weight: 600;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.hist-ts-val {
  font-size: 11px;
  color: var(--text);
  font-weight: 600;
}
.hist-ts-empty .hist-ts-val { color: var(--muted); }

/* ===== Duration badge ===== */
.badge.hist-duration { background: #ecfdf5; color: #065f46; }

/* ===== Verification badges ===== */
.badge.verified   { background: #dcfce7; color: #166534; }
.badge.unverified { background: #fef9c3; color: #854d0e; }
.verified-at      { font-size: 11px; color: var(--muted); margin-left: 4px; }

/* ===== Unverified summary block ===== */
.unverified-summary {
  background: var(--surface);
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
}
.unverified-summary-header {
  font-size: 12px;
  font-weight: 700;
  color: #854d0e;
  margin-bottom: 6px;
}
.unverified-summary-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.unverified-summary-item {
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  padding: 2px 0;
}
.unverified-summary-item:hover { color: var(--accent); text-decoration: underline; }

/* ===== Task logs panel ===== */
.task-logs-panel {
  border-top: 1px solid var(--border);
  padding: 10px 16px 12px;
  background: var(--surface-alt);
}
.task-logs-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}
.task-log-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--border);
}
.task-log-item:last-child { border: none; }
.task-log-time {
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.task-log-type {
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.task-log-type.started   { color: var(--accent); }
.task-log-type.completed { color: var(--success); }
.task-log-type.failed    { color: var(--danger); }
.task-log-msg {
  color: var(--text);
  line-height: 1.5;
}

/* ===== Member Panel ===== */
.member-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.member-panel-loading {
  text-align: center;
  color: var(--muted);
  padding: 16px;
  font-size: 13px;
}
.member-panel-header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}
.member-panel-title {
  font-size: 15px;
  font-weight: 700;
}
.member-panel-time {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
}

/* ===== Member Cards ===== */
.member-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.member-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  background: var(--bg);
  transition: box-shadow .15s;
}
.member-card.kochan {
  border-color: #3b82f6;
  background: #eff6ff;
}
.member-card.kochan.status-active {
  border-color: #059669;
  background: #f0fdf4;
  box-shadow: 0 0 0 3px #bbf7d0;
}
.member-card.status-error {
  border-color: var(--danger);
  background: #fff5f5;
  box-shadow: 0 0 0 3px #fecaca;
}
.member-card-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}
.member-card-role {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}
.member-card-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
}
.member-status-icon { font-size: 14px; line-height: 1; }
.member-status-label {
  font-size: 13px;
  font-weight: 700;
}
.status-active  .member-status-label { color: #059669; }
.status-standby .member-status-label { color: #d97706; }
.status-offline .member-status-label { color: var(--muted); }
.status-error   .member-status-label { color: var(--danger); }
.status-busy    .member-status-label { color: #2563eb; }
.member-card-detail {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}
.kochan-elapsed {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #065f46;
  background: #d1fae5;
  padding: 3px 10px;
  border-radius: 6px;
}

/* ===== Kochan Stats ===== */
.kochan-stats {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-bottom: 20px;
}
.kochan-stats-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
}
.kochan-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.k-stat {
  text-align: center;
  padding: 10px 8px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.k-stat-num {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}
.k-stat-label { font-size: 11px; color: var(--muted); }
.k-success { color: var(--success); }
.k-danger  { color: var(--danger); }
.k-muted   { color: var(--muted); font-size: 15px; }
.k-accent  { color: var(--accent); font-size: 15px; }

/* ===== Activity Timeline ===== */
.activity-timeline {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.timeline-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
}
.timeline-items {
  display: flex;
  flex-direction: column;
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.tl-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px dashed var(--border);
}
.tl-item:last-child { border: none; }
.tl-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.tl-completed   .tl-dot { background: var(--success); }
.tl-failed      .tl-dot { background: var(--danger); }
.tl-in_progress .tl-dot { background: #3b82f6; animation: pulse-tl-dot 1.2s ease-in-out infinite; }
.tl-pending     .tl-dot { background: #f59e0b; }
.tl-held        .tl-dot { background: var(--held); }
.tl-rejected    .tl-dot { background: var(--muted); }
@keyframes pulse-tl-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .45; transform: scale(.7); }
}
.tl-content { flex: 1; min-width: 0; }
.tl-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 3px;
}
.tl-id { font-size: 11px; color: var(--muted); margin-right: 2px; }
.tl-member {
  font-size: 10px;
  font-weight: 700;
  color: #166534;
  background: #f0fdf4;
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 4px;
}
.tl-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.tl-badge { padding: 1px 6px; font-size: 10px; }
.tl-duration { font-size: 10px; color: var(--muted); }
.tl-time { font-size: 10px; color: var(--muted); margin-left: auto; }

/* ===== Schedule Dashboard ===== */
.schedule-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.schedule-inner { display: flex; flex-direction: column; gap: 16px; }
.schedule-loading { text-align: center; color: var(--muted); padding: 16px; font-size: 13px; }

.sched-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.sched-title { font-size: 15px; font-weight: 700; }
.sched-header-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.sched-overall-badge {
  padding: 3px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
}
.sob-ok    { background: #d1fae5; color: #065f46; }
.sob-warn  { background: #fef3c7; color: #92400e; }
.sob-alert { background: #fee2e2; color: #991b1b; }
.sched-upd { font-size: 11px; color: var(--muted); }

/* KPI バー */
.sched-kpi-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.sched-kpi {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 8px;
  text-align: center;
}
.sched-kpi-num {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--accent);
}
.sched-kpi-label { font-size: 11px; color: var(--muted); }
.skn-ok     { color: var(--success); }
.skn-warn   { color: var(--warning); }
.skn-danger { color: var(--danger); }

/* セクション見出し */
.sched-section-head {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

/* ガントチャート */
.gantt-chart { display: flex; flex-direction: column; gap: 0; }

.gantt-row {
  display: flex;
  align-items: center;
  height: 40px;
  border-bottom: 1px dashed var(--border);
}
.gantt-row:last-child { border: none; }

.gantt-row-name {
  width: 80px;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 8px;
}
.gantt-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.gsd-completed   { background: var(--success); }
.gsd-in_progress { background: #3b82f6; animation: pulse-tl-dot 1.2s ease-in-out infinite; }
.gsd-not_started { background: var(--border); }
.gsd-delayed     { background: var(--danger); }

.gantt-bars-wrap {
  flex: 1;
  position: relative;
  height: 28px;
  background: var(--surface-alt);
  border-radius: 4px;
  overflow: hidden;
}

/* グリッドライン */
.gantt-grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
  z-index: 0;
}
.gantt-month-label {
  display: none; /* 軸行で表示するので非表示 */
}

/* 今日マーカー */
.gantt-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--danger);
  z-index: 3;
  opacity: .8;
}

/* 計画バー */
.gantt-bar-plan {
  position: absolute;
  top: 3px;
  height: 10px;
  border-radius: 3px;
  z-index: 1;
  opacity: .45;
  overflow: hidden;
  white-space: nowrap;
}
.gantt-bar-label {
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  padding: 0 4px;
  line-height: 10px;
}
.gantt-phase-completed   { background: var(--success); }
.gantt-phase-in_progress { background: #3b82f6; }
.gantt-phase-not_started { background: var(--muted); }
.gantt-phase-delayed     { background: var(--danger); }

/* 実績バー */
.gantt-bar-actual {
  position: absolute;
  top: 15px;
  height: 10px;
  border-radius: 3px;
  background: #1a3a5c;
  z-index: 2;
  opacity: .75;
}

/* 軸行 */
.gantt-axis-row { display: flex; height: 20px; margin-top: 4px; }
.gantt-axis-spacer { width: 80px; flex-shrink: 0; }
.gantt-axis-area { flex: 1; position: relative; }
.gantt-axis-label {
  position: absolute;
  font-size: 10px;
  color: var(--muted);
  transform: translateX(-50%);
  white-space: nowrap;
}

/* 凡例 */
.gantt-legend {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--muted);
  justify-content: flex-end;
}
.gl-item { display: flex; align-items: center; gap: 4px; }
.gl-plan-bar   { display: inline-block; width: 24px; height: 8px; border-radius: 2px; background: #3b82f6; opacity: .45; }
.gl-actual-bar { display: inline-block; width: 24px; height: 8px; border-radius: 2px; background: #1a3a5c; opacity: .75; }
.gl-today-bar  { display: inline-block; width: 2px;  height: 16px; background: var(--danger); opacity: .8; }

/* 工程プログレスバー */
.proc-progress-wrap { display: flex; align-items: center; gap: 10px; }
.proc-progress-track {
  flex: 1;
  height: 10px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.proc-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1a7a4a, #3b82f6);
  border-radius: 99px;
  transition: width .4s ease;
}
.proc-progress-pct { font-size: 13px; font-weight: 700; color: var(--accent); min-width: 36px; text-align: right; }

/* 工程グリッド */
.proc-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.proc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12px;
  border-bottom: 1px dashed var(--border);
  background: var(--surface);
}
.proc-item:last-child { border: none; }
.proc-item.proc-completed   { background: #f0fdf4; }
.proc-item.proc-in_progress { background: #eff6ff; }
.proc-item.proc-delayed     { background: #fff5f5; }

.proc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.proc-completed   .proc-dot { background: var(--success); }
.proc-in_progress .proc-dot { background: #3b82f6; animation: pulse-tl-dot 1.2s ease-in-out infinite; }
.proc-not_started .proc-dot { background: var(--border); }
.proc-delayed     .proc-dot { background: var(--danger); }

.proc-name  { flex: 1; font-weight: 600; }
.proc-dates { font-size: 11px; color: var(--muted); white-space: nowrap; }

.proc-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}
.pb-completed   { background: #d1fae5; color: #065f46; }
.pb-in_progress { background: #dbeafe; color: #1e40af; }
.pb-not_started { background: #f1f5f9; color: #64748b; }
.pb-delayed     { background: #fee2e2; color: #991b1b; }

/* Phase 5-C: 工程レビュー拡張 */

/* レビュー状態バッジ */
.pb-rv-review_in_progress { background: #fef3c7; color: #92400e; }
.pb-rv-review_completed   { background: #dcfce7; color: #166534; }

/* Q解決カウンター */
.proc-q-resolved {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: #f1f5f9;
  color: #64748b;
  white-space: nowrap;
  flex-shrink: 0;
}
.proc-q-resolved.pqr-done {
  background: #d1fae5;
  color: #065f46;
}

/* 致命傷ラインマーカー */
.proc-critical-mark {
  font-size: 10px;
  margin-right: 2px;
  flex-shrink: 0;
}
.proc-critical-line {
  border-left: 3px solid #f59e0b !important;
}
.proc-critical-line.proc-in_progress { background: #fffbeb; }
.proc-critical-line.proc-not_started { background: #fffbeb; }

/* 詳細リンク */
.proc-detail-link {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--bg);
  transition: background .12s, color .12s;
}
.proc-detail-link:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* セクションヘッダーのレビューサマリー */
.proc-review-summary {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
  font-weight: 400;
}
.prs-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 99px;
}
.prs-done { background: #dcfce7; color: #166534; }
.prs-wip  { background: #fef3c7; color: #92400e; }

/* モバイル: 詳細リンクを保持、Q解決を非表示 */
@media (max-width: 640px) {
  .proc-q-resolved { display: none; }
  .proc-review-summary { display: none; }
}

/* ===== Theme Switcher ===== */
.theme-switcher {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}
.theme-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  border: 1.5px solid rgba(255,255,255,.3);
  color: rgba(255,255,255,.65);
  background: rgba(255,255,255,.1);
  padding: 0;
  transition: background .15s, border-color .15s, color .15s;
}
.theme-btn:hover {
  background: rgba(255,255,255,.22);
  border-color: rgba(255,255,255,.6);
  color: #fff;
}
.theme-btn.active {
  background: rgba(255,255,255,.88);
  border-color: #fff;
  color: var(--accent);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .card-judgment    { grid-template-columns: 1fr 1fr; }
  .stats-bar        { grid-template-columns: repeat(2, 1fr); }
  .app-header h1    { font-size: 15px; }
  .history-stats    { grid-template-columns: repeat(2, 1fr); }
  .hist-timestamps  { grid-template-columns: repeat(2, 1fr); }
  .member-cards     { grid-template-columns: repeat(2, 1fr); }
  .kochan-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .member-panel     { padding: 14px 12px; }
  .timeline-items   { max-height: 280px; }
  .sched-kpi-bar    { grid-template-columns: repeat(2, 1fr); }
  .gantt-row-name   { width: 56px; font-size: 10px; }
  .schedule-panel   { padding: 14px 12px; }
  .proc-dates       { display: none; }
}

/* ===== Phase 4-G: 想定時間進捗バー ===== */
.task-progress {
  margin-top: 8px;
}
.progress-bar-wrap {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width .4s ease;
}
.progress-green  { background: #1a7a4a; }
.progress-yellow { background: #b45309; }
.progress-red    { background: #b8002e; }
.progress-purple { background: #7c3aed; }
.progress-text {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

/* ===== Phase 4-G: 警告バナー ===== */
.anomaly-banner {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  border-left: 4px solid;
}
.anomaly-warning   { background: #fffbeb; color: #92400e; border-color: #f59e0b; }
.anomaly-critical  { background: #fff1f2; color: #9f1239; border-color: #f43f5e; }
.anomaly-emergency { background: #f5f3ff; color: #4c1d95; border-color: #7c3aed; animation: pulse-border .8s infinite; }
.anomaly-error     { background: #fff1f2; color: #9f1239; border-color: #b8002e; }

@keyframes pulse-border {
  0%, 100% { border-color: #7c3aed; }
  50%       { border-color: #c4b5fd; }
}

/* member card の警告色 */
.member-card.status-warning   { border-left: 3px solid #f59e0b; }
.member-card.status-critical  { border-left: 3px solid #f43f5e; }
.member-card.status-emergency { border-left: 3px solid #7c3aed; background: #faf5ff; }

/* ===== Phase 4-G: 異常履歴 ===== */
.anomaly-history {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
}
.anomaly-history-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.anomaly-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.anomaly-row:last-child { border-bottom: none; }
.anomaly-time  { color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.anomaly-msg   { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anomaly-badge { font-size: 11px; padding: 2px 6px; border-radius: 4px; flex-shrink: 0; }
.ab-sent    { background: #dcfce7; color: #166534; }
.ab-failed  { background: #fef2f2; color: #991b1b; }
.ab-pending { background: #fff7ed; color: #9a3412; }
.ab-skipped { background: var(--bg); color: var(--muted); }

/* ===== くろくん失敗集タブ ===== */
.filter-btn.failure-tab { border-color: #fca5a5; color: #dc2626; }
.filter-btn.failure-tab:hover { border-color: #dc2626; color: #dc2626; }
.filter-btn.failure-tab.active { background: #dc2626; border-color: #dc2626; color: #fff; }

.fp-card {
  background: var(--surface);
  border: 1px solid #fee2e2;
  border-left: 4px solid #dc2626;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.fp-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.fp-title { font-weight: 600; font-size: 15px; flex: 1; }
.fp-context { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.fp-keywords { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.fp-keyword {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}
.fp-meta { font-size: 11px; color: var(--muted); margin-top: 10px; }

/* ===== Phase 4-M: チーム別2分割レイアウト ===== */
.team-split-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.team-col { min-width: 0; }
.team-col-header {
  font-size: 13px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  margin-bottom: 10px;
}
.team-col-header.strategy {
  background: rgba(24, 95, 165, 0.08);
  color: var(--accent);
  border-left-color: var(--accent);
}
.team-col-header.dev {
  background: rgba(26, 122, 74, 0.08);
  color: var(--success);
  border-left-color: var(--success);
}
.team-col-empty {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

/* 実行中エリア */
#inprogress-area { margin-bottom: 20px; }
.inprogress-area-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--success);
  margin-bottom: 10px;
}
.inprogress-card { border-color: #bbf7d0 !important; }

/* 直近の動き チームバッジ */
.tl-team-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 3px;
  vertical-align: middle;
}
.tl-team-strategy {
  background: rgba(24, 95, 165, 0.1);
  color: var(--accent);
}
.tl-team-dev {
  background: rgba(26, 122, 74, 0.1);
  color: var(--success);
}

/* メンバーパネル 2分割 */
.member-two-col {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 16px;
  margin-bottom: 20px;
}
.member-team-section { min-width: 0; }
.member-team-header {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.member-team-header.strategy { color: var(--accent); border-bottom-color: var(--accent); }
.member-team-header.dev      { color: var(--success); border-bottom-color: var(--success); }
.member-two-col .member-cards {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .team-split-container { grid-template-columns: 1fr; }
  .member-two-col       { grid-template-columns: 1fr; }
}

/* ===== Fatal Line Dashboard ===== */
.fl-panel { padding: 0 0 32px; }

.fl-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.fl-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.fl-panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.fl-sheet-link {
  font-size: 12px;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 3px 10px;
  transition: background .15s;
}
.fl-sheet-link:hover { background: var(--accent); color: #fff; }

.fl-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.fl-progress-track {
  flex: 1;
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}
.fl-progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 5px;
  transition: width .4s ease;
}
.fl-progress-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.fl-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.fl-legend-item { display: flex; align-items: center; gap: 4px; }
.fl-legend-note { font-size: 11px; color: var(--muted); margin-left: auto; }

.fl-group { margin-bottom: 16px; }
.fl-group-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 6px 0 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
}

.fl-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.fl-table th {
  background: var(--surface-alt);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-align: left;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}
.fl-th-id     { width: 64px; }
.fl-th-title  { min-width: 180px; }
.fl-th-rec    { min-width: 200px; }
.fl-th-ans    { min-width: 140px; }
.fl-th-status { width: 120px; }

.fl-row {
  cursor: pointer;
  transition: background .12s;
}
.fl-row:hover { background: var(--surface-alt); }
.fl-row td {
  padding: 9px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.fl-row:last-child td { border-bottom: none; }

.fl-id {
  font-size: 12px;
  font-weight: 700;
  font-family: monospace;
  color: var(--accent);
}
.fl-title { font-weight: 500; }
.fl-recommended { font-size: 12px; color: var(--muted); }

.fl-answer { font-size: 12px; font-weight: 600; }
.fl-answer-empty { color: var(--muted); }

.fl-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.fl-status-white  { background: var(--surface-alt); color: var(--muted); border: 1px solid var(--border); }
.fl-status-blue   { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.fl-status-green  { background: #dcfce7; color: #166534; border: 1px solid #86efac; }

html[data-theme="c"] .fl-status-blue  { background: #1e3a5f; color: #93c5fd; border-color: #3b82f6; }
html[data-theme="c"] .fl-status-green { background: #14532d; color: #4ade80; border-color: #22c55e; }

/* --- fl 管理者モード --- */
.fl-row-clickable { cursor: pointer; }
.fl-row-clickable:hover td { background: var(--surface-alt); }

.fl-admin-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  margin-left: 8px;
}

.fl-edit-input {
  width: 100%;
  min-width: 80px;
  padding: 3px 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
}
.fl-edit-input:focus {
  outline: none;
  border-color: var(--accent);
}

.fl-edit-select {
  padding: 3px 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}
.fl-edit-select:focus { outline: none; border-color: var(--accent); }

.fl-th-adv { min-width: 120px; }

html[data-theme="c"] .fl-admin-badge { background: #3b2e00; color: #fcd34d; border-color: #92400e; }
html[data-theme="c"] .fl-edit-input,
html[data-theme="c"] .fl-edit-select { background: #1e293b; color: #e2e8f0; border-color: #475569; }
