:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --text: #151922;
  --muted: #6d7582;
  --line: #dfe5ec;
  --blue: #2f6fed;
  --green: #1b9a66;
  --amber: #c98112;
  --red: #d94848;
  --shadow: 0 16px 48px rgba(19, 28, 45, 0.12);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ui-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  position: relative;
  width: min(430px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--surface-2);
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 14px 14px 82px;
}

.side-rail {
  display: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 2px 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.auth-button[hidden] {
  display: none;
}

.command-search {
  display: none;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.05;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 15px;
}

.icon-button,
.secondary-button,
.text-button,
.primary-button,
.segment,
.nav-item {
  border: 0;
  cursor: pointer;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 18px;
}

.icon-button.loading .ui-icon {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.view {
  display: none;
  gap: 12px;
  min-width: 0;
}

.view.active {
  display: grid;
}

.command-hero {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid #cfe0ff;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #f2f7ff 100%);
}

.command-hero h2 {
  max-width: 680px;
  font-size: 24px;
  line-height: 1.12;
}

.hero-copy {
  max-width: 640px;
  margin-top: 8px;
  color: #475569;
  font-size: 14px;
  line-height: 1.45;
}

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

.section-heading,
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.panel-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sync-pill,
.priority,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf3ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.command-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.command-metric {
  min-height: 86px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.command-metric span,
.command-metric small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.command-metric strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 26px;
  line-height: 1;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.health-card,
.panel,
.project-card,
.task-card,
.output-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.health-card {
  position: relative;
  min-height: 82px;
  padding: 12px;
}

.health-card p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.health-card strong {
  display: block;
  margin-top: 18px;
  font-size: 16px;
}

.status-dot {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}

.health-card.warn .status-dot {
  background: var(--amber);
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.panel {
  padding: 12px;
}

.panel-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

canvas {
  width: 100%;
  margin-top: 10px;
}

.next-action {
  margin: 12px 0;
  color: #303846;
  font-size: 14px;
  line-height: 1.4;
}

.primary-button,
.secondary-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.primary-button {
  background: var(--blue);
  color: white;
}

.secondary-button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.text-button {
  background: transparent;
  color: var(--blue);
  font-weight: 800;
}

.full {
  width: 100%;
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.toggle-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.toggle-field span {
  display: grid;
  gap: 2px;
}

.toggle-field strong {
  font-size: 13px;
}

.toggle-field small {
  color: var(--muted);
  font-size: 11px;
}

.task-list,
.project-list,
.output-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.workflow-heading {
  align-items: flex-end;
}

.workflow-heading > div {
  display: grid;
  gap: 5px;
}

.workflow-heading p {
  max-width: 680px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.workflow-toolbar {
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
}

.workflow-filters {
  display: flex;
  width: max-content;
}

.workflow-filters .segment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.workflow-filters .segment span {
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(109, 117, 130, 0.12);
  color: inherit;
  font-size: 10px;
}

.workflow-filters .segment.active span {
  background: #e8eefb;
  color: var(--blue);
}

.workflow-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.workflow-stat {
  --stage-color: var(--blue);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 8px;
  min-width: 0;
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--stage-color);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.workflow-stat span {
  align-self: center;
  font-size: 12px;
  font-weight: 850;
}

.workflow-stat strong {
  font-size: 20px;
  line-height: 1;
}

.workflow-stat small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}

.workflow-stat.active {
  border-color: var(--stage-color);
  box-shadow: 0 0 0 2px var(--stage-soft);
}

.stage-queued {
  --stage-color: #64748b;
  --stage-soft: #f1f5f9;
}

.stage-in_progress {
  --stage-color: var(--blue);
  --stage-soft: #edf3ff;
}

.stage-review {
  --stage-color: var(--amber);
  --stage-soft: #fff6e6;
}

.stage-done,
.stage-ready {
  --stage-color: var(--green);
  --stage-soft: #eaf8f1;
}

.stage-archived {
  --stage-color: #7c6f95;
  --stage-soft: #f3f0f7;
}

.stage-failed {
  --stage-color: var(--red);
  --stage-soft: #fff0f0;
}

.task-list.kanban-mode {
  display: block;
}

.department-grid {
  display: grid;
  gap: 10px;
}

.department-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.department-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.department-title {
  font-size: 15px;
  font-weight: 900;
  line-height: 1.2;
}

.department-head span,
.department-card p,
.department-stats span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.department-head b {
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf3ff;
  color: var(--blue);
  font-size: 11px;
}

.department-head b.standby {
  background: #f1f4f7;
  color: var(--muted);
}

.department-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.department-stats div {
  display: grid;
  gap: 2px;
  min-height: 56px;
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-2);
}

.department-stats strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.department-detail {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.department-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.department-summary div,
.department-line {
  border-radius: 8px;
  background: var(--surface-2);
}

.department-summary div {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.department-summary span,
.department-line span,
.activity-item small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.department-summary strong {
  font-size: 18px;
}

.department-columns {
  display: grid;
  gap: 10px;
}

.department-columns section {
  display: grid;
  align-content: start;
  gap: 8px;
}

.department-columns h4 {
  margin: 0;
  font-size: 13px;
}

.department-line {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px;
  border: 0;
  color: var(--text);
  text-align: left;
}

.department-line strong {
  font-size: 13px;
  line-height: 1.3;
}

.projects-panel {
  display: grid;
  gap: 12px;
}

.task-card,
.project-card,
.output-card {
  padding: 12px;
}

.task-card,
.output-card {
  --stage-color: #64748b;
  --stage-soft: #f1f5f9;
  position: relative;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: hidden;
  border-left: 3px solid var(--stage-color);
}

.card-stage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stage-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--stage-color);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
}

.stage-label i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stage-color);
}

.priority-chip,
.result-type {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.priority-chip.urgent {
  color: var(--red);
}

.priority-chip.low {
  color: #64748b;
}

.card-owner-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.agent-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--stage-soft);
  color: var(--stage-color);
  font-size: 12px;
  font-weight: 900;
}

.card-owner-row div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.card-owner-row strong {
  overflow: hidden;
  font-size: 11px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-owner-row small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-summary {
  display: -webkit-box;
  overflow: hidden;
  color: #475569;
  font-size: 11px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.next-step {
  display: grid;
  gap: 3px;
  padding: 8px 9px;
  border-radius: 7px;
  background: var(--stage-soft);
}

.next-step span {
  color: var(--stage-color);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.next-step strong {
  color: #303846;
  font-size: 11px;
  line-height: 1.3;
}

.task-header,
.project-header,
.output-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.task-title,
.project-title,
.output-title {
  font-size: 14px;
  font-weight: 850;
  line-height: 1.25;
}

.task-meta,
.project-meta,
.output-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.task-action {
  margin-top: 10px;
}

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

.workflow-actions {
  align-items: center;
}

.workflow-actions .task-action {
  min-height: 32px;
  margin-top: 0;
  padding: 0 10px;
  font-size: 11px;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(198px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 4px;
}

.kanban-column {
  --stage-color: #64748b;
  --stage-soft: #f1f5f9;
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 198px;
  padding: 10px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--stage-color);
  border-radius: 8px;
  background: #f8fafc;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.kanban-column.drop-target {
  border-color: var(--blue);
  background: #edf3ff;
}

.task-card[draggable="true"] {
  cursor: grab;
}

.task-card.dragging {
  opacity: 0.45;
}

.kanban-column-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.kanban-column-head h3 {
  margin: 0;
  color: var(--stage-color);
  font-size: 13px;
  line-height: 1.2;
}

.kanban-column-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.kanban-column-head strong {
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface);
  color: #303846;
  font-size: 12px;
}

.kanban-list {
  display: grid;
  gap: 8px;
}

.task-card.compact {
  padding: 10px;
}

.task-card.compact .task-title {
  font-size: 13px;
}

.task-card.compact .task-meta {
  font-size: 11px;
}

.task-card.compact .card-summary {
  -webkit-line-clamp: 2;
}

.task-card.compact .workflow-actions {
  gap: 6px;
}

.task-card.compact .workflow-actions .task-action {
  flex: 1 1 72px;
  padding: 0 7px;
}

.todoist-panel {
  display: grid;
  gap: 10px;
}

.todoist-list {
  display: grid;
  gap: 8px;
}

.todoist-list.compact .todoist-item:nth-child(n + 4) {
  display: none;
}

.activity-feed {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.activity-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 9px;
  padding: 9px;
  border-radius: 8px;
  background: var(--surface-2);
}

.activity-item > span {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--blue);
}

.activity-item.review > span {
  background: var(--amber);
}

.activity-item.error > span {
  background: var(--red);
}

.activity-item.todoist > span {
  background: var(--green);
}

.activity-item div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.activity-item strong {
  font-size: 13px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.todoist-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.todoist-item div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.todoist-item strong {
  font-size: 13px;
  line-height: 1.3;
}

.todoist-item span,
.todoist-item small {
  color: var(--muted);
  font-size: 11px;
}

.pipeline-step {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border-radius: 8px;
  background: var(--surface-2);
}

.pipeline-step > span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #edf3ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
}

.pipeline-step div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.pipeline-step strong,
.calendar-preview-item strong {
  font-size: 13px;
  line-height: 1.3;
}

.pipeline-step small,
.calendar-preview-item span,
.calendar-preview-item small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.pipeline-step b {
  text-align: right;
  color: #303846;
  font-size: 14px;
}

.calendar-preview-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(72px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.calendar-day {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 116px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.calendar-day.has-item {
  border-color: #b8cdf9;
  background: #f3f7ff;
}

.calendar-day span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.calendar-day strong {
  font-size: 22px;
  line-height: 1;
}

.calendar-day small {
  color: #475569;
  font-size: 11px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.status-pill.queued,
.status-pill.running,
.status-pill.in_progress {
  background: #edf3ff;
  color: var(--blue);
}

.status-pill.review,
.status-pill.draft {
  background: #fff6e6;
  color: var(--amber);
}

.status-pill.done,
.status-pill.approved {
  background: #eaf8f1;
  color: var(--green);
}

.status-pill.failed,
.status-pill.archived {
  background: #fff0f0;
  color: var(--red);
}

.status-pill.idea {
  background: #edf3ff;
  color: var(--blue);
}

.status-pill.ready,
.status-pill.published {
  background: #eaf8f1;
  color: var(--green);
}

.project-card {
  display: grid;
  gap: 12px;
}

.project-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-box {
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-2);
}

.stat-box span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.stat-box strong {
  display: block;
  margin-top: 2px;
}

.task-form {
  display: grid;
  gap: 12px;
}

.copywriter-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

label {
  display: grid;
  gap: 6px;
}

label span,
.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 12px;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.route-box {
  display: grid;
  gap: 8px;
  border: 1px solid #cfe0ff;
  background: #f3f7ff;
  border-radius: 8px;
  padding: 12px;
}

.route-box p {
  color: #334b7e;
  font-size: 13px;
  line-height: 1.35;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 2px;
  padding: 3px;
  border-radius: 8px;
  background: #e9eef5;
}

.department-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.compact-segmented .segment {
  min-height: 26px;
  padding: 0 7px;
}

.segment {
  min-height: 30px;
  border-radius: 7px;
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.segment.active {
  background: var(--surface);
  color: var(--text);
}

.output-list {
  gap: 16px;
}

.output-group {
  --stage-color: #64748b;
  --stage-soft: #f1f5f9;
  display: grid;
  gap: 10px;
  min-width: 0;
  padding-top: 12px;
  border-top: 2px solid var(--stage-color);
}

.output-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.output-group-head div {
  display: grid;
  gap: 4px;
}

.output-group-head h3 {
  color: var(--stage-color);
  font-size: 15px;
}

.output-group-head p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.output-group-head > strong {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 26px;
  border-radius: 999px;
  background: var(--stage-soft);
  color: var(--stage-color);
  font-size: 12px;
}

.output-grid {
  display: grid;
  gap: 10px;
}

.linked-task {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.linked-task span,
.result-summary > span,
.detail-result-content > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.linked-task strong {
  overflow: hidden;
  font-size: 11px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-summary {
  display: grid;
  gap: 5px;
}

.result-summary p {
  display: -webkit-box;
  overflow: hidden;
  color: #303846;
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.output-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.output-actions .primary-button,
.output-actions .secondary-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 11px;
}

.output-actions .text-button {
  min-height: 32px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 11px;
}

.result-detail-head {
  --stage-color: #64748b;
  --stage-soft: #f1f5f9;
  display: grid;
  gap: 7px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.result-detail-head h4 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.result-detail-head p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.result-progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.result-progress div {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 0;
  color: #9aa3af;
}

.result-progress i {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
}

.result-progress span {
  overflow: hidden;
  width: 100%;
  font-size: 9px;
  font-weight: 800;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-progress .complete,
.result-progress .current {
  color: var(--blue);
}

.result-progress .complete i {
  border-color: var(--blue);
  background: var(--blue);
  color: white;
}

.result-progress .current i {
  border: 2px solid var(--blue);
  color: var(--blue);
}

.result-facts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.result-facts .detail-row {
  display: grid;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.detail-linked-task {
  padding: 10px;
}

.detail-next-step {
  padding: 10px;
}

.detail-result-content {
  display: grid;
  gap: 7px;
}

.detail-markdown {
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #303846;
  font-size: 12px;
  line-height: 1.5;
}

.detail-markdown h4,
.detail-markdown h5,
.detail-markdown h6 {
  margin: 12px 0 5px;
  color: var(--text);
  font-size: 13px;
}

.detail-markdown h4:first-child,
.detail-markdown h5:first-child,
.detail-markdown h6:first-child {
  margin-top: 0;
}

.detail-markdown p {
  margin: 0 0 8px;
}

.detail-markdown ul,
.detail-markdown ol {
  margin: 0 0 10px;
  padding-left: 20px;
}

.detail-markdown li + li {
  margin-top: 3px;
}

.content-preview,
.content-board,
.agent-load,
.timeline,
.pipeline-list,
.calendar-preview {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.content-mini {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.content-mini span,
.content-mini small,
.content-card small,
.content-card p,
.timeline-item small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.content-mini strong,
.content-card strong {
  font-size: 14px;
  line-height: 1.3;
}

.content-board {
  grid-template-columns: 1fr;
}

.content-card {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.content-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.content-actions .secondary-button {
  min-height: 34px;
  padding: 0 6px;
  font-size: 11px;
}

.schedule-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 6px;
}

.schedule-edit input {
  min-height: 34px;
  padding: 0 8px;
  font-size: 12px;
}

.schedule-edit .secondary-button {
  min-height: 34px;
  padding: 0 8px;
  font-size: 11px;
}

.content-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.calendar-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.calendar-line span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.calendar-line strong {
  font-size: 12px;
}

.rubric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.rubric-item {
  display: grid;
  gap: 5px;
  min-height: 82px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.rubric-item strong {
  font-size: 13px;
}

.rubric-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.agent-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 8px;
  color: #303846;
  font-size: 11px;
  font-weight: 800;
}

.load-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef5;
}

.load-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.ops-panel {
  display: grid;
  gap: 10px;
}

.ops-alerts {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.ops-alert {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 8px;
  background: #fff6e6;
  border: 1px solid #f0d9aa;
}

.ops-alert.critical {
  background: #fff0f0;
  border-color: #f2b8b8;
}

.ops-alert strong {
  color: #303846;
  font-size: 12px;
}

.ops-alert span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.ops-radar,
.ops-trends,
.memory-signals,
.ops-agent {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.ops-agent-summary,
.ops-agent-action {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.ops-agent-summary {
  border: 1px solid #d8e5fb;
  background: #f3f7ff;
}

.ops-agent-summary.warning,
.ops-agent-summary.review {
  border-color: #f0d9aa;
  background: #fff8eb;
}

.ops-agent-summary.critical {
  border-color: #f2b8b8;
  background: #fff0f0;
}

.ops-agent-summary.ok {
  border-color: #bee7d2;
  background: #eefaf4;
}

.ops-agent-summary strong,
.ops-agent-action strong {
  font-size: 13px;
  line-height: 1.3;
}

.ops-agent-summary span,
.ops-agent-action span,
.ops-agent-action small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.ops-agent-actions {
  display: grid;
  gap: 8px;
}

.radar-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 10px;
}

.radar-row div:first-child,
.memory-signal {
  display: grid;
  gap: 3px;
}

.radar-row strong,
.memory-signal strong {
  font-size: 13px;
}

.radar-row span,
.memory-signal span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.radar-row b {
  text-align: right;
  font-size: 12px;
}

.radar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef5;
}

.radar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.memory-signal {
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.trend-bars {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  min-height: 132px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.trend-day {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 7px;
  min-width: 0;
}

.trend-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(4px, 1fr));
  align-items: end;
  gap: 3px;
  min-height: 86px;
}

.trend-columns i,
.trend-legend b {
  display: block;
  border-radius: 999px 999px 3px 3px;
}

.trend-day span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-align: center;
  text-transform: uppercase;
}

.trend-error {
  background: var(--red);
}

.trend-review {
  background: var(--amber);
}

.trend-done {
  background: var(--green);
}

.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.trend-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.trend-legend b {
  width: 8px;
  height: 8px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(21, 25, 34, 0.38);
  z-index: 50;
}

.modal-box {
  display: grid;
  gap: 12px;
  width: min(420px, 100%);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-error {
  color: var(--red);
  font-size: 13px;
  font-weight: 750;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-box {
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
}

.detail-close {
  width: 32px;
  height: 32px;
  font-size: 18px;
}

.detail-body,
.detail-stack {
  display: grid;
  gap: 10px;
}

.detail-row,
.detail-note,
.detail-subgrid div {
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.detail-row span,
.detail-note span,
.detail-subgrid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.detail-row strong,
.detail-subgrid strong {
  text-align: right;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.detail-note {
  display: grid;
  gap: 6px;
}

.detail-note p {
  color: #303846;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.detail-subgrid,
.detail-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.detail-subgrid div {
  display: grid;
  gap: 4px;
}

.detail-pre {
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  background: #f4f6f8;
  color: #222a35;
  font-size: 12px;
  line-height: 1.35;
}

.detail-link,
.attachment-list a {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.attachment-list,
.task-timeline {
  display: grid;
  gap: 7px;
}

.attachment-list p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.task-timeline > div {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.task-timeline i {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--blue);
}

.task-timeline p,
.task-timeline strong,
.task-timeline small {
  display: block;
}

.task-timeline p {
  font-size: 12px;
}

.task-timeline strong {
  margin-bottom: 2px;
  color: var(--text);
  font-size: 11px;
}

.task-timeline small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.style-center-panel,
.style-example-form,
.style-example-list {
  display: grid;
  gap: 10px;
}

.style-fingerprint {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.style-fingerprint > div {
  display: grid;
  gap: 4px;
  min-height: 64px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.style-fingerprint span,
.style-example-item span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.style-fingerprint strong,
.style-example-item strong {
  font-size: 12px;
  line-height: 1.3;
}

.style-example-item {
  display: grid;
  gap: 6px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.style-example-item > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.style-example-item p {
  color: #303846;
  font-size: 12px;
  line-height: 1.4;
}

.ops-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.ok-text {
  color: var(--green);
}

.warn-text {
  color: var(--amber);
}

.timeline-item {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 10px;
}

.timeline-item > span {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--blue);
}

.timeline-item div {
  display: grid;
  gap: 3px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.timeline-item strong {
  font-size: 13px;
  line-height: 1.3;
}

.empty-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.todo-list {
  margin: 12px 0 0;
  padding-left: 20px;
  color: #303846;
  font-size: 14px;
  line-height: 1.6;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 52px 1fr 1fr 1fr;
  gap: 4px;
  width: min(430px, 100%);
  margin: 0;
  transform: translateX(-50%);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
  z-index: 10;
}

.nav-item {
  display: grid;
  place-items: center;
  gap: 3px;
  min-height: 50px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.nav-item .ui-icon {
  width: 19px;
  height: 19px;
}

.nav-item.active {
  color: var(--blue);
  background: #edf3ff;
}

.nav-item.create {
  align-self: center;
  min-height: 48px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 36px));
  padding: 11px 14px;
  border: 1px solid #b8d1ff;
  border-radius: 8px;
  background: #f5f8ff;
  color: #20365f;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 750;
}

.toast.error {
  border-color: #f0bcbc;
  background: #fff5f5;
  color: #8b2424;
}

@media (max-width: 360px) {
  .chart-grid,
  .health-grid,
  .form-grid,
  .command-strip,
  .rubric-grid,
  .content-actions,
  .detail-actions,
  .detail-subgrid,
  .schedule-edit,
  .department-stats,
  .radar-row,
  .style-fingerprint {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 760px) {
  body {
    background: #e9eef5;
  }

  .app-shell {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    align-items: start;
    width: min(1320px, calc(100vw - 32px));
    min-height: 0;
    margin: 16px auto;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
  }

  .side-rail {
    position: sticky;
    top: 0;
    grid-row: 1 / 4;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 18px;
    min-height: calc(100vh - 34px);
    padding: 18px 14px;
    border-right: 1px solid var(--line);
    background: #ffffff;
  }

  .rail-brand {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .rail-brand > span {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--blue);
    color: white;
    font-weight: 900;
  }

  .rail-brand div {
    display: grid;
    gap: 2px;
  }

  .rail-brand strong {
    font-size: 15px;
  }

  .rail-brand small,
  .rail-status span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
  }

  .rail-nav {
    display: grid;
    align-content: start;
    gap: 6px;
  }

  .rail-item {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 38px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #475569;
    cursor: pointer;
    font-weight: 850;
    text-align: left;
    padding: 0 10px;
  }

  .rail-item.active {
    background: #edf3ff;
    color: var(--blue);
  }

  .rail-status {
    display: grid;
    gap: 4px;
    padding: 10px;
    border-radius: 8px;
    background: var(--surface-2);
  }

  .rail-status strong {
    font-size: 12px;
    line-height: 1.3;
  }

  .topbar {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-columns: auto minmax(320px, 560px) auto;
    padding: 18px 18px 12px;
  }

  .command-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
  }

  .command-search input {
    min-height: 40px;
    padding: 0 12px;
    background: var(--surface);
  }

  .view {
    grid-column: 2;
    grid-row: 2;
    padding: 0 18px;
  }

  h1 {
    font-size: 30px;
  }

  h2 {
    font-size: 20px;
  }

  .view.active {
    gap: 10px;
  }

  #view-home.active {
    grid-template-columns: 1.05fr 1fr 1fr;
    align-items: start;
  }

  .dashboard-title {
    grid-column: 1 / -1;
  }

  .dashboard-hero {
    grid-column: 1 / span 2;
  }

  .dashboard-summary {
    grid-column: 3;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-health {
    grid-column: 1 / -1;
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .dashboard-charts {
    grid-column: 1 / span 2;
  }

  .dashboard-next {
    grid-column: 3;
    min-height: 100%;
  }

  .dashboard-content {
    grid-column: 1;
  }

  .dashboard-todoist {
    grid-column: 2;
  }

  .dashboard-pipeline {
    grid-column: 3;
    grid-row: span 2;
  }

  .dashboard-calendar {
    grid-column: 1;
  }

  .dashboard-agents {
    grid-column: 2;
  }

  .dashboard-tasks {
    grid-column: 3;
  }

  .dashboard-activity {
    grid-column: 1 / span 2;
  }

  .dashboard-tasks .task-list,
  .dashboard-activity .activity-feed {
    max-height: 360px;
    overflow: auto;
    padding-right: 2px;
  }

  .dashboard-tasks .card-summary,
  .dashboard-tasks .workflow-actions .task-action:not([data-task-open]) {
    display: none;
  }

  #taskList {
    max-height: 620px;
    overflow: auto;
    padding-right: 2px;
  }

  #outputList {
    max-height: 620px;
    overflow: auto;
    padding-right: 2px;
  }

  .command-metric,
  .health-card {
    min-height: 74px;
  }

  .command-metric strong {
    font-size: 24px;
  }

  .health-card strong {
    margin-top: 14px;
    font-size: 14px;
  }

  canvas {
    max-height: 116px;
  }

  #view-projects.active,
  #view-tasks.active,
  #view-outputs.active {
    grid-template-columns: 1fr;
  }

  #view-projects .section-heading,
  .department-detail-panel,
  .projects-panel {
    grid-column: 1 / -1;
  }

  .department-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .department-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .task-list.expanded {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workflow-overview {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .output-overview {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .output-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .result-facts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #view-content.active,
  #view-ops.active {
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
    align-items: start;
  }

  #view-content .section-heading,
  #view-ops .section-heading {
    grid-column: 1 / -1;
  }

  .content-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #view-create.active {
    grid-template-columns: minmax(0, 720px);
    justify-content: center;
  }

  #view-create .section-heading {
    width: 100%;
  }

  .task-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .task-form label:nth-child(2),
  .route-box,
  .toggle-field,
  .task-form .full {
    grid-column: 1 / -1;
  }

  .bottom-nav {
    display: none;
  }

  .nav-item.create {
    border-radius: 8px;
  }
}

@media (min-width: 1040px) {
  .dashboard-tasks .task-list {
    max-height: 300px;
  }

  .next-action {
    font-size: 13px;
  }
}
