* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  line-height: 1.45;
  letter-spacing: 0.01em;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 36px;
  background: #111827;
  border-bottom: 1px solid #1f2937;
}

.hero h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

.hero p {
  margin: 0;
  color: #94a3b8;
}

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

.primary,
.secondary,
.ghost {
  border-radius: 9px;
  padding: 9px 13px;
  font-weight: 600;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.primary {
  background: linear-gradient(180deg, #38bdf8, #22d3ee);
  color: #082f49;
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 8px 18px rgba(14, 165, 233, 0.22);
}

.primary:hover {
  box-shadow: 0 10px 24px rgba(14, 165, 233, 0.3);
}

.secondary {
  background: #1e293b;
  color: #dbeafe;
  border-color: #334155;
}

.secondary:hover {
  border-color: #475569;
  background: #243246;
}

.ghost {
  background: rgba(15, 23, 42, 0.45);
  color: #cbd5e1;
  border: 1px solid #334155;
}

.ghost:hover {
  border-color: #475569;
  color: #e2e8f0;
}

.top-nav {
  display: flex;
  gap: 8px;
  padding: 10px 36px;
  border-bottom: 1px solid #1f2937;
  background: #0b1220;
}

.top-nav-primary,
.top-nav-secondary {
  position: sticky;
  z-index: 10;
}

.top-nav-primary { top: 0; }
.top-nav-secondary { top: 49px; }

.top-nav-primary {
  background: #0b1220;
}

.top-nav-secondary {
  background: #0f172a;
  border-top: 1px solid #111827;
}

.tab-btn {
  border: 1px solid #334155;
  background: #111827;
  color: #cbd5f5;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.tab-btn:hover {
  border-color: #475569;
}

.tab-btn.active {
  background: #38bdf8;
  color: #0f172a;
  border-color: #38bdf8;
}

.subtab-btn {
  font-size: 12px;
  padding: 7px 10px;
}

main {
  padding: 20px 36px 90px;
}

.page-shell {
  display: grid;
  gap: 14px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.overview-controls {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.overview-controls label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: #cbd5f5;
}

.overview-controls select {
  min-width: 180px;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 8px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 10px;
}

.live-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 12px;
}

.kpi-card h3 { margin: 0 0 8px; font-size: 13px; color: #94a3b8; }
.kpi-card p { margin: 0; font-size: 24px; font-weight: 700; }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.chart-card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.2);
}

.chart-card h3 { margin: 0; font-size: 14px; }

.panel-card {
  box-shadow: 0 1px 0 rgba(148, 163, 184, 0.08);
}

.panel-section {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.section-header h3 {
  margin: 0;
}

.section-header p {
  margin: 4px 0 0;
  font-size: 12px;
  color: #a6b5cc;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #1f2937;
  border-radius: 10px;
  max-width: 100%;
  background: #0c1426;
}

.table-wrap table {
  width: 100%;
  min-width: 540px;
  border-collapse: collapse;
  font-size: 12px;
}

.table-wrap th,
.table-wrap td {
  padding: 9px 10px;
  border-bottom: 1px solid #1f2937;
  text-align: left;
}

.table-wrap thead th {
  color: #9db0ca;
  background: #0f172a;
  position: sticky;
  top: 0;
  z-index: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 11px;
}

.table-wrap tbody tr {
  transition: background 120ms ease;
}

.table-wrap tbody tr:hover {
  background: rgba(56, 189, 248, 0.08);
}

.muted {
  color: #9fb0c9;
  font-size: 12px;
}

.ai-summary {
  margin: 0;
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 10px;
  color: #cbd5f5;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 320px;
  overflow: auto;
}

.summary {
  margin-bottom: 16px;
  color: #cbd5f5;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.item-card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 12px;
  overflow: hidden;
}

.card-open {
  all: unset;
  display: block;
  width: 100%;
  cursor: pointer;
  padding: 14px;
}

.card-open:hover {
  background: #0b1220;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.decision-icon {
  font-size: 20px;
}

.decision-badge {
  font-size: 11px;
  border-radius: 999px;
  padding: 4px 8px;
  background: #1f2937;
  color: #cbd5f5;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.decision-badge[data-decision="approve"] {
  background: #14532d;
  color: #bbf7d0;
}

.decision-badge[data-decision="modify"] {
  background: #78350f;
  color: #fde68a;
}

.decision-badge[data-decision="deny"] {
  background: #7f1d1d;
  color: #fecaca;
}

.item-card h2 {
  margin: 0 0 6px;
  font-size: 15px;
  line-height: 1.35;
}

.meta {
  margin: 0 0 8px;
  color: #94a3b8;
  font-size: 12px;
}

.summary {
  margin: 0;
  color: #cbd5f5;
  font-size: 13px;
}

.modal {
  width: min(620px, 92vw);
  border: 1px solid #334155;
  border-radius: 12px;
  background: #0b1220;
  color: #e2e8f0;
  padding: 0;
  box-shadow: 0 30px 70px rgba(2, 6, 23, 0.55);
}

.modal::backdrop {
  background: rgba(2, 6, 23, 0.7);
}

.modal-content {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.modal-details {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 10px 12px;
  max-height: 220px;
  overflow: auto;
}

.modal-details p {
  margin: 0 0 8px;
  font-size: 13px;
  color: #cbd5f5;
}

.modal-details p:last-child {
  margin-bottom: 0;
}

.modal-content label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #cbd5f5;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 8px;
  font-size: 14px;
}

.modal-actions {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.status {
  position: fixed;
  bottom: 20px;
  right: 24px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #111827;
  border: 1px solid #1f2937;
  color: #cbd5f5;
  min-width: 220px;
}

.status[data-tone="success"] {
  border-color: #22c55e;
  color: #86efac;
}

.status[data-tone="error"] {
  border-color: #f87171;
  color: #fecaca;
}

.status[data-tone="info"] {
  border-color: #38bdf8;
  color: #bae6fd;
}

.todo-add {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.todo-add input {
  flex: 1;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 8px;
}

.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.todo-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 10px;
}

.todo-item label {
  display: flex;
  gap: 8px;
  align-items: center;
}

.history-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.ops-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.ops-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.ops-system {
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 10px;
}

.ops-system-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
}

.ops-system-grid div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  background: #111827;
  border: 1px solid #1f2937;
  font-size: 12px;
}

.ops-logs {
  margin: 0;
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 10px;
  color: #cbd5f5;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 320px;
  overflow: auto;
}

.search-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.search-controls input,
.search-controls select,
.ops-editor {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 8px;
}

.ops-editor {
  width: 100%;
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.docs-content {
  font-size: 14px;
  color: #cbd5f5;
}

.docs-content h4 {
  margin: 12px 0 6px;
}

.shortcut-hint {
  border: 1px dashed #334155;
  background: rgba(56, 189, 248, 0.08);
  color: #bae6fd;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}

.marketing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.marketing-actions {
  margin: 0;
  padding-left: 18px;
  color: #cbd5f5;
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.marketing-mini-cards {
  margin-bottom: 0;
}

.research-form-grid {
  display: grid;
  gap: 8px;
}

.research-form-grid input,
.research-form-grid select,
.research-form-grid textarea {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 8px;
}

.research-insight-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  color: #cbd5f5;
}

.research-chip-row {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.research-chip {
  font-size: 11px;
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 2px 8px;
  color: #cbd5f5;
  background: #0f172a;
}

#research-source-table tr.is-selected,
#briefs-table tr.is-selected {
  background: rgba(56, 189, 248, 0.14);
}

#briefs-table tbody tr {
  cursor: pointer;
}

.briefs-editor-grid {
  align-items: start;
}

.brief-list-toolbar {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.brief-list-filters {
  grid-template-columns: 140px 180px 170px minmax(240px, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.brief-list-filters input,
.brief-list-filters select {
  height: 34px;
  font-size: 12px;
}

.brief-table-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #cbd5f5;
  font-size: 11px;
  text-transform: lowercase;
}

.brief-table-chip.status-done {
  border-color: #166534;
  color: #86efac;
  background: rgba(22, 101, 52, 0.2);
}

.brief-table-chip.status-in_progress {
  border-color: #0e7490;
  color: #67e8f9;
  background: rgba(14, 116, 144, 0.2);
}

.brief-table-chip.status-submitted {
  border-color: #854d0e;
  color: #fde68a;
  background: rgba(133, 77, 14, 0.2);
}

.brief-table-chip.status-draft {
  border-color: #475569;
  color: #cbd5f5;
}

.brief-table-chip.priority-high {
  border-color: #991b1b;
  color: #fecaca;
  background: rgba(153, 27, 27, 0.2);
}

.brief-table-chip.priority-medium {
  border-color: #854d0e;
  color: #fde68a;
  background: rgba(133, 77, 14, 0.2);
}

.brief-table-chip.priority-low {
  border-color: #14532d;
  color: #bbf7d0;
  background: rgba(20, 83, 45, 0.2);
}

.brief-detail-split {
  display: grid;
  grid-template-columns: 1.4fr 0.95fr;
  gap: 16px;
  align-items: start;
}

.brief-detail-main,
.brief-detail-sidebar {
  min-width: 0;
}

.brief-stage-header {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 10px;
  background: #0c1426;
  border: 1px solid #1e293b;
}

.brief-stage-header .muted {
  display: block;
  margin: 0 0 4px;
}

.brief-stage-badge,
.brief-stage-status {
  display: inline-flex;
  align-items: center;
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 5px 11px;
  color: #dbeafe;
  background: #0f172a;
  font-size: 12px;
  font-weight: 600;
}

.brief-stage-status {
  color: #bae6fd;
  border-color: #0e7490;
  background: rgba(14, 116, 144, 0.15);
}

.brief-stage-status[data-status="done"],
.brief-stage-status[data-status="approved"] {
  border-color: #166534;
  color: #86efac;
  background: rgba(22, 101, 52, 0.2);
}

.brief-stage-status[data-status="rework"],
.brief-stage-status[data-status="denied"] {
  border-color: #991b1b;
  color: #fecaca;
  background: rgba(153, 27, 27, 0.2);
}

.brief-stage-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}

.brief-stage-pill {
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  color: #cbd5f5;
  background: #0f172a;
}

.brief-stage-pill.is-current {
  border-color: #22d3ee;
  color: #67e8f9;
  background: rgba(34, 211, 238, 0.12);
}

.brief-stage-pill.is-done {
  border-color: #22c55e;
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
}

.brief-output-controls {
  display: flex;
  justify-content: flex-end;
  margin: 6px 0;
}

.brief-output-controls label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid #334155;
  background: #0f172a;
}

.brief-stage-output {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.brief-latest-output,
.brief-output-card {
  border: 1px solid #1e293b;
  border-radius: 10px;
  background: #0b1220;
  padding: 12px;
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.24);
}

.brief-latest-output {
  white-space: pre-wrap;
  max-height: 260px;
  overflow: auto;
}

.brief-output-card > header {
  font-size: 12px;
  margin-bottom: 8px;
}

.brief-output-block {
  border-top: 1px dashed #334155;
  padding-top: 8px;
  margin-top: 8px;
}

.brief-output-block h5 {
  margin: 0 0 6px;
  color: #cbd5f5;
  font-size: 13px;
}

.brief-output-block pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #e2e8f0;
}

.brief-action-form {
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 12px;
  background: #0c1426;
  gap: 10px;
}

.brief-action-form textarea {
  min-height: 120px;
}

.brief-action-buttons {
  grid-template-columns: 1fr;
}

.brief-action-buttons button,
#brief-toggle-history-btn {
  width: 100%;
}

