/* ============ TruCoast CRM ============ */

:root {
  --navy: #00297a;
  --navy-deep: #0a1b4a;
  --royal: #051aae;
  --royal-soft: #3a56d4;
  --periwinkle: #8fa5f5;
  --ink: #1c2333;
  --slate: #5a6478;
  --mist: #f4f7fc;
  --mist-2: #e8eef8;
  --line: #dbe4f0;
  --white: #fff;
  --green: #1d9e55;
  --green-bg: #e6f6ec;
  --amber: #b07d10;
  --amber-bg: #fdf3dd;
  --red: #c53030;
  --red-bg: #fdecec;
  --purple: #6b46c1;
  --purple-bg: #f1eafc;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(10,27,74,.08);
  --shadow-md: 0 8px 28px rgba(10,27,74,.13);
  --font-head: "Montserrat", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

*:disabled {
  background-color: light-dark(rgba(239, 239, 239, 0.3), rgba(59, 59, 59, 0.3)) !important;
}

body {
  font-family: var(--font-body);
  background: var(--mist);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4 { font-family: var(--font-head); color: var(--navy); }
button { font: inherit; cursor: pointer; }
a { color: var(--royal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Login ---------- */

.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, var(--navy-deep) 0%, var(--navy) 60%, var(--royal) 100%);
  padding: 24px; position: relative; overflow: hidden;
}
.login-waves { position: absolute; bottom: 0; left: 0; right: 0; opacity: .25; pointer-events: none; }
.login-card {
  background: var(--white); border-radius: 16px; box-shadow: var(--shadow-md);
  width: 100%; max-width: 400px; padding: 42px 38px; position: relative; z-index: 2;
}
.login-card img { height: 84px; margin: 0 auto 10px; display: block; }
.login-card .sub { text-align: center; color: var(--slate); font-size: .9rem; margin-bottom: 28px; }
.login-card h1 { text-align: center; font-size: 1.15rem; margin-bottom: 4px; }

/* ---------- Layout ---------- */

.app { display: none; min-height: 100vh; }
/* minmax(0, 1fr), not bare 1fr — a plain 1fr track won't shrink below its
   content's intrinsic width, so a long unbroken string anywhere inside (an
   email, a notes field) silently pushes the whole layout wider than the
   viewport instead of wrapping. */
.app.active { display: grid; grid-template-columns: 232px minmax(0, 1fr); }

.sidebar {
  background: var(--navy-deep); color: rgba(255,255,255,.8);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand img { height: 56px; }
.sidebar nav { padding: 14px 10px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 9px; color: rgba(255,255,255,.75);
  font-weight: 500; font-size: .92rem; text-decoration: none; transition: background .12s, color .12s;
}
.sidebar nav a svg { width: 19px; height: 19px; flex: none; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--royal); color: #fff; }
.sidebar-foot { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1); font-size: .8rem; color: rgba(255,255,255,.45); }

/* Collapsible nav group ("Manage") — same look as a regular nav link, plus a
   chevron that rotates open, revealing indented child links underneath. */
.nav-group-toggle {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 14px; border-radius: 9px; border: 0; background: transparent;
  color: rgba(255,255,255,.75); font-weight: 500; font-size: .92rem; font-family: inherit;
  transition: background .12s, color .12s;
}
.nav-group-toggle svg { width: 19px; height: 19px; flex: none; }
.nav-group-toggle span { flex: 1; text-align: left; }
.nav-group-toggle .chevron { width: 15px; height: 15px; transition: transform .18s ease; }
.nav-group-toggle:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-group-toggle.has-active { color: #fff; }
.nav-group-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.nav-group {
  display: grid; grid-template-rows: 0fr; overflow: hidden;
  transition: grid-template-rows .2s ease;
}
.nav-group.open { grid-template-rows: 1fr; }
.nav-group > div { overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.nav-group a { padding-left: 30px !important; font-size: .88rem !important; }
.nav-group a svg { width: 16px !important; height: 16px !important; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--white); border-bottom: 1px solid var(--line);
  padding: 0 28px; height: 62px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 1.05rem; }
.topbar-user { position: relative; font-size: .88rem; color: var(--slate); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--royal); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .82rem; font-family: var(--font-head);
}
.user-menu-trigger {
  display: flex; align-items: center; gap: 10px; background: transparent; border: 0;
  cursor: pointer; padding: 6px 10px 6px 6px; border-radius: 9px;
  font-size: .88rem; font-weight: 600; color: var(--navy);
}
.user-menu-trigger:hover { background: var(--mist-2); }
.user-menu-caret { color: var(--slate); transition: transform .15s ease; flex-shrink: 0; }
#user-menu.open .user-menu-caret { transform: rotate(180deg); }
.user-menu-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 190px;
  background: var(--white); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 28px rgba(10,27,74,.14); padding: 6px; z-index: 30;
  display: none;
}
.user-menu-dropdown.open { display: block; }
.user-menu-item {
  display: block; width: 100%; text-align: left; background: transparent; border: 0;
  padding: 9px 12px; border-radius: 7px; font-size: .88rem; font-weight: 500;
  color: var(--navy); cursor: pointer;
}
.user-menu-item:hover { background: var(--mist-2); }
.user-menu-item-danger:hover { background: var(--red-bg); color: var(--red); }
.user-menu-divider { height: 1px; background: var(--line); margin: 6px 4px; }

.view { padding: 28px; max-width: 1280px; width: 100%; opacity: 0; transform: translateY(6px); }
.view.view-in { opacity: 1; transform: none; transition: opacity .22s ease, transform .22s cubic-bezier(.22,1,.36,1); }
@media (prefers-reduced-motion: reduce) {
  .view { opacity: 1; transform: none; }
}

/* ---------- Components ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 9px;
  font-weight: 600; font-size: .88rem; padding: 9px 16px;
  transition: background .12s, box-shadow .12s, transform .1s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--royal); color: #fff; }
.btn-primary:hover { background: #0620c9; }
.btn-ghost { background: transparent; color: var(--navy); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-ghost:hover { background: var(--mist-2); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.panel {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.panel-head h3 { font-size: .98rem; }
.panel-body { padding: 20px; }

/* Stat cards */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat-card .label { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--slate); margin-bottom: 6px; }
.stat-card .value { font-family: var(--font-head); font-weight: 800; font-size: 1.7rem; color: var(--navy); }
.stat-card .hint { font-size: .78rem; color: var(--slate); margin-top: 2px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .89rem; }
table.data th {
  text-align: left; font-size: .74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--slate); padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: #fafcff; white-space: nowrap;
}
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--mist); }
/* Currency/numeric columns (Total, Value, Amount, Subtotal, Tax, Discount) —
   right-aligned on both the header and its cells so the figures themselves
   line up for scanning, not just the (left-aligned-by-default) column label. */
