/* BrainView AI — construction management
   Palette: navy rail + cool paper + one blue signal
   Type: Archivo (UI) / IBM Plex Mono (quantities, money, IDs) */

:root {
  /* rail / ink */
  --navy-900: #05101f;
  --navy-800: #0a1c33;
  --navy-700: #102a49;
  --navy-600: #17395f;
  --navy-line: #1d4472;

  --ink: #101822;
  --steel: #64748b;
  --steel-2: #94a3b8;

  --paper: #f5f7fa;
  --card: #ffffff;
  --rule: #e2e8f0;
  --rule-soft: #eef2f7;

  /* brand */
  --blue: #2f6fed;
  --blue-600: #1d5bd6;
  --blue-700: #16469f;
  --blue-300: #8fbaf9;
  --blue-wash: #eaf2fe;
  --sky: #38bdf8;

  /* semantic */
  --hivis: #e0590f;
  --hivis-ink: #9a3d0a;
  --hivis-wash: #fff2e9;

  --moss: #0f8a5f;
  --moss-wash: #e6f6ef;
  --rust: #b3261e;
  --rust-wash: #fdeceb;
  --amber: #9a6700;
  --amber-wash: #fdf5e3;

  --rail-w: 252px;
  --bar-h: 64px;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;

  --shadow-1: 0 1px 2px rgba(16, 24, 34, .05);
  --shadow-2: 0 2px 4px rgba(16, 24, 34, .05), 0 8px 20px rgba(16, 24, 34, .05);
  --shadow-3: 0 18px 44px rgba(16, 24, 34, .14);

  --ease: cubic-bezier(.32, .72, .32, 1);

  --ff: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --fm: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--ff);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 3px; }

/* ---------- shell ---------- */
.app { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail-w);
  flex: 0 0 var(--rail-w);
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(47, 111, 237, .20), transparent 60%),
    linear-gradient(180deg, var(--navy-700) 0%, var(--navy-800) 46%, var(--navy-900) 100%);
  color: #c9d6e8;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  border-right: 1px solid rgba(255, 255, 255, .06);
}

.rail-head { padding: 20px 16px 16px; }

