:root {
  --bg: #EEF4FF; --surface: #FFFFFF; --surface-2: #F5F9FF; --line: #C9DBFF; --text: #0B2A8C; --text-2: #33467E; --muted: #5D6E9E;
  --brand: #0B2A8C; --brand-2: #1652D9; --accent: #F68020; --ok: #0E7A43; --ok-bg: #E3F6EC; --err: #B42318; --err-bg: #FDECEC;
  --chip: #EAF2FF; --chip-on: #1652D9; --chip-on-text: #FFFFFF; --star-on: #FFF1E3; --shadow: 0 6px 18px rgba(11, 42, 140, .10);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #081335; --surface: #0F1E4A; --surface-2: #132657; --line: #2A3F7C; --text: #E8EFFF; --text-2: #C3D0F2; --muted: #93A4D4;
    --brand-2: #4D86FF; --accent: #FF9A3D; --ok: #5FD39A; --ok-bg: #0F3A2A; --err: #FF8A80; --err-bg: #3D1717;
    --chip: #172B60; --chip-on: #3D7BFF; --star-on: #3A2410; --shadow: 0 6px 18px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Montserrat, "Segoe UI", Roboto, Arial, sans-serif; font-size: 16px; line-height: 1.45; padding-bottom: env(safe-area-inset-bottom, 0px); }
a { color: var(--brand-2); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.center { text-align: center; }
.muted { color: var(--muted); opacity: .45; }

/* header */
.top { position: sticky; top: 0; z-index: 5; background: linear-gradient(100deg, #0B2A8C 0%, #1652D9 100%); color: #fff; box-shadow: 0 2px 12px rgba(11, 42, 140, .3); padding-top: env(safe-area-inset-top, 0px); }
.top-in { max-width: 820px; margin: 0 auto; padding: 12px 16px 10px; display: flex; align-items: center; gap: 12px; }
.logo-chip { background: #fff; border-radius: 10px; padding: 5px 9px; display: flex; flex-shrink: 0; }
.logo-chip img { display: block; height: 34px; width: auto; }
.top-text { min-width: 0; }
.top-title { font-weight: 800; font-size: 17px; line-height: 1.15; }
.top-sub { font-size: 12.5px; opacity: .88; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { max-width: 820px; margin: 0 auto; padding: 0 12px 10px; display: flex; gap: 6px; overflow-x: auto; }
.tab { flex: 1 0 auto; border-radius: 10px; padding: 9px 12px; font-size: 13.5px; font-weight: 700; background: rgba(255, 255, 255, .14); color: #fff; text-decoration: none; text-align: center; }
.tab[aria-current="page"] { background: #fff; color: #0B2A8C; }

main { max-width: 820px; margin: 0 auto; padding: 16px 16px 120px; }
.narrow { max-width: 460px; margin: 0 auto; }
.foot { text-align: center; color: var(--muted); font-size: 12px; font-weight: 600; padding: 0 16px 110px; }

h1 { font-size: 22px; font-weight: 800; margin: 4px 0 4px; line-height: 1.2; }
h2 { font-size: 15px; font-weight: 800; margin: 0 0 12px; }
.lead-in { color: var(--muted); font-size: 14px; margin: 0 0 16px; font-weight: 500; }
.hint { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.note { border-radius: 12px; padding: 12px 14px; font-size: 14px; font-weight: 600; margin: 0 0 14px; }
.note.err { background: var(--err-bg); color: var(--err); }
.note.ok { background: var(--ok-bg); color: var(--ok); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

/* fields */
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; min-width: 0; }
fieldset.field { border: 0; padding: 0; }
legend, label { font-size: 13.5px; font-weight: 700; color: var(--text-2); }
legend { padding: 0; margin-bottom: 6px; }
.req { color: var(--accent); }
input[type=text], input[type=tel], input[type=email], input[type=search], input[type=password], textarea, select {
  width: 100%; border: 1.5px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 12px 13px; font-size: 16px; font-weight: 600; outline: none;
}
select { appearance: auto; }
input:focus, textarea:focus, select:focus { border-color: var(--brand-2); background: var(--surface); }
input[aria-invalid="true"] { border-color: var(--err); }
.field-err { color: var(--err); font-size: 13px; font-weight: 600; }
textarea { min-height: 96px; resize: vertical; }

/* chips (checkboxes and radios) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-block; border: 1.5px solid var(--line); background: var(--chip); border-radius: 999px; padding: 8px 13px; font-size: 13.5px; font-weight: 700; color: var(--text); user-select: none; }
.chip input:checked + span { background: var(--chip-on); border-color: var(--chip-on); color: var(--chip-on-text); }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* star rating (5 4 3 2 1 in the page, shown 1–5) */
.stars { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; gap: 6px; }
.stars input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.stars label { width: 46px; height: 46px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--chip); font-size: 22px; color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.stars input:checked ~ label { background: var(--star-on); border-color: var(--accent); color: var(--accent); }
.stars input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }
.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--brand-2); font-weight: 700; font-size: 13px; cursor: pointer; align-self: flex-start; }

/* buttons */
.btn { border: 0; border-radius: 12px; padding: 13px 18px; font-weight: 800; font-size: 15.5px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn-primary { background: linear-gradient(100deg, #0B2A8C, #1652D9); color: #fff; }
.btn-primary:disabled { opacity: .55; cursor: wait; }
.btn-ghost { background: var(--chip); color: var(--text); border: 1.5px solid var(--line); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-block { width: 100%; margin-top: 4px; }
.btn-block + .btn-block { margin-top: 10px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--surface); border-top: 1px solid var(--line); padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -6px 18px rgba(11, 42, 140, .10); }
.savebar-in { max-width: 820px; margin: 0 auto; display: flex; gap: 10px; }
.savebar .btn-primary { flex: 1; }

.done { text-align: center; padding: 28px 18px; }
.done-mark { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 12px; background: var(--ok-bg); color: var(--ok); display: flex; align-items: center; justify-content: center; }

/* list */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; }
.filters .field { margin-bottom: 10px; }
.empty { text-align: center; color: var(--muted); font-weight: 600; }
.lead { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--brand-2); border-radius: 14px; padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.lead.contacted { border-left-color: var(--ok); }
.lead.off { opacity: .6; }
.lead-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.lead-co { font-weight: 800; font-size: 16.5px; line-height: 1.2; overflow-wrap: anywhere; }
.lead-person { font-size: 14px; color: var(--text-2); font-weight: 600; margin-top: 2px; }
.lead-time { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.lead-rows { margin: 10px 0 0; display: grid; gap: 4px; }
.lead-rows div { display: grid; grid-template-columns: 110px 1fr; gap: 8px; font-size: 14px; }
.lead-rows dt { color: var(--muted); font-weight: 600; }
.lead-rows dd { margin: 0; color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.lead-rows dd.pre { white-space: pre-line; font-weight: 500; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { font-size: 12px; font-weight: 700; background: var(--chip); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.lead-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.inline { display: inline-flex; gap: 8px; flex-wrap: wrap; margin: 0; }
.reset input { width: 150px; padding: 8px 10px; font-size: 14px; border-radius: 10px; }
.act { border: 1.5px solid var(--line); background: var(--chip); color: var(--text); border-radius: 10px; padding: 8px 12px; font-size: 13.5px; font-weight: 700; text-decoration: none; cursor: pointer; }
.act.ok { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.act.danger { color: var(--err); }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; }
