:root {
  --bg: #f4f7fb;
  --bg2: #eef3f9;
  --panel: #ffffff;
  --panel2: #f8fbff;
  --line: #d7e2ef;
  --ink: #102033;
  --muted: #5b6d85;
  --faint: #8a9bb0;
  --paper: #ffffff;
  --copper: #1f6feb;
  --copper2: #1558d6;
  --accent: #1f6feb;
  --accent2: #1558d6;
  --on-accent: #ffffff;
  --ink-dark: #ffffff;
  --ok: #14865a;
  --warn: #c47a12;
  --bad: #d23b3b;
  --tile: #c44b2a;
  --elec: #b8860b;
  --hvac: #c45c28;
  --real: #1a7a86;
  --hoa: #6b5aa8;
  --pool: #1b7aa8;
  --insp: #7a6a4a;
  --exist: #5a6a80;
  --radius: 14px;
  --sans: "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "SF Pro Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", Menlo, ui-monospace, monospace;
  --navh: 64px;
  --shadow: 0 1px 2px rgba(16, 32, 51, .06), 0 8px 24px rgba(16, 32, 51, .04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: var(--sans);
  line-height: 1.45;
  background:
    radial-gradient(900px 380px at 8% -18%, #d7e8ff 0%, transparent 58%),
    radial-gradient(640px 320px at 100% 0%, #e8f0fb 0%, transparent 52%),
    var(--bg);
}
a { color: var(--accent2); }
button, .btn {
  appearance: none; font: 650 .86rem/1.25 var(--sans);
  min-height: 44px; padding: .7rem 1rem; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem; text-decoration: none; white-space: nowrap;
  max-width: 100%;
}
button.wrap, .btn.wrap {
  white-space: normal; width: 100%; text-align: center; height: auto; line-height: 1.3;
}
button.primary, .btn.primary {
  background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 800;
}
button.ok, .btn.ok { background: var(--ok); color: #fff; border-color: transparent; }
button.bad, .btn.bad { background: var(--bad); color: #fff; border-color: transparent; }
button.ghost, .btn.ghost { background: transparent; }
button.warn, .btn.warn { background: var(--warn); color: #fff; border: 0; }
button:disabled { opacity: .45; cursor: not-allowed; }
input, textarea, select {
  width: 100%; min-height: 44px; padding: .7rem .8rem; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(31, 111, 235, .35);
  border-color: var(--accent);
}
textarea { min-height: 88px; resize: vertical; }
label { display: block; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: .4rem 0 .25rem; }
.app { max-width: 1120px; margin: 0 auto; padding: 12px 14px calc(var(--navh) + 20px); }
header.top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 6px 0 14px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(145deg, #4b8dff, var(--accent2));
  box-shadow: 0 6px 16px rgba(31, 111, 235, .28);
  display: grid; place-items: center; font-weight: 800; color: #fff; font-size: .85rem;
}
h1 { font-family: var(--serif); font-size: 1.35rem; letter-spacing: -.02em; font-weight: 700; }
.sub { color: var(--muted); font-size: .8rem; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 14px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px;
  box-shadow: var(--shadow);
}
.kpi b { display: block; font-family: var(--serif); font-size: 1.45rem; font-weight: 700; letter-spacing: -.03em; }
.kpi span { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }
.kpi.alert b { color: var(--bad); }
.kpi.money b { color: var(--accent2); }
.grid { display: grid; gap: 10px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 10px; font-weight: 700;
}
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.name { font-family: var(--serif); font-size: 1.2rem; font-weight: 700; }
.money { font-family: var(--serif); font-size: 1.6rem; color: var(--accent2); letter-spacing: -.03em; font-weight: 700; }
.sla { font-family: var(--serif); font-size: 1.8rem; font-weight: 700; }
.sla.ok { color: var(--ok); }
.sla.hot { color: var(--bad); }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: .18rem .5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
  background: #f7fafc;
}
.chip.roofer { color: var(--tile); border-color: #f0cfc4; background: #fff5f1; }
.chip.electrician { color: #9a6f00; border-color: #ead7a4; background: #fff8e6; }
.chip.hvac { color: var(--hvac); border-color: #f0d2c2; background: #fff6f0; }
.chip.realtor { color: var(--real); border-color: #b7dce0; background: #f1fafb; }
.chip.hoa { color: var(--hoa); border-color: #d5ccea; background: #f6f3fc; }
.chip.pool { color: var(--pool); border-color: #b7d7ea; background: #f0f8fd; }
.chip.inspector { color: var(--insp); border-color: #ddd3c2; background: #faf7f2; }
.chip.existing_solar { color: var(--exist); border-color: #cdd6e2; background: #f4f7fb; }
.chip.due { color: var(--warn); border-color: #efd3a4; background: #fff8ea; }
.chip.sent { color: var(--ok); border-color: #b7e0cc; background: #eefaf4; }
.chip.held, .chip.failed { color: var(--bad); border-color: #f0c4c4; background: #fff1f1; }
.muted { color: var(--muted); font-size: .84rem; }
.faint { color: var(--faint); font-size: .78rem; }
.draft {
  background: #f7faff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  font-size: .92rem; white-space: pre-wrap;
}
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--navh);
  background: rgba(255,255,255,.92); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; align-items: stretch;
  padding: 0 4px env(safe-area-inset-bottom); z-index: 20; backdrop-filter: blur(10px);
}
.nav a {
  flex: 1; color: var(--muted); text-decoration: none; font-size: .68rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; min-height: 44px;
}
.nav a.on { color: var(--accent2); }
.nav .dot {
  min-width: 18px; height: 18px; border-radius: 99px; background: var(--bad); color: #fff;
  font-size: .65rem; display: inline-grid; place-items: center; margin-left: 4px;
}
.desk-nav { display: none; gap: 6px; flex-wrap: wrap; }
.filters { display: flex; gap: 6px; overflow-x: auto; padding: 0 0 10px; -webkit-overflow-scrolling: touch; }
.filters button { min-height: 40px; padding: .4rem .75rem; border-radius: 999px; flex: 0 0 auto; }
.filters button.on { background: var(--accent); color: #fff; border-color: transparent; }
.kanban { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.col { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: 120px; }
.col h3 { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.deal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 6px; cursor: pointer; }
.toast {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--accent2); color: #fff; padding: .7rem 1rem; border-radius: 12px;
  z-index: 50; font-weight: 700; box-shadow: 0 8px 30px rgba(16,32,51,.18); max-width: 92vw;
}
.modal-bg {
  position: fixed; inset: 0; background: rgba(16, 32, 51, .4); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 0 0;
  padding: 16px; width: min(560px, 100%); max-height: 88vh; overflow: auto;
}
.photo-btn {
  min-height: 88px; border: 1px dashed var(--accent); border-radius: 16px;
  display: grid; place-items: center; background: #f4f8ff; color: var(--accent2); font-weight: 700;
  cursor: pointer; text-align: center; padding: 12px;
}
.photo-btn input { display: none; }
.qr { background: #fff; padding: 10px; border-radius: 12px; display: inline-block; border: 1px solid var(--line); }
.qr img { display: block; width: 160px; height: 160px; }
.empty { padding: 24px 8px; text-align: center; color: var(--muted); }
.list-item { border-top: 1px solid var(--line); padding: 12px 0; }
.list-item:first-child { border-top: 0; padding-top: 0; }
.mono { font-family: var(--mono); font-size: .78rem; }
.two { display: grid; grid-template-columns: 1fr; gap: 10px; }
.banner {
  background: #edf4ff; border: 1px solid #c5d8f6; color: #1a4fa3;
  border-radius: 12px; padding: 10px 12px; font-size: .84rem; margin-bottom: 10px;
}
.more-menu {
  position: fixed; right: 10px; bottom: calc(var(--navh) + 10px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 8px; z-index: 30; min-width: 180px; display: none;
  box-shadow: var(--shadow);
}
.more-menu a { display: block; padding: 10px 12px; color: var(--ink); text-decoration: none; min-height: 44px; }
@media (min-width: 860px) {
  .app { padding-bottom: 40px; padding-left: 168px; }
  .nav { display: none; }
  .desk-nav {
    display: flex; flex-direction: column; position: fixed; left: 12px; top: 18px; width: 140px;
  }
  .desk-nav a {
    color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: 10px; min-height: 40px;
    display: flex; align-items: center;
  }
  .desk-nav a.on { background: #e8f1ff; color: var(--accent2); font-weight: 700; }
  .kpis { grid-template-columns: repeat(6, 1fr); }
  .two { grid-template-columns: 1.2fr .8fr; }
  .modal { border-radius: 18px; margin-bottom: 8vh; }
  .modal-bg { align-items: center; }
}
@media (max-width: 430px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 1.15rem; }
  .app { padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 820px) {
  html, body { overflow-x: hidden; width: 100%; }
  .desk-nav { display: none !important; }
  .nav { display: flex; }
  .app, #root, main { padding-left: 12px; padding-right: 12px; padding-bottom: calc(var(--navh) + 24px); max-width: 100%; overflow-x: hidden; min-width: 0; }
  .two { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi, .kpi b, .kpi span { min-width: 0; overflow-wrap: anywhere; }
  .kanban { display: grid; grid-template-columns: 1fr; overflow: visible; }
  .kanban .col { min-width: 0; width: 100%; flex: none; }
  button, .btn {
    min-height: 48px; font-size: .95rem; white-space: normal; max-width: 100%;
    height: auto; line-height: 1.3; box-sizing: border-box;
  }
  .stack button, .stack .btn, .grid button, .grid .btn { width: 100%; }
  .row { max-width: 100%; min-width: 0; }
  .row > button, .row > .btn { flex: 1 1 calc(50% - 8px); min-width: 0; }
  .spread { flex-wrap: wrap; max-width: 100%; min-width: 0; }
  .filters { flex-wrap: wrap; overflow: visible; }
  .filters button { flex: 1 1 auto; white-space: normal; min-width: 0; }
  .chip { white-space: normal; max-width: 100%; }
  .card, .list-item, .name, .muted, .banner, .draft, .mono, .faint, .sub, h1, h2, h3, p, td, th, label {
    overflow-wrap: anywhere; word-break: break-word; max-width: 100%; min-width: 0;
  }
  input, select, textarea { max-width: 100%; min-width: 0; }
  .qr, .qr img { max-width: 100%; height: auto; }
  .more-menu { left: 10px; right: 10px; min-width: 0; max-width: calc(100vw - 20px); }
  .nav a { min-width: 0; font-size: .62rem; letter-spacing: 0; padding: 0 2px; white-space: normal; line-height: 1.15; }
  .toast { max-width: calc(100vw - 24px); white-space: normal; }
  .name { font-size: 1.28rem; }
  .money, .sla { font-size: 1.55rem; }
  .phone-hide { display: none !important; }
  header.top { padding-bottom: 8px; }
  .card { padding: 14px 14px 16px; }
}
.hidden { display: none !important; }
.stack { display: grid; gap: 8px; }
.file-name { font-size: .78rem; color: var(--ok); }
