:root {
  --fg: #000;
  --bg: #fff;
  --muted: #777;
  --line: #000;
  --removed: #bbb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 1rem;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.4;
}

h1 {
  margin: 0;
  font-size: 13px;
  font-weight: bold;
}

header {
  border-bottom: 1px solid var(--line);
  padding-bottom: .5rem;
  margin-bottom: 1rem;
}

label { white-space: nowrap; }

select, button, input[type="text"] {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 1px 4px;
}

button { cursor: pointer; }
button:hover { background: var(--fg); color: var(--bg); }

#filters select {
  width: 100%;
}

main {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 800px) {
  main { grid-template-columns: 1fr; }
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 0;
  margin: 0 0 .75rem 0;
  padding: .4rem .5rem .5rem;
}

legend { padding: 0 .25rem; }

.checks {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.checks label, label.inline {
  display: flex;
  align-items: center;
  gap: .35rem;
  white-space: nowrap;
  cursor: pointer;
}

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

input[type="checkbox"] {
  accent-color: #000;
  margin: 0;
}

.range {
  display: grid;
  gap: 2px;
}

input[type="range"] {
  width: 100%;
  accent-color: #000;
  margin: 0;
}

output {
  color: var(--muted);
  font-size: 12px;
}

#counts {
  margin: 0;
  color: var(--muted);
}

#charts {
  display: grid;
  gap: 1rem;
}

figure {
  margin: 0;
  border: 1px solid var(--line);
}

figcaption {
  border-bottom: 1px solid var(--line);
  padding: .25rem .5rem;
}

.chart { padding: .25rem; }

svg { display: block; width: 100%; height: auto; }

.axis { stroke: var(--line); stroke-width: 1; }
.grid { stroke: #e5e5e5; stroke-width: 1; }
.tick-label { fill: var(--muted); font-size: 10px; }
.axis-label { fill: var(--fg); font-size: 11px; }

.point {
  fill: none;
  stroke: var(--fg);
  stroke-width: 1;
  cursor: pointer;
}

.point:hover { fill: var(--fg); }

/* Sold/withdrawn ads stay visible but recede, so the live market reads first.
   Per-iskanje coloring (inline stroke) overrides the color but keeps the
   dashed pattern, so removed/active stays distinguishable either way. */
.point.removed { stroke: var(--removed); stroke-dasharray: 1 1; }

.fit-line { fill: none; stroke-width: 1.5; }

.empty { fill: var(--muted); font-size: 11px; }

#fit-controls {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: .5rem;
}

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

#fit-controls button.active {
  background: var(--fg);
  color: var(--bg);
}

#legend {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1rem;
  padding: .4rem .5rem;
  border: 1px solid var(--line);
}

#legend[hidden] { display: none; }

.legend-item {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: 12px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  display: inline-block;
  border: 1px solid var(--line);
}

#preview {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 2px;
  max-width: 280px;
}

#preview img {
  display: block;
  width: 260px;
  height: auto;
  background: #f0f0f0;
}

/* Needed because the rule above outranks the browser's [hidden] default, so an
   ad without a photo would otherwise show a broken image icon. */
#preview img[hidden] { display: none; }

#preview-text {
  padding: 2px 3px 1px;
  font-size: 11px;
  white-space: pre-line;
}

#searches-manage {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: .75rem;
}

#searches-manage h2 {
  margin: 0 0 .5rem;
  font-size: 13px;
  font-weight: bold;
}

#searches-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: .75rem;
}

#searches-table th, #searches-table td {
  border: 1px solid var(--line);
  padding: .25rem .5rem;
  text-align: left;
  font-weight: normal;
}

#searches-table a { color: inherit; }

#add-search-form {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}

#add-search-form input[type="text"] {
  flex: 1 1 auto;
  min-width: 160px;
}

.error {
  color: #b00020;
}

footer {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: .5rem;
  color: var(--muted);
}
