:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #0f172a;
  color: #e5e7eb;
}

body {
  margin: 0;
  padding: 1.5rem;
  max-width: 1200px;
  margin-inline: auto;
}

h1 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.card {
  background: #020617;
  border-radius: 1rem;
  padding: 1.2rem 1.4rem;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.85);
  border: 1px solid #1e293b;
  margin-bottom: 1.2rem;
}

.card h2 {
  font-size: 1.2rem;
  margin-top: 0;
  margin-bottom: 0.8rem;
}

.grid {
  display: grid;
  gap: 0.8rem;
}

@media (min-width: 768px) {
  .grid-cols-2-md {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

label {
  font-size: 0.85rem;
  color: #9ca3af;
  display: block;
  margin-bottom: 0.25rem;
}

input,
select {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border-radius: 0.6rem;
  border: 1px solid #1f2933;
  background: #020617;
  color: #e5e7eb;
  font-size: 0.9rem;
  box-sizing: border-box;
}

input:focus,
select:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px #38bdf8;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  background: linear-gradient(135deg, #22c55e, #0ea5e9);
  color: white;
  margin-top: 0.8rem;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.6rem;
}

.secondary-btn {
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  border: 1px solid #4b5563;
  background: transparent;
  color: #e5e7eb;
  cursor: pointer;
}

.secondary-btn:hover {
  border-color: #e5e7eb;
  background: rgba(15, 23, 42, 0.9);
}

.secondary-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.hint {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

.status {
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.status.error {
  color: #f97373;
}

.status.ok {
  color: #22c55e;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.8rem;
  font-size: 0.85rem;
}

th,
td {
  padding: 0.35rem 0.4rem;
  text-align: left;
  white-space: nowrap;
}

th {
  border-bottom: 1px solid #1f2933;
  color: #9ca3af;
  font-weight: 600;
  font-size: 0.8rem;
}

tr:nth-child(even) td {
  background: rgba(15, 23, 42, 0.6);
}

code {
  background: rgba(15, 23, 42, 0.9);
  padding: 0.1rem 0.3rem;
  border-radius: 0.3rem;
  font-size: 0.8rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.75rem;
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

a {
  color: #38bdf8;
}

#params-details {
  border-radius: 1rem;
}

#params-details[open] {
  margin-top: 0.1rem;
}

.params-summary {
  list-style: none;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 600;
  margin: -0.4rem -0.4rem 0.8rem -0.4rem;
  padding: 0.3rem 0.4rem 0.6rem 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.params-summary::-webkit-details-marker {
  display: none;
}

.item-card-trader-tip {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: #9ca3af;
}

.item-card-trader-tip strong {
  color: #e5e7eb;
}

.item-card-trader-tip .profit {
  color: #bbf7d0;
  font-weight: 600;
}

/* ===== Случайный обзор рынка (компактные капсулы) ===== */

.random-overview {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.random-card {
  border-radius: 0.9rem;
  padding: 0.55rem 0.75rem;
  background: #020617;
  border: 1px dashed #334155;
  cursor: pointer;
  text-align: left;
}

.random-card:hover {
  border-style: solid;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.9);
}

.random-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.random-card-sub {
  font-size: 0.78rem;
  color: #cbd5f5;
}

.random-card-sub strong {
  color: #e5e7eb;
}

.random-card-foot {
  font-size: 0.74rem;
  color: #9ca3af;
  margin-top: 0.25rem;
}

.random-card-hint {
  font-size: 0.74rem;
  color: #64748b;
  margin-top: 0.2rem;
}

.random-card-details {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px dashed #1f2937;
}

/* Чтобы вложенная карточка выглядела аккуратно внутри random-card */
.item-card-details .item-card-header {
  margin-bottom: 0.4rem;
}

/* маленький индикатор-стрелочка */
.params-summary::before {
  content: "▾";
  font-size: 0.9rem;
  opacity: 0.8;
  transition: transform 0.15s ease;
}

#params-details:not([open]) .params-summary::before {
  transform: rotate(-90deg);
}

/* ===== Результаты ===== */

.results-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  align-items: flex-start;
  margin-bottom: 0.6rem;
}

.results-main-info {
  font-size: 0.9rem;
}

.results-main-info strong {
  font-weight: 600;
}

.results-meta {
  font-size: 0.78rem;
  color: #9ca3af;
}

.results-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.results-tag {
  border-radius: 999px;
  padding: 0.08rem 0.55rem;
  font-size: 0.74rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  white-space: nowrap;
}

.results-tag-accent {
  border-color: rgba(56, 189, 248, 0.7);
  background: radial-gradient(
    circle at top left,
    rgba(56, 189, 248, 0.25),
    rgba(15, 23, 42, 0.95)
  );
}

.results-table-wrapper {
  overflow-x: auto;
}

/* ===== Карточки результатов вместо таблицы ===== */

.item-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.5rem;
}

.item-card {
  border-radius: 1rem;
  padding: 0.8rem 1rem;
  background: #020617;
  border: 1px solid #1e293b;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.8);
}

.item-card-header {
  margin-bottom: 0.5rem;
}

.item-card-title {
  font-size: 1rem;
  font-weight: 600;
}

.item-card-subtitle {
  font-size: 0.78rem;
  color: #9ca3af;
}