table.data th.num, table.data td.num { text-align: right; }
.td-main { font-weight: 600; color: var(--ink); }
.td-sub { font-size: .8rem; color: var(--slate); }

.empty-state { padding: 48px 24px; text-align: center; color: var(--slate); }
.empty-state h4 { color: var(--slate); margin-bottom: 6px; font-family: var(--font-body); font-weight: 600; }

/* Chips */
.chip {
  display: inline-block; font-size: .74rem; font-weight: 700; border-radius: 999px;
  padding: 3px 11px; white-space: nowrap; letter-spacing: .01em;
}
.chip.new         { background: var(--purple-bg); color: var(--purple); }
.chip.contacted   { background: #e3ecfd; color: #1d4fd7; }
.chip.walkthrough { background: var(--amber-bg); color: var(--amber); }
.chip.quoted      { background: #e0f2f7; color: #0e6880; }
.chip.won         { background: var(--green-bg); color: var(--green); }
.chip.lost        { background: var(--mist-2); color: var(--slate); }
.chip.scheduled   { background: #e3ecfd; color: #1d4fd7; }
.chip.in_progress { background: var(--amber-bg); color: var(--amber); }
.chip.completed   { background: var(--green-bg); color: var(--green); }
.chip.cancelled   { background: var(--mist-2); color: var(--slate); }
.chip.draft       { background: var(--mist-2); color: var(--slate); }
.chip.sent        { background: #e3ecfd; color: #1d4fd7; }
.chip.paid        { background: var(--green-bg); color: var(--green); }
.chip.overdue     { background: var(--red-bg); color: var(--red); }
.chip.void        { background: var(--mist-2); color: var(--slate); }
.chip.commercial  { background: #e3ecfd; color: var(--navy); }
.chip.residential { background: var(--purple-bg); color: var(--purple); }
.chip.accepted    { background: var(--green-bg); color: var(--green); }
.chip.declined    { background: var(--red-bg); color: var(--red); }
.chip.expired     { background: var(--mist-2); color: var(--slate); }
.chip.converted   { background: var(--purple-bg); color: var(--purple); }
.chip.unscheduled { background: var(--mist-2); color: var(--slate); }
.chip.en_route    { background: var(--amber-bg); color: var(--amber); }

.svc-tag { display: inline-block; font-size: .72rem; font-weight: 600; background: var(--mist-2); color: var(--navy); border-radius: 999px; padding: 2px 9px; margin: 2px 3px 2px 0; }

/* Filter bar */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.filter-tabs { display: flex; gap: 4px; background: var(--mist-2); border-radius: 9px; padding: 4px; flex-wrap: wrap; }
.filter-tabs button {
  border: 0; background: transparent; border-radius: 7px; padding: 6px 13px;
  font-weight: 600; font-size: .82rem; color: var(--slate);
}
.filter-tabs button.active { background: var(--white); color: var(--navy); box-shadow: var(--shadow-sm); }
.search-input { position: relative; margin-left: auto; }
.search-input input[type="text"] { padding: 9px 12px 9px 36px; width: 240px; }
.search-input svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--slate); }

/* Forms */
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=date],
input[type=time], input[type=number], select, textarea {
  width: 100%; padding: 9px 12px; font: inherit; font-size: .9rem;
  border: 1.5px solid var(--line); border-radius: 8px; background: var(--white); color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--royal); box-shadow: 0 0 0 3px rgba(5,26,174,.1);
}
textarea { resize: vertical; min-height: 80px; }
label.fl { display: block; font-weight: 600; font-size: .8rem; color: var(--navy); margin: 0 0 5px; }
.fgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 16px; }
.fgrid .full { grid-column: 1 / -1; }
.form-err { color: var(--red); background: var(--red-bg); border-radius: 8px; padding: 10px 14px; font-size: .86rem; margin-top: 14px; display: none; }
.form-err.show { display: block; }

