:root {
  --bg: #f6f7f4;
  --ink: #17201a;
  --muted: #647067;
  --line: #d9ded6;
  --panel: #ffffff;
  --green: #16724a;
  --red: #b5403b;
  --amber: #9b6516;
  --blue: #245f8f;
  --shadow: 0 14px 36px rgba(23, 32, 26, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

a {
  color: var(--blue);
  font-weight: 750;
  text-decoration: none;
}

.shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar,
.actions,
.panel-header,
.metrics,
.tabs,
.filters,
.card-title-row {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

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

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

h1 {
  font-size: 33px;
  line-height: 1.12;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
}

.actions,
.filters {
  flex-wrap: wrap;
  gap: 10px;
}

.icon-button,
.primary-button,
.secondary-button,
.small-button,
.watch-toggle,
.tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  cursor: pointer;
}

.icon-button {
  width: 40px;
  background: var(--panel);
  color: var(--ink);
  font-size: 20px;
}

.primary-button {
  border-color: #1d6c50;
  padding: 0 15px;
  background: #1d6c50;
  color: #fff;
  font-weight: 750;
}

.secondary-button {
  border-color: #b9c7bd;
  padding: 0 15px;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.tabs {
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.tab {
  flex: 0 0 auto;
  padding: 0 13px;
  background: #fff;
  color: var(--muted);
  font-weight: 750;
}

.tab.active {
  border-color: #1d6c50;
  background: #e7f4ec;
  color: var(--green);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric,
.panel,
.product-card,
.trend-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 25px;
}

.metric .time-value {
  display: block;
  font-size: 16px;
  line-height: 1.25;
}

.indicator-strip {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.indicator-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  border: 1px solid #cbd9e7;
  border-radius: 8px;
  padding: 12px 15px;
  background: #f3f8fc;
}

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

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

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

.indicator-card .indicator-label {
  margin-bottom: 4px;
  color: var(--blue);
  font-weight: 850;
}

.indicator-value {
  text-align: right;
}

.indicator-value strong {
  font-size: 22px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel {
  margin-top: 14px;
  overflow: hidden;
}

.panel-header {
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.panel-header.compact {
  align-items: center;
}

.status,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 750;
}

.status.on {
  background: #e7f4ec;
  color: var(--green);
}

.status.off {
  background: #f5ece4;
  color: var(--amber);
}

input[type="search"],
input[type="number"],
input[type="text"],
input[type="url"],
select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fbfcfb;
}

input[type="search"] {
  width: min(360px, 100%);
}

input[type="number"] {
  width: 92px;
}

input[type="file"] {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fbfcfb;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fbfcfb;
  resize: vertical;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 18px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td {
  font-size: 14px;
}

.signal-buy {
  color: var(--green);
  font-weight: 850;
}

.signal-watch {
  color: var(--amber);
  font-weight: 850;
}

.signal-risk {
  color: var(--red);
  font-weight: 850;
}

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

.trend-grid,
.source-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.product-card,
.trend-card,
.source-card {
  padding: 15px;
  box-shadow: none;
}

.product-visual {
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid #e6e9e3;
  border-radius: 8px;
  background: #f7faf7;
}

.product-visual img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-fallback {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--muted);
  font-size: 22px;
  font-weight: 850;
}

.card-title-row {
  justify-content: space-between;
  gap: 12px;
}

.jp-name {
  color: var(--muted);
  font-size: 12px;
  min-height: 18px;
}

.code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.series-code {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 6px;
  padding: 0 8px;
  background: #17201a;
  color: #fff;
  font-size: 12px;
  font-weight: 850;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 12px;
}

.source-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.source-chip-row.compact {
  gap: 4px;
  margin: 0 0 4px;
}

.source-chip-row.compact .source-chip {
  min-height: 22px;
  padding: 0 7px;
}

.dense-wrap table {
  min-width: 1380px;
}

.dense-table th,
.dense-table td {
  padding: 8px 11px;
}

.dense-table tbody tr:hover {
  background: #fbfcfb;
}

.dense-product {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-width: 250px;
}

.dense-product img {
  width: 46px;
  height: 34px;
  border: 1px solid #e6e9e3;
  border-radius: 6px;
  object-fit: cover;
  background: #f7faf7;
}

.image-fallback.mini {
  width: 46px;
  height: 34px;
  border-radius: 6px;
  font-size: 10px;
}

.dense-product strong,
.dense-product span {
  display: block;
}

.dense-product strong {
  font-size: 13px;
}

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

.compare-table {
  min-width: 1180px;
}

.compare-product {
  min-width: 280px;
}

.platform-stack {
  display: grid;
  gap: 6px;
  min-width: 360px;
}

.platform-line {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(150px, auto);
  gap: 10px;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid #e6e9e3;
  border-radius: 8px;
  background: #fbfcfb;
}

.platform-line.lowest {
  border-color: #b7d9c3;
  background: #f1faf4;
}

.platform-line span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.chase-card {
  display: grid;
  gap: 2px;
  min-width: 190px;
}

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

.chase-card strong {
  font-size: 13px;
}

.chase-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.tiny {
  margin-top: 4px;
  font-size: 11px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.status-chip.confirmed {
  border: 1px solid #b7d9c3;
  background: #e7f4ec;
  color: var(--green);
}

.status-chip.mapping {
  border: 1px solid #e6c7a4;
  background: #fff8ee;
  color: var(--amber);
}

.status-chip.neutral {
  border: 1px solid #cbd9e7;
  background: #f3f8fc;
  color: var(--blue);
}

.validation-box {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 12px;
  padding: 10px;
  border: 1px solid #e6e9e3;
  border-radius: 8px;
  background: #fbfcfb;
}

.holding-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  margin: 10px 0;
  border: 1px solid #e6e9e3;
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  font-size: 13px;
}

.holding-line strong {
  font-size: 15px;
}

.validation-box span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.validation-box strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
}

.validation-box.low {
  border-color: #e6c7a4;
  background: #fff8ee;
}

.validation-box.medium {
  border-color: #cbd9e7;
  background: #f3f8fc;
}

.validation-box.high {
  border-color: #b7d9c3;
  background: #f1faf4;
}

.validation-box.empty-line {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.outlier-row {
  background: #fff8ee;
}

.warn-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-left: 8px;
  border-radius: 999px;
  padding: 0 8px;
  background: #f5ece4;
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.source-chip.covered {
  border-color: #b7d9c3;
  background: #e7f4ec;
  color: var(--green);
}

.source-card {
  display: grid;
  gap: 10px;
}

.source-card strong {
  font-size: 22px;
}

.coverage-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0eb;
}

.coverage-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

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

.pill {
  background: #eef1ed;
  color: #3f4c43;
}

.watch-toggle,
.small-button {
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
}

.watch-toggle.active {
  border-color: #1d6c50;
  background: #e7f4ec;
  color: var(--green);
}

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

.price-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid #e6e9e3;
  border-radius: 8px;
  background: #fbfcfb;
}

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

.price-value {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 850;
}

.trend-card {
  min-height: 150px;
}

.spark {
  width: 100%;
  height: 64px;
  margin-top: 14px;
  color: var(--green);
  background: #f7faf7;
  border: 1px solid #e6e9e3;
  border-radius: 8px;
}

.trend-range,
.trend-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.watch-list {
  display: grid;
  gap: 0;
}

.entry-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
  align-items: start;
}

.entry-grid .panel:first-child {
  grid-row: span 2;
}

.entry-task-list {
  display: grid;
  gap: 0;
}

.entry-task {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.entry-task-meta {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

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

.entry-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.entry-form input,
.entry-form select {
  width: 100%;
}

.entry-form .wide,
.entry-form button {
  grid-column: 1 / -1;
}

.watch-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 110px 150px 150px 82px;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.watch-row span,
.watch-row label {
  color: var(--muted);
  font-size: 13px;
}

.watch-row strong,
.watch-row span {
  display: block;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.empty {
  padding: 24px 18px;
  color: var(--muted);
}

.empty.small {
  padding: 18px 0 0;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #17201a;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(246, 247, 244, 0.92);
  backdrop-filter: blur(10px);
}

.auth-gate.hidden {
  display: none;
}

.auth-card {
  display: grid;
  width: min(420px, 100%);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card p {
  color: var(--muted);
  font-size: 13px;
}

.auth-card input {
  width: 100%;
}

@media (max-width: 980px) {
  .metrics,
  .product-grid,
  .trend-grid,
  .indicator-card,
  .source-grid,
  .entry-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .watch-row {
    grid-template-columns: 1fr 110px;
  }

  .entry-grid .panel:first-child {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 20px, 1320px);
    padding-top: 18px;
  }

  .topbar,
  .panel-header,
  .panel-header.compact,
  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }

  h1 {
    font-size: 27px;
  }

  .metric {
    padding: 12px;
  }

  .metric strong {
    font-size: 22px;
  }

  .metrics,
  .product-grid,
  .trend-grid,
  .indicator-card,
  .source-grid,
  .entry-grid,
  .entry-form,
  .entry-task {
    grid-template-columns: 1fr;
  }

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

  .indicator-value {
    text-align: left;
  }

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

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