.city-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.city-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  border-radius: 0.9rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
}

.city-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.8);
}

.city-pill-title {
  font-weight: 600;
  font-size: 0.82rem;
}

.city-pill-line {
  font-size: 0.78rem;
  color: #cbd5f5;
}

.city-pill-line--best-sell {
  color: #bbf7d0;
  font-weight: 600;
}

.city-pill-line--best-sell::before {
  content: "★ ";
  opacity: 0.9;
}

.city-pill-line--best-buy {
  color: #fecaca;
  font-weight: 600;
}

.city-pill-line--best-buy::before {
  content: "★ ";
  opacity: 0.9;
}

/* капсула без данных */

.city-pill--empty {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

/* Цвета для конкретных городов */

.city-pill--caerleon {
  border-color: #f97316;
  background: radial-gradient(
    circle at top left,
    rgba(248, 113, 22, 0.28),
    rgba(15, 23, 42, 0.95)
  );
}

.city-pill--bridgewatch {
  border-color: #facc15;
  background: radial-gradient(
    circle at top left,
    rgba(250, 204, 21, 0.25),
    rgba(15, 23, 42, 0.95)
  );
}

.city-pill--thetford {
  border-color: #6366f1;
  background: radial-gradient(
    circle at top left,
    rgba(99, 102, 241, 0.3),
    rgba(15, 23, 42, 0.95)
  );
}

.city-pill--martlock {
  border-color: #22c55e;
  background: radial-gradient(
    circle at top left,
    rgba(34, 197, 94, 0.25),
    rgba(15, 23, 42, 0.95)
  );
}

.city-pill--lymhurst {
  border-color: #16a34a;
  background: radial-gradient(
    circle at top left,
    rgba(22, 163, 74, 0.3),
    rgba(15, 23, 42, 0.95)
  );
}

.city-pill--fort-sterling {
  border-color: #e5e7eb;
  background: radial-gradient(
    circle at top left,
    rgba(148, 163, 184, 0.28),
    rgba(15, 23, 42, 0.95)
  );
}

.city-pill--brecilien {
  border-color: #ec4899;
  background: radial-gradient(
    circle at top left,
    rgba(236, 72, 153, 0.32),
    rgba(15, 23, 42, 0.95)
  );
}

.city-pill--black-market {
  border-color: #0ea5e9;
  background: radial-gradient(
    circle at top left,
    rgba(14, 165, 233, 0.32),
    rgba(15, 23, 42, 0.98)
  );
}

/* подсветка строк таблицы */

.results-table tr:hover td {
  background: rgba(56, 189, 248, 0.08);
}

.results-table th,
.results-table td {
  padding: 0.35rem 0.55rem;
}

.results-table th.numeric,
.results-table td.numeric {
  text-align: right;
}

/* липкий заголовок таблицы */

.results-table thead th {
  position: sticky;
  top: 0;
  background: #020617;
}

/* маленькая подпись «только активные ордера» */

.results-note {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 0.3rem;
}

/* ===== История цен ===== */

#history-panel {
  margin-top: 1rem;
  border-top: 1px dashed #1f2933;
  padding-top: 0.8rem;
  display: none; /* по умолчанию скрыт */
}

#history-title {
  font-size: 1rem;
  margin: 0 0 0.25rem 0;
}

.history-meta {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-bottom: 0.4rem;
}

.history-chart-wrap {
  position: relative;
  width: 100%;
  max-width: 640px;
  height: 260px;
}

/* canvas растягивается по контейнеру */
#history-chart {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

#history-status {
  margin-top: 0.3rem;
  font-size: 0.78rem;
}

/* ===== Значки в заголовке истории ===== */

.history-title-pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-left: 0.3rem;
}

.history-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.08rem 0.6rem;
  font-size: 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.8);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  white-space: nowrap;
}

.history-pill-item {
  border-color: rgba(56, 189, 248, 0.9);
  background: radial-gradient(
    circle at top left,
    rgba(56, 189, 248, 0.25),
    rgba(15, 23, 42, 0.95)
  );
}

.history-pill-city {
  border-color: rgba(34, 197, 94, 0.8);
  background: radial-gradient(
    circle at top left,
    rgba(34, 197, 94, 0.25),
    rgba(15, 23, 42, 0.95)
  );
}

/* ====== Item picker ======= */

.item-picker {
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px dashed #1f2933;
}

.item-results {
  margin-top: 0.5rem;
  max-height: 220px;
  overflow-y: auto;
  border-radius: 0.75rem;
  border: 1px solid #111827;
  background: rgba(15, 23, 42, 0.9);
}

.item-row {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 0.4rem 0.6rem;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.item-row:hover {
  background: rgba(56, 189, 248, 0.08);
}

.item-row-main {
  font-size: 0.85rem;
  color: #ffffff; /* RU название белым */
}

.item-row-sub {
  font-size: 0.75rem;
  color: #9ca3af;
}

.item-name-ru {
  display: block;
  font-size: 0.75rem;
  color: #9ca3af;
}

.selected-items {
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  background: rgba(22, 163, 74, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.5);
  color: #bbf7d0;
  gap: 0.25rem;
}

.chip-remove {
  border: none;
  background: transparent;
  color: #f97373;
  cursor: pointer;
  padding: 0;
  font-size: 0.8rem;
  line-height: 1;
}