.pw-reqs {
  display: none; list-style: none; margin-top: 14px; padding: 10px 14px;
  background: var(--mist); border-radius: 8px; font-size: .8rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 6px 20px;
}
.pw-reqs.show { display: grid; }
.pw-reqs li { color: var(--red); transition: color .15s ease; }
.pw-reqs li.met { color: var(--green); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,27,74,.5); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 20px 20px;
  backdrop-filter: blur(2px);
  animation: modal-fade .16s ease;
}
.modal {
  background: var(--white); border-radius: 14px; box-shadow: var(--shadow-md);
  width: 100%; max-width: 560px; max-height: 86vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: modal-in .18s cubic-bezier(.22,1,.36,1);
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal { animation: none; }
}
/* Header and footer stay put; only the body scrolls — a long form (e.g. the
   Contact & Addresses editor) shouldn't be able to scroll the title, close
   button, or Save/Cancel actions out of view. */
.modal-head {
  padding: 18px 24px; border-bottom: 1px solid var(--line); display: flex;
  justify-content: space-between; align-items: center; flex: none;
}
.modal-head h3 { font-size: 1.02rem; }
.modal-close { background: none; border: 0; font-size: 1.4rem; color: var(--slate); line-height: 1; padding: 4px; }
.modal-body { padding: 22px 24px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex: none; }

