:root {
  --bg: #0b0d12;
  --surface: #12151d;
  --surface-2: #171b25;
  --line: #232a38;
  --line-soft: #1b202b;
  --text: #e9ecf3;
  --muted: #8d97ab;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.28);
  --radius: 14px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #f0f2f6;
  --line: #dfe3ea;
  --line-soft: #eaedf2;
  --text: #131722;
  --muted: #66708a;
  --accent: #2f6bff;
  --accent-soft: rgba(47, 107, 255, 0.1);
  --ok: #0f9d63;
  --ok-soft: rgba(15, 157, 99, 0.12);
  --warn: #b47407;
  --warn-soft: rgba(180, 116, 7, 0.12);
  --danger: #d93a3a;
  --danger-soft: rgba(217, 58, 58, 0.1);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 17px; }
.muted { color: var(--muted); }
.tiny { font-size: 12.5px; }
.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 18px;
}

.brand p { margin: 0; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}

.icon-btn:hover { color: var(--text); border-color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field.inline { min-width: 110px; }
.field.inline.wide { min-width: 190px; }

input, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
}

input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

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

.chip {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

main { padding: 20px 24px 56px; max-width: 1420px; margin: 0 auto; }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 18px 24px 0;
  max-width: 1420px;
  margin: 0 auto;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.kpi-value { font-size: 22px; font-weight: 650; letter-spacing: -0.03em; }
.kpi-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.accent .kpi-value { color: var(--accent); }
.kpi.ok .kpi-value { color: var(--ok); }

.info-banner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 14px 24px 0;
  padding: 10px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  text-align: center;
}

.info-banner a { color: var(--accent); font-weight: 600; text-decoration: none; white-space: nowrap; }
.info-banner a:hover { text-decoration: underline; }

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.toolbar-fields {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.count-line { margin: 14px 2px; }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 16px;
}

.listing {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.listing:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }

.listing-media { position: relative; aspect-ratio: 3 / 2; background: var(--surface-2); }
.listing-media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.listing-media .no-photo {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 24px;
}

.media-badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.media-portal { position: absolute; top: 10px; right: 10px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid var(--line);
  color: var(--muted);
  backdrop-filter: blur(6px);
}

.badge.new { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.badge.drop { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.badge.rise { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }

.listing-media .badge {
  background: rgba(8, 10, 15, 0.72);
  border-color: rgba(255, 255, 255, 0.16);
  color: #f4f6fb;
}

.listing-media .badge.new { background: rgba(91, 140, 255, 0.94); border-color: transparent; color: #fff; }
.listing-media .badge.drop { background: rgba(16, 160, 110, 0.94); border-color: transparent; color: #fff; }
.listing-media .badge.rise { background: rgba(190, 130, 10, 0.94); border-color: transparent; color: #fff; }

.listing-body { padding: 14px 15px 15px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.price-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.price { font-size: 19px; font-weight: 680; letter-spacing: -0.03em; }
.price-old { font-size: 13px; color: var(--muted); text-decoration: line-through; }
.ppm { font-size: 12.5px; color: var(--muted); margin-left: auto; }

.listing-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.listing-title:hover { color: var(--accent); }
.specs { display: flex; gap: 12px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.specs b { color: var(--text); font-weight: 600; }

.listing-foot {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty-icon { font-size: 26px; margin-bottom: 8px; opacity: 0.8; }
.empty-title { color: var(--text); font-weight: 600; margin-bottom: 4px; }

.skeleton {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  height: 290px;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.footnote {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 32px;
}

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

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  main, .kpis { padding-left: 16px; padding-right: 16px; }
}