/* logo lockup */
.mark {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 6px 2px;
}
.mark-glyph {
  width: 42px; height: 42px; flex: 0 0 42px; display: block;
  filter: drop-shadow(0 2px 10px rgba(143, 186, 249, .35));
}
.mark-name {
  font-weight: 700; font-size: 19px; letter-spacing: -.015em; color: #fff;
  line-height: 1.1;
}
.mark-name span { font-weight: 400; color: #fff; opacity: .92; }

.rail-co {
  margin: 4px 16px 6px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .05);
}
.rail-co-name { font-size: 12.5px; font-weight: 600; color: #eaf1fa; }
.rail-co-meta { font-size: 10.5px; color: #7b93b1; font-family: var(--fm); margin-top: 1px; }

.nav { padding: 10px; overflow-y: auto; flex: 1; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .1); border-radius: 3px; }
.nav-group { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .07); }
.nav-group:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.nav-group-label {
  font-size: 10px; color: #6d88a8; padding: 0 12px 7px;
  letter-spacing: .16em; text-transform: uppercase; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--r-sm); margin-bottom: 2px;
  color: #a8bcd4; cursor: pointer; border: 1px solid transparent; background: none;
  width: 100%; text-align: left; font-size: 13.5px; font-weight: 500;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.on {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-600) 100%);
  color: #fff; font-weight: 600;
  box-shadow: 0 6px 16px rgba(47, 111, 237, .34);
  border-color: rgba(255, 255, 255, .12);
}
.nav-ico { width: 17px; height: 17px; flex: 0 0 17px; opacity: .72; }
.nav-item:hover .nav-ico, .nav-item.on .nav-ico { opacity: 1; }
.nav-count {
  margin-left: auto; font-family: var(--fm); font-size: 10.5px;
  color: #bdd0e6; background: rgba(255, 255, 255, .09); padding: 1px 7px; border-radius: 9px;
}
.nav-item.on .nav-count { background: rgba(255, 255, 255, .2); color: #fff; }
.nav-tag {
  margin-left: auto; font-size: 9px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--blue-300); border: 1px solid rgba(143, 186, 249, .32);
  padding: 1px 6px; border-radius: 9px; font-weight: 600;
}
.nav-item.on .nav-tag { color: #fff; border-color: rgba(255, 255, 255, .4); }
.nav-foot { margin-top: 16px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .07); }
.nav-foot .nav-item { font-size: 12.5px; color: #6d88a8; }

/* ---------- demo block in the rail ---------- */
.rail-demo {
  margin: 4px 16px 8px; padding: 11px 12px; border-radius: var(--r-sm);
  background: rgba(47,111,237,.14); border: 1px solid rgba(143,186,249,.28);
}
.rail-demo-k { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700; color: var(--blue-300); }
.rail-demo-t { font-size: 11.5px; color: #a8bcd4; line-height: 1.4; margin: 4px 0 9px; }
.rail-demo-btn {
  display: block; text-align: center; padding: 7px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  color: #fff; background: linear-gradient(135deg, var(--blue) 0%, var(--blue-600) 100%); text-decoration: none;
  box-shadow: 0 6px 16px rgba(47,111,237,.3);
}
.rail-demo-btn:hover { background: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-700) 100%); text-decoration: none; }
.rail-demo-links { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11.5px; }
.rail-demo-links a { color: #bdd0e6; }
.rail-demo-links a:hover { color: #fff; }

/* ---------- main ---------- */
.main { flex: 1; margin-left: var(--rail-w); min-width: 0; display: flex; flex-direction: column; }

.bar {
  height: var(--bar-h); flex: 0 0 var(--bar-h);
  background: rgba(246, 247, 251, .82);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 14px;
  padding: 0 26px; position: sticky; top: 0; z-index: 40;
}
.bar-title { font-size: 15px; font-weight: 650; letter-spacing: -.012em; }
.bar-sub { font-size: 12px; color: var(--steel); }
.search { margin-left: auto; position: relative; width: min(340px, 34vw); }
.search input {
  width: 100%; padding: 9px 12px 9px 33px;
  border: 1px solid var(--rule); border-radius: 999px;
  background: #fff; font-size: 13px; box-shadow: var(--shadow-1);
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.search input:focus { outline: none; border-color: var(--blue-300); box-shadow: 0 0 0 3px var(--blue-wash); }
.search svg { position: absolute; left: 12px; top: 10px; width: 14px; height: 14px; color: var(--steel); }
.search-pop {
  position: absolute; top: 44px; left: 0; right: 0; background: #fff;
  border: 1px solid var(--rule); border-radius: var(--r); box-shadow: var(--shadow-3);
  max-height: 340px; overflow: auto; z-index: 50; padding: 5px;
}
.search-pop-item { padding: 9px 11px; cursor: pointer; font-size: 13px; border-radius: var(--r-sm); }
.search-pop-item:hover { background: var(--blue-wash); }
.search-pop-item .k { font-size: 10.5px; color: var(--steel); font-family: var(--fm); letter-spacing: .04em; }
.search-pop-empty { padding: 14px; color: var(--steel); font-size: 13px; }

.view { padding: 26px; flex: 1; max-width: 1560px; width: 100%; }

/* ---------- primitives ---------- */
.eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--blue); margin-bottom: 6px;
}
.h1 { font-size: 30px; font-weight: 700; letter-spacing: -.03em; margin: 0 0 4px; line-height: 1.14; }
.lede { color: var(--steel); font-size: 14px; margin: 0 0 20px; max-width: 64ch; }
.lede-brand { color: var(--blue-600); font-weight: 550; }

.sec { margin-top: 34px; }
.sec-head {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px;
  border-bottom: 1px solid var(--rule); padding-bottom: 9px;
}
.sec-head h2 { font-size: 15px; font-weight: 650; margin: 0; letter-spacing: -.015em; }
.sec-head .n { font-family: var(--fm); font-size: 12px; color: var(--steel); }
.sec-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 15px; border-radius: var(--r-sm); border: 1px solid var(--rule);
  background: #fff; cursor: pointer; font-size: 13px; font-weight: 550;
  white-space: nowrap; box-shadow: var(--shadow-1);
  transition: border-color .14s var(--ease), background .14s var(--ease), transform .14s var(--ease);
}
.btn:hover { border-color: var(--steel-2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-600) 100%);
  border-color: var(--blue-600); color: #fff; font-weight: 600;
  box-shadow: 0 6px 16px rgba(47, 111, 237, .28);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-700) 100%); border-color: var(--blue-700); }
