:root {
  --bg: #f4efe6;
  --bg-deep: #e3d6c1;
  --panel: rgba(255, 251, 244, 0.9);
  --panel-strong: #fffaf2;
  --line: rgba(72, 56, 33, 0.14);
  --text: #241a0f;
  --muted: #6c5d48;
  --accent: #165dff;
  --accent-soft: rgba(22, 93, 255, 0.1);
  --positive: #0e8a4a;
  --negative: #b33e28;
  --shadow: 0 16px 48px rgba(53, 39, 18, 0.1);
  --radius: 24px;
  --font: "IBM Plex Sans", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.82), transparent 28%),
    linear-gradient(140deg, var(--bg) 0%, #efe7da 46%, var(--bg-deep) 100%);
}

button,
input {
  font: inherit;
}

.page-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 18px 18px 56px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 28px 24px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: linear-gradient(180deg, rgba(255, 251, 244, 0.98), rgba(252, 247, 239, 0.9));
  box-shadow: var(--shadow);
}

.hero-merged {
  display: grid;
  gap: 14px;
}

.hero-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3.2vw, 40px);
  line-height: 1.08;
}

.hero-copy p:last-child,
.panel-head p {
  margin-top: 12px;
  color: var(--muted);
}

.hero-copy p:last-child {
  max-width: 760px;
  font-size: 15px;
  line-height: 1.55;
}

.hero-side {
  display: grid;
  gap: 10px;
  min-width: 280px;
}

.hero-side-compact {
  min-width: 280px;
  max-width: 300px;
  justify-items: stretch;
  gap: 10px;
}

.edge-meta-grid {
  display: grid;
  gap: 10px;
}

.alert-board {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 251, 244, 0.72);
}

.alert-board-inline {
  margin-top: 14px;
}

.alert-board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.alert-board-head strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.alert-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.alert-legend-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.alert-legend-pill.is-super-strong {
  background: #cf1322;
  color: #fff;
}

.alert-legend-pill.is-strong {
  background: #ff7875;
  color: #fff;
}

.alert-legend-pill.is-medium {
  background: #ffd591;
  color: #1f1f1f;
}

.alert-legend-pill.is-weak {
  background: #fff1b8;
  color: #1f1f1f;
}

.alert-cards {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 172px;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.alert-card {
  display: grid;
  gap: 10px;
  min-height: 176px;
  padding: 12px 12px 11px;
  border-radius: 14px;
  color: inherit;
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease;
  align-content: start;
}

.alert-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(53, 39, 18, 0.1);
}

.alert-card.is-super-strong {
  background: #cf1322;
  color: #fff;
}

.alert-card.is-strong {
  background: #ff7875;
  color: #fff;
}

.alert-card.is-medium {
  background: #ffd591;
  color: #1f1f1f;
}

.alert-card.is-weak {
  background: #fff1b8;
  color: #1f1f1f;
}

.alert-card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}

.alert-city {
  font-size: 14px;
  line-height: 1.15;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.alert-date {
  font-size: 11px;
  line-height: 1;
  opacity: 0.82;
  white-space: nowrap;
}

.alert-card-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: end;
  font-size: 12px;
}

.alert-card-grid span {
  opacity: 0.86;
  min-width: 0;
}

.alert-card-grid strong {
  font-size: 13px;
  font-weight: 700;
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}

.alert-empty {
  padding: 14px 0;
  color: var(--muted);
  font-size: 13px;
}

.hero-card,
.toolbar,
.strategy-board,
.summary-card,
.panel,
.position-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 16px 18px;
  border-radius: 18px;
}

.hero-meta {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 251, 244, 0.82);
}

.hero-meta span {
  font-size: 12px;
  color: var(--muted);
}

.hero-meta strong {
  font-size: 15px;
  line-height: 1.5;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.hero-link-card {
  display: block;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(22, 93, 255, 0.08);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}

.hero-card span,
.hero-link-card span,
.summary-card span,
.metric-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.hero-card strong,
.hero-link-card strong {
  display: block;
  margin-top: 6px;
  font-size: 15px;
  word-break: break-all;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.hero-link-chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.hero-link-chip:hover {
  background: rgba(22, 93, 255, 0.08);
  color: var(--accent);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 14px;
  margin-top: 20px;
  padding: 18px;
  border-radius: var(--radius);
}

.toolbar-merged {
  margin-top: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.toolbar-action {
  display: flex;
  align-items: flex-end;
}

.hero-links .primary-btn {
  padding: 10px 16px;
}

.control {
  display: grid;
  gap: 8px;
}

.control span {
  font-size: 13px;
  color: var(--muted);
}

.control input {
  min-width: 280px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-strong);
}

.control select {
  min-width: 220px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-strong);
}

.mode-switches {
  min-width: 280px;
}

.mode-switch-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.favorite-toolbar {
  min-width: 240px;
}

.favorite-switch-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.favorite-switch-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.favorite-switch-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(42, 25, 9, 0.08);
}

