:root {
  --bg: #eef3f7;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #182230;
  --muted: #667085;
  --line: #d9e0ea;
  --accent: #0f766e;
  --accent-2: #7c3aed;
  --blue: #2563eb;
  --warning: #b54708;
  --danger: #b42318;
  --success-soft: #ecfdf3;
  --warning-soft: #fff4e5;
  --danger-soft: #fef3f2;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 220px;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.14), rgba(37, 99, 235, 0.08) 48%, rgba(124, 58, 237, 0.12));
  pointer-events: none;
}
a { color: inherit; }
.shell { position: relative; width: min(1480px, 100%); margin: 0 auto; padding: 26px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 22px;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(30px, 4vw, 54px); line-height: 1.05; letter-spacing: 0; }
.topbar p { color: var(--muted); font-size: 18px; margin-top: 8px; }

.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.button, .badge, .live-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 900;
  text-decoration: none;
}
.button { background: var(--accent); color: #fff; border-color: var(--accent); }
.button:hover, .primary-action:hover { filter: brightness(0.96); }
.badge.muted { color: var(--muted); }
.live-badge span {
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 999px;
  background: #12b76a;
  box-shadow: 0 0 0 5px rgba(18, 183, 106, 0.14);
}

.alert {
  padding: 12px 14px;
  border: 1px solid rgba(15, 118, 110, 0.25);
  border-radius: 8px;
  background: var(--success-soft);
  color: var(--accent);
  font-weight: 900;
  margin-bottom: 14px;
}

.view-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
}
.view-tabs a {
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-decoration: none;
  font-weight: 900;
  white-space: nowrap;
}
.view-tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metric {
  min-height: 118px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(24, 34, 48, 0.04);
}
.metric span { color: var(--muted); font-size: 15px; font-weight: 900; }
.metric strong { display: block; margin-top: 14px; font-size: 46px; line-height: 1; }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
  box-shadow: 0 12px 28px rgba(24, 34, 48, 0.05);
}
.panel-wide { min-width: 0; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 { font-size: 24px; }
.panel-head span { color: var(--muted); font-weight: 900; }

.tasks { display: grid; gap: 10px; }
.task {
  position: relative;
  padding: 14px 14px 14px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.task::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 4px;
  border-radius: 0 999px 999px 0;
  background: var(--accent);
}
.task-high::before { background: var(--warning); }
.task-topline {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}
.task-topline strong { color: var(--accent); }
.task-topline a {
  text-decoration: none;
  font-weight: 950;
  line-height: 1.45;
}
.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 14px;
}
.pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 950;
}
.status-open, .priority-normal { background: #eef2f7; color: var(--muted); }
.status-doing, .status-done { background: var(--success-soft); color: var(--accent); }
.status-blocked, .priority-high { background: var(--danger-soft); color: var(--danger); }
.status-muted, .priority-low { background: #f2f4f7; color: #475467; }
.approval-open, .risk-medium { background: var(--warning-soft); color: var(--warning); }
.approval-doing, .approval-done, .risk-low { background: var(--success-soft); color: var(--accent); }
.approval-blocked, .risk-high { background: var(--danger-soft); color: var(--danger); }
.approval-muted { background: #f2f4f7; color: #475467; }

.task-description, .task-scope, .task-step {
  margin-top: 9px;
  line-height: 1.55;
  font-size: 14px;
}
.task-description { color: var(--muted); }
.task-scope {
  padding-left: 10px;
  border-left: 3px solid rgba(15, 118, 110, 0.28);
  color: var(--ink);
}
.task-step {
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.task-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.task-actions button, .primary-action {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  color: var(--ink);
  font: inherit;
  font-weight: 950;
}
.primary-action {
  border: 0;
  background: var(--accent);
  color: #fff;
}

.category-list { display: grid; gap: 8px; }
.category-list a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 900;
}
.category-list a.active { border-color: var(--accent); background: var(--success-soft); }
.category-list em { color: var(--muted); font-style: normal; font-size: 12px; }

.approvals { display: grid; gap: 12px; }
.approval-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fbfcfe);
}
.approval-card.risk-high { border-color: rgba(180, 35, 24, 0.28); }
.approval-card.risk-medium { border-color: rgba(181, 71, 8, 0.26); }
.approval-topline {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}
.approval-topline strong { color: var(--accent-2); }
.approval-topline a {
  font-weight: 950;
  line-height: 1.45;
  text-decoration: none;
}
.approval-actions button:first-child { background: var(--accent); color: #fff; border-color: var(--accent); }
.review-notes {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
  font-weight: 750;
}
.agent-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}
.agent-panel p { line-height: 1.55; }
.agent-panel strong { font-size: 24px; color: var(--accent); }
.agent-orb {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: conic-gradient(from 180deg, var(--accent), var(--blue), var(--accent-2), var(--accent));
}
.agent-orb span {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 0 0 7px rgba(15, 118, 110, 0.12);
}

.automation-panel {
  display: grid;
  gap: 10px;
}
.automation-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  background: var(--success-soft);
}
.automation-actions label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 950;
  white-space: nowrap;
}
.case-list {
  display: grid;
  gap: 10px;
}
.case-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-decoration: none;
}
.case-card:hover { border-color: rgba(15, 118, 110, 0.45); }
.case-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.case-title strong {
  font-size: 18px;
  line-height: 1.35;
}
.case-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.case-metrics span {
  min-height: 54px;
  padding: 9px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}
.case-metrics b {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 22px;
}
.case-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.back-link {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--accent);
  font-weight: 950;
  text-decoration: none;
}
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 16px;
}
.detail-summary, .edit-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.detail-item {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}
.detail-item span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 950;
}
.detail-item strong { line-height: 1.45; }
.detail-block { display: grid; gap: 8px; margin-top: 12px; }
.detail-block h3 { font-size: 17px; }
.detail-copy, .raw-box {
  white-space: pre-wrap;
  line-height: 1.7;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.edit-form { margin-top: 14px; }
.edit-form label, .note-form {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 950;
}
.edit-form .wide { grid-column: 1 / -1; }
.edit-form input, .edit-form select, .edit-form textarea, .note-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 750;
}
.note-form { margin-bottom: 12px; }
.timeline-card {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 8px;
}
.timeline-card span { color: var(--muted); font-size: 12px; font-weight: 900; }
.empty { color: var(--muted); font-weight: 850; line-height: 1.6; }
pre {
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
}

@media (max-width: 920px) {
  .shell { padding: 18px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .metrics, .grid, .detail-layout, .detail-summary, .edit-form { grid-template-columns: 1fr; }
  .automation-actions, .case-metrics { grid-template-columns: 1fr; }
  .task-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
