:root {
  --canvas: #f7f5ef;
  --paper: #fffdf8;
  --surface: #eee8dc;
  --ink: #171615;
  --muted: #6f6a60;
  --line: #ded6c9;
  --accent: #b45f46;
  --accent-dark: #743d31;
  --dark: #181715;
  --dark-soft: #24221f;
  --danger: #b83232;
  --success: #2d7a54;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  margin: 0;
  min-height: 100vh;
  padding-bottom: 72px;
}

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

.shell {
  margin: 0 auto;
  max-width: 1440px;
  padding: 32px 24px 76px;
}

.site-nav {
  align-items: center;
  background: rgba(247, 245, 239, .96);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 28px;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.site-brand {
  color: var(--ink);
  display: grid;
  gap: 2px;
  min-width: 190px;
  text-decoration: none;
}

.site-brand span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.site-brand strong {
  font-size: 16px;
}

.site-nav-links {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.site-nav-links a,
.site-nav-links span {
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  padding: 8px 10px;
  text-decoration: none;
}

.site-nav-links a {
  background: transparent;
  color: var(--muted);
}

.site-nav-links a.active {
  background: var(--paper);
  color: var(--ink);
}

.site-nav-links span {
  opacity: .62;
}

.page-header {
  align-items: flex-start;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 28px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

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

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

h1 {
  font-family: Georgia, "Songti SC", serif;
  font-size: 44px;
  font-weight: 500;
  line-height: 1.1;
  margin-bottom: 0;
}

h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

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

.button {
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 40px;
  padding: 10px 16px;
  text-decoration: none;
}

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

.button.action-create {
  background: oklch(96% .035 150);
  border-color: oklch(78% .08 150);
  color: #226744;
}

.button.action-copy {
  background: oklch(96% .035 252);
  border-color: oklch(78% .08 252);
  color: #31578f;
}

.button.action-update {
  background: oklch(96% .035 64);
  border-color: oklch(78% .08 64);
  color: #7b4b13;
}

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

.button.full {
  width: 100%;
}

.button.light {
  background: #fffdf8;
  color: var(--dark);
}

.button.dark-subtle {
  background: var(--dark-soft);
  border-color: #3a3731;
  color: #fffdf8;
}

.button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.button.danger {
  background: #fff7f5;
  border-color: #e7b8b0;
  color: var(--danger);
}

.site-footer {
  align-items: center;
  background: rgba(247, 245, 239, .97);
  border-top: 1px solid var(--line);
  bottom: 0;
  color: var(--muted);
  display: grid;
  font-size: 13px;
  grid-template-columns: 1fr auto 1fr;
  left: 0;
  min-height: 56px;
  padding: 0 24px;
  position: fixed;
  right: 0;
  z-index: 4;
}

.site-footer > div {
  display: flex;
  gap: 10px;
  grid-column: 2;
  justify-content: center;
}

.site-footer strong {
  color: var(--ink);
}

.footer-logout {
  color: var(--accent-dark);
  font-weight: 800;
  grid-column: 3;
  justify-self: end;
  text-decoration: none;
}

.gate-page {
  min-height: 100vh;
}

.access-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 80px rgba(23, 22, 21, .08);
  margin: 15vh auto 0;
  max-width: 440px;
  padding: 36px;
}

.access-form,
.modal form {
  display: grid;
  gap: 16px;
}

.home-page {
  background: #11140f;
}

.home-page main {
  min-height: calc(100vh - 120px);
}

.home-hero {
  background:
    linear-gradient(90deg, rgba(17, 20, 15, .92), rgba(17, 20, 15, .62) 48%, rgba(17, 20, 15, .08)),
    var(--hero-image) center / cover no-repeat;
  color: #fffdf8;
  min-height: calc(100vh - 120px);
  padding: 72px 24px 120px;
}

.home-hero-inner {
  align-content: end;
  display: grid;
  gap: 48px;
  grid-template-columns: minmax(0, 680px) minmax(280px, 420px);
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1440px;
  min-height: calc(100vh - 312px);
}

.home-hero-copy {
  align-self: end;
  min-width: 0;
}

.home-hero h1 {
  color: #fffdf8;
  font-size: 76px;
  max-width: 680px;
}

.home-hero .eyebrow {
  color: #e2b36f;
}

.home-hero-lede {
  color: rgba(255, 253, 248, .86);
  font-size: 22px;
  margin: 24px 0 32px;
  max-width: 560px;
  overflow-wrap: anywhere;
}

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

.home-signal-grid {
  align-self: end;
  display: grid;
  gap: 12px;
  margin: 0;
  min-width: 0;
}

.home-signal-grid div {
  background: rgba(255, 253, 248, .88);
  border: 1px solid rgba(255, 253, 248, .42);
  border-radius: 8px;
  color: var(--dark);
  display: grid;
  gap: 4px;
  padding: 18px;
}

.home-signal-grid dt {
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
}

.home-signal-grid dd {
  font-size: 18px;
  font-weight: 900;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 8px;
}

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

textarea {
  resize: vertical;
}

.field-error,
.staging-error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  min-height: 18px;
}

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

.board {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-rows: auto auto 48px minmax(0, 1fr) 48px;
  min-height: 620px;
  padding: 18px;
}

.board-header {
  align-items: start;
  display: flex;
  justify-content: space-between;
}

.board-short {
  background: var(--surface);
  border-radius: 6px;
  color: var(--accent-dark);
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
  padding: 4px 8px;
}

.board-count {
  color: var(--muted);
  font-size: 20px;
}

.board-description {
  color: var(--muted);
  font-size: 13px;
  min-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-search,
.source-search {
  height: 48px;
  min-height: 48px;
}

.item-list {
  align-content: start;
  display: grid;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.is-filtered-out,
.is-staged-source {
  display: none !important;
}

.item-card {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: grab;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  height: 58px;
  padding: 10px 12px;
}

.item-card > div {
  min-width: 0;
}

.item-card h3,
.record-card h2,
.staged-card h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-card h3 {
  margin: 0;
}

.item-card p,
.record-card p,
.staged-card p,
.candidate-card p {
  color: var(--muted);
  display: -webkit-box;
  font-size: 13px;
  line-clamp: 2;
  margin-bottom: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.icon-text-button {
  align-self: start;
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
  padding: 0;
}

.staging {
  background: var(--dark);
  border-radius: 8px;
  color: #fffdf8;
  display: grid;
  gap: 14px;
  margin-top: 22px;
  padding: 24px;
}

.staging h2 {
  margin-bottom: 0;
}

.staging-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  margin: 0;
}

.staged-card {
  background: var(--dark-soft);
  border: 1px solid #3a3731;
  border-radius: 8px;
  height: 156px;
  padding: 18px 14px 18px;
  position: relative;
}

.staged-remove {
  align-items: center;
  background: #fffdf8;
  border: 0;
  border-radius: 999px;
  color: var(--dark);
  cursor: pointer;
  display: flex;
  font-size: 13px;
  font-weight: 900;
  height: 24px;
  justify-content: center;
  line-height: 1;
  position: absolute;
  right: 10px;
  top: 10px;
  width: 24px;
}

.staged-card span {
  color: #e8a55a;
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.staged-card p {
  color: #bdb8ad;
  min-height: 38px;
}

.staging-actions {
  display: flex;
  justify-content: space-between;
}

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

.record-card,
.empty-panel,
.detail-card,
.source-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}

.record-card {
  display: grid;
  gap: 8px;
  min-height: 160px;
  padding: 20px;
}

.record-card span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.empty-panel,
.detail-card {
  padding: 24px;
}

.detail-page {
  background: #fbfaf6;
}

.detail-shell {
  max-width: 1440px;
}

.detail-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}

.record-fields {
  display: grid;
  gap: 18px;
  margin: 0;
}

.record-fields div {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: 200px minmax(0, 1fr);
  padding-top: 16px;
}

dt {
  color: var(--muted);
  font-weight: 800;
}

dd {
  margin: 0;
}

.sources-section {
  margin-top: 28px;
}

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

.source-card {
  display: grid;
  gap: 16px;
  grid-template-rows: auto 1fr auto;
  min-height: 220px;
  padding: 18px;
}

.source-card ul {
  display: grid;
  align-content: start;
  gap: 8px;
  list-style: none;
  margin: 0;
  min-height: 48px;
  padding: 0;
}

.source-card li {
  background: var(--surface);
  border-radius: 6px;
  height: 40px;
  line-height: 24px;
  overflow: hidden;
  padding: 8px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-card .button {
  align-self: end;
  height: 48px;
}

.modal[hidden] {
  display: none;
}

.modal {
  align-items: center;
  background: rgba(23, 22, 21, .45);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 10;
}

.modal-panel {
  background: var(--paper);
  border-radius: 8px;
  box-shadow: 0 24px 90px rgba(23, 22, 21, .24);
  max-height: 90vh;
  max-width: 520px;
  overflow: auto;
  padding: 24px;
  position: relative;
  width: 100%;
}

.modal-panel.wide {
  max-width: 760px;
}

.modal-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  position: absolute;
  right: 18px;
  top: 18px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.source-search,
.source-candidates {
  width: 100%;
}

.source-candidates {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.candidate-card {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 14px;
}

.candidate-card.selected {
  border-color: var(--success);
  box-shadow: inset 0 0 0 1px var(--success);
}

.candidate-card button {
  background: var(--surface);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  padding: 8px 12px;
}

.tiktok-page {
  background: #fbfaf6;
}

.tiktok-shell {
  display: grid;
  gap: 14px;
  padding-top: 24px;
}

.tiktok-shell .page-header {
  margin-bottom: 0;
}

.tiktok-shell .page-header h1 {
  font-size: 38px;
}

.tiktok-shell .page-header .muted {
  margin-bottom: 8px;
}

.calculator-layout {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.summary-grid {
  display: block;
}

.input-module,
.metric-panel,
.strategy-card,
.history-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.calculator-panel,
.metric-panel {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.calculator-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.panel-heading h2,
.fee-section h2 {
  margin-bottom: 0;
}

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

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

.parameter-grid {
  align-items: stretch;
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.input-module {
  align-content: start;
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 22px;
}

.input-module h3 {
  margin-bottom: 0;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.fee-section .toggle-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.check-field {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex: 1 1 220px;
  font-size: 14px;
  font-weight: 800;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
}

.field-grid .check-field {
  align-self: end;
  min-height: 40px;
}

.fee-section .check-field {
  flex: initial;
  min-width: 0;
}

.check-field input {
  flex: 0 0 auto;
  min-height: 18px;
  width: 18px;
}

.check-field-strong {
  background: #fff7f5;
  border-color: #e7b8b0;
}

.save-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.save-row .field-error {
  margin: 0;
}

.fee-section {
  display: grid;
  gap: 14px;
}

.fee-note {
  background: var(--surface);
  border-radius: 6px;
  color: var(--accent-dark);
  display: inline-flex;
  font-size: 13px;
  font-weight: 900;
  min-height: 36px;
  padding: 8px 10px;
  width: fit-content;
}

.metric-list,
.strategy-card dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.metric-list div,
.strategy-card dl div {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding-top: 10px;
}

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

.parameter-grid .metric-list {
  grid-template-columns: 1fr;
}

.metric-list dd,
.strategy-card dd {
  color: var(--ink);
  font-weight: 900;
}

.history-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.history-heading {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.history-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.history-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 10px;
  grid-template-rows: auto auto;
  min-height: 116px;
  padding: 12px;
  text-decoration: none;
}

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

.history-meta {
  align-items: start;
  display: grid;
  gap: 4px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.history-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta small {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.history-meta span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.history-strategy {
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 7px 8px;
  position: relative;
}

.history-strategy.is-positive {
  background: oklch(96% .035 24);
  border-color: oklch(82% .09 24);
}

.history-strategy.is-negative {
  background: oklch(96% .035 150);
  border-color: oklch(80% .08 150);
}

.history-strategy.is-main {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.history-strategy.is-main::after {
  align-items: center;
  background: var(--accent);
  border-radius: 999px;
  color: #fff;
  content: "✓";
  display: flex;
  font-size: 10px;
  font-weight: 900;
  height: 16px;
  justify-content: center;
  position: absolute;
  right: 6px;
  top: 6px;
  width: 16px;
}

.history-strategy b,
.history-strategy em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-strategy b {
  color: var(--muted);
  font-size: 11px;
}

.history-strategy em {
  color: var(--ink);
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
}

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

.strategy-card {
  display: grid;
  gap: 8px 14px;
  align-content: start;
  grid-template-areas:
    "kicker kicker"
    "title profit"
    "meta meta"
    "tags tags";
  grid-template-columns: minmax(0, 1fr) auto;
  cursor: pointer;
  min-height: 0;
  padding: 14px 16px;
}

.strategy-card.is-positive {
  background: oklch(96% .035 24);
  border-color: oklch(82% .09 24);
}

.strategy-card.is-negative {
  background: oklch(96% .035 150);
  border-color: oklch(80% .08 150);
}

.strategy-card.is-main {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.strategy-card:focus-visible {
  outline: 3px solid rgba(179, 78, 54, .28);
  outline-offset: 3px;
}

.strategy-card span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  grid-area: kicker;
}

.strategy-card strong {
  color: var(--accent-dark);
  font-size: 30px;
  grid-area: profit;
  justify-self: end;
  line-height: 1;
}

.strategy-card h2 {
  font-size: 18px;
  grid-area: title;
  margin-bottom: 0;
}

.strategy-card dl {
  gap: 8px;
  grid-area: meta;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.strategy-card dl div {
  padding-top: 7px;
}

.strategy-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  grid-area: tags;
  margin-top: 2px;
}

.strategy-tags em {
  background: var(--surface);
  border-radius: 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  padding: 5px 7px;
}

.strategy-tags b {
  color: inherit;
  font-weight: 900;
}

@media (max-width: 1180px) {
  .board-grid,
  .source-grid,
  .strategy-grid,
  .summary-grid,
  .history-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .parameter-grid::before {
    display: none;
  }

  .input-module:nth-child(2) {
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 16px;
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: 96px;
  }

  .site-nav,
  .site-footer {
    align-items: flex-start;
    display: grid;
    gap: 10px;
    padding: 12px 18px;
  }

  .site-nav-links {
    justify-content: flex-start;
  }

  .site-footer {
    grid-template-columns: 1fr;
  }

  .site-footer > div,
  .footer-logout {
    grid-column: 1;
    justify-self: start;
  }

  .page-header,
  .staging-actions,
  .record-fields div,
  .save-row {
    display: grid;
  }

  .board-grid,
  .record-grid,
  .source-grid,
  .field-grid,
  .strategy-grid,
  .calculator-layout,
  .summary-grid,
  .parameter-grid,
  .metric-list,
  .history-list {
    grid-template-columns: 1fr;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .history-meta,
  .history-strategies {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 34px;
  }

  .home-hero {
    background:
      linear-gradient(180deg, rgba(17, 20, 15, .94), rgba(17, 20, 15, .74) 58%, rgba(17, 20, 15, .34)),
      var(--hero-image) center / cover no-repeat;
    padding: 48px 18px 130px;
  }

  .home-hero-inner {
    gap: 30px;
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .home-hero h1 {
    font-size: 44px;
  }

  .home-hero-lede {
    font-size: 18px;
    max-width: 100%;
  }

  .home-hero-actions .button {
    width: 100%;
  }
}