.favorite-switch-btn.is-active {
  background: linear-gradient(135deg, var(--text), #7a4d18);
  color: #fff;
  border-color: #7a4d18;
  box-shadow: 0 12px 24px rgba(42, 25, 9, 0.16);
}

.favorite-switch-empty {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.mode-switch-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
}

.mode-switch-btn.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.primary-btn,
.secondary-btn,
.city-toggle,
.sort-btn {
  cursor: pointer;
}

.primary-btn,
.secondary-btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
}

.primary-btn {
  background: var(--text);
  color: #fff;
}

.secondary-btn {
  background: var(--accent-soft);
  color: var(--accent);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

@media (max-width: 980px) {
  .ad-banner-card {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .ad-banner-art {
    justify-content: start;
  }

  .hero-top {
    grid-template-columns: 1fr;
  }

  .hero-side,
  .hero-side-compact {
    min-width: 0;
  }

  .toolbar-action {
    width: 100%;
  }

  .alert-board-head {
    display: grid;
    gap: 10px;
  }
}

.strategy-board {
  margin-top: 20px;
  padding: 20px;
  border-radius: 24px;
}

.strategy-board-head {
  display: block;
}

.strategy-board-copy {
  max-width: 920px;
}

.strategy-copy {
  margin-top: 12px;
  color: var(--muted);
}

.strategy-rule-box {
  max-width: none;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(223, 213, 198, 0.32);
}

.strategy-rule-box-hero {
  align-self: stretch;
  max-width: 100%;
}

.strategy-rule-box span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.strategy-rule-lines {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  margin-bottom: 12px;
}

.strategy-rule-line {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  font-size: 13px;
  line-height: 1.5;
}

.strategy-rule-line b {
  text-align: left;
}

.strategy-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 0;
}

.strategy-legend-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.strategy-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.strategy-cards {
  display: grid;
  gap: 18px;
  margin-top: 16px;
}

.strategy-date-section {
  display: grid;
  gap: 8px;
}

.strategy-date-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.strategy-date-head h3,
.strategy-date-head small {
  margin: 0;
}

.strategy-date-head small {
  color: var(--muted);
}

.strategy-date-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 10px;
}

.strategy-mini-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  min-height: 132px;
  padding: 12px 10px;
  border-radius: 12px;
  border: 0;
  box-shadow: none;
  color: #fff;
  text-decoration: none;
  align-content: start;
}

.strategy-mini-card:hover {
  transform: translateY(-1px);
}

.strategy-mini-card.is-super-strong {
  background: #cf1322;
}

.strategy-mini-card.is-strong {
  background: #ff7875;
}

.strategy-mini-card.is-medium {
  background: #ffd591;
  color: #1f1f1f;
}

.strategy-mini-card.is-weak {
  background: #fff1b8;
  color: #1f1f1f;
}

.strategy-mini-card.is-watch {
  background: #d9f7be;
  color: #1f1f1f;
}

.strategy-mini-top,
.strategy-mini-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.strategy-mini-top strong {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
}

.strategy-mini-top span,
.strategy-mini-row span {
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
}

.strategy-mini-card.is-medium .strategy-mini-top span,
.strategy-mini-card.is-medium .strategy-mini-row span,
.strategy-mini-card.is-weak .strategy-mini-top span,
.strategy-mini-card.is-weak .strategy-mini-row span,
.strategy-mini-card.is-watch .strategy-mini-top span,
.strategy-mini-card.is-watch .strategy-mini-row span {
  color: rgba(31, 31, 31, 0.72);
}

.strategy-legend-item.is-super-strong {
  background: #cf1322;
  color: #fff;
}

.strategy-legend-item.is-strong {
  background: #ff7875;
  color: #fff;
}

.strategy-legend-item.is-medium {
  background: #ffd591;
  color: #1f1f1f;
}

.strategy-legend-item.is-weak {
  background: #fff1b8;
  color: #1f1f1f;
}

.strategy-legend-item.is-watch {
  background: #d9f7be;
  color: #1f1f1f;
}

.strategy-mini-row strong {
  font-size: 14px;
  font-weight: 700;
}

.strategy-empty {
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.32);
}

.strategy-summary .summary-card {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 251, 244, 0.82);
  box-shadow: none;
}

.strategy-summary .summary-card strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.strategy-summary .summary-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.panel {
  margin-top: 20px;
  padding: 22px;
  border-radius: 24px;
}