/* Detail layout */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 12px; font-size: .9rem; }
.kv dt { color: var(--slate); font-weight: 500; }
.kv dd { color: var(--ink); word-break: break-word; }
.customer-profile-list { display: grid; gap: 12px; }
.customer-profile-list-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 2px; }
.modal.modal-wide { max-width: 760px; }
.customer-editor-list { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.customer-address-row { padding: 14px; border-bottom: 1px solid var(--mist-2); }
.customer-address-row:last-child { border-bottom: 0; }
.customer-editor-row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.customer-contact-options { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 11px; }
.customer-contact-options label, .customer-primary-choice { display: flex; align-items: center; gap: 6px; color: var(--slate); font-size: .8rem; }
.customer-contact-options input, .customer-primary-choice input { width: auto; }
.customer-contact-line { display: grid; grid-template-columns: minmax(110px,.65fr) minmax(180px,1.35fr) auto auto; gap: 10px; align-items: end; padding: 12px 14px; border-bottom: 1px solid var(--mist-2); }
.customer-contact-line:last-child { border-bottom: 0; }
.customer-contact-line .btn { margin-bottom: 1px; }
.customer-primary-choice { padding-bottom: 9px; white-space: nowrap; }
.customer-state-zip { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }

/* Activity timeline */
.timeline { list-style: none; }
.timeline li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--mist-2); }
.timeline li:last-child { border-bottom: 0; }
.tl-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--mist-2); color: var(--navy); display: flex; align-items: center; justify-content: center; flex: none; margin-top: 2px; }
.tl-dot svg { width: 15px; height: 15px; }
.tl-body { min-width: 0; }
.tl-meta { font-size: .76rem; color: var(--slate); margin-top: 2px; }
.tl-text { font-size: .89rem; white-space: pre-wrap; word-break: break-word; }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head h3 { font-size: 1.05rem; }
.cal-nav { display: flex; gap: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; }
.cal-dow { background: #fafcff; padding: 8px 6px; text-align: center; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--slate); }
.cal-cell { background: var(--white); min-height: 104px; padding: 6px 7px; font-size: .8rem; position: relative; cursor: pointer; transition: background .1s; }
.cal-cell:hover { background: var(--mist); }
.cal-cell.other { background: #fafbfd; color: #b6c0d4; }
.cal-cell .dnum { font-weight: 600; margin-bottom: 4px; }
.cal-cell.today .dnum { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; background: var(--royal); color: #fff; border-radius: 50%; }
.cal-job {
  display: block; border-radius: 6px; padding: 3px 7px; margin-bottom: 3px;
  font-size: .72rem; font-weight: 600; color: #fff; background: var(--royal-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-job.completed { background: var(--green); }
.cal-job.in_progress { background: var(--amber); }
.cal-job.cancelled { background: #9aa4b8; text-decoration: line-through; }

/* Toast */
#toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--navy-deep); color: #fff; border-radius: 10px; padding: 13px 18px;
  font-size: .88rem; box-shadow: var(--shadow-md); animation: slideup .25s ease;
  max-width: 340px;
}
.toast.err { background: var(--red); }
@keyframes slideup { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Pipeline mini-board */
.pipe-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.pipe-col { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; text-align: center; }
.pipe-col .n { font-family: var(--font-head); font-weight: 800; font-size: 1.35rem; color: var(--navy); }
.pipe-col .l { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--slate); }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* Invoice line-item builder */
.inv-section-head { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 8px; }
.inv-section-label { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--navy); margin: 0; }
.inv-lines-table { border: 1px solid var(--line); border-radius: 9px; overflow-x: auto; }
.inv-line-cols {
  display: grid; grid-template-columns: 1fr 64px 90px 64px 90px 28px;
  gap: 8px; align-items: center;
}
.inv-line-row { padding: 7px 10px; border-bottom: 1px solid var(--mist-2); min-width: 460px; }
.inv-line-row:last-child { border-bottom: 0; }
.inv-line-head {
  background: #fafcff; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--slate); padding: 8px 10px; min-width: 460px;
}
.inv-line-name strong { display: block; font-size: .85rem; color: var(--navy); font-weight: 600; line-height: 1.25; }
.inv-line-name .td-sub { font-size: .72rem; }
.inv-line-row input[type=text], .inv-line-row input[type=number] { padding: 6px 8px; font-size: .85rem; }
.inv-line-tax { text-align: center; }
.inv-line-tax label { display: flex; align-items: center; gap: 5px; font-size: .78rem; color: var(--slate); justify-content: center; white-space: nowrap; }
.inv-line-tax input { width: auto; }
.inv-line-total { font-weight: 600; font-size: .88rem; text-align: right; padding-right: 4px; }
.inv-line-remove {
  border: 0; background: var(--red-bg); color: var(--red); border-radius: 6px;
  width: 22px; height: 22px; line-height: 1; font-size: 1rem; padding: 0;
  transition: background .12s, transform .12s;
}
.inv-line-remove:hover { background: #f8d5d5; transform: scale(1.06); }
.inv-line-note-row { margin-top: 6px; }
.inv-line-note {
  width: 100%; padding: 5px 8px; font-size: .78rem; color: var(--slate);
  border: 1px dashed var(--line); border-radius: 6px; background: #fafcff;
}

.catalog-pick-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.catalog-pick-filters input[type=text] { flex: 1; min-width: 180px; }
.catalog-pick-list { max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; }
.catalog-pick-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--mist-2); cursor: pointer; transition: background .12s;
}
.catalog-pick-row:last-child { border-bottom: 0; }
.catalog-pick-row:hover { background: #fafcff; }
.catalog-pick-row.disabled { cursor: not-allowed; opacity: .45; }
.catalog-pick-row.disabled:hover { background: none; }
.catalog-pick-name { flex: 1; min-width: 0; }
.catalog-pick-name strong { display: block; font-size: .88rem; color: var(--navy); font-weight: 600; }
.catalog-pick-name .td-sub { font-size: .74rem; }
.catalog-pick-price { font-weight: 600; font-size: .86rem; white-space: nowrap; min-width: 64px; text-align: right; }

.inv-promo-row { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.inv-promo-row input { width: auto; flex: 1; }
#inv-promo-result { font-size: .82rem; font-weight: 600; }
#inv-promo-result.ok { color: var(--green); }
#inv-promo-result.err { color: var(--red); }

.inv-summary {
  margin-top: 16px; margin-left: auto; max-width: 280px;
  background: #fafcff; border: 1px solid var(--line); border-radius: 9px; padding: 12px 16px;
}
.inv-summary > div { display: flex; justify-content: space-between; padding: 4px 0; font-size: .88rem; color: var(--slate); }
.inv-summary .total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; font-size: 1rem; color: var(--navy); }
.inv-summary .total strong { color: var(--royal); font-family: var(--font-head); }
.inv-summary:has(> :only-child) .total { border-top: 0; margin-top: 0; padding-top: 0; }

/* Read-only, customer-facing invoice presentation (the default view for an
   existing invoice — Edit switches to the internal form). Deliberately looks
   like a document, not an app screen: no chips/badges beyond the status, no
   editable-looking inputs. */
.inv-doc-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 20px; margin-bottom: 24px; border-bottom: 2px solid var(--line);
}
.inv-doc-logo { height: 86px; }
.inv-doc-head-right { text-align: right; }
.inv-doc-title {
  font-family: var(--font-head); font-size: 1.3rem; font-weight: 800;
  color: var(--navy); letter-spacing: .06em;
}
.inv-doc-number { color: var(--slate); font-size: .88rem; margin: 3px 0 10px; }
.inv-doc-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px 16px; margin-bottom: 28px;
}
.inv-doc-meta h5 {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--slate); margin-bottom: 8px;
}
.inv-doc-meta p { margin: 2px 0; font-size: .9rem; color: var(--ink); }
.inv-doc-meta p .td-sub { font-size: .82rem; }
.inv-doc-meta .td-main { font-weight: 700; color: var(--navy); }
.inv-doc-table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.inv-doc-table th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .03em;
  color: var(--slate); padding: 8px 10px; border-bottom: 1.5px solid var(--line);
}
.inv-doc-table td { padding: 11px 10px; border-bottom: 1px solid var(--mist-2); font-size: .9rem; }
.inv-doc-table th:not(:first-child), .inv-doc-table td:not(:first-child) { text-align: right; }
.inv-doc-notes {
  margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line);
}
.inv-doc-notes h5 {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--slate); margin-bottom: 6px;
}
.inv-doc-notes p { font-size: .88rem; color: var(--ink); white-space: pre-wrap; }
@media (max-width: 640px) {
  .inv-doc-meta { grid-template-columns: 1fr; }
  .inv-doc-table th, .inv-doc-table td { padding: 8px 6px; font-size: .82rem; }
}