.brief-history-wrap {
  margin-top: 4px;
  border-top: 1px solid #1f2937;
  padding-top: 12px;
}

.brief-history-wrap h4 {
  margin: 0 0 8px;
}

.brief-thread-history {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  max-height: 340px;
  overflow: auto;
  padding-right: 2px;
}

.brief-thread-item {
  border: 1px solid #1e293b;
  border-radius: 9px;
  padding: 10px;
  background: #0b1220;
}

.brief-thread-item header {
  font-size: 12px;
  margin-bottom: 6px;
}

.brief-thread-item pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #e2e8f0;
}

.brief-thread-item.actor-user {
  border-left: 3px solid #f59e0b;
}

.brief-thread-item.actor-assistant {
  border-left: 3px solid #38bdf8;
}

.brief-thread-item.actor-system {
  border-left: 3px solid #22c55e;
}

#brief-detail-modal .modal-content {
  gap: 14px;
  padding: 16px;
}

#brief-detail-modal .section-header {
  align-items: center;
}

#brief-detail-modal .section-header h3 {
  font-size: 16px;
}

.brief-modal-header-actions {
  display: inline-flex;
  gap: 8px;
}

.saved-ok {
  animation: savedPulse 1.2s ease;
}

@keyframes savedPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(34, 197, 94, 0); }
  35% { transform: scale(1.02); box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.2); }
  100% { transform: scale(1); box-shadow: 0 0 0 rgba(34, 197, 94, 0); }
}

