:root {
  --bg: #f8f8f6;
  --fg: #1a1a1a;
  --muted: #666;
  --border: #d8d8d4;
  --accent: #1a4b8c;
  --good: #1f6f3a;
  --warn-bg: #fff8e1;
  --warn-border: #d4af37;
  --bad: #aa2020;
  --tag-bg: #ececea;
}
*, *::before, *::after { box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
       max-width: 1180px; margin: 0 auto; padding: 0 1.25rem 4rem;
       background: var(--bg); color: var(--fg); line-height: 1.5; }
header { display: flex; gap: 1.5rem; align-items: baseline; padding: 1rem 0; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
header .brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--fg); }
header nav { display: flex; gap: 1.25rem; }
header nav a { text-decoration: none; color: var(--muted); }
header nav a:hover { color: var(--fg); }

a { color: var(--accent); }
section { margin: 1.5rem 0; }
h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
.muted { color: var(--muted); }
.banner { padding: 0.6rem 0.9rem; border-radius: 6px; margin: 0.5rem 0; }
.banner-warn { background: var(--warn-bg); border: 1px solid var(--warn-border); }
.banner-info { background: #e7f0ff; border: 1px solid #b0c8ee; }
.banner-bad { background: #ffeded; border: 1px solid #e0a0a0; }

.listing-row { display: grid; grid-template-columns: 80px 1fr auto; gap: 1rem;
               padding: 0.6rem 0; border-bottom: 1px solid var(--border); align-items: center; }
.listing-row > img, .listing-row .thumb-placeholder {
  width: 80px; height: 60px; object-fit: cover; border-radius: 4px;
  background: var(--tag-bg);
}
.listing-row > img.broken { visibility: hidden; }

ul.failure-reasons { margin: 0.25rem 0 0; padding-left: 1.1rem; font-size: 0.85rem; color: var(--muted); }
ul.failure-reasons li { margin: 0.1rem 0; }
.listing-row.filtered { opacity: 0.85; }
.listing-row .price { font-weight: 600; }
.listing-row .ppb { color: var(--muted); font-size: 0.85rem; }
.listing-row .title a { text-decoration: none; }
.listing-row .meta { font-size: 0.85rem; color: var(--muted); }

.tag { display: inline-block; padding: 0.1rem 0.5rem; margin: 2px 4px 2px 0;
       border-radius: 4px; background: var(--tag-bg); font-size: 0.8rem; }
.tag.neg { background: #ffd9d9; }
.tag.attr { background: #d9e9ff; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 2rem; }
@media (max-width: 800px) { .detail-grid { grid-template-columns: 1fr; } }
.photo-hero { width: 100%; aspect-ratio: 4 / 3; background: var(--tag-bg); border-radius: 6px; overflow: hidden; position: relative; }
.photo-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-hero img.broken { display: none; }
.photo-hero img.broken + ::after,
.photo-hero:has(img.broken)::after,
.photo-hero:not(:has(img))::after {
  content: "Photos unavailable — view on Daft.ie";
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.9rem; padding: 1rem; text-align: center;
}
.photo-strip { display: flex; gap: 0.5rem; overflow-x: auto; margin-top: 0.5rem; }
.photo-strip img { height: 110px; border-radius: 4px; cursor: pointer; flex-shrink: 0; object-fit: cover; }
.photo-strip img.broken { display: none; }

.facts { background: white; padding: 1rem; border: 1px solid var(--border); border-radius: 6px; }
.facts dt { font-weight: 600; font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.facts dd { margin: 0; }

textarea { width: 100%; min-height: 240px; font-family: ui-monospace, SFMono-Regular, monospace;
           padding: 0.6rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; }
button, .button { padding: 0.5rem 1rem; border: 1px solid var(--border); border-radius: 6px;
                  background: white; cursor: pointer; font-size: 0.9rem; }
button.primary { background: var(--accent); color: white; border-color: var(--accent); }
button:hover { background: var(--tag-bg); }
button.primary:hover { opacity: 0.9; background: var(--accent); }
form.inline { display: inline; }
.kv { font-size: 0.85rem; }
.kv span { color: var(--muted); }

.page-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.tick-status { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--muted); }
.tick-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.tick-dot.live { background: var(--good); box-shadow: 0 0 0 3px rgba(31,111,58,0.18); }
.tick-dot.stale { background: var(--warn-border); }
.tick-dot.dead { background: var(--bad); }

.outcome-history { font-size: 0.85rem; }
.outcome-history li { margin: 0.25rem 0; }

/* Forms */
.card-form { background: white; padding: 1.5rem; border: 1px solid var(--border); border-radius: 8px; max-width: 720px; }
.card-form fieldset { border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem 1rem 1rem; margin: 1rem 0; }
.card-form legend { font-weight: 600; padding: 0 0.5rem; }
.card-form label { display: block; margin: 0.5rem 0; }
.card-form label > input[type="text"], .card-form label > input[type="email"], .card-form label > input[type="tel"], .card-form label > input[type="number"], .card-form label > input[type="url"], .card-form label > select {
  display: block; width: 100%; padding: 0.5rem; margin-top: 0.25rem;
  border: 1px solid var(--border); border-radius: 4px; font-size: 0.95rem; font-family: inherit;
}
.card-form label.checkbox { display: flex; align-items: center; gap: 0.5rem; margin: 0.4rem 0; cursor: pointer; }
.card-form label.checkbox input { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

/* Filter rule rows */
.rule-list { background: white; padding: 1rem; border: 1px solid var(--border); border-radius: 8px; margin: 0.75rem 0; }
.rule-list h2 { margin-top: 0; }
.rule-row { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem 1rem; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.rule-row:last-of-type { border-bottom: none; }
.rule-row .rule-text { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 0.9rem; }
.rule-row .rule-text .field { color: var(--accent); font-weight: 600; }
.rule-row .rule-text .op { color: var(--muted); margin: 0 0.4rem; }
.rule-row .rule-text .val { color: var(--good); }
.rule-row .rule-text .tag-result { display: inline-block; padding: 0.1rem 0.5rem; margin-left: 0.5rem; background: var(--tag-bg); border-radius: 4px; font-family: inherit; font-size: 0.8rem; }
.rule-row form { margin: 0; }
.add-rule { display: grid; grid-template-columns: 160px 110px 1fr auto; gap: 0.5rem; padding: 0.75rem 0; align-items: center; }
.add-rule input, .add-rule select { padding: 0.45rem; border: 1px solid var(--border); border-radius: 4px; font-size: 0.9rem; font-family: inherit; }
.add-rule.with-tag { grid-template-columns: 160px 110px 1fr 140px auto; }
.add-rule.vision-rule { grid-template-columns: 200px 1fr auto; }
.tab-bar { display: flex; gap: 0.5rem; margin: 1rem 0; border-bottom: 1px solid var(--border); }
.tab-bar a { padding: 0.5rem 1rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.tab-bar a.active { color: var(--fg); border-bottom-color: var(--accent); }