.date-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding: 2px 0 4px;
}

.date-filter-btn {
  border: 1px solid var(--line);
  background: rgba(255, 251, 244, 0.82);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.date-filter-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(22, 93, 255, 0.28);
}

.date-filter-btn.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.panel-head-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.panel-fetched-at {
  display: grid;
  justify-items: end;
  gap: 4px;
  min-width: 240px;
}

.panel-fetched-at span {
  font-size: 12px;
  color: var(--muted);
}

.panel-fetched-at strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.city-summary-view {
  margin-top: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1160px;
  border-collapse: collapse;
}

thead th {
  position: sticky;
  top: 12px;
  z-index: 4;
  padding: 12px 14px;
  text-align: left;
  background: rgba(252, 252, 249, 0.92);
  color: #6b7280;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-bottom: 1px solid #ecebe4;
  backdrop-filter: blur(10px);
}

.sort-btn {
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 600;
  padding: 0;
}

.sort-btn.is-active::after {
  content: " ↑";
}

.sort-btn.is-active.desc::after {
  content: " ↓";
}

tbody td {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.city-row {
  background: #fff;
}

.city-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  padding: 0;
}

.date-city-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}

.date-city-toggle::before {
  content: "▸";
  color: var(--muted);
  transition: transform 120ms ease;
}

.city-row.is-open .date-city-toggle::before {
  transform: rotate(90deg);
}

.date-city-date-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(223, 213, 198, 0.6);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.table-wrap {
  border: 1px solid #ecebe4;
  border-radius: 16px;
  background: #fff;
  overflow: auto;
}

.city-toggle::before {
  content: "▸";
  color: var(--muted);
  transition: transform 120ms ease;
}

.city-row.is-open .city-toggle::before {
  transform: rotate(90deg);
}

.details-row td {
  background: rgba(245, 238, 228, 0.92);
  padding-top: 12px;
  padding-bottom: 14px;
}

.details-panel {
  display: grid;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.orders-timeline {
  margin-top: 16px;
  display: grid;
  gap: 18px;
}

.date-group {
  display: grid;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.date-group:first-child {
  border-top: 0;
}

.date-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 6px 2px 0;
}

.date-group-title {
  font-size: 14px;
  font-weight: 700;
}

.date-group-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.date-group-list {
  display: grid;
  gap: 12px;
}

.date-city-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 251, 244, 0.88);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.date-city-table thead th {
  position: static;
  top: auto;
}

.date-city-table th,
.date-city-table td {
  padding: 11px 12px;
  text-align: left;
  border-top: 1px solid var(--line);
}

.date-city-table th {
  border-top: 0;
  background: rgba(223, 213, 198, 0.42);
  color: var(--muted);
  font-size: 12px;
}

.weather-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 4px 10px;
  border: 1px solid rgba(22, 93, 255, 0.22);
  border-radius: 999px;
  background: rgba(22, 93, 255, 0.08);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.weather-link:hover {
  background: rgba(22, 93, 255, 0.14);
}

.weather-range-cell {
  white-space: nowrap;
  color: var(--text);
  font-weight: 600;
}

.city-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.city-link:hover {
  text-decoration: underline;
}

.position-card {
  padding: 13px;
  border-radius: 18px;
  background: rgba(255, 251, 244, 0.98);
  position: relative;
  z-index: 1;
}

.position-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.position-card-link:hover .position-card {
  border-color: rgba(22, 93, 255, 0.28);
}

.empty-card {
  color: var(--muted);
}

.position-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.position-title {
  font-weight: 600;
  line-height: 1.4;
}

.market-link {
  color: inherit;
  text-decoration: none;
}

.market-link:hover {
  text-decoration: underline;
}

.position-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.position-first-buy {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.position-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}

.position-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.metric {
  padding: 9px 11px;
  border-radius: 12px;
  background: rgba(223, 213, 198, 0.42);
}

.metric-value {
  margin-top: 4px;
  font-weight: 600;
}

.positive {
  color: var(--positive);
}

.negative {
  color: var(--negative);
}

.is-error {
  color: var(--negative);
}

@media (max-width: 920px) {
  .hero,
  .panel-head {
    flex-direction: column;
  }

  .hero-side {
    width: 100%;
    min-width: 0;
  }

  .toolbar {
    display: grid;
  }

  .control input {
    min-width: 0;
    width: 100%;
  }

  .panel-head-actions,
  .panel-fetched-at {
    width: 100%;
  }

  .panel-fetched-at {
    justify-items: start;
  }

  .strategy-date-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .strategy-rule-box {
    width: 100%;
  }

  .strategy-date-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .strategy-date-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