.skeleton-line {
  display: inline-block;
  height: 12px;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #1f2937 25%, #334155 45%, #1f2937 65%);
  background-size: 280% 100%;
  animation: shimmer 1.1s linear infinite;
}

.skeleton-line.w-20 { width: 20%; }
.skeleton-line.w-30 { width: 30%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-70 { width: 70%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-90 { width: 90%; }

.skeleton-table {
  width: 100%;
  border-collapse: collapse;
}

.skeleton-table th,
.skeleton-table td {
  padding: 8px;
  border-bottom: 1px solid #1f2937;
}

.is-skeleton {
  min-height: 24px;
  display: flex;
  align-items: center;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

canvas {
  width: 100%;
  height: auto;
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 8px;
}

@media (max-width: 1100px) {
  .brief-list-filters {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .brief-detail-split {
    grid-template-columns: 1fr;
  }

  .brief-action-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .brief-action-buttons button,
  #brief-toggle-history-btn {
    width: auto;
  }
}

@media (max-width: 720px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 18px;
  }

  .top-nav {
    padding: 10px 16px;
    overflow: auto;
  }

  .top-nav-primary,
  .top-nav-secondary {
    position: static;
  }

  .overview-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .kpi-grid,
  .live-grid {
    grid-template-columns: 1fr;
  }

  .todo-add {
    flex-direction: column;
  }

  .ops-system-grid {
    grid-template-columns: 1fr;
  }

  .brief-detail-split {
    grid-template-columns: 1fr;
  }

  .brief-list-filters,
  .brief-action-buttons {
    grid-template-columns: 1fr;
  }

  .brief-stage-header {
    grid-template-columns: 1fr;
  }

  main {
    padding: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.settings-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

