:root {
  --paper: #f3f0e8;
  --paper-2: #ece8dd;
  --card: #fffdf8;
  --ink: #17160f;
  --ink-2: #4b483d;
  --muted: #908c7d;
  --line: #e2dcc9;
  --line-2: #d3cdb8;
  --accent: #e8401f;
  --accent-press: #c8350f;
  --accent-soft: #fbe6de;
  --green: #2f8f4e;
  --green-soft: #e2efe4;
  --red: #c0392b;
  --red-soft: #f7e3e0;
  --amber: #a76a15;
  --amber-soft: #f6ecd6;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(23, 22, 15, 0.04);
  --shadow: 0 2px 4px rgba(23, 22, 15, 0.04), 0 18px 40px -26px rgba(23, 22, 15, 0.4);
  --display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Space Mono', ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(23, 22, 15, 0.045) 1px, transparent 0);
  background-size: 22px 22px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
code {
  background: var(--paper-2); padding: 2px 6px; border-radius: 5px;
  font-size: 0.85em; font-family: var(--mono); border: 1px solid var(--line);
}
::selection { background: var(--accent); color: #fff; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: rgba(243, 240, 232, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark { width: 38px; height: 38px; flex-shrink: 0; }
.brand .mark svg, .brand .mark img { width: 100%; height: 100%; display: block; }
.brand .word {
  font-family: var(--display); font-weight: 700; font-size: 18px;
  letter-spacing: -0.02em; line-height: 1; text-transform: uppercase;
}
.brand .word b { color: var(--accent); font-weight: 700; }
.brand .word .sub {
  display: block; font-family: var(--mono); font-size: 9.5px; font-weight: 400;
  letter-spacing: 0.16em; color: var(--muted); margin-top: 3px; text-transform: uppercase;
}
.topbar nav { display: flex; gap: 10px; align-items: center; }

.container { max-width: 920px; margin: 0 auto; padding: 36px 24px 90px; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink);
  padding: 9px 15px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600;
  font-family: inherit; transition: all 0.14s ease; white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: var(--ink); }
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 2px 0 var(--accent-press);
}
.btn-primary:hover { background: var(--accent-press); border-color: var(--accent-press); transform: translateY(1px); box-shadow: 0 1px 0 var(--accent-press); }
.btn-ghost { background: transparent; box-shadow: none; border-color: var(--line-2); }
.btn-ghost:hover { background: var(--card); }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: var(--red-soft); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }

/* ── Page head ──────────────────────────────────────────── */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 28px; gap: 16px;
  padding-bottom: 20px; border-bottom: 1px solid var(--line);
}
.page-head h1 { font-family: var(--display); font-size: 28px; font-weight: 700; letter-spacing: -0.025em; }
.page-head p { color: var(--ink-2); font-size: 14px; margin-top: 6px; }

