:root {
  --ink: #17221d;
  --muted: #6b7771;
  --paper: #f5f3ed;
  --surface: #fffefa;
  --line: #dfe3dc;
  --green: #176b4d;
  --green-dark: #0e4a35;
  --green-soft: #dcebe3;
  --lime: #c9e769;
  --shadow: 0 18px 50px rgba(29, 43, 36, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
svg { width: 100%; height: 100%; }

.topbar {
  height: 70px; padding: 0 clamp(20px, 4vw, 64px); display: flex; align-items: center; gap: 42px;
  background: rgba(255, 254, 250, .94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; font-size: 20px; letter-spacing: -.5px; }
.brand strong { color: var(--green); }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; background: var(--green); color: white; padding: 11px; }
.brand-mark svg { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark.small { width: 36px; height: 36px; padding: 8px; border-radius: 11px; }
.main-nav { display: flex; align-items: stretch; height: 100%; gap: 30px; }
.main-nav a { position: relative; display: flex; align-items: center; text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 650; }
.main-nav a:hover, .main-nav a.active { color: var(--green-dark); }
.main-nav a.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--green); border-radius: 3px 3px 0 0; }
.top-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.live-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid #c9d7cf; border-radius: 999px; color: #315a49; background: #f3faf6; font-size: 12px; font-weight: 750; max-width: 260px; }
.live-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: #37a56f; box-shadow: 0 0 0 4px rgba(55,165,111,.12); }
.live-pill.working i { background: #e2a129; animation: pulse 1.2s infinite; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--muted); cursor: pointer; }
.icon-button:hover { color: var(--ink); border-color: #b9c4bd; }

.page-shell { width: min(1460px, calc(100% - 40px)); margin: 0 auto; padding: 46px 0 70px; }
.page-intro { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 9px; color: var(--green); font-size: 11px; letter-spacing: .18em; font-weight: 850; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font: 600 clamp(30px, 4vw, 48px)/1.06 Georgia, "Times New Roman", serif; letter-spacing: -.035em; }
h2 { margin-bottom: 6px; font: 600 27px/1.15 Georgia, "Times New Roman", serif; letter-spacing: -.02em; }
h3 { margin-bottom: 5px; }
.muted, .page-intro .muted { color: var(--muted); }

.button { min-height: 42px; padding: 0 17px; border: 1px solid transparent; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; font-weight: 750; font-size: 13px; cursor: pointer; text-decoration: none; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.primary { color: white; background: var(--green); box-shadow: 0 8px 20px rgba(23,107,77,.2); }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { color: var(--green-dark); border-color: #c9d5ce; background: white; }
.button.secondary:hover { border-color: var(--green); }
.button.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.button.compact { min-height: 35px; padding: 0 12px; font-size: 12px; border-radius: 9px; }
.button.full { width: 100%; min-height: 48px; }
.refresh-icon { font-size: 18px; line-height: 1; }
.text-button { border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 16px; }
.stat-card { min-height: 138px; padding: 22px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 17px; display: flex; flex-direction: column; box-shadow: 0 5px 24px rgba(25,39,32,.035); }
.stat-card.accent { background: var(--green); color: white; border-color: var(--green); position: relative; overflow: hidden; }
.stat-card.accent::after { content: ""; position: absolute; width: 110px; height: 110px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; right: -28px; top: -34px; box-shadow: 0 0 0 25px rgba(255,255,255,.04), 0 0 0 50px rgba(255,255,255,.025); }
.stat-label { font-size: 10px; font-weight: 850; letter-spacing: .13em; opacity: .72; }
.stat-card > strong { margin: auto 0 2px; font-size: 35px; letter-spacing: -.04em; line-height: 1; }
.stat-card strong small { font-size: 16px; color: var(--muted); }
.stat-card .time-value { font-size: 20px; letter-spacing: -.02em; }
.stat-note { font-size: 12px; opacity: .67; }

.setup-callout { display: flex; align-items: center; gap: 16px; margin: 16px 0 22px; padding: 16px 19px; background: #eef3df; border: 1px solid #d9e1be; border-radius: 14px; }
.setup-callout .callout-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--lime); color: #405613; }
.setup-callout p { margin: 2px 0 0; color: #68704f; font-size: 13px; }
.setup-callout a { margin-left: auto; color: #45601a; font-size: 13px; font-weight: 800; text-decoration: none; white-space: nowrap; }

.content-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.listings-panel { padding: 25px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.panel-head p, .section-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.panel-tools { display: flex; align-items: center; gap: 10px; }
.search-form { height: 38px; min-width: 245px; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: #f8f7f3; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); }
.search-form input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }
.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #f7f6f1; }
.segmented a { padding: 6px 11px; border-radius: 7px; font-size: 12px; font-weight: 750; text-decoration: none; color: var(--muted); }
.segmented a.active { background: white; color: var(--green-dark); box-shadow: 0 2px 7px rgba(30,46,38,.08); }

.listing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 17px; padding-top: 22px; }
.listing-card { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: white; transition: .2s ease; }
.listing-card:hover { transform: translateY(-2px); border-color: #bdc9c1; box-shadow: 0 12px 30px rgba(30,46,38,.08); }
.listing-card.is-new { border-color: #9dcab5; box-shadow: inset 0 0 0 1px #d8eee4; }
.listing-image { height: 168px; display: block; position: relative; background: linear-gradient(135deg, #d9e2dc, #f0eee7); background-size: cover; background-position: center; text-decoration: none; }
.listing-image::after { content: ""; position: absolute; inset: 45% 0 0; background: linear-gradient(transparent, rgba(12,25,18,.34)); }
.house-placeholder { position: absolute; inset: 0; display: grid; place-items: center; font-size: 64px; color: rgba(21,84,61,.22); }
.new-badge, .source-badge { position: absolute; z-index: 2; top: 12px; padding: 6px 9px; border-radius: 7px; font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.new-badge { left: 12px; color: #29410c; background: var(--lime); }
.source-badge { right: 12px; color: white; background: rgba(17,34,26,.73); backdrop-filter: blur(6px); max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listing-body { padding: 17px; }
.listing-meta { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 9px; color: var(--muted); font-size: 10px; }
.listing-meta span:first-child { color: var(--green); font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.listing-body h3 { min-height: 43px; font-size: 15px; line-height: 1.35; }
.listing-body h3 a { text-decoration: none; }
.listing-body h3 a:hover { color: var(--green); }
.listing-numbers { display: flex; align-items: baseline; gap: 11px; margin-top: 15px; }
.listing-numbers strong { font-size: 20px; letter-spacing: -.025em; }
.listing-numbers span { color: var(--muted); font-size: 12px; }
.listing-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid #edf0ec; }
.empty-state { padding: 65px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--ink); margin-top: 20px; }
.empty-radar { width: 74px; height: 74px; display: inline-block; position: relative; border: 1px solid #bad1c5; border-radius: 50%; box-shadow: 0 0 0 12px #edf3ef, 0 0 0 13px #dce8e1; }
.empty-radar::after { content: ""; position: absolute; width: 32px; height: 1px; background: var(--green); left: 50%; top: 50%; transform-origin: left; transform: rotate(-36deg); }

.settings-layout, .sources-section { margin-top: 64px; scroll-margin-top: 90px; }
.section-heading { margin-bottom: 18px; }
.section-heading h2 { font-size: 34px; }
.settings-form { overflow: hidden; }
.form-section { padding: 28px 30px; border-bottom: 1px solid var(--line); }
.form-section-title { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 21px; }
.form-section-title > span { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #bad0c4; border-radius: 50%; color: var(--green); font-size: 10px; font-weight: 850; }
.form-section-title h3 { font-size: 16px; }
.form-section-title p { margin: 0; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; gap: 17px; }
.form-grid.two { grid-template-columns: 1.25fr 1fr; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.form-grid label, .stack-form label, .source-editor label { display: flex; flex-direction: column; gap: 7px; color: #38443e; font-size: 12px; font-weight: 750; }
input, textarea, select { width: 100%; border: 1px solid #d2d9d4; border-radius: 9px; padding: 10px 12px; background: white; color: var(--ink); outline: none; transition: .16s ease; }
input { min-height: 41px; }
textarea { resize: vertical; line-height: 1.45; }
select { min-height: 41px; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,77,.1); }
label small { color: var(--muted); font-weight: 450; line-height: 1.35; }
.field-stack { display: grid; gap: 14px; }
.check-row, .toggle-row { flex-direction: row !important; align-items: center; }
.check-row input { width: 18px; min-height: 18px; accent-color: var(--green); }
.toggle-row { justify-content: space-between; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #faf9f5; }
.toggle-row span { display: flex; flex-direction: column; gap: 3px; }
.toggle-row input { width: 42px; min-height: 23px; accent-color: var(--green); }
.compact-grid { align-items: end; }
.form-footer { padding: 18px 30px; display: flex; justify-content: space-between; align-items: center; background: #f7f8f4; color: var(--muted); font-size: 12px; }
.email-test-form { margin-top: 12px; display: flex; justify-content: end; }
.notification-test-actions { margin-top: 12px; display: flex; justify-content: end; gap: 10px; flex-wrap: wrap; }

.row-heading { display: flex; justify-content: space-between; align-items: end; }
.source-total { padding: 7px 11px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); font-size: 11px; font-weight: 800; }
.source-list { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.source-row { border-bottom: 1px solid var(--line); }
.source-row:last-child { border-bottom: 0; }
.source-row summary { min-height: 72px; padding: 13px 19px; display: grid; grid-template-columns: 12px minmax(190px, 1.4fr) 90px 180px 24px; align-items: center; gap: 15px; list-style: none; cursor: pointer; }
.source-row summary::-webkit-details-marker { display: none; }
.source-row[open] summary { background: #f8f8f4; }
.source-dot { width: 8px; height: 8px; border-radius: 50%; background: #aab2ae; }
.source-dot.status-u-redu { background: #39a874; box-shadow: 0 0 0 4px #e3f3eb; }
.source-dot.status-djelomicno { background: #e0a12e; box-shadow: 0 0 0 4px #faf0d8; }
.source-dot.status-greska { background: #c95f57; box-shadow: 0 0 0 4px #f8e5e3; }
.source-name, .source-result, .source-status { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.source-name strong { font-size: 13px; }
.source-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10px; }
.source-result strong, .source-status strong { font-size: 12px; }
.source-result small, .source-status small { color: var(--muted); font-size: 10px; }
.chevron { color: var(--muted); transition: transform .2s; }
.source-row[open] .chevron { transform: rotate(180deg); }
.source-editor { padding: 20px 40px 24px 46px; display: grid; grid-template-columns: minmax(250px, 1fr) 190px 210px auto; align-items: end; gap: 16px; background: #fbfbf8; border-top: 1px solid #edf0ec; }
.source-editor .wide { grid-row: span 2; }
.source-error { grid-column: 2 / -1; margin: 0; padding: 9px 11px; border-radius: 8px; background: #fbebe9; color: #8f3933; font-size: 11px; }
.small-toggle { min-height: 68px; }

.run-log { margin-top: 24px; border: 1px solid var(--line); border-radius: 12px; background: #eceee9; color: #4b5751; }
.run-log summary { padding: 14px 16px; cursor: pointer; font-size: 12px; font-weight: 750; }
.run-log pre { margin: 0; padding: 17px; border-top: 1px solid #d9ddd7; overflow: auto; font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; }
.alert { margin-bottom: 18px; padding: 13px 16px; border-radius: 11px; font-size: 13px; font-weight: 650; }
.alert.success { color: #19573f; background: #e4f3eb; border: 1px solid #c3e1d2; }
.alert.error { color: #82362f; background: #fae9e6; border: 1px solid #edc8c3; }

footer { min-height: 70px; padding: 0 clamp(20px, 4vw, 64px); display: flex; justify-content: space-between; align-items: center; gap: 20px; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }

.login-page { background: #0f3528; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(390px, .75fr); }
.login-brand { min-height: 100vh; padding: clamp(50px, 8vw, 110px); position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; color: white; background: radial-gradient(circle at 75% 25%, #28765b 0, #15503b 32%, #0f3528 68%); }
.login-brand .brand-mark { margin-bottom: 55px; color: #173a2c; background: var(--lime); }
.login-brand .eyebrow { color: #b7d9c8; }
.login-brand h1 { max-width: 680px; font-size: clamp(50px, 6vw, 86px); line-height: .98; }
.login-brand h1 span { color: var(--lime); }
.login-brand > p:last-of-type { max-width: 540px; color: #bdd0c7; line-height: 1.7; }
.radar-art { position: absolute; width: 460px; height: 460px; right: -80px; bottom: -150px; border: 1px solid rgba(201,231,105,.2); border-radius: 50%; }
.radar-art i { position: absolute; inset: 17%; border: 1px solid rgba(201,231,105,.15); border-radius: 50%; }
.radar-art i:nth-child(2) { inset: 34%; }
.radar-art i:nth-child(3) { inset: 49%; }
.radar-art b { position: absolute; left: 50%; top: 50%; width: 48%; height: 1px; background: linear-gradient(90deg, var(--lime), transparent); transform-origin: left; animation: sweep 5s linear infinite; }
.login-card { min-height: 100vh; padding: clamp(42px, 7vw, 90px); display: flex; flex-direction: column; justify-content: center; gap: 28px; background: var(--surface); }
.login-card h2 { font-size: 38px; }
.login-card .muted { line-height: 1.6; }
.stack-form { display: grid; gap: 17px; }
.login-foot { margin: 28px 0 0; color: #a1aaa5; font-size: 11px; text-align: center; }

@keyframes pulse { 50% { opacity: .35; } }
@keyframes sweep { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .listing-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .source-editor { grid-template-columns: 1fr 1fr; }
  .source-editor .wide { grid-column: 1 / -1; grid-row: auto; }
  .source-error { grid-column: 1 / -1; }
  .form-grid.three { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .topbar { height: 62px; padding: 0 15px; gap: 12px; }
  .brand { font-size: 17px; }
  .main-nav { display: none; }
  .live-pill { max-width: 142px; }
  .page-shell { width: min(100% - 24px, 1460px); padding-top: 28px; }
  .page-intro { align-items: flex-start; }
  .page-intro h1 { font-size: 34px; }
  .page-intro .muted { max-width: 450px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { min-height: 120px; padding: 18px; }
  .stat-card > strong { font-size: 29px; }
  .stat-card .time-value { font-size: 15px; }
  .setup-callout { align-items: flex-start; }
  .setup-callout a { display: none; }
  .listings-panel { padding: 16px; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .panel-tools { width: 100%; flex-wrap: wrap; }
  .search-form { flex: 1 1 100%; }
  .listing-grid { grid-template-columns: 1fr; }
  .form-section { padding: 23px 18px; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .form-footer { padding: 17px 18px; gap: 15px; }
  .source-row summary { grid-template-columns: 10px minmax(150px, 1fr) 65px 20px; gap: 10px; }
  .source-status { display: none; }
  .source-editor { padding: 17px; grid-template-columns: 1fr; }
  .source-editor .wide, .source-error { grid-column: auto; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-card { min-height: 100vh; padding: 34px 24px; }
  footer { align-items: flex-start; flex-direction: column; justify-content: center; padding-top: 18px; padding-bottom: 18px; }
}

@media (max-width: 470px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-intro { flex-direction: column; }
  .page-intro form, .page-intro .button { width: 100%; }
  .source-row summary { grid-template-columns: 10px minmax(120px, 1fr) 52px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
