:root {
  --orange: #ef4e23;
  --amber: #f9a51a;
  --teal: #149a9d;
  --magenta: #9f1d51;
  --ink: #151515;
  --ink-2: #3a3a3a;
  --muted: #6f6f6f;
  --line: #e6e6e6;
  --bg: #f5f5f3;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Montserrat", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; }

/* ---------- top bar ---------- */
.topbar { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 1000; }
.topbar-inner {
  max-width: 1440px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: #fff; }
.logo { height: 34px; width: auto; display: block; filter: brightness(1.15); }
.brand-divider { width: 1px; height: 26px; background: #444; }
.brand-product { font-weight: 700; font-size: 17px; letter-spacing: .02em; }

.event-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field span { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #a8a8a8; }
.field input, .field select {
  background: #242424; color: #fff; border: 1px solid #383838; border-radius: 8px;
  padding: 8px 10px; font-size: 13px; font-weight: 500; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--orange); }
.field-place input { width: 160px; }
.field-num input { width: 104px; }
.field-time input { width: 190px; color-scheme: dark; }

.btn {
  border: 0; border-radius: 8px; padding: 9px 16px; font-weight: 700; font-size: 13px;
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: #d9411a; }
.btn-ghost { background: transparent; border: 1px solid #cfcfcf; color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }

.tabs { display: flex; gap: 4px; background: #242424; border-radius: 9px; padding: 3px; }
.tabs a { color: #bdbdbd; text-decoration: none; font-weight: 700; font-size: 13px; padding: 6px 14px; border-radius: 7px; }
.tabs a.on { background: var(--orange); color: #fff; }
.tabs a:not(.on):hover { color: #fff; }

/* ---------- layout ---------- */
.report { max-width: 1440px; margin: 0 auto; padding: 28px 24px 48px; display: flex; flex-direction: column; gap: 20px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 6px; color: var(--orange); font-weight: 700; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.hero h1 { margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -.01em; }
.subtitle { margin: 6px 0 0; color: var(--muted); font-weight: 500; }
.hero-actions { display: flex; gap: 8px; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); border-top: 4px solid var(--line); }
.kpi:nth-child(1) { border-top-color: var(--magenta); }
.kpi:nth-child(2) { border-top-color: var(--orange); }
.kpi:nth-child(3) { border-top-color: var(--amber); }
.kpi:nth-child(4) { border-top-color: var(--teal); }
.kpi:nth-child(5) { border-top-color: var(--ink); }
.kpi:nth-child(6) { border-top-color: #8b8b8b; }
.kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.kpi-value { font-size: 28px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.threshold-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.threshold-label { font-weight: 700; font-size: 13px; }
.threshold-hint { color: var(--muted); font-size: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid #d4d4d4; background: #fff; color: var(--ink-2); padding: 6px 13px;
  border-radius: 999px; font-weight: 700; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
}
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); gap: 20px; }
.side { display: flex; flex-direction: column; gap: 20px; }
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .01em; }
.tag { font-size: 11px; font-weight: 600; color: var(--muted); background: #f1f1f0; padding: 3px 9px; border-radius: 999px; }
.card-note { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- map ---------- */
.map-card { display: flex; flex-direction: column; }
#map { height: 560px; border-radius: 10px; overflow: hidden; background: #e9e9e6; }
.map-tools { display: flex; align-items: center; gap: 14px; }
.seg { display: inline-flex; border: 1px solid #d4d4d4; border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 5px 11px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--ink); color: #fff; }
.opacity { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.opacity input { accent-color: var(--orange); width: 90px; }

.legend { display: flex; align-items: center; gap: 0; margin-top: 12px; flex-wrap: wrap; row-gap: 8px; }
.legend .ttl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-right: 10px; }
.legend .sw { display: flex; flex-direction: column; align-items: center; min-width: 46px; }
.legend .sw b { display: block; width: 100%; height: 12px; }
.legend .sw:first-of-type b { border-radius: 6px 0 0 6px; }
.legend .sw:last-of-type b { border-radius: 0 6px 6px 0; }
.legend .sw span { font-size: 11px; font-weight: 600; margin-top: 3px; color: var(--ink-2); }
.legend .extra { display: inline-flex; align-items: center; gap: 6px; margin-left: 18px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.legend .dash { width: 22px; border-top: 3px dashed var(--orange); }
.legend .dot { width: 12px; height: 12px; border-radius: 50%; background: #127a3e; border: 2px solid #fff; box-shadow: 0 0 0 1px #127a3e; }

.event-pin { background: none; border: 0; }
.event-pin div {
  width: 22px; height: 22px; border-radius: 50% 50% 50% 0; background: var(--orange);
  transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.place-label {
  background: rgba(255,255,255,.92); border: 0; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.2);
  font-family: "Montserrat", sans-serif; font-weight: 700; font-size: 11px; color: var(--ink); padding: 2px 7px;
}
.place-label::before { display: none; }
.leaflet-container { font-family: "Montserrat", sans-serif; }
.leaflet-tooltip, .leaflet-popup-content { font-family: "Montserrat", sans-serif; font-size: 12px; }

/* ---------- bars ---------- */
.big-num { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.big-sub { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 56px; align-items: center; gap: 10px; font-size: 12px; }
.bar-row .lbl { font-weight: 600; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .track { display: block; height: 10px; background: #f0f0ee; border-radius: 6px; overflow: hidden; }
.bar-row .fill { display: block; height: 100%; background: var(--orange); border-radius: 6px; }
.bar-row .val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.income-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.income-stats .big-num { font-size: 26px; }
.hist { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding-top: 4px; }
.hist div { flex: 1; background: var(--teal); border-radius: 3px 3px 0 0; min-height: 1px; position: relative; }
.hist div:hover { background: var(--orange); }
.hist-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); font-weight: 600; margin-top: 4px; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; max-height: 420px; overflow-y: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; white-space: nowrap;
}
table.data td { padding: 9px 10px; border-bottom: 1px solid #f1f1f0; font-variant-numeric: tabular-nums; }
table.data td.num, table.data th.num { text-align: right; }
table.data tr.sel td { background: #fff4ef; }
table.data tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--orange); }
.size-pill { display: inline-block; min-width: 46px; text-align: center; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 12px; color: #fff; }
.muted { color: var(--muted); }

.method h2 { margin-bottom: 8px; }
.method p, .method li { color: var(--ink-2); font-size: 12.5px; }
.method ul { padding-left: 18px; margin: 0 0 10px; }
.errors { color: var(--magenta); font-weight: 600; }
.foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; padding-top: 6px; }
.foot-logo { height: 24px; }

/* ---------- loading / errors ---------- */
.loading { position: fixed; inset: 0; top: 70px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: rgba(245,245,243,.85); z-index: 900; }
.loading p { font-weight: 700; font-size: 16px; margin: 12px 0 0; }
.loading small { color: var(--muted); }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid #e2e2e2; border-top-color: var(--orange); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { max-width: 720px; margin: 40px auto; background: #fff; border-left: 4px solid var(--magenta); padding: 16px 20px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 600; }
[hidden] { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
  .side { display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .topbar-inner { padding: 12px 16px; }
  .event-form { margin-left: 0; }
  .report { padding: 20px 16px 40px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side, .grid-two { grid-template-columns: 1fr; display: grid; }
  #map { height: 420px; }
  .hero h1 { font-size: 24px; }
}

/* ---------- print ---------- */
@media print {
  @page { size: letter; margin: 12mm; }
  body { background: #fff; font-size: 11px; }
  .topbar { position: static; background: #fff; color: var(--ink); border-bottom: 2px solid var(--orange); }
  .event-form, .hero-actions, .map-tools, .threshold-hint, .tabs, .no-print { display: none !important; }
  .logo { filter: none; }
  .brand-product { color: var(--ink); }
  .brand-divider { background: #ccc; }
  .report { padding: 12px 0; gap: 12px; }
  .card, .kpi { box-shadow: none; border: 1px solid var(--line); break-inside: avoid; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid-main { grid-template-columns: 1fr; }
  .side, .grid-two { display: grid; grid-template-columns: 1fr 1fr; }
  #map { height: 430px; }
  .table-wrap { max-height: none; overflow: visible; }
  .chip:not(.on) { display: none; }
}

/* ---------- accounts, credits, saved reports ---------- */
.account { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.topbar .event-form { flex-basis: 100%; justify-content: flex-end; margin-left: 0; }
.credit-pill { color: #fff; text-decoration: none; font-weight: 700; font-size: 12px; padding: 6px 12px; border-radius: 999px; background: #2b2b2b; border: 1px solid #3c3c3c; white-space: nowrap; }
.credit-pill:hover { border-color: var(--orange); }
.credit-pill.empty { background: var(--magenta); border-color: var(--magenta); }
#org-switcher .cl-organizationSwitcherTrigger, #org-switcher button { color: #fff; }
.dev-user { font-size: 11px; font-weight: 700; color: var(--amber); }
.saved-note { margin: 4px 0 0; font-size: 12px; font-weight: 600; color: var(--teal); }
.saved-note:empty { display: none; }

.intro { max-width: 760px; margin: 64px auto; padding: 0 24px; }
.intro h1 { font-size: 30px; font-weight: 800; margin: 0 0 12px; }
.intro p { font-size: 15px; color: var(--ink-2); }
.intro .muted, .muted { color: var(--muted); }
.intro a, .gate a, .banner a, .empty a { color: var(--orange); font-weight: 700; }

.gate { max-width: 1040px; margin: 56px auto; padding: 0 24px; display: grid; grid-template-columns: 1fr auto; gap: 48px; align-items: center; }
.gate h1 { font-size: 32px; font-weight: 800; margin: 0 0 12px; }
.gate p { font-size: 15px; color: var(--ink-2); }

dialog.hr-dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: 460px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25); font-family: inherit; color: var(--ink); }
dialog.hr-dialog::backdrop { background: rgba(21,21,21,.45); }
.hr-dialog-body { padding: 22px 24px 8px; }
.hr-dialog-body h3 { margin: 0 0 10px; font-size: 18px; font-weight: 800; }
.hr-dialog-body p { margin: 0 0 10px; font-size: 14px; }
.hr-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px 20px; }
.hr-dialog-actions a { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-sm { padding: 5px 12px; font-size: 12px; text-decoration: none; display: inline-block; }
a.btn { text-decoration: none; display: inline-block; }

.banner { border-radius: 10px; padding: 12px 16px; font-weight: 600; background: #fff; box-shadow: var(--shadow); border-left: 4px solid var(--teal); }
.banner.warn { border-left-color: var(--amber); }
.reports-grid { grid-template-columns: 2fr 1fr; align-items: start; }
.reports-grid .side { display: flex; }
.credit-big { font-size: 44px; font-weight: 800; line-height: 1; }
.credit-big span { font-size: 14px; font-weight: 700; color: var(--muted); margin-left: 8px; }
.lots { list-style: none; padding: 0; margin: 12px 0 0; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.plan { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; font: inherit; color: var(--ink); text-decoration: none; }
.plan:hover { border-color: var(--orange); box-shadow: 0 0 0 1px var(--orange); }
.plan-name { font-weight: 800; font-size: 15px; }
.plan-price { font-weight: 800; font-size: 18px; color: var(--orange); grid-row: span 2; align-self: center; }
.plan-each { font-size: 12px; color: var(--muted); font-weight: 600; }
.plan-contact { background: #f6f6f4; }
.kind { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 6px; color: #fff; background: var(--teal); margin-right: 4px; }
.kind.property { background: var(--orange); }
td.expiring { color: var(--magenta); font-weight: 700; }

@media (max-width: 900px) {
  .gate { grid-template-columns: 1fr; }
  .reports-grid { grid-template-columns: 1fr; }
}
@media print {
  .account, .saved-note, .intro { display: none !important; }
}

/* ---------- lightning (area and property pages) ---------- */
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.toggle input { accent-color: var(--orange); }
.legend .ltg-ramp { width: 40px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, hsl(48,100%,62%), hsl(10,100%,40%)); box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.ltg-grid { display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; gap: 24px; align-items: center; }
.ltg-stats { display: grid; gap: 10px; }
.ltg-stats div { background: #f6f6f4; border-radius: 10px; padding: 10px 12px; }
.ltg-stats span { display: block; font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ltg-stats b { display: block; font-size: 22px; font-weight: 800; margin: 2px 0; }
.ltg-stats small { display: block; font-size: 12px; color: var(--muted); }
.ltg-bars { width: 100%; height: 170px; display: block; }
.ltg-bars text { font-family: "Montserrat", sans-serif; font-size: 10px; fill: #6f6f6f; font-weight: 600; }
.ltg-bars .evt { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 3 3; }
.ltg-key { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.ltg-key span { display: inline-flex; align-items: center; gap: 6px; }
.ltg-key i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.ltg-key i.evt { width: 14px; height: 0; border-top: 2px dashed var(--ink); border-radius: 0; }
@media (max-width: 900px) { .ltg-grid { grid-template-columns: 1fr; } }
@media print { .toggle { display: none; } }
