:root {
  --ink: #102b2d;
  --muted: #657879;
  --faint: #8fa0a0;
  --paper: #ffffff;
  --canvas: #f3f7f6;
  --nav: #092b2d;
  --nav-soft: #123b3d;
  --aqua: #58c3bf;
  --aqua-soft: #dff5f3;
  --blue: #1677ff;
  --blue-soft: #eaf2ff;
  --amber: #c27816;
  --amber-soft: #fff2d9;
  --red: #c64848;
  --red-soft: #ffecec;
  --green: #25845f;
  --green-soft: #e4f5ed;
  --line: #dce6e4;
  --shadow: 0 12px 32px rgba(16, 43, 45, 0.08);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; color: #d7eeee; background: linear-gradient(180deg, #092b2d, #061f21); display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; color: white; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-weight: 850; letter-spacing: -.04em; color: var(--nav); background: linear-gradient(145deg, #b8efec, #58c3bf); box-shadow: 0 8px 20px rgba(88,195,191,.2); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; }
.brand small { margin-top: 2px; color: #87aaa9; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }

.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 13px; border-radius: 11px; color: #a9c6c5; text-decoration: none; font-weight: 650; font-size: 14px; transition: .15s ease; }
.sidebar nav a:hover { color: white; background: rgba(255,255,255,.05); }
.sidebar nav a.active { color: white; background: var(--nav-soft); box-shadow: inset 3px 0 var(--aqua); }
.sidebar nav a span { width: 20px; text-align: center; font-size: 18px; }
.sidebar nav a b { min-width: 22px; margin-left: auto; padding: 2px 6px; border-radius: 999px; color: #062728; background: var(--aqua); text-align: center; font-size: 11px; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 10px 2px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: 12px; }
.sidebar-foot small { margin-top: 2px; color: #7fa3a2; font-size: 11px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #51d795; box-shadow: 0 0 0 4px rgba(81,215,149,.12); }

main { min-width: 0; }
.topbar { min-height: 88px; padding: 18px clamp(20px, 3vw, 42px); display: flex; align-items: center; gap: 18px; background: rgba(255,255,255,.9); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 15; backdrop-filter: blur(14px); }
.topbar > div { margin-right: auto; }
.topbar h1 { margin: 2px 0 0; font-size: clamp(21px, 2vw, 27px); letter-spacing: -.035em; }
.eyebrow { margin: 0; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .11em; font-weight: 750; }
.mobile-menu { display: none !important; }
.search-box { width: min(310px, 28vw); height: 42px; display: flex; align-items: center; gap: 9px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: var(--canvas); }
.search-box:focus-within { border-color: var(--aqua); box-shadow: 0 0 0 3px rgba(88,195,191,.13); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; }

.privacy-banner { margin: 18px clamp(20px, 3vw, 42px) 0; padding: 12px 15px; display: flex; align-items: center; gap: 15px; border: 1px solid #cbe5e2; border-radius: 12px; background: #eaf8f6; }
.privacy-banner.hidden { display: none; }
.privacy-banner div { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.privacy-banner span { color: var(--muted); }
.text-button { margin-left: auto; border: 0; color: var(--ink); background: transparent; font-weight: 750; font-size: 12px; }

.page { padding: 24px clamp(20px, 3vw, 42px) 48px; }
.page-head { margin-bottom: 19px; display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.page-head h2 { margin: 0 0 5px; font-size: 20px; letter-spacing: -.025em; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.button-row { display: flex; flex-wrap: wrap; gap: 9px; }
.button { min-height: 40px; padding: 0 15px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: white; font-weight: 750; font-size: 13px; box-shadow: 0 2px 4px rgba(16,43,45,.03); }
.button:hover { border-color: #b9cfcc; transform: translateY(-1px); }
.button.primary { border-color: var(--nav); color: white; background: var(--nav); }
.button.aqua { border-color: #52bcb8; color: #062728; background: var(--aqua); }
.button.danger { border-color: #efc2c2; color: var(--red); background: var(--red-soft); }
.button.small { min-height: 32px; padding: 0 10px; font-size: 12px; }
.button.ghost { background: transparent; }
.button:disabled { opacity: .5; pointer-events: none; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { position: relative; min-height: 126px; padding: 19px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 6px 20px rgba(16,43,45,.04); }
.kpi::after { content: ""; position: absolute; width: 80px; height: 80px; right: -25px; bottom: -30px; border-radius: 50%; background: var(--aqua-soft); }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 700; }
.kpi strong { display: block; margin: 10px 0 6px; font-size: 29px; line-height: 1; letter-spacing: -.05em; }
.kpi small { color: var(--faint); font-size: 11px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .8fr); gap: 18px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 6px 20px rgba(16,43,45,.035); }
.card + .card { margin-top: 16px; }
.card-head { min-height: 58px; padding: 0 18px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0; font-size: 14px; }
.card-head span { margin-left: auto; color: var(--muted); font-size: 11px; }
.card-body { padding: 18px; }

.draft-tray { margin-bottom: 18px; padding: 14px 16px; display: flex; align-items: center; gap: 18px; border-color: #e4cf94; background: #fffaf0; }
.draft-tray > div:first-child { min-width: 155px; }
.draft-tray strong, .draft-tray span { display: block; }
.draft-tray strong { font-size: 12px; }
.draft-tray span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.draft-actions { flex: 1; display: flex; flex-wrap: wrap; gap: 8px; }
.draft-actions .button { height: auto; min-height: 38px; text-align: left; }
.draft-actions .button span { color: var(--ink); font-size: 11px; }
.draft-actions .button small { display: block; margin-top: 2px; color: var(--faint); font-size: 9px; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 11px 14px; color: var(--faint); border-bottom: 1px solid var(--line); text-align: left; text-transform: uppercase; letter-spacing: .06em; font-size: 10px; }
.data-table td { padding: 14px; border-bottom: 1px solid #edf2f1; vertical-align: middle; font-size: 13px; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f9fbfb; }
.table-wrap { overflow-x: auto; }
.person strong, .person small { display: block; }
.person strong { font-size: 13px; }
.person small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.actions { display: flex; justify-content: flex-end; gap: 7px; }
.money { font-variant-numeric: tabular-nums; font-weight: 750; }
.muted { color: var(--muted); }

.manager-head { margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.manager-head strong, .manager-head span { display: block; }
.manager-head strong { font-size: 14px; }
.manager-head span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.property-stack { display: grid; gap: 13px; }
.property-card { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #fbfdfd; }
.property-card.archived, .unit-row.archived { opacity: .68; }
.property-card-head { padding: 15px; display: flex; justify-content: space-between; gap: 14px; }
.property-card-head h3 { margin: 0; font-size: 14px; }
.property-card-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.property-card-head small { display: block; margin-top: 5px; color: var(--faint); font-size: 10px; }
.title-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.unit-list { border-top: 1px solid var(--line); background: white; }
.unit-row { min-height: 62px; padding: 11px 15px 11px 30px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #edf2f1; }
.unit-row:last-child { border-bottom: 0; }
.unit-row strong, .unit-row span, .unit-row small { display: block; }
.unit-row strong { font-size: 12px; }
.unit-row span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.unit-row small { margin-top: 3px; color: var(--faint); font-size: 9px; }
.unit-empty { padding: 14px; border: 1px dashed #cad9d7; border-radius: 9px; color: var(--muted); background: #fafcfc; font-size: 11px; text-align: center; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; background: #eef3f2; color: #526565; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; white-space: nowrap; }
.badge.blue { color: #1461bc; background: var(--blue-soft); }
.badge.green { color: var(--green); background: var(--green-soft); }
.badge.amber { color: var(--amber); background: var(--amber-soft); }
.badge.red { color: var(--red); background: var(--red-soft); }
.badge.aqua { color: #14716d; background: var(--aqua-soft); }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-action { min-height: 88px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; background: #fafcfc; color: var(--ink); font-weight: 750; text-align: left; }
.quick-action span { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--aqua-soft); }
.quick-action:hover { border-color: var(--aqua); }
.activity-list { display: grid; }
.activity { position: relative; padding: 11px 0 11px 24px; border-bottom: 1px solid #edf2f1; }
.activity:last-child { border-bottom: 0; }
.activity::before { content: ""; position: absolute; left: 3px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--aqua); box-shadow: 0 0 0 4px var(--aqua-soft); }
.activity strong, .activity small { display: block; }
.activity strong { font-size: 12px; }
.activity small { margin-top: 4px; color: var(--muted); font-size: 10px; }

.empty { min-height: 260px; padding: 32px; display: grid; place-items: center; text-align: center; }
.empty-icon { width: 58px; height: 58px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 18px; color: #14716d; background: var(--aqua-soft); font-size: 24px; }
.empty h3 { margin: 0 0 7px; font-size: 16px; }
.empty p { max-width: 430px; margin: 0 auto 17px; color: var(--muted); font-size: 13px; line-height: 1.6; }

.stage-board { display: grid; grid-template-columns: repeat(4, minmax(225px, 1fr)); gap: 13px; overflow-x: auto; padding-bottom: 4px; }
.stage-column { min-height: 300px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #edf3f2; }
.stage-title { padding: 2px 3px 11px; display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: .07em; }
.stage-title b { min-width: 23px; padding: 3px 6px; border-radius: 999px; color: var(--muted); background: white; text-align: center; font-size: 10px; }
.lead-card { margin-bottom: 9px; padding: 14px; border: 1px solid #d8e4e2; border-radius: 12px; background: white; box-shadow: 0 3px 10px rgba(16,43,45,.035); }
.lead-card.sample { border-style: dashed; }
.lead-card h4 { margin: 0 0 3px; font-size: 13px; }
.lead-card p { margin: 8px 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.lead-card .meta { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 10px; }
.lead-card .actions { margin-top: 12px; justify-content: flex-start; }

.filter-row { margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.filter-chip { min-height: 32px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: white; font-size: 11px; font-weight: 750; }
.filter-chip.active { border-color: var(--nav); color: white; background: var(--nav); }

.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .65fr); gap: 18px; }
.settings-section { padding: 20px; }
.settings-section h3 { margin: 0 0 6px; font-size: 15px; }
.settings-section > p { margin: 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.danger-zone { border-color: #efd2d2; }
.boundary-note { padding: 13px 14px; border-left: 3px solid var(--amber); border-radius: 8px; color: #6b572e; background: var(--amber-soft); font-size: 11px; line-height: 1.55; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; padding: 22px; display: grid; place-items: center; background: rgba(2, 23, 24, .68); backdrop-filter: blur(5px); }
.modal { width: min(680px, 100%); max-height: calc(100vh - 44px); overflow: auto; border-radius: 18px; background: white; box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.modal.wide { width: min(860px, 100%); }
.modal-head { min-height: 66px; padding: 0 21px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-head p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.icon-button { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; font-size: 17px; }
.modal-head .icon-button { margin-left: auto; }
.modal-body { padding: 21px; }
.modal-foot { padding: 15px 21px; display: flex; align-items: center; justify-content: flex-end; gap: 9px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: white; }
.modal-foot [data-action='reset-draft'] { margin-right: auto; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label, .field > span { color: #405657; font-size: 11px; font-weight: 800; }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cfdcda; border-radius: 10px; outline: none; color: var(--ink); background: white; }
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--aqua); box-shadow: 0 0 0 3px rgba(88,195,191,.14); }
.field small { color: var(--faint); font-size: 10px; }
.form-section { grid-column: 1 / -1; margin-top: 5px; padding-top: 16px; border-top: 1px solid var(--line); }
.form-section h3 { margin: 0 0 4px; font-size: 13px; }
.form-section p { margin: 0 0 13px; color: var(--muted); font-size: 11px; }
.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check-item { min-height: 40px; padding: 8px 10px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 9px; font-size: 11px; }
.check-item input { width: 16px; height: 16px; accent-color: var(--green); }
.check-item > span { min-width: 0; }
.check-item strong, .check-item small { display: block; }
.check-item small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.equipment-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inline-create { padding: 13px 14px; border: 1px solid var(--line); border-radius: 11px; background: #fafcfc; }
.inline-create summary { cursor: pointer; color: var(--ink); font-size: 12px; font-weight: 800; }
.inline-create[open] summary { margin-bottom: 14px; }
.equipment-record { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fafcfc; }
.equipment-record > p { margin: 5px 0 13px; }
.line-total { padding: 14px; display: flex; justify-content: space-between; border-radius: 10px; color: white; background: var(--nav); font-size: 14px; font-weight: 800; }

.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 150; display: grid; gap: 8px; }
.toast { max-width: 360px; padding: 12px 15px; border-radius: 11px; color: white; background: var(--nav); box-shadow: var(--shadow); font-size: 12px; font-weight: 700; animation: toast-in .2s ease; }
.toast.error { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1060px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: 244px; transition: transform .2s ease; box-shadow: 20px 0 50px rgba(0,0,0,.25); }
  body.menu-open .sidebar { transform: translateX(0); }
  body.menu-open::after { content: ""; position: fixed; inset: 0; z-index: 19; background: rgba(0,0,0,.35); }
  .mobile-menu { display: grid !important; }
  .topbar { min-height: 72px; padding: 12px 15px; gap: 10px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 20px; }
  .topbar > .button { min-width: 42px; width: 42px; padding: 0; overflow: hidden; color: transparent; position: relative; }
  .topbar > .button::after { content: "+"; position: absolute; inset: 0; display: grid; place-items: center; color: white; font-size: 22px; }
  .search-box { width: 42px; padding: 0; justify-content: center; }
  .search-box input { position: absolute; left: 15px; right: 15px; top: 76px; width: calc(100% - 30px); height: 42px; padding: 0 13px; border: 1px solid var(--aqua); border-radius: 10px; background: white; box-shadow: var(--shadow); display: none; }
  .search-box:focus-within input { display: block; }
  .privacy-banner { margin: 13px 14px 0; }
  .privacy-banner div { display: block; }
  .privacy-banner span { display: block; margin-top: 2px; }
  .page { padding: 18px 14px 36px; }
  .page-head { align-items: flex-start; }
  .draft-tray { display: block; }
  .draft-tray > div:first-child { margin-bottom: 10px; }
  .draft-actions { display: grid; }
  .stage-board { grid-template-columns: 1fr; overflow: visible; }
  .stage-column { min-height: auto; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .kpi { min-height: 108px; padding: 15px; }
  .kpi strong { font-size: 25px; }
  .form-grid, .checklist { grid-template-columns: 1fr; }
  .equipment-picker { grid-template-columns: 1fr; }
  .field.full, .form-section { grid-column: auto; }
  .manager-head, .property-card-head, .unit-row { align-items: flex-start; flex-direction: column; }
  .property-card-head .actions, .unit-row .actions { justify-content: flex-start; flex-wrap: wrap; }
  .unit-row { padding-left: 15px; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal, .modal.wide { width: 100%; max-height: 94vh; border-radius: 18px 18px 0 0; }
  .hide-mobile { display: none; }
}

@media (max-width: 430px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-head { display: block; }
  .page-head .button-row { margin-top: 12px; }
}