.btn-dark { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.btn-dark:hover { background: var(--navy-700); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 5px; }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: rgba(16, 24, 34, .05); border-color: transparent; }
.btn-danger { color: var(--rust); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.card {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r);
  box-shadow: var(--shadow-1);
}
.pad { padding: 18px; }

/* money strip */
.strip {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r);
  overflow: hidden; box-shadow: var(--shadow-1);
}
.strip-cell { padding: 17px 19px; border-left: 1px solid var(--rule-soft); }
.strip-cell:first-child { border-left: none; }
.strip-k { font-size: 12px; color: var(--steel); margin-bottom: 6px; font-weight: 500; }
.strip-v { font-family: var(--fm); font-size: 27px; font-weight: 500; letter-spacing: -.035em; }
.strip-v.alert { color: var(--hivis-ink); }
.strip-v.good { color: var(--moss); }
.strip-note { font-size: 11.5px; color: var(--steel); margin-top: 5px; }
.strip-note b { font-weight: 600; color: var(--ink); font-family: var(--fm); }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 18px; }
.split-3 { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; }

.stat { padding: 15px 17px; }
.stat-k { font-size: 12px; color: var(--steel); font-weight: 500; }
.stat-v { font-family: var(--fm); font-size: 22px; margin-top: 4px; letter-spacing: -.03em; }
.stat-d { font-size: 11.5px; margin-top: 4px; color: var(--steel); }

