:root {
  color-scheme: light;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  background: #f4f6fb;
  color: #172033;
}

* { box-sizing: border-box; }

body { margin: 0; }

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #111827;
  color: #fff;
  padding: 24px 16px;
}

.brand {
  display: grid;
  gap: 6px;
  margin-bottom: 28px;
}

.brand strong { font-size: 20px; }
.brand span { color: #9ca3af; font-size: 13px; }

.nav { display: grid; gap: 8px; }

.nav-item {
  background: transparent;
  border: 0;
  border-radius: 12px;
  color: #d1d5db;
  cursor: pointer;
  font-size: 15px;
  padding: 12px 14px;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: #2563eb;
  color: #fff;
}

.main-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.topbar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  padding: 22px 28px;
}

.topbar h1 { font-size: 24px; margin: 0 0 6px; }

.topbar p,
.section-header p {
  color: #64748b;
  margin: 0;
}

.content { padding: 22px; }

.view { display: none; }
.view.active { display: block; }

.card {
  background: #fff;
  border: 1px solid #dde4ef;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgb(25 37 61 / 8%);
  padding: 20px;
}

h2 { font-size: 18px; margin: 0 0 16px; }
h3 { font-size: 15px; margin: 16px 0 10px; }

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

.section-header input {
  min-width: 280px;
}

/* ===== Header Stats ===== */
.header-stats {
  display: flex;
  gap: 8px;
}

.stat-chip {
  background: #f3f6fb;
  border-radius: 999px;
  color: #475569;
  font-size: 13px;
  padding: 6px 12px;
  white-space: nowrap;
}

/* ===== Task Form ===== */
.task-form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ===== Task List ===== */
.task-list {
  display: grid;
  gap: 12px;
}

.task-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
}

.task-card-header {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
}

.task-card-header h3 {
  flex: 1;
  margin: 0;
}

.task-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ===== Badges ===== */
.badge {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  white-space: nowrap;
}

.badge-draft { background: #e5e7eb; color: #374151; }
.badge-published { background: #dbeafe; color: #1d4ed8; }
.badge-closed { background: #fef3c7; color: #92400e; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

/* ===== Overlay ===== */
.overlay {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 50;
}

.overlay.hidden { display: none; }

.overlay-backdrop {
  background: rgb(15 23 42 / 50%);
  inset: 0;
  position: absolute;
}

.overlay-panel {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgb(15 23 42 / 35%);
  max-height: 80vh;
  max-width: 680px;
  overflow: auto;
  position: relative;
  width: min(90vw, 680px);
}

.overlay-header {
  align-items: center;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  padding: 20px 24px;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.overlay-header h2 { margin: 0; }

.overlay-close {
  background: transparent;
  border: 0;
  color: #6b7280;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  padding: 0 4px;
}

.overlay-body { padding: 20px 24px; }

/* ===== Detail Fields ===== */
.detail-section {
  display: grid;
  gap: 10px;
}

.detail-field {
  align-items: center;
  display: flex;
  gap: 12px;
}

.detail-label {
  color: #6b7280;
  font-size: 14px;
  min-width: 100px;
}

.assignment-table {
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 8px;
  width: 100%;
}

.assignment-table th,
.assignment-table td {
  border: 1px solid #e5e7eb;
  padding: 8px 10px;
  text-align: left;
}

.assignment-table th {
  background: #f9fafb;
  font-weight: 600;
}

/* ===== Workers ===== */
.worker-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
}

.worker-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
}

.worker-card-header {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 4px;
}

.worker-card-header h3 {
  flex: 1;
  margin: 0;
}

.worker-status-dot {
  border-radius: 50%;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.worker-status-dot.online { background: #22c55e; }
.worker-status-dot.busy { background: #f59e0b; }
.worker-status-dot.offline { background: #9ca3af; }

.badge-online { background: #d1fae5; color: #065f46; }
.badge-busy { background: #fef3c7; color: #92400e; }
.badge-offline { background: #f3f4f6; color: #6b7280; }

/* ===== Videos ===== */
.video-workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 420px;
}

.video-list,
.comment-panel {
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.video-list { display: grid; gap: 12px; }

.video-card {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  cursor: pointer;
  padding: 14px;
}

.video-card.active,
.video-card:hover {
  border-color: #2563eb;
  box-shadow: 0 8px 20px rgb(37 99 235 / 12%);
}

.video-card h3 { margin-top: 0; }

.selected-video {
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 14px;
  padding-bottom: 14px;
}

/* ===== Comments ===== */
.comment-list {
  display: grid;
  gap: 12px;
}

.comment-thread { display: grid; gap: 0; }

.comment-replies {
  border-left: 3px solid #cbd5e1;
  display: grid;
  gap: 10px;
  margin: 4px 0 14px 8px;
  padding-left: 14px;
}

.comment-card {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
}

.comment-card--reply { background: #f8fafc; }
.comment-card h3 { margin-top: 0; }
.comment-card p { line-height: 1.6; margin: 8px 0; }

.comment-tier {
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.comment-orphan-note { font-size: 13px; margin: 14px 0 8px; }

/* ===== Runs ===== */
.list { display: grid; gap: 12px; }

.list-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
}

.list-item h3 { margin-top: 0; }

/* ===== Common ===== */
.muted,
.meta {
  color: #66758c;
}

.meta { font-size: 13px; line-height: 1.7; }

.metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.metric-row span {
  background: #eef4ff;
  border-radius: 999px;
  color: #1d4ed8;
  font-size: 12px;
  padding: 5px 9px;
}

/* ===== Buttons ===== */
button {
  background: #2563eb;
  border: 0;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 16px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  background: #e8eef8;
  color: #1d2b45;
}

button.small {
  font-size: 12px;
  padding: 6px 12px;
}

button.danger {
  color: #dc2626;
}

input,
select,
textarea {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
}

/* select 原先没有任何样式定义，不补会和相邻 input 明显不一致 */
select {
  background: #fff;
  color: inherit;
}

textarea {
  resize: vertical;
}

label {
  color: #526077;
  display: grid;
  font-size: 13px;
  gap: 6px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

a {
  color: #2563eb;
  font-weight: 700;
  text-decoration: none;
}

.placeholder-card {
  max-width: 760px;
}

.settings-summary {
  background: #f8fafc;
  border-radius: 12px;
  color: #475569;
  line-height: 1.8;
  padding: 14px;
}

/* ===== Responsive ===== */
@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .nav { grid-template-columns: repeat(3, 1fr); }
  .video-workspace { grid-template-columns: 1fr; }
  .video-list, .comment-panel { max-height: none; }
  .task-form-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .task-form-grid,
  .worker-list,
  .nav { grid-template-columns: 1fr; }
  .topbar,
  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .section-header input { min-width: 0; width: 100%; }
}

/* ===== Message Pool ===== */

/* 内容列跨两列，避免长文本被挤成窄条 */
.message-content-field {
  grid-column: span 2;
}

.message-row {
  align-items: center;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  display: grid;
  gap: 10px;
  grid-template-columns: 130px minmax(0, 1fr) auto;
  padding: 12px 14px;
}

.message-row--off {
  opacity: 0.6;
}

.message-row .task-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-top: 0;
}
