:root {
  --bg: #edf3ef;
  --panel: rgba(255, 255, 255, 0.9);
  --ink: #13251f;
  --muted: #5b6e66;
  --line: rgba(19, 37, 31, 0.13);
  --accent: #08745e;
  --accent-soft: #dff3ec;
  --danger: #b91c1c;
  --warn: #b45309;
  --shadow: 0 18px 52px rgba(13, 36, 29, 0.1);
  --soft-shadow: 0 10px 30px rgba(13, 36, 29, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 8%, rgba(22, 160, 133, 0.2), transparent 28rem),
    radial-gradient(circle at 94% 0, rgba(216, 139, 31, 0.14), transparent 25rem),
    linear-gradient(135deg, #fcfdfb 0%, var(--bg) 56%, #e6efe9 100%);
  color: var(--ink);
  font-family: "Trebuchet MS", "Aptos", "Segoe UI", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(19, 37, 31, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(19, 37, 31, 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
  content: "";
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

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

.shell {
  width: calc(100% - 18px);
  max-width: none;
  margin: 0 auto;
  padding: 10px 0 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  padding: clamp(13px, 1.7vw, 23px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    radial-gradient(circle at 4% 0, rgba(8, 116, 94, 0.16), transparent 25rem),
    rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(8, 116, 94, 0.13);
  content: "";
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(31px, 3.4vw, 58px);
  line-height: 0.98;
  letter-spacing: -0.065em;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

select,
button,
.actions a {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 850;
}

select {
  min-width: 220px;
  padding: 0 10px;
}

button,
.actions a {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.actions a:hover {
  border-color: var(--accent);
  box-shadow: var(--soft-shadow);
  transform: translateY(-1px);
}

button,
.actions a {
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

button:focus-visible,
.actions a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(37, 95, 232, 0.34);
  outline-offset: 2px;
}

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

.stats article,
.combined-panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(12px);
}

.stats article {
  display: grid;
  gap: 3px;
  min-height: 70px;
  padding: 12px 14px;
}

.stats span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.stats strong {
  font-size: 20px;
  line-height: 1.1;
}

.stats .error {
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 22vw);
  gap: 10px;
  align-items: start;
}

.combined-panel {
  min-width: 0;
  overflow: hidden;
}

.report-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}

.combined-panel h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.combined-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.combined-panel p.error {
  color: var(--danger);
}

.card-actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.card-actions button,
.card-actions a {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.card-actions button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.table-panel {
  overflow: auto;
  height: calc(100vh - 148px);
  min-height: 250px;
  scrollbar-color: #8b918e #edf1ef;
  scrollbar-width: thin;
}

.combined-table {
  min-width: 1080px;
}

.side-layout {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.side-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(12px);
}

.side-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 252, 251, 0.78);
}

.side-panel h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.side-panel header span {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 950;
}

.side-list {
  display: grid;
  align-content: start;
  gap: 7px;
  height: calc((100vh - 200px) / 2);
  min-height: 250px;
  overflow: auto;
  padding: 8px;
  scrollbar-color: #8b918e #edf1ef;
  scrollbar-width: thin;
}

.side-empty {
  margin: 0;
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.side-row {
  display: grid;
  gap: 7px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.side-row a {
  color: var(--ink);
  font-size: 15px;
  font-weight: 950;
  text-decoration: none;
}

.side-row a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.side-row small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-row dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin: 0;
}

.side-row dl div {
  min-width: 0;
  padding: 5px 6px;
  border-radius: 6px;
  background: #f5f8f6;
}

.side-row dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}

.side-row dd {
  margin: 1px 0 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

th,
td {
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(238, 244, 241, 0.96);
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

tr.multi-source {
  background: linear-gradient(90deg, var(--accent-soft), #ffffff 76%);
}

tr.multi-source td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

td a {
  color: var(--ink);
  font-weight: 950;
  text-decoration: none;
}

td a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.price-value {
  display: block;
  font-weight: 950;
}

.overall-move {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.move-up {
  color: var(--accent);
}

.move-down {
  color: var(--danger);
}

.count-hover {
  min-height: 25px;
  min-width: 34px;
  justify-content: center;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 950;
}

.count-tooltip {
  position: fixed;
  z-index: 9999;
  display: grid;
  gap: 7px;
  width: min(410px, calc(100vw - 16px));
  max-height: 360px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(23, 33, 29, 0.2);
  white-space: normal;
}

.count-tooltip[hidden] {
  display: none;
}

.count-tooltip b {
  color: var(--accent);
  font-size: 13px;
}

.count-tooltip p {
  margin: 0;
  color: var(--muted);
  font-weight: 850;
}

.count-tooltip table {
  min-width: 0;
  font-size: 12px;
}

.count-tooltip th,
.count-tooltip td {
  padding: 5px 6px;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  margin: 1px 4px 1px 0;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  vertical-align: middle;
}

input {
  width: 82px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 850;
}

input.saving {
  border-color: var(--warn);
  background: #fff7ed;
}

input.error {
  border-color: var(--danger);
  background: #fff1f1;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .shell {
    width: calc(100% - 14px);
    padding-top: 7px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: clamp(32px, 11vw, 48px);
  }

  .actions,
  select,
  button,
  .actions a {
    width: 100%;
  }

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

  .side-layout {
    grid-template-columns: 1fr;
  }

  .table-panel,
  .side-list {
    height: min(430px, 58vh);
  }

  .report-card-head {
    flex-direction: column;
  }

  .card-actions {
    width: 100%;
  }

  .card-actions button,
  .card-actions a {
    flex: 1;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  button,
  .actions a {
    transition: none;
  }
}