/* ── Banner ─────────────────────────────────────────────── */
.banner {
  padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 24px;
  font-size: 13.5px; display: flex; gap: 10px; align-items: center;
}
.banner-warn { background: var(--amber-soft); border: 1px solid #e7d4a8; color: var(--amber); }
.banner svg { width: 17px; height: 17px; flex-shrink: 0; }

/* ── Alert cards ────────────────────────────────────────── */
.cards { display: grid; gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.card-off { opacity: 0.62; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-top h3 { font-family: var(--display); font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }

.badge {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700; padding: 4px 10px;
  border-radius: 6px; text-transform: uppercase; letter-spacing: 0.05em;
  display: inline-flex; align-items: center; gap: 6px;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-on { background: var(--green-soft); color: var(--green); }
.badge-off { background: var(--paper-2); color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 16px 0 4px; }
.chip {
  font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 7px;
  background: var(--paper); border: 1px solid var(--line); color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 7px;
}
.chip-site { background: var(--ink); border-color: var(--ink); color: #f3f0e8; }
.chip-site.pending { background: var(--paper); border-color: var(--line-2); color: var(--muted); }
.chip .chip-logo { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.chip-site.pending .dot { background: var(--muted); }
.chip-filter { font-family: var(--mono); font-size: 11px; }

.card-meta {
  display: flex; flex-wrap: wrap; gap: 18px; color: var(--ink-2);
  font-size: 12.5px; margin: 16px 0; padding-top: 16px; border-top: 1px solid var(--line);
}
.card-meta span { display: inline-flex; align-items: center; gap: 6px; }
.card-meta svg { width: 14px; height: 14px; color: var(--muted); }

.card-status { font-size: 12px; color: var(--muted); margin-bottom: 16px; font-family: var(--mono); }
.card-status .ok { color: var(--green); }
.card-status .err { color: var(--red); }
.card-status .neutral { color: var(--ink-2); }

.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-actions form { margin: 0; }

/* ── Empty ──────────────────────────────────────────────── */
.empty {
  text-align: center; padding: 76px 20px;
  border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--card);
}
.empty .ico {
  width: 58px; height: 58px; margin: 0 auto 20px; border-radius: 16px;
  background: var(--ink); display: grid; place-items: center;
}
.empty .ico svg { width: 27px; height: 27px; stroke: var(--accent); }
.empty h2 { font-family: var(--display); font-size: 19px; font-weight: 600; margin-bottom: 7px; }
.empty p { color: var(--ink-2); font-size: 14px; margin-bottom: 22px; }

/* ── Forms ──────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 18px; max-width: 720px; }
.fieldset {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm);
}
.fieldset > .legend { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.fieldset > .legend .n {
  width: 25px; height: 25px; border-radius: 7px; background: var(--ink);
  color: var(--accent); font-family: var(--mono); font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
.fieldset > .legend h3 { font-family: var(--display); font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.fieldset > .hint { color: var(--muted); font-size: 12.5px; margin: 0 0 18px 36px; }

label { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; font-weight: 600; }
label .lbl { color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px; font-family: var(--mono); }
input, textarea, select {
  background: var(--paper); border: 1px solid var(--line-2); color: var(--ink);
  padding: 11px 13px; border-radius: var(--radius-sm); font-size: 14px;
  font-family: inherit; font-weight: 500; transition: border-color 0.14s, box-shadow 0.14s;
  width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted); font-weight: 400; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--card);
}
select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23908c7d' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── Site selector ──────────────────────────────────────── */
.site-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.site-opt {
  position: relative; cursor: pointer; border: 1.5px solid var(--line-2);
  border-radius: var(--radius-sm); padding: 14px 15px; background: var(--paper);
  transition: all 0.14s ease; display: flex; align-items: center; gap: 12px;
}
.site-opt:hover { border-color: var(--ink); }
.site-opt input { position: absolute; opacity: 0; pointer-events: none; }
.site-opt .site-logo { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; box-shadow: var(--shadow-sm); object-fit: cover; }
.site-opt .info { flex: 1; }
.site-opt .check {
  width: 21px; height: 21px; border-radius: 6px; border: 1.5px solid var(--line-2);
  background: var(--card); flex-shrink: 0; display: grid; place-items: center; transition: all 0.14s;
}
.site-opt .check svg { width: 13px; height: 13px; stroke: #fff; opacity: 0; }
.site-opt .info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.site-opt .info .name { font-family: var(--display); font-weight: 600; font-size: 14.5px; }
.site-opt .info .meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.site-opt .tag {
  margin-left: auto; font-family: var(--mono); font-size: 9.5px; font-weight: 700; padding: 3px 8px;
  border-radius: 5px; text-transform: uppercase; letter-spacing: 0.05em;
}
.site-opt .tag.ready { background: var(--green-soft); color: var(--green); }
.site-opt .tag.soon { background: var(--amber-soft); color: var(--amber); }
.site-opt:has(input:checked) { border-color: var(--ink); background: var(--card); }
.site-opt:has(input:checked) .check { background: var(--accent); border-color: var(--accent); }
.site-opt:has(input:checked) .check svg { opacity: 1; }

/* ── Switch ─────────────────────────────────────────────── */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch-row .txt .t { font-family: var(--display); font-weight: 600; font-size: 15px; }
.switch-row .txt .d { color: var(--ink-2); font-size: 12.5px; margin-top: 3px; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--paper-2); border: 1px solid var(--line-2);
  border-radius: 999px; transition: 0.2s; cursor: pointer;
}
.switch .slider::before {
  content: ''; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: var(--muted); border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); background: #fff; }

/* ── Preview ────────────────────────────────────────────── */
.preview { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.pv {
  border-radius: var(--radius-sm); padding: 11px 14px; font-size: 13px;
  border: 1px solid var(--line); background: var(--paper);
}
.pv-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.pv-head span:last-child { font-family: var(--mono); font-size: 11.5px; }
.pv.ok { border-color: #bfe0c6; background: var(--green-soft); }
.pv.ok .pv-head { color: var(--green); }
.pv.err { border-color: #e9c4bf; background: var(--red-soft); }
.pv.err .pv-head { color: var(--red); }
.pv.soon { background: var(--amber-soft); border-color: #e7d4a8; }
.pv.soon .pv-head { color: var(--amber); }
.pv ul { margin: 8px 0 0; padding-left: 17px; color: var(--ink-2); font-size: 12.5px; }
.pv li { margin: 2px 0; }

.form-actions { display: flex; gap: 12px; align-items: center; padding-top: 4px; }
.advanced > summary {
  cursor: pointer; color: var(--ink-2); font-size: 13px; font-weight: 600;
  list-style: none; display: flex; align-items: center; gap: 7px; user-select: none;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary svg { width: 14px; height: 14px; transition: transform 0.2s; }
.advanced[open] > summary svg { transform: rotate(90deg); }
.advanced .body { margin-top: 12px; }
.muted { color: var(--muted); font-weight: 400; }

/* ── Login ──────────────────────────────────────────────── */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  padding: 40px 36px; width: 360px; text-align: center;
}
.login-card .mark { width: 56px; height: 56px; margin: 0 auto 20px; }
.login-card .mark svg, .login-card .mark img { width: 100%; height: 100%; }
.login-card h1 { font-family: var(--display); font-size: 24px; font-weight: 700; text-transform: uppercase; letter-spacing: -0.01em; }
.login-card h1 b { color: var(--accent); }
.login-card .tag { font-family: var(--mono); color: var(--muted); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; margin: 8px 0 26px; }
.login-card input { text-align: center; margin-bottom: 13px; }
.alert-error {
  background: var(--red-soft); color: var(--red); padding: 9px;
  border-radius: var(--radius-sm); font-size: 12.5px; margin-bottom: 13px;
}

/* ── Listings ───────────────────────────────────────────── */
.listing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.listing {
  display: flex; flex-direction: column; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); transition: transform 0.14s, box-shadow 0.14s, border-color 0.14s;
}
.listing:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-2); }
.listing-img { aspect-ratio: 4 / 3; background: var(--paper-2); overflow: hidden; position: relative; }
.listing-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.listing-img .noimg { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); }
.listing-img .noimg svg { width: 32px; height: 32px; }
.listing-body { padding: 13px 14px 14px; display: flex; flex-direction: column; gap: 5px; }
.listing-title {
  font-family: var(--display); font-weight: 600; font-size: 13.5px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.listing-price {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--accent);
}
.listing-site-dot {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover; border: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.listing-meta { display: flex; flex-wrap: wrap; gap: 8px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-2); }
.listing-meta span { display: inline-flex; }
.listing-meta span + span::before { content: '·'; margin-right: 8px; color: var(--line-2); }
.listing-date { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 3px; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 880px) { .listing-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) {
  .grid-2, .grid-3, .site-grid, .field-pair, .listing-grid { grid-template-columns: 1fr; }
  .container { padding: 24px 16px 60px; }
  .topbar { padding: 12px 16px; }
  .brand .word .sub { display: none; }
}
