/* Brand fonts (SIL Open Font License; see fonts/OFL-*.txt). */
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("fonts/Inter-400.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("fonts/Inter-600.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("fonts/Inter-700.ttf") format("truetype"); }
@font-face { font-family: "Source Serif 4"; font-weight: 600; font-display: swap; src: url("fonts/SourceSerif4-600.ttf") format("truetype"); }

/* HOA Line brand: ink, parchment, brass, slate, moss (matches the app). */
:root {
  --ink: #1b2a38;
  --ink-alt: #233748;
  --parchment: #f2ede1;
  --parchment-alt: #eae2d0;
  --brass: #b08d57;
  --brass-dark: #8c6d3f;
  --slate: #5c6b73;
  --moss: #4c7a62;
  --danger: #b3413a;
  --white: #ffffff;
  --line: rgba(27, 42, 56, 0.14);
  --radius: 6px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--parchment); font-size: 15px; line-height: 1.45; }
h1, h2, h3 { font-family: "Source Serif 4", Georgia, serif; font-weight: 600; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--ink); color: var(--parchment);
}
.brand { font-family: "Source Serif 4", Georgia, serif; font-size: 20px; font-weight: 600; }
.brand span { color: var(--brass); font-family: Inter, sans-serif; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; margin-left: 4px; }
#tabs { display: flex; gap: 4px; flex-wrap: wrap; }
#tabs a {
  color: var(--parchment); text-decoration: none; padding: 6px 12px; border-radius: var(--radius);
  display: inline-flex; align-items: center; gap: 6px;
}
#tabs a:hover { background: var(--ink-alt); }
#tabs a.active { background: var(--parchment); color: var(--ink); }
.badge {
  background: var(--brass); color: var(--ink); border-radius: 10px; padding: 0 7px;
  font-size: 12px; font-weight: 700; min-width: 20px; text-align: center;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.community-picker { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.community-picker select { max-width: 220px; }
.topbar .link { color: var(--parchment); }

/* Layout */
main { max-width: 1100px; margin: 0 auto; padding: 24px; }
.view-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.view-head p { margin: 0; color: var(--slate); }
.toolbar { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 14px;
}
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.muted { color: var(--slate); }
.small { font-size: 13px; }
.grid { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0; }
.grid dt { color: var(--slate); }
.grid dd { margin: 0; }
.empty { text-align: center; color: var(--slate); padding: 48px 16px; }
.quote {
  border-left: 3px solid var(--brass); background: var(--parchment); padding: 10px 14px;
  margin: 10px 0; white-space: pre-wrap; border-radius: 0 var(--radius) var(--radius) 0;
}
details { margin: 8px 0; }
summary { cursor: pointer; color: var(--brass-dark); font-weight: 600; }
.turn { margin: 6px 0; white-space: pre-wrap; }
.turn b { color: var(--slate); }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Forms */
label.field { display: block; margin: 10px 0; }
label.field > span { display: block; font-size: 13px; color: var(--slate); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=file], select, textarea {
  font: inherit; color: var(--ink); background: var(--white);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brass); outline-offset: -1px; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.choice {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); margin: 6px 0; cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--brass); background: #fbf8f1; }
.choice.disabled { opacity: .55; cursor: not-allowed; }

button {
  font: inherit; font-weight: 600; border-radius: var(--radius); padding: 8px 16px;
  border: 1px solid var(--ink); background: var(--ink); color: var(--parchment); cursor: pointer;
}
button:hover { background: var(--ink-alt); }
button.secondary { background: transparent; color: var(--ink); }
button.secondary:hover { background: var(--parchment-alt); }
button.danger { background: var(--danger); border-color: var(--danger); }
button.link { background: none; border: none; padding: 0; color: var(--brass-dark); font-weight: 600; }
button.link:hover { text-decoration: underline; background: none; }
button.link.danger-link { color: var(--danger); }
button:disabled { opacity: .55; cursor: wait; }

/* Tables */
table { width: 100%; margin-bottom: 16px; border-collapse: collapse; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--slate); background: #faf8f3; }
tr:last-child td { border-bottom: none; }
td .row { gap: 12px; }

/* Status pills */
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.pill.ready, .pill.answered, .pill.ok { background: rgba(76,122,98,.14); color: var(--moss); }
.pill.queued, .pill.processing, .pill.pending { background: rgba(176,141,87,.18); color: var(--brass-dark); }
.pill.failed, .pill.warn { background: rgba(179,65,58,.12); color: var(--danger); }
.code {
  font-family: ui-monospace, Consolas, monospace; font-size: 18px; letter-spacing: .08em;
  background: var(--parchment); padding: 6px 12px; border-radius: var(--radius); display: inline-block;
}
.result { border: 1px solid var(--moss); background: #f2f7f4; }
.result.warn { border-color: var(--danger); background: #fbf1f0; }

/* Sign-in */
.signin { max-width: 380px; margin: 12vh auto; }
.signin h1 { margin-bottom: 4px; }

/* Toasts */
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.toast { background: var(--ink); color: var(--parchment); padding: 10px 16px; border-radius: var(--radius); max-width: 380px; box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.toast.error { background: var(--danger); }

/* Modal */
dialog { border: none; border-radius: var(--radius); padding: 0; width: min(860px, 94vw); max-height: 86vh; }
dialog::backdrop { background: rgba(27,42,56,.45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--white); }
#modal-body { padding: 16px 20px; }
.passage { border-bottom: 1px solid var(--line); padding: 10px 0; }
.passage pre { white-space: pre-wrap; font: inherit; margin: 6px 0 0; }

/* County check on access requests */
.county-check { border: 1px solid var(--line); border-left: 4px solid var(--brass); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; background: #fbf8f1; }
.county-check.ok { border-left-color: var(--moss); background: #f2f7f4; }
.county-check.warn { border-left-color: var(--danger); background: #fbf1f0; }
.county-check p { margin: 8px 0; }
.county-check .row { gap: 8px; }
.county-matches { margin: 8px 0; font-size: 13.5px; }
.county-matches th, .county-matches td { padding: 8px 10px; }

/* Test chat */
.chat { display: grid; gap: 12px; padding: 0; overflow: hidden; }
.chat-log { display: grid; gap: 12px; align-content: start; padding: 18px 20px 4px; min-height: 320px; max-height: 64vh; overflow-y: auto; }
.chat-msg { max-width: 82%; padding: 10px 14px; border-radius: 12px; overflow-wrap: anywhere; }
.chat-msg.user { justify-self: end; background: var(--ink); color: var(--parchment); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.chat-msg.bot { justify-self: start; background: var(--parchment); border-bottom-left-radius: 4px; display: grid; gap: 8px; }
.chat-answer p { margin: 0 0 6px; }
.chat-answer p:last-child { margin-bottom: 0; }
.chat-answer ul, .chat-answer ol { margin: 0 0 6px; padding-left: 20px; }
.chat-cites { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-cite { font-size: 12px; background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 2px 9px; }
.chat-msg details { margin: 0; }
.chat-msg .passage { border-bottom: 1px solid var(--line); }
.chat-msg .passage.cited { border-left: 3px solid var(--moss); padding-left: 10px; }
.chat-msg .passage pre { font-size: 13px; max-height: 180px; overflow-y: auto; }
.chat-form { display: flex; gap: 10px; align-items: flex-end; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.chat-form textarea { min-height: 44px; }
@media (max-width: 720px) { .chat-msg { max-width: 100%; } }

/* Member directory: county lots drawn as SVG, colored by owner type */
:root {
  --lot-owner: #2e8b6f;
  --lot-away: #d08a1e;
  --lot-company: #b4533a;
  --lot-builder: #5566b0;
  --lot-hoa: #b3cba5;
  --lot-row: #d9ddd6;
  --map-ground: #e8ece7;
}
.dir-lot.t-owner, .dir-sw.t-owner { fill: var(--lot-owner); background: var(--lot-owner); }
.dir-lot.t-away, .dir-sw.t-away { fill: var(--lot-away); background: var(--lot-away); }
.dir-lot.t-company, .dir-sw.t-company { fill: var(--lot-company); background: var(--lot-company); }
.dir-lot.t-builder, .dir-sw.t-builder { fill: var(--lot-builder); background: var(--lot-builder); }
.dir-lot.t-hoa, .dir-sw.t-hoa { fill: var(--lot-hoa); background: var(--lot-hoa); }
.dir-lot.t-row, .dir-sw.t-row { fill: var(--lot-row); background: var(--lot-row); }

.dir-stats { display: flex; flex-wrap: wrap; gap: 6px 26px; margin: 0 0 16px; }
.dir-stats div { display: grid; gap: 2px; }
.dir-stats dt { font-size: 11.5px; color: var(--slate); letter-spacing: .05em; text-transform: uppercase; }
.dir-stats dd { margin: 0; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

.dir-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .dir-main { grid-template-columns: minmax(0, 1fr); } }

.dir-mapbox { position: relative; background: var(--map-ground); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; height: min(74vh, 720px); min-height: 360px; }
.dir-map { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; }
.dir-map.dragging { cursor: grabbing; }
.dir-lot { stroke: var(--white); stroke-width: .6; vector-effect: non-scaling-stroke; cursor: pointer; transition: opacity .15s; }
.dir-lot.dim { opacity: .14; }
.dir-lot:hover { stroke: var(--ink); stroke-width: 1.2; }
.dir-lot.sel { stroke: var(--ink); stroke-width: 2.4; }
.dir-phase { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; opacity: .55; pointer-events: none; }
.dir-phase-label { font-family: Inter, sans-serif; font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: var(--map-ground); stroke-linejoin: round; text-anchor: middle; pointer-events: none; }
.dir-map.phases-off .dir-phases { display: none; }
.dir-mapbox button { position: absolute; background: var(--white); color: var(--ink); border: 1px solid var(--line); font-size: 13px; font-weight: 600; padding: 0 10px; height: 34px; }
.dir-mapbox button:hover { background: var(--parchment); }
.dir-zoom { position: absolute; right: 10px; top: 10px; display: grid; gap: 4px; }
.dir-zoom button { position: static; width: 34px; padding: 0; font-size: 16px; }
.dir-phase-toggle { left: 10px; top: 10px; }
.dir-hint { position: absolute; left: 10px; bottom: 8px; font-size: 11.5px; color: var(--slate); }

.dir-side { display: grid; gap: 12px; }
.dir-side .card { margin: 0; padding: 14px; }
.dir-side label.field { margin: 0 0 10px; }
.dir-legend { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 2px; }
.dir-legend button {
  width: 100%; display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center;
  padding: 6px 8px; background: none; border: 1px solid transparent; color: var(--ink);
  font-weight: 400; font-size: 13.5px; text-align: left;
}
.dir-legend button:hover { background: var(--parchment); }
.dir-legend button[aria-pressed=false] { color: var(--slate); }
.dir-legend button[aria-pressed=false] .dir-sw { opacity: .25; }
.dir-legend small { display: block; font-size: 11.5px; color: var(--slate); }
.dir-sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.dir-n { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--slate); font-variant-numeric: tabular-nums; }

.dir-detail h2 { font-size: 18px; margin-bottom: 8px; }
.dir-detail .grid { grid-template-columns: 84px 1fr; font-size: 13.5px; margin: 10px 0 0; }
.dir-detail dd { overflow-wrap: anywhere; }
.dir-type { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px 2px 7px; border-radius: 10px; background: var(--parchment); }
.dir-type .dir-sw { width: 9px; height: 9px; border-radius: 50%; }

.dir-list-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.dir-list-head button { padding: 4px 10px; font-size: 12.5px; }
.dir-list { max-height: 360px; overflow-y: auto; margin: 10px -14px -14px; border-top: 1px solid var(--line); }
.dir-row {
  display: grid; grid-template-columns: 8px 1fr; gap: 10px; width: 100%; padding: 8px 14px;
  background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  color: var(--ink); font-weight: 400; font-size: 13.5px; text-align: left;
}
.dir-row:hover { background: var(--parchment); }
.dir-row.sel { background: var(--parchment); box-shadow: inset 3px 0 0 var(--brass); }
.dir-row .dir-sw { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; }
.dir-row .small { display: block; }
@media (prefers-reduced-motion: reduce) { .dir-lot { transition: none; } }

@media (max-width: 720px) {
  .topbar { padding: 10px 16px; gap: 12px; }
  .topbar-right { margin-left: 0; }
  main { padding: 16px; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  td { border-bottom: none; padding: 4px 12px; }
  tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
}
.who { font-size: 13px; color: var(--brass); }

/* Orders (owners) */
.pill.active, .pill.current { background: rgba(76,122,98,.14); color: var(--moss); }
.pill.draft, .pill.void, .pill.canceled { background: rgba(92,107,115,.14); color: var(--slate); }
.pill.sent, .pill.accepted, .pill.processing { background: rgba(176,141,87,.18); color: var(--brass-dark); }
.pill.past_due, .pill.unpaid { background: rgba(179,65,58,.12); color: var(--danger); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #faf8f3; }
.order-link { word-break: break-all; font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--parchment); padding: 8px 10px; border-radius: var(--radius); }
.hash { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
