:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #f8faf7;
  --ink: #17211f;
  --muted: #63716c;
  --line: #dce3de;
  --deep: #14211e;
  --deep-2: #20352f;
  --green: #2f7a5f;
  --green-soft: #e2f1e8;
  --blue: #2f65a7;
  --blue-soft: #e7eef8;
  --amber: #a86716;
  --amber-soft: #fff1db;
  --red: #b6493f;
  --red-soft: #f8dfda;
  --shadow: 0 16px 48px rgba(31, 45, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

.sidebar {
  color: #edf7f1;
  background: var(--deep);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--deep);
  background: #dcebe2;
  font-weight: 800;
}

.brand-block strong {
  display: block;
  font-size: 20px;
}

.brand-block span {
  color: #9eb2aa;
  font-size: 13px;
}

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

.nav-list button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #dcebe2;
  background: transparent;
  cursor: pointer;
  text-align: left;
  padding: 0 14px;
}

.nav-list button.active,
.nav-list button:hover {
  color: #fff;
  background: var(--deep-2);
  border-color: rgba(255, 255, 255, 0.08);
}

.side-note {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.side-note span {
  display: block;
  color: #9eb2aa;
  font-size: 13px;
  margin-bottom: 6px;
}

.side-note strong {
  font-size: 15px;
  line-height: 1.45;
}

.workspace {
  padding: 28px;
  display: grid;
  gap: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 32px;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-action,
.primary-btn,
.secondary-btn,
.secondary-link {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
  text-decoration: none;
}

.icon-action {
  width: 44px;
  background: var(--surface);
  color: var(--ink);
  font-size: 20px;
}

.token-input {
  width: min(360px, 32vw);
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
}

.status-pill {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--green);
  background: var(--green-soft);
  white-space: nowrap;
}

.status-pill[data-state="bad"] {
  color: var(--red);
  background: var(--red-soft);
}

.view {
  display: grid;
  gap: 20px;
}

.hidden {
  display: none !important;
}

.hero-panel {
  min-height: 190px;
  border-radius: 8px;
  padding: 24px;
  color: #f7fff9;
  background:
    linear-gradient(120deg, rgba(20, 33, 30, 0.98), rgba(42, 96, 78, 0.9)),
    linear-gradient(35deg, rgba(47, 101, 167, 0.28), transparent 48%);
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  box-shadow: var(--shadow);
}

.hero-panel .eyebrow {
  color: #a9dfc6;
}

.hero-panel h2 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 0;
}

.hero-actions,
.row-actions,
.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn,
.secondary-link {
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-btn {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.primary-btn.full {
  width: 100%;
}

.secondary-btn,
.secondary-link {
  color: var(--ink);
  background: var(--surface);
}

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

.metric {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric span,
.section-head span,
.market-row span,
.report-card span,
.event-card span,
.memory-card span,
.domain-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
}

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

.content-grid.wide-left {
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
}

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

.panel-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.report-list,
.event-list,
.market-list,
.scene-grid,
.push-cards,
.memory-list,
.stat-list,
.warning-list,
.domain-grid {
  display: grid;
  gap: 12px;
}

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

.report-card,
.event-card,
.market-row,
.scene-card,
.push-card,
.memory-card,
.domain-card,
.stat-row,
.warning-card,
.empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.domain-card {
  min-height: 130px;
  padding: 14px;
}

.domain-card div,
.memory-card div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.domain-card strong,
.memory-card strong {
  word-break: break-word;
}

.domain-card p,
.memory-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.report-card {
  padding: 16px;
}

.report-card h3 {
  margin-bottom: 4px;
  font-size: 18px;
}

.report-card pre,
.chat-answer {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.58;
}

.report-card pre {
  margin-bottom: 0;
  max-height: 340px;
  overflow: auto;
}

.event-card,
.memory-card {
  padding: 14px;
}

.event-card p {
  margin: 8px 0 0;
  line-height: 1.5;
}

.compact-list {
  max-height: 470px;
  overflow: auto;
}

.market-row {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.market-row strong,
.market-row span,
.error-text {
  display: block;
}

.market-price {
  text-align: right;
}

.up {
  color: var(--red) !important;
}

.down {
  color: var(--green) !important;
}

.flat {
  color: var(--muted) !important;
}

.error-text {
  margin-top: 4px;
  color: var(--amber);
  max-width: 280px;
  font-size: 12px;
  line-height: 1.35;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  min-height: 44px;
  padding: 0 10px;
}

textarea {
  min-height: 116px;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

.config-area {
  min-height: 180px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

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

.field-stack,
.field-line {
  display: grid;
  gap: 10px;
}

.field-grid label,
.field-stack label,
.field-line,
.switch-row {
  color: var(--muted);
  font-size: 13px;
}

.field-grid input,
.field-grid select,
.field-stack input,
.field-stack select,
.field-stack textarea,
.field-line input,
.field-line textarea {
  margin-top: 8px;
}

.switch-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.switch-row input {
  width: auto;
  min-height: auto;
}

.chatbox {
  display: grid;
  gap: 12px;
}

.chat-answer {
  min-height: 48px;
  color: var(--muted);
}

.scene-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.scene-card {
  min-height: 86px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
}

.scene-card strong,
.scene-card span {
  display: block;
}

.scene-card span {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
}

.push-card,
.stat-row {
  min-height: 62px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.push-card.on {
  border-color: #a7d5bd;
  background: var(--green-soft);
}

.warning-card {
  padding: 12px;
  color: var(--amber);
  background: var(--amber-soft);
  line-height: 1.45;
}

.search-row {
  align-items: stretch;
  margin-bottom: 12px;
}

.search-row input {
  flex: 1 1 220px;
}

.empty {
  padding: 18px;
  color: var(--muted);
  border-style: dashed;
}

@media (max-width: 1220px) {
  .metric-grid,
  .domain-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
  }

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

  .side-note {
    display: none;
  }

  .content-grid.wide-left,
  .content-grid.even,
  .metric-grid,
  .domain-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .hero-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .token-input {
    width: 100%;
  }

  .hero-panel h2 {
    font-size: 24px;
  }

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

  .scene-grid,
  .field-grid,
  .field-grid.two {
    grid-template-columns: 1fr;
  }
}

@media (orientation: landscape) and (min-width: 1000px) {
  .workspace {
    padding: 22px 28px;
  }

  .report-card pre,
  .chat-answer {
    font-size: 17px;
  }
}
