:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #d8dce3;
  --text: #1c2128;
  --muted: #5d6570;
  --accent: #176b52;
  --accent-weak: #e3f2ec;
  --danger: #a5382c;
  --danger-weak: #fbeae8;
  --warn: #8a5a00;
  --warn-weak: #fdf3dd;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.tab-button.active {
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 600;
}

.layout {
  max-width: 980px;
  margin: 20px auto;
  padding: 0 16px;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

#tab-approval .form-row {
  grid-template-columns: 1fr 1.4fr auto;
}

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

input, textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  min-width: 0;
}

textarea {
  width: 100%;
  resize: vertical;
  margin-bottom: 10px;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.approval {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 120px;
}

.approval.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.approval-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.badge {
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.pending { background: var(--warn-weak); color: var(--warn); }
.badge.approved { background: var(--accent-weak); color: var(--accent); }
.badge.rejected, .badge.timeout { background: var(--danger-weak); color: var(--danger); }
.badge.revised { background: #e8eefc; color: #3452a3; }

.approval h2 {
  font-size: 18px;
  margin: 0 0 8px;
  letter-spacing: 0;
}

.context { color: var(--muted); margin: 0 0 10px; white-space: pre-wrap; }
.meta { color: var(--muted); font-size: 12px; }

.proposed, .note {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 10px;
}

.proposed span, .note span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  border-radius: 6px;
  padding: 10px;
}

.actions { margin-top: 12px; }
.action-buttons { display: flex; gap: 8px; }
.action-buttons .approve { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.action-buttons .reject { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.action-buttons .revise { background: #3452a3; border-color: #3452a3; color: #fff; font-weight: 600; }

.status {
  margin-bottom: 10px;
  font-size: 12px;
}
.status.ok { color: var(--accent); }
.status.error { color: var(--danger); }

.messages {
  height: 420px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  align-self: flex-start;
  max-width: 82%;
}

.message.mine {
  align-self: flex-end;
  background: var(--accent-weak);
  border-color: #bfe0d2;
}

.message-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.message-body {
  word-break: break-word;
  white-space: pre-wrap;
}

.empty-state {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 720px) {
  .form-row, #tab-approval .form-row {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 0 12px;
  }
  .layout {
    padding: 0 10px;
  }
}

/* Landing page */
.site-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-brand {
  font-size: 17px;
  font-weight: 700;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.site-nav a.nav-cta {
  color: #fff;
  background: var(--accent);
  padding: 7px 14px;
  border-radius: 6px;
  font-weight: 600;
}

.hero {
  max-width: 1080px;
  margin: 0 auto;
  padding: 64px 24px 56px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
}

.hero h1 {
  font-size: 40px;
  line-height: 1.25;
  margin: 0 0 16px;
  letter-spacing: 0;
}

.hero-copy p {
  color: var(--muted);
  font-size: 16px;
  margin: 0 0 22px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.button {
  display: inline-block;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 10px 18px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.hero-meta {
  color: var(--muted);
  font-size: 13px;
}

.stats-band {
  background: #101418;
  color: #fff;
}

.stats-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 30px 24px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat {
  text-align: center;
}

.stat strong {
  display: block;
  font-size: 34px;
  color: #37b27d;
  letter-spacing: 0;
}

.stat span {
  color: #aeb6bf;
  font-size: 13px;
}

.hero-console {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101418;
  color: #e6ebf0;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
}

.console-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.console-row.peer {
  justify-content: flex-end;
}

.console-row.peer .console-msg {
  background: #1d4f3d;
}

.console-msg {
  background: #26303a;
  border-radius: 6px;
  padding: 10px 12px;
  max-width: 80%;
}

.agent-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #37b27d;
  margin-top: 12px;
  flex: none;
}

.console-approval {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid #26303a;
  padding-top: 12px;
}

.console-approval button {
  background: var(--accent);
  border: none;
  color: #fff;
  font-weight: 600;
  border-radius: 6px;
  padding: 6px 14px;
}

.band {
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.band-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 24px;
}

.band h2 {
  font-size: 26px;
  margin: 0 0 24px;
  letter-spacing: 0;
}

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

.feature {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.feature h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.feature p {
  margin: 0;
  color: var(--muted);
}

.steps {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 10px;
  max-width: 720px;
}

.demo-intro {
  color: var(--muted);
  margin: 0 0 14px;
}

.code-block {
  background: #101418;
  color: #e6ebf0;
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  margin: 0 0 16px;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 360px));
  gap: 14px;
}

.pricing {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.pricing h3 {
  margin: 0 0 6px;
}

.pricing .price {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 12px;
}

.pricing ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px 24px;
  display: flex;
  gap: 18px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.site-footer a {
  color: var(--muted);
}

/* Auth + dashboard */
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-label {
  color: var(--muted);
  font-size: 13px;
}

.home-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

button.ghost {
  background: transparent;
}

.auth-wrap {
  display: flex;
  justify-content: center;
  padding: 48px 16px;
}

.auth-panel {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.auth-panel h1 {
  font-size: 20px;
  margin: 0 0 18px;
  letter-spacing: 0;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
}

.auth-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 600;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form button {
  align-self: flex-start;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}

.auth-note {
  color: var(--muted);
  font-size: 13px;
  margin: 14px 0 0;
}

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

.dashboard-grid .panel h2 {
  font-size: 16px;
  margin: 0 0 12px;
  letter-spacing: 0;
}

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

.form-row.three {
  grid-template-columns: 1fr 1fr auto;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.list-item code {
  color: var(--muted);
  font-size: 12px;
}

.muted {
  color: var(--muted);
}

.approval.compact {
  min-height: 0;
}

.approval.compact h3 {
  font-size: 15px;
  margin: 0 0 8px;
  letter-spacing: 0;
}

@media (max-width: 820px) {
  .hero {
    grid-template-columns: 1fr;
    padding: 40px 20px;
  }
  .hero h1 {
    font-size: 30px;
  }
  .feature-grid,
  .pricing-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .stats-inner {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-grid .wide {
    grid-column: auto;
  }
  .site-nav a:not(.nav-cta) {
    display: none;
  }
}