/* module launcher cards */
.mod-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.mod {
  display: flex; gap: 12px; align-items: center; text-align: left;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 13px 15px; cursor: pointer; box-shadow: var(--shadow-1); width: 100%;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), transform .16s var(--ease);
}
.mod:hover {
  border-color: var(--blue-300); box-shadow: var(--shadow-2); transform: translateY(-2px);
}
.mod:hover .mod-chip { background: var(--blue); color: #fff; }
.mod-chip {
  flex: 0 0 34px; height: 34px; border-radius: 8px;
  background: var(--blue-wash); color: var(--blue-600);
  font-family: var(--fm); font-size: 11px; font-weight: 600;
  display: grid; place-items: center; letter-spacing: -.02em;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.mod-t { font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }

/* tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--r); background: #fff; box-shadow: var(--shadow-1); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
  text-align: left; font-weight: 600; font-size: 11px; color: var(--steel);
  padding: 11px 14px; border-bottom: 1px solid var(--rule); background: #fafbfd;
  white-space: nowrap; position: sticky; top: 0; letter-spacing: .05em; text-transform: uppercase;
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: #f8f9ff; }
.num { font-family: var(--fm); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--fm); }
.dim { color: var(--steel); }
.strong { font-weight: 600; }
.wrap-cell { min-width: 180px; }

.pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap; letter-spacing: .01em;
}
.pill-moss { background: var(--moss-wash); color: var(--moss); }
.pill-rust { background: var(--rust-wash); color: var(--rust); }
.pill-amber { background: var(--amber-wash); color: var(--amber); }
.pill-blue { background: var(--blue-wash); color: var(--blue-600); }
.pill-grey { background: #f0f1f6; color: var(--steel); }
.pill-hivis { background: var(--hivis-wash); color: var(--hivis-ink); }

.stepper {
  display: inline-flex; align-items: center; gap: 2px;
  border: 1px solid var(--rule); border-radius: 999px; padding: 1px;
  background: #fff; vertical-align: middle;
}
.stepper button {
  width: 22px; height: 22px; border: none; background: none; cursor: pointer;
  color: var(--steel); border-radius: 50%; font-size: 13px; line-height: 1;
  display: grid; place-items: center; padding: 0;
}
.stepper button:hover { background: var(--blue-wash); color: var(--blue-600); }
.stepper b { min-width: 30px; text-align: center; font-family: var(--fm); font-weight: 600; }

.empty { padding: 44px 20px; text-align: center; color: var(--steel); }
.empty h3 { margin: 0 0 6px; font-size: 15.5px; color: var(--ink); }
.empty p { margin: 0 0 14px; font-size: 13px; }

/* forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--steel); margin-bottom: 5px; font-weight: 550; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--rule);
  border-radius: var(--r-sm); background: #fff;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue-300); outline: none; box-shadow: 0 0 0 3px var(--blue-wash);
}
.field input:disabled { background: #f4f5f9; color: var(--steel-2); border-style: dashed; }
.field textarea { min-height: 78px; resize: vertical; }
.fields { display: grid; gap: 0 14px; }
.f2 { grid-template-columns: 1fr 1fr; }
.f3 { grid-template-columns: repeat(3, 1fr); }
.hint { font-size: 11.5px; color: var(--steel); margin-top: 4px; }

/* modal */
.scrim {
  position: fixed; inset: 0; background: rgba(5, 16, 31, .5);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  z-index: 100; display: flex; align-items: flex-start; justify-content: center;
  padding: 46px 16px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: var(--r-lg); width: 100%; max-width: 640px;
  box-shadow: 0 30px 70px rgba(5, 16, 31, .34); animation: pop .16s var(--ease);
  overflow: hidden;
}
.modal.wide { max-width: 920px; }
@keyframes pop { from { transform: translateY(-8px) scale(.99); opacity: 0 } }
@media (prefers-reduced-motion: reduce) { .modal { animation: none } }
.modal-head {
  padding: 17px 20px; border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 10px;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.015em; }
.modal-body { padding: 20px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--rule);
  display: flex; gap: 8px; justify-content: flex-end; background: #fafbfd;
}
.x { margin-left: auto; border: none; background: none; cursor: pointer; color: var(--steel); font-size: 22px; line-height: 1; padding: 0 4px; }
.x:hover { color: var(--ink); }

/* toast */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--navy-800); color: #fff; padding: 12px 16px; border-radius: var(--r-sm);
  font-size: 13px; box-shadow: 0 12px 30px rgba(5, 16, 31, .32); animation: pop .16s var(--ease);
  max-width: 330px; border: 1px solid rgba(255, 255, 255, .08);
}
.toast.good { border-left: 3px solid var(--moss); }
.toast.bad { border-left: 3px solid var(--hivis); }

/* charts */
.chart { width: 100%; display: block; }
.chart .bar-r { fill: var(--blue-300); transition: fill .16s var(--ease); }
.chart .bar-r:hover { fill: var(--blue); }
.chart .bar-r.hot { fill: var(--blue); }
.chart .gl { stroke: var(--rule-soft); stroke-width: 1; }
.chart .lbl { font-size: 10px; fill: var(--steel); font-family: var(--fm); }

