:root {
  --ink: #192e25;
  --muted: #53635a;
  --green: #24573d;
  --green-dark: #173b2c;
  --lime: #dceda9;
  --bg: #f5f6f0;
  --paper: #fff;
  --line: #dce4d8;
  --soft: #ebf0e6;
  --warning: #795111;
  --danger: #a03c2c;
  color-scheme: light;
  font: 15px/1.5 "DM Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.95rem, 3vw, 2.9rem); line-height: 1.07; letter-spacing: -.045em; }
h2 { font-size: 1.23rem; line-height: 1.23; letter-spacing: -.025em; }
h3 { font-size: 1.04rem; line-height: 1.35; }
a { color: var(--green); text-underline-offset: .2em; }
a, p, dd, h1, h2, h3, summary { overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; }
button, summary, select { cursor: pointer; }
button:disabled { opacity: .46; cursor: default; }
:focus-visible { outline: 3px solid #578644; outline-offset: 3px; }
.small, small { font-size: .83rem; }
.muted { color: var(--muted); }
.primary, .secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 42px;
  padding: .53rem .85rem; border: 1px solid var(--line); border-radius: .6rem; font-weight: 640;
  color: var(--ink); background: var(--paper); text-decoration: none; text-align: center; line-height: 1.3;
}
.primary { color: #fff; background: var(--green); border-color: var(--green); }
.primary:hover:not(:disabled) { background: var(--green-dark); }
.secondary:hover:not(:disabled) { border-color: #adbfaa; background: var(--soft); }
.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 5; background: var(--paper); padding: .7rem; }
.skip-link:focus { top: 1rem; }
.brand {
  color: var(--green-dark); display: flex; align-items: center; gap: .55rem; width: fit-content;
  font-size: 2rem; letter-spacing: -.07em; line-height: 1; text-decoration: none;
}
.brand span { color: #66904b; }
.brand img { border-radius: .55rem; }
.radar-page { display: grid; grid-template-columns: 223px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column;
  gap: 2rem; padding: 1.9rem 1.25rem 1.25rem; background: var(--paper); border-right: 1px solid var(--line);
}
.sidebar nav { display: grid; gap: .35rem; }
.sidebar nav a {
  display: flex; align-items: center; gap: .6rem; min-height: 42px; color: var(--muted);
  text-decoration: none; font-weight: 610; border-radius: .55rem; padding: .42rem .65rem;
}
.sidebar nav a[aria-current="page"], .sidebar nav a:hover { color: var(--green-dark); background: var(--soft); }
.sidebar nav a span { font-size: 1.35rem; line-height: 1; width: 1.24em; text-align: center; flex: none; }
.sidebar nav small { margin-left: auto; }
.sidebar > button { margin-top: auto; font-size: .85rem; }
.workspace { width: 100%; max-width: 1520px; margin: 0 auto; min-width: 0; padding: 0 clamp(1rem, 4vw, 3.75rem) 3rem; }
.topbar, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: .85rem 1.5rem; }
.topbar { min-height: 70px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.topbar p { min-width: 0; }
.topbar button, .section-heading > button { flex: none; }
.section-heading { margin: 1.65rem 0 1.4rem; align-items: flex-end; }
.section-heading p { color: var(--muted); margin-top: .48rem; max-width: 57ch; }
.section-heading #watch-back { display: inline-block; margin-bottom: .55rem; }
.sync-status { color: var(--danger); min-height: 0; padding-top: .35rem; }
.sync-status:empty { padding: 0; }
.watch-grid, .offer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 252px), 1fr)); gap: .85rem; }
.watch-card, .watch-row, .offer-card, .panel, .empty {
  background: var(--paper); border: 1px solid var(--line); border-radius: .84rem; min-width: 0;
}
.watch-card { display: grid; align-content: space-between; position: relative; padding: .95rem 1rem 1rem; gap: .7rem; }
.watch-card h2 a, .watch-row h3 a { color: var(--ink); }
.watch-card p, .watch-row p { color: var(--muted); font-size: .88rem; }
.watch-card header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.watch-card footer, .button-row, .dialog-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.watch-card footer { justify-content: space-between; }
.watch-count { display: inline-flex; align-items: center; border-radius: 2rem; padding: .23rem .6rem; color: var(--green-dark); background: var(--lime); font-weight: 700; font-size: .83rem; }
.badge { display: inline-block; color: var(--green); background: var(--soft); border-radius: .4rem; padding: .12rem .42rem; font-size: .8rem; font-weight: 620; }
.badge.warning { background: #fbf0d8; color: var(--warning); }
.badge.error { background: #fae9e4; color: var(--danger); }
.empty { padding: 1.2rem; grid-column: 1 / -1; }
.empty p { color: var(--muted); margin-top: .25rem; }
.panel { margin-top: 1rem; padding: .95rem 1rem; }
.panel h2 + *, .panel summary + * { margin-top: .55rem; }
.global-sources { margin-top: 1.3rem; }
.source-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 162px), 1fr)); gap: .8rem; }
.source-cell { min-width: 0; display: grid; align-content: start; gap: .22rem; padding-top: .55rem; }
.source-cell small { color: var(--muted); }
.source-cell .badge { justify-self: start; }
.watch-list { display: grid; gap: .58rem; }
.watch-row { display: flex; justify-content: space-between; align-items: center; gap: .65rem; padding: .8rem; }
.watch-row p { margin-top: .2rem; }
.watch-list .button-row { flex: none; font-size: .82rem; }
.watch-list .button-row button { min-height: 38px; }
.filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: .7rem; margin-top: 1rem; }
.filters .check-label { margin-bottom: .55rem; }
.search-field { flex: 1 1 230px; }
label { display: grid; min-width: 0; gap: .27rem; font-weight: 620; font-size: .88rem; }
input:not([type="checkbox"]):not([type="file"]), textarea, select {
  display: block; min-width: 0; width: 100%; min-height: 42px; border: 1px solid #cbd7ca;
  border-radius: .48rem; color: var(--ink); background: var(--paper); padding: .5rem .6rem;
}
textarea { resize: vertical; }
.check-label { display: flex; align-items: center; gap: .38rem; }
input[type=checkbox] { flex: 0 0 auto; margin: 0; width: 1rem; height: 1rem; accent-color: var(--green); }
.file-button { position: relative; cursor: pointer; }
.file-button input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.file-button:focus-within { outline: 3px solid #578644; outline-offset: 3px; }
.result-count { color: var(--muted); margin-top: 1.15rem; margin-bottom: .5rem; }
.offer-card { display: grid; overflow: hidden; align-content: start; }
.offer-photo { position: relative; display: grid; place-items: center; min-height: 105px; background: var(--soft); }
.offer-photo img { display: block; width: 100%; height: 133px; object-fit: contain; }
.offer-photo span { font-size: .85rem; color: var(--muted); }
.favorite { position: absolute; right: .65rem; top: .65rem; width: 42px; font-size: 1.25rem; padding: .35rem; }
.offer-content { display: grid; align-content: start; gap: .55rem; padding: .85rem; }
.offer-content header { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.offer-content .price { font-size: 1.4rem; color: var(--green-dark); font-weight: 800; }
.offer-content .spec-text { color: var(--muted); font-size: .85rem; }
.market-links, .market-history { display: grid; gap: .55rem; }
.market-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem; font-size: .87rem; padding: .2rem 0; border-top: 1px solid var(--line); }
.market-line a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .5rem 0 0; }
.watch-counts { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.watch-recent { display: inline-flex; align-items: center; min-height: 44px; font-size: .83rem; font-weight: 620; }
.pagination { display: flex; align-items: center; justify-content: center; gap: .65rem; margin-top: 1rem; }
.alerts-list { list-style: none; display: grid; gap: .6rem; padding: 0; }
.alerts-list li { display: grid; gap: .15rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.alerts-list small { color: var(--muted); }
dialog {
  width: min(660px, calc(100% - 1.45rem)); max-height: min(88vh, 880px); max-height: min(88dvh, 880px);
  margin: auto; padding: 1rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--paper); color: var(--ink);
  overflow: auto; box-shadow: 0 24px 90px #142c2438;
}
dialog::backdrop { background: #142c2480; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: 1rem; }
.dialog-heading h2 { font-size: 1.48rem; }
.dialog-heading button { flex: none; }
.dialog-actions { margin-top: .65rem; justify-content: flex-end; }
dialog p + *, dialog fieldset + * { margin-top: .5rem; }
.form-grid, .checkbox-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.form-grid .wide { grid-column: 1 / -1; }
fieldset { margin: .9rem 0; min-width: 0; border: 1px solid var(--line); border-radius: .55rem; padding: .55rem .65rem; }
legend, summary { font-weight: 690; }
fieldset .muted, .form-advanced .muted { font-size: .85rem; margin-bottom: .55rem; }
.form-advanced { border-top: 1px solid var(--line); padding: .65rem 0; }
.form-advanced > * + * { margin-top: .65rem; }
#watch-error { color: var(--danger); }
.watch-options { padding: .55rem 0; }
.key-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: .65rem 0; }
.toast { position: fixed; z-index: 3; inset: auto 1rem max(1rem, env(safe-area-inset-bottom)) auto; max-width: calc(100vw - 2rem); padding: .7rem .95rem; background: var(--green-dark); color: white; border-radius: .6rem; }
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-card { width: min(100%, 430px); padding: clamp(1rem, 5vw, 2rem); background: var(--paper); border: 1px solid var(--line); border-radius: 1rem; }
.login-card > * + *, .login-card form > * + * { margin-top: .75rem; }
.login-card .sub, .login-card .hint, .login-divider { color: var(--muted); font-size: .9rem; }
.login-card h1 span, .login-card .eyebrow { color: var(--green); }
.login-card .primary { width: 100%; }
@media (max-width: 900px) {
  .radar-page { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: .45rem; padding: .75rem max(1rem, env(safe-area-inset-right)) .5rem max(1rem, env(safe-area-inset-left)); }
  .sidebar nav { grid-column: 1 / -1; grid-row: 2; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .2rem; }
  .sidebar nav a { justify-content: center; text-align: center; }
  .sidebar > button { margin-top: 0; }
}
@media (max-width: 590px) {
  :root { font-size: 14px; }
  .sidebar nav a { flex-direction: column; gap: .12rem; padding: .32rem .12rem; font-size: .73rem; line-height: 1.15; min-height: 49px; }
  .sidebar nav small { display: none; }
  .sidebar nav a span { font-size: 1.2rem; }
  .section-heading, .watch-row { align-items: flex-start; flex-direction: column; }
  .topbar { min-height: 59px; }
  .watch-list .button-row { width: 100%; }
  .watch-list .button-row button { min-height: 40px; }
  .workspace { padding-inline: 1rem; }
  .watch-grid, .offer-grid { grid-template-columns: 1fr; }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
  .filters .search-field { grid-column: 1 / -1; }
  .filters .check-label { margin: 0; }
  input:not([type="checkbox"]):not([type="file"]), textarea, select { font-size: 16px; }
}
@media (max-width: 360px) {
  .checkbox-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
