:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #eef4f6;
  --text: #17202a;
  --muted: #667085;
  --line: #d9e2e8;
  --accent: #0f766e;
  --accent-2: #b45309;
  --danger: #b42318;
  --shadow: 0 14px 45px rgba(25, 38, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.12), transparent 34rem),
    linear-gradient(135deg, #f7fafc 0%, #eef4f6 48%, #f8f5ef 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
}

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 700;
}

button:active {
  transform: translateY(1px);
}

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

textarea {
  resize: vertical;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  color: #1f2937;
  font-size: 13px;
  line-height: 1.55;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
}

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

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

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

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

h2 {
  font-size: 22px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
  line-height: 1.2;
  margin-bottom: 10px;
}

.icon-btn {
  width: 44px;
  min-width: 44px;
  padding: 0;
  font-size: 20px;
}

.auth-panel,
.detail,
.project-list,
.note-box,
.quick-grid section,
article section {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(217, 226, 232, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel {
  padding: 18px;
}

.auth-panel p {
  color: var(--muted);
  margin: 8px 0 14px;
}

.token-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.count-pill {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  min-height: 42px;
  border-radius: 8px;
  background: #182230;
  color: #fff;
  font-weight: 800;
}

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 14px;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  max-height: calc(100vh - 140px);
  overflow: auto;
}

.project-card {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  min-height: 72px;
  padding: 10px;
}

.project-card.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.project-color {
  width: 10px;
  height: 100%;
  border-radius: 6px;
  background: var(--accent);
}

.project-card strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.project-card span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.detail {
  min-height: calc(100vh - 140px);
  padding: 14px;
  overflow: hidden;
}

.empty-state {
  min-height: 56vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
  color: var(--muted);
}

.workspace-mark {
  width: 118px;
  height: 88px;
  display: grid;
  grid-template-columns: 1.1fr 0.8fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  transform: rotate(-2deg);
}

.workspace-mark span {
  border-radius: 8px;
  border: 1px solid rgba(23, 32, 42, 0.12);
  box-shadow: 0 10px 20px rgba(25, 38, 52, 0.14);
}

.workspace-mark span:nth-child(1) {
  grid-row: span 2;
  background: #0f766e;
}

.workspace-mark span:nth-child(2) {
  background: #d97706;
}

.workspace-mark span:nth-child(3) {
  background: #334155;
}

.workspace-mark span:nth-child(4) {
  background: #f8fafc;
}

.detail-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.detail-head p {
  color: var(--muted);
  margin-top: 5px;
  font-size: 13px;
  word-break: break-word;
}

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.quick-grid section,
article section {
  padding: 12px;
  box-shadow: none;
}

.note-box,
.rag-box,
.task-box {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.secondary-btn {
  background: #334155;
}

.danger-btn {
  background: var(--danger);
}

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

.note-item {
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-2);
}

.note-item time {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

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

.rag-status,
.rag-empty {
  color: var(--muted);
  font-size: 13px;
}

.rag-results {
  display: grid;
  gap: 10px;
}

.rag-result {
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #fff;
}

.rag-source {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  background: var(--panel-2);
}

.rag-source strong {
  font-size: 13px;
  line-height: 1.3;
  word-break: break-word;
}

.rag-source span {
  color: var(--muted);
  font-size: 12px;
}

.rag-result pre {
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  background: #0f172a;
  color: #e5e7eb;
}

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

.task-empty {
  color: var(--muted);
  font-size: 13px;
}

.task-item {
  width: 100%;
  display: grid;
  gap: 5px;
  text-align: left;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 12px;
}

.task-item.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.task-item.running {
  border-color: #2563eb;
}

.task-item.failed,
.task-item.rejected,
.task-item.cancelled {
  border-color: var(--danger);
}

.task-item strong {
  font-size: 13px;
  line-height: 1.35;
}

.task-item span,
.task-detail-head span {
  color: var(--muted);
  font-size: 12px;
}

.task-detail {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.task-detail-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

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

.task-head-actions {
  display: flex !important;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.task-approval {
  display: grid;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
}

.task-approval p {
  color: #7c2d12;
  font-size: 13px;
}

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

.approval-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.36);
}

.approval-card {
  width: min(520px, 100%);
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.28);
}

.approval-card strong {
  font-size: 16px;
}

.approval-card p {
  max-height: 36vh;
  overflow: auto;
  white-space: pre-wrap;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.5;
}

.task-log {
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #020617;
  color: #dbeafe;
}

.task-result {
  white-space: pre-wrap;
  padding: 10px;
  border-radius: 8px;
  background: #ecfdf5;
  border: 1px solid #99f6e4;
  color: #134e4a;
  font-size: 13px;
  line-height: 1.5;
}

.section-title {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.doc-text {
  max-height: 360px;
  overflow: auto;
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 12px;
}

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

.file-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.file-item:last-child {
  border-bottom: 0;
}

.file-item small {
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 5;
  padding: 12px 14px;
  border-radius: 8px;
  background: #17202a;
  color: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

@media (max-width: 820px) {
  h1 {
    font-size: 24px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .project-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 78vw);
    overflow-x: auto;
    max-height: none;
  }

  .detail {
    min-height: 58vh;
  }

  .detail-head,
  .quick-grid,
  .section-title {
    grid-template-columns: 1fr;
  }

  .detail-head button {
    width: 100%;
  }

  .token-row {
    grid-template-columns: 1fr;
  }

  .rag-actions {
    grid-template-columns: 1fr;
  }

  .task-detail-head,
  .approval-actions {
    grid-template-columns: 1fr;
  }

  .task-head-actions {
    justify-content: stretch;
  }

  .task-head-actions button {
    width: 100%;
  }
}