/* takeoff */
.tk-grid {
  background-color: #fcfcfe;
  background-image:
    linear-gradient(var(--rule-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule-soft) 1px, transparent 1px);
  background-size: 24px 24px;
  border: 1px solid var(--rule); border-radius: var(--r);
  padding: 18px; box-shadow: var(--shadow-1);
}
.tk-row {
  display: grid; grid-template-columns: 1.6fr 90px 90px 90px 1fr 100px 34px;
  gap: 9px; align-items: start; padding: 12px 0; border-bottom: 1px dashed var(--rule);
}
.tk-row:last-of-type { border-bottom: none; }
.tk-row .field { margin: 0; }
.tk-row:not(.tk-head) .field label { display: none; }
.tk-head .li-head { font-size: 11px; color: var(--steel); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.tk-total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 16px 20px; color: #fff; border-radius: var(--r); margin-top: 16px;
  background:
    radial-gradient(120% 160% at 100% 0%, rgba(47, 111, 237, .45), transparent 60%),
    linear-gradient(135deg, var(--navy-700), var(--navy-900));
  box-shadow: var(--shadow-2);
}
.tk-total .v { font-family: var(--fm); font-size: 27px; letter-spacing: -.03em; }

/* line item editor */
.li-row {
  display: grid; grid-template-columns: 1fr 80px 90px 100px 110px 32px;
  gap: 9px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--rule-soft);
}
.li-head { font-size: 11px; color: var(--steel); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.li-row input, .li-row select { padding: 7px 9px; border: 1px solid var(--rule); border-radius: 5px; width: 100%; }
.icon-btn { border: none; background: none; cursor: pointer; color: var(--steel); padding: 5px; border-radius: 5px; }
.icon-btn:hover { background: var(--rust-wash); color: var(--rust); }

/* doc preview (estimate / invoice) */
.doc { background: #fff; border: 1px solid var(--rule); border-radius: var(--r); padding: 30px; box-shadow: var(--shadow-1); }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--navy-800); padding-bottom: 16px; }
.doc-co { font-size: 19px; font-weight: 700; letter-spacing: -.025em; }
.doc-meta { text-align: right; font-family: var(--fm); font-size: 12px; color: var(--steel); }
.doc-meta .no { font-size: 18px; color: var(--ink); }
.doc-tot { margin-left: auto; width: min(310px, 100%); margin-top: 16px; }
.doc-tot .r { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.doc-tot .r.grand { border-top: 2px solid var(--navy-800); margin-top: 6px; padding-top: 10px; font-size: 18px; font-weight: 700; }
.doc-tot .r span:last-child { font-family: var(--fm); }

/* AI panel */
.ai-log { display: flex; flex-direction: column; gap: 13px; min-height: 240px; }
.ai-msg { max-width: 84%; padding: 12px 15px; border-radius: 14px; font-size: 13.5px; line-height: 1.55; }
.ai-msg.me {
  align-self: flex-end; color: #fff; border-bottom-right-radius: 4px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-600) 100%);
  box-shadow: 0 6px 16px rgba(47, 111, 237, .26);
}
.ai-msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--rule); border-bottom-left-radius: 4px; box-shadow: var(--shadow-1); }
.ai-msg table { font-size: 12.5px; margin-top: 8px; width: 100%; border-collapse: collapse; }
.ai-msg td { padding: 4px 8px 4px 0; border-bottom: 1px solid var(--rule-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.chip {
  border: 1px solid var(--rule); background: #fff; border-radius: 999px;
  padding: 6px 13px; font-size: 12.5px; cursor: pointer; box-shadow: var(--shadow-1);
  transition: border-color .14s var(--ease), color .14s var(--ease);
}
.chip:hover { border-color: var(--blue-300); color: var(--blue-600); }

/* remodel */
.rm-pane { border: 1px solid var(--rule); border-radius: var(--r); background: #fff; overflow: hidden; box-shadow: var(--shadow-1); }
.rm-drop {
  border: 1.5px dashed var(--rule); border-radius: var(--r); padding: 38px 20px;
  text-align: center; color: var(--steel); cursor: pointer; background: #fbfbfe;
}
.rm-drop:hover { border-color: var(--blue-300); background: var(--blue-wash); }
.rm-img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: cover; background: #eef0f6; }
.rm-cap { padding: 10px 14px; font-size: 12px; color: var(--steel); border-top: 1px solid var(--rule); display: flex; justify-content: space-between; align-items: center; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-left: 1px solid var(--rule); border-top: 1px solid var(--rule); background: #fff; border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-1); }
.cal-dow { padding: 9px; font-size: 10.5px; color: var(--steel); font-weight: 600; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); background: #fafbfd; text-align: center; letter-spacing: .08em; text-transform: uppercase; }
.cal-day { min-height: 100px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 6px; }
.cal-day.off { background: #fafbfd; }
.cal-day.today .cal-n { background: var(--blue); color: #fff; border-radius: 50%; font-weight: 600; }
.cal-n { font-family: var(--fm); font-size: 11.5px; color: var(--steel); width: 21px; height: 21px; display: grid; place-items: center; }
.cal-ev {
  font-size: 11px; padding: 3px 6px; border-radius: 4px; margin-top: 3px;
  background: var(--blue-wash); color: var(--blue-600); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 2px solid var(--blue);
}
.cal-ev.crew { background: var(--hivis-wash); color: var(--hivis-ink); border-left-color: var(--hivis); }
.cal-ev.insp { background: var(--moss-wash); color: var(--moss); border-left-color: var(--moss); }

/* progress */
.pbar { height: 6px; background: #eceef5; border-radius: 999px; overflow: hidden; min-width: 70px; }
.pbar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), var(--sky)); }
.pbar i.over { background: linear-gradient(90deg, var(--hivis), #f08b4b); }

.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--rule); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 9px 14px; border: none; background: none; cursor: pointer; font-size: 13px; color: var(--steel); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--blue-600); font-weight: 650; border-bottom-color: var(--blue); }

.crumb { font-size: 12.5px; color: var(--steel); margin-bottom: 8px; }
.crumb a { color: var(--steel); }
.crumb a:hover { color: var(--blue-600); }

.kv { display: grid; grid-template-columns: 132px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--steel); }
.kv dd { margin: 0; }

.mobile-only { display: none; }
.tabbar { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1240px) {
  .mod-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .split, .split-3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  :root { --bar-h: 56px; }
  .rail {
    transform: translateX(-100%); transition: transform .2s var(--ease);
    box-shadow: 0 0 50px rgba(0, 0, 0, .4);
  }
  .rail.open { transform: none; }
  .main { margin-left: 0; }
  .view { padding: 16px 14px 92px; }
  .bar { padding: 0 14px; gap: 10px; }
  .search { width: auto; flex: 1; min-width: 110px; }
  .bar-sub { display: none; }
  .bar > div:not(.search) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-only { display: inline-flex; }
  #menuBtn { padding: 7px; flex: 0 0 auto; }
  #menuBtn svg { width: 20px; height: 20px; }
  .sec-head { flex-wrap: wrap; }
  .sec-head .right { margin-left: 0; width: 100%; }
  .sec-head .right .btn { flex: 1; }
  .bar-title { font-size: 14px; }
  .h1 { font-size: 23px; }
  .lede { font-size: 13.5px; }
  .strip { grid-template-columns: 1fr 1fr; }
  .strip-cell:nth-child(3) { border-left: none; }
  .strip-cell:nth-child(n+3) { border-top: 1px solid var(--rule-soft); }
  .strip-v { font-size: 22px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .mod-grid { grid-template-columns: 1fr 1fr; }
  .f2, .f3 { grid-template-columns: 1fr; }

  .tk-row { grid-template-columns: 1fr 1fr; gap: 8px 10px; }
  .tk-row .field:first-child { grid-column: 1 / -1; }
  .tk-head { display: none; }
  .tk-row:not(.tk-head) .field label { display: block; }
  .li-row { grid-template-columns: 1fr 1fr; gap: 6px 8px; padding: 12px 0; }
  .li-row > *:first-child { grid-column: 1 / -1; }
  .li-head { display: none; }

  .scrim { padding: 0; align-items: stretch; }
  .modal { max-width: none; border-radius: 0; min-height: 100%; }
  .modal-foot { position: sticky; bottom: 0; }

  .cal { font-size: 11px; }
  .cal-day { min-height: 64px; padding: 3px; }
  .cal-ev { font-size: 9.5px; padding: 1px 4px; }

  /* stacked table rows */
  .tbl.stack thead { display: none; }
  .tbl.stack tbody tr { display: block; border-bottom: 1px solid var(--rule); padding: 12px 14px; }
  .tbl.stack tbody tr:last-child { border-bottom: none; }
  .tbl.stack td { display: flex; justify-content: space-between; gap: 12px; border: none; padding: 3px 0; text-align: left; }
  .tbl.stack td::before { content: attr(data-l); color: var(--steel); font-size: 12px; flex: 0 0 auto; }
  .tbl.stack td.num { justify-content: space-between; }
  .tbl.stack td.lead { font-weight: 650; font-size: 14.5px; padding-bottom: 6px; }
  .tbl.stack td.lead::before { display: none; }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: linear-gradient(180deg, var(--navy-800), var(--navy-900));
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar button {
    background: none; border: none; color: #8aa3c0; padding: 10px 2px 9px;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10px; cursor: pointer;
  }
  .tabbar button.on { color: var(--blue-300); }
  .tabbar svg { width: 19px; height: 19px; }
  .toasts { bottom: 76px; right: 12px; left: 12px; }
  .toast { max-width: none; }
}

@media print {
  .rail, .bar, .tabbar, .no-print { display: none !important; }
  .main { margin: 0 } .view { padding: 0 } body { background: #fff }
  .doc, .card, .tbl-wrap { border: none; box-shadow: none; padding: 0 }
}

/* ---------- messages ---------- */
.msg { max-width: 82%; }
.msg-meta { font-size: 11px; color: var(--steel); margin-bottom: 4px; }
.msg-body {
  padding: 10px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.55;
  border: 1px solid var(--rule); background: #fff; box-shadow: var(--shadow-1);
}
.msg-office { align-self: flex-end; text-align: right; }
.msg-office .msg-body {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-600) 100%);
  color: #fff; border-color: var(--blue-600); border-bottom-right-radius: 4px;
  text-align: left; box-shadow: 0 6px 16px rgba(47, 111, 237, .26);
}
.msg-customer .msg-body { border-bottom-left-radius: 4px; border-left: 3px solid var(--blue-300); }
.msg-crew .msg-body { border-bottom-left-radius: 4px; border-left: 3px solid var(--hivis); }

/* ---------- job photos ---------- */
.ph-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 16px; margin-top: 4px;
}
.ph {
  margin: 0; background: #fff; border: 1px solid var(--rule); border-radius: var(--r);
  overflow: hidden; box-shadow: var(--shadow-1);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), transform .16s var(--ease);
}
.ph:hover { border-color: var(--blue-300); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.ph img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: cover; background: #eef2f7; }
.ph-none {
  aspect-ratio: 4/3; display: grid; place-content: center; gap: 5px; text-align: center;
  background:
    repeating-linear-gradient(45deg, rgba(47,111,237,.05) 0 10px, transparent 10px 20px),
    linear-gradient(160deg, var(--navy-700), var(--navy-900));
  color: #a8bcd4; padding: 16px;
}
.ph-none span { font-size: 12px; font-weight: 600; color: #dce6f5; }
.ph-none small { font-size: 10.5px; opacity: .75; }
.ph figcaption { padding: 12px 14px 14px; }
.ph-cap { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

@media (max-width: 860px) {
  .msg { max-width: 92%; }
  .ph-grid { grid-template-columns: 1fr; }
}
