:root {
  /* Grace Construction logo: navy #0B1E3C, red #ED1C24, orange #F47221 */
  --brand: #0b1e3c; --brand-dk: #07142a; --accent: #f47221; --red: #ed1c24; --ok: #1f8a4c; --err: #c0392b;
  --bg: #f4f6f9; --card: #fff; --text: #1b2430; --muted: #6b7686; --line: #e3e7ed;
  --radius: 14px; --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
  --nav-h: 64px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.35rem; margin: .2rem 0 .8rem; } h2 { font-size: 1.1rem; margin: 1.2rem 0 .6rem; } h3 { font-size: 1rem; margin: .8rem 0 .4rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .6rem; padding: .55rem 1rem;
  background: #fff; color: var(--brand); border-bottom: 3px solid var(--accent); padding-top: calc(.55rem + env(safe-area-inset-top)); }
.topbar .title { font-weight: 700; flex: 1; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar a { color: var(--brand); font-weight: 600; }
.topbar .mark { height: 30px; width: auto; display: block; }
.topbar .back { font-size: 1.8rem; line-height: 1; padding: 0 .3rem 0 0; }
.brand-logo { display: block; width: 220px; max-width: 70%; height: auto; margin: 0 auto; }
main { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom)); }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: #fff; border-top: 1px solid var(--line);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); font-size: .72rem; gap: 2px; }
.bottomnav a.active { color: var(--brand); font-weight: 600; }
.bottomnav svg { width: 24px; height: 24px; }
@media (min-width: 900px) { .bottomnav { top: 0; bottom: 0; right: auto; width: 88px; height: auto; flex-direction: column; justify-content: flex-start; border-top: 0; border-right: 1px solid var(--line); padding-top: 70px; }
  .bottomnav a { flex: 0 0 72px; } main { padding-left: 110px; padding-bottom: 2rem; } .topbar { padding-left: 110px; } }

/* cards & lists */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: .8rem; }
.lead-card { display: block; color: inherit; }
.lead-card .row1 { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.lead-card .name { font-weight: 650; font-size: 1.05rem; }
.lead-card .meta { color: var(--muted); font-size: .88rem; margin-top: .15rem; }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #e8eef7; color: var(--brand-dk); }
.badge.new { background: #fde8e9; color: #b3151b; } .badge.won { background: #dff3e7; color: var(--ok); } .badge.lost { background: #f8e1df; color: var(--err); }
.badge.err { background: #f8e1df; color: var(--err); } .badge.ok { background: #dff3e7; color: var(--ok); }
.quick { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .5rem; margin-top: .8rem; }
.quick a, .quick button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; min-height: 56px; border-radius: 12px;
  background: #eef3fa; color: var(--brand-dk); font-size: .78rem; font-weight: 600; border: 0; font-family: inherit; }
.quick svg { width: 22px; height: 22px; }
.quick .wa { background: #e3f6ea; color: #128c4a; }

/* kanban */
.kanban { display: flex; gap: .8rem; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: .5rem; -webkit-overflow-scrolling: touch; }
.kanban .col { flex: 0 0 82%; max-width: 320px; scroll-snap-align: start; background: #e9edf3; border-radius: var(--radius); padding: .6rem; }
@media (min-width: 900px) { .kanban .col { flex: 1 0 220px; } }
.kanban .col h3 { margin: .2rem .3rem .6rem; font-size: .9rem; display: flex; justify-content: space-between; }
.kanban .card { padding: .7rem; margin-bottom: .5rem; }

/* forms & buttons */
label { display: block; font-size: .85rem; color: var(--muted); margin: .7rem 0 .25rem; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; padding: .75rem .8rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--text); }
textarea { min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(244,114,33,.3); border-color: var(--accent); }
.check { display: flex; align-items: center; gap: .6rem; margin: .5rem 0; color: var(--text); font-size: 1rem; }
.check input { width: 22px; height: 22px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 48px; padding: .7rem 1.1rem; border-radius: 12px; border: 0;
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.btn.block { width: 100%; } .btn.ghost { background: #eef3fa; color: var(--brand-dk); } .btn.accent { background: var(--accent); color: #2a1a00; }
.btn.danger { background: #fbe9e7; color: var(--err); } .btn.sm { min-height: 38px; padding: .4rem .8rem; font-size: .88rem; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; } .row > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding: .2rem 0 .6rem; }
.chip { flex: 0 0 auto; padding: .45rem .9rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--text); font-size: .88rem; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.flash { padding: .8rem 1rem; border-radius: 12px; margin-bottom: .8rem; background: #e8eef7; }
.flash.error { background: #fbe9e7; color: var(--err); } .flash.ok { background: #e3f6ea; color: var(--ok); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.table-wrap { overflow-x: auto; }
.timeline .item { border-left: 3px solid var(--line); padding: .2rem 0 .7rem .8rem; }
.timeline .item.sys { border-color: #c9d6ea; color: var(--muted); font-size: .9rem; }
.fab { position: fixed; right: 1rem; bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: #2a1a00; display: flex; align-items: center; justify-content: center; font-size: 2rem; box-shadow: 0 6px 16px rgba(0,0,0,.18); z-index: 15; }

/* estimator */
.est-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-bottom: .8rem; }
.est-tabs button { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font: inherit; font-weight: 600; color: var(--text); }
.est-tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.seg { display: flex; flex-wrap: wrap; gap: .4rem; }
.seg button { flex: 1 0 auto; min-height: 44px; padding: .4rem .7rem; border-radius: 10px; border: 1px solid var(--line); background: #fff; font: inherit; color: var(--text); }
.seg button.on { background: #e8eef7; border-color: var(--brand); color: var(--brand-dk); font-weight: 650; }
.stepper { display: flex; align-items: center; gap: .4rem; }
.stepper button { width: 48px; height: 48px; border-radius: 12px; border: 0; background: #eef3fa; font-size: 1.4rem; color: var(--brand-dk); }
.stepper input { text-align: center; font-size: 1.3rem; font-weight: 650; }
.est-line { display: flex; justify-content: space-between; gap: .6rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.est-total { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line);
  margin: 0 -1rem; padding: .8rem 1rem; display: flex; align-items: center; gap: .8rem; z-index: 10; }
.est-total .amt { font-size: 1.4rem; font-weight: 750; flex: 1; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; } @media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi .v { font-size: 1.4rem; font-weight: 750; } .kpi .l { color: var(--muted); font-size: .8rem; }
.install-tip { background: #fff8e8; border: 1px solid #f3dca6; }
.hidden { display: none !important; }
