:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-soft: #0b1829;
  --panel: #0f1f34;
  --panel-2: #13283f;
  --text: #e8f4ff;
  --muted: #8fb1d1;
  --line: #203a57;
  --brand-a: #339ff6;
  --brand-b: #9bf7ff;
  --brand-c: #2554f5;
  --brand-d: #30befd;
  --danger: #f87171;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(51, 159, 246, 0.2), transparent 34rem),
    linear-gradient(180deg, #07111f 0%, #0a1424 46%, #06101d 100%);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell,
.admin-shell {
  min-height: 100vh;
  padding: 20px;
}

.topbar,
.filters,
.stats-grid,
.workspace,
.upload-panel {
  max-width: 1440px;
  margin: 0 auto;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 800;
}

h1 span,
.brand-mark {
  background: linear-gradient(90deg, var(--brand-a), var(--brand-b), var(--brand-c), var(--brand-d));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

h2 {
  font-size: 16px;
}

.topbar p,
.detail-header p,
.panel-header span,
label,
.stats-grid span,
.insights span,
.upload-panel p,
.selected-file {
  color: var(--muted);
}

.actions,
.upload-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button,
.file-button,
.link-button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 6px;
  min-height: 36px;
  padding: 7px 12px;
  cursor: pointer;
  text-decoration: none;
}

.file-button,
.login-form button,
#replaceButton {
  background: linear-gradient(90deg, var(--brand-c), var(--brand-a), var(--brand-d));
  border-color: rgba(155, 247, 255, 0.5);
  color: white;
}

button:hover,
.file-button:hover,
.link-button:hover {
  border-color: var(--brand-b);
}

#fileInput,
#historyInput {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(2, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #09192b;
  color: var(--text);
  min-height: 38px;
  padding: 7px 10px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(155, 247, 255, 0.35);
  border-color: var(--brand-b);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stats-grid article,
.insights article,
.upload-panel,
.login-panel {
  background: rgba(15, 31, 52, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.stats-grid strong,
.insights strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(270px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.item-panel,
.detail-panel {
  background: rgba(15, 31, 52, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.item-panel {
  min-height: 660px;
  overflow: hidden;
}

.panel-header,
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-header {
  background: linear-gradient(90deg, rgba(37, 84, 245, 0.16), rgba(48, 190, 253, 0.08));
}

.item-list {
  max-height: 610px;
  overflow: auto;
}

.item-row {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: left;
  padding: 11px 14px;
}

.item-row:hover,
.item-row.active {
  background: rgba(51, 159, 246, 0.15);
}

.item-row.active {
  box-shadow: inset 3px 0 0 var(--brand-b);
}

.item-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.detail-panel {
  overflow: hidden;
}

.price-chip {
  flex: 0 0 auto;
  background: rgba(155, 247, 255, 0.1);
  color: var(--brand-b);
  border: 1px solid rgba(155, 247, 255, 0.35);
  border-radius: 6px;
  padding: 8px 10px;
  font-weight: 750;
}

.chart-wrap {
  position: relative;
  padding: 14px;
  height: 380px;
}

#priceChart {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #081625;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  display: grid;
  gap: 3px;
  min-width: 190px;
  max-width: 280px;
  padding: 9px 10px;
  border: 1px solid rgba(155, 247, 255, 0.45);
  border-radius: 6px;
  background: rgba(7, 17, 31, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.chart-tooltip strong {
  color: var(--brand-b);
}

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

.insights {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  padding: 0 14px 14px;
}

.table-wrap {
  max-height: 260px;
  overflow: auto;
  border-top: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  position: sticky;
  top: 0;
  background: #0b1b2e;
  color: var(--muted);
  font-size: 12px;
}

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

.site-footer {
  max-width: 1440px;
  margin: 18px auto 0;
  padding: 14px 0 6px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.login-panel {
  width: min(440px, calc(100vw - 32px));
  margin: 12vh auto 0;
  padding: 24px;
}

.brand-mark {
  display: inline-block;
  margin-bottom: 12px;
  font-weight: 800;
}

.login-panel h1 {
  margin-bottom: 8px;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.error-text {
  min-height: 20px;
  margin-top: 10px;
  color: var(--danger);
}

.upload-panel {
  display: grid;
  gap: 12px;
}

.selected-file {
  min-height: 22px;
}

.review-summary {
  border: 1px solid rgba(155, 247, 255, 0.3);
  border-radius: 6px;
  background: rgba(155, 247, 255, 0.08);
  padding: 9px 10px;
}

.blocked-list {
  display: grid;
  gap: 6px;
  max-height: 340px;
  overflow: auto;
}

.blocked-row {
  display: grid;
  gap: 2px;
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 6px;
  background: rgba(248, 113, 113, 0.08);
  padding: 8px 10px;
}

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

.hidden {
  display: none !important;
}

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

  .topbar,
  .detail-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .item-panel {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .app-shell,
  .admin-shell {
    padding: 12px;
  }

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

  h1 {
    font-size: 23px;
  }
}