/* Multi-technician assignment picker (job scheduling) */
.tech-picker { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.tech-picker-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-bottom: 1px solid var(--mist-2); flex-wrap: wrap;
}
.tech-picker-row:last-child { border-bottom: 0; }
.tech-picker-row label { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: .88rem; flex: 1; min-width: 160px; }
.tech-picker-row label input { width: auto; }
.tech-picker-row input[type=number] { width: 140px; padding: 5px 8px; font-size: .82rem; }

.mobile-nav-btn { display: none; }

@media (max-width: 1000px) {
  .detail-grid, .two-col { grid-template-columns: minmax(0, 1fr); }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .pipe-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .app.active { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 90; width: 232px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-md); }
  .mobile-nav-btn { display: inline-flex; background: none; border: 0; color: var(--navy); margin-right: 10px; }
  .view { padding: 18px 14px; }
  .fgrid { grid-template-columns: minmax(0, 1fr); }
  .customer-contact-line { grid-template-columns: minmax(0, 1fr); }
  .customer-primary-choice { padding-bottom: 0; }
  .search-input { margin-left: 0; width: 100%; }
  .search-input input[type="text"] { width: 100%; }
  /* The label column of a plain .kv is too narrow on a phone once it has to
     hold multi-line contact info (email addresses, phone numbers, badges) —
     stack the label above its content instead of squeezing them side by side. */
  .kv-contact { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .kv-contact dt {
    margin-top: 16px; text-transform: uppercase; font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  }
  .kv-contact dt:first-child { margin-top: 0; }
}
