/* /var/www/rbrs/portal/assets/css/portal.css
   ADD portal styles. One layout for every brand; brand colours swap via body class. */

:root {
  --brand: #1F35D6;
  --brand-dark: #1A2CB3;
  --bar: #0E1A4F;
  --ink: #1B2233;
  --muted: #5B6478;
  --line: #DFE3EC;
  --bg: #F4F6FB;
  --card: #FFFFFF;
  --success-bg: #E7F6EC; --success-ink: #1C6B37;
  --error-bg: #FDECEC;   --error-ink: #A12A2A;
  --info-bg: #E9EDFC;    --info-ink: #1A2C8F;
  --radius: 8px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

body.brand-automateav {
  --brand: #7A8436;
  --brand-dark: #66702C;
  --bar: #3D3D3D;
  --info-bg: #F1F3E4;
  --info-ink: #4D5420;
}

*, *::before, *::after { box-sizing: border-box; }

body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.6; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
h1 { font-size: 1.6rem; margin: 0 0 16px; font-weight: 600; }
h2 { font-size: 1.15rem; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 1rem; margin: 22px 0 6px; font-weight: 600; }
p { margin: 0 0 12px; }
code { font-family: var(--mono); }

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 460px; }
main.wrap { padding-top: 32px; padding-bottom: 48px; min-height: calc(100vh - 140px); }

/* Top bar */
.topbar { background: var(--bar); color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.brand img { width: 130px; height: auto; display: block; }
.product { font-weight: 600; letter-spacing: 0.12em; font-size: 0.85rem; padding: 2px 8px; border: 1px solid rgba(255,255,255,0.45); border-radius: 4px; }
.topnav { display: flex; align-items: center; gap: 16px; font-size: 0.95rem; }
.topnav a, .topnav .link-button { color: #fff; }
.who { color: #C9D0EE; }
.inline-form { display: inline; margin: 0; }
.link-button { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; margin-bottom: 20px; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }

/* Forms */
.field { margin-bottom: 16px; min-width: 0; }
.field label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; }
.field input { width: 100%; padding: 11px 12px; border: 1px solid #C7CDDA; border-radius: var(--radius); font: inherit; color: var(--ink); background: #fff; }
.field input:focus, .inline-row input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hint { color: var(--muted); font-size: 0.88rem; margin: 6px 0 14px; }
.code-input { font-family: var(--mono); font-size: 1.25rem; letter-spacing: 0.2em; }
.code-input::placeholder { font-family: var(--font); font-size: 0.95rem; letter-spacing: normal; }
.code-input.short { width: 170px; padding: 9px 12px; border: 1px solid #C7CDDA; border-radius: var(--radius); }
.inline-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons */
.btn { display: inline-block; background: var(--brand); color: #fff; border: 2px solid var(--brand); border-radius: var(--radius); padding: 10px 20px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-block { width: 100%; }
.btn-secondary { background: #fff; color: var(--brand); }
.btn-secondary:hover { background: var(--info-bg); color: var(--brand-dark); }

/* Messages */
.notice { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; font-weight: 500; }
.notice-success { background: var(--success-bg); color: var(--success-ink); }
.notice-error { background: var(--error-bg); color: var(--error-ink); }
.notice-info { background: var(--info-bg); color: var(--info-ink); }

/* 2FA setup */
.steps { padding-left: 1.2em; }
.steps li { margin-bottom: 12px; }
.qr { margin: 12px 0; }
.qr img { display: block; width: 200px; height: 200px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.secret { display: inline-block; margin-top: 4px; padding: 4px 8px; background: var(--bg); border-radius: 4px; word-break: break-all; }
.recovery-codes { list-style: none; padding: 16px; margin: 16px 0 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; background: var(--bg); border-radius: var(--radius); }
.recovery-codes code { font-size: 1.05rem; }
details summary { cursor: pointer; color: var(--brand); }

/* Account */
.details { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; margin-right: 6px; }
.pill-on { background: var(--success-bg); color: var(--success-ink); }
.pill-off { background: var(--error-bg); color: var(--error-ink); }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 8px 6px; }
.table td { border-bottom: 1px solid var(--line); padding: 8px 6px; }

/* ---------- Stage 2: customers & contacts ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 4px; }
.head-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.crumbs { font-size: 0.9rem; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.btn-small { padding: 6px 14px; font-size: 0.92rem; }

.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar input[type=search] { flex: 1 1 280px; min-width: 0; padding: 9px 12px; border: 1px solid #C7CDDA; border-radius: var(--radius); font: inherit; background: #fff; }
.filter-bar select, .field select { padding: 9px 10px; border: 1px solid #C7CDDA; border-radius: var(--radius); font: inherit; background: #fff; color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; cursor: pointer; }
.field label.check { display: inline-flex; font-weight: 400; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); margin: 0; }

.card.flush { padding: 0; overflow: hidden; }
.card.empty { text-align: center; padding: 40px 24px; }
.customer-list, .branch-list { list-style: none; margin: 0; padding: 0; }
.customer-list > li { border-bottom: 1px solid var(--line); }
.customer-list > li:last-child { border-bottom: 0; }
.customer-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; text-decoration: none; color: var(--ink); flex-wrap: wrap; }
.customer-row:hover { background: var(--bg); }
.cust-name { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.cust-meta { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.count { color: var(--muted); font-size: 0.88rem; }
.branch-row { padding-top: 9px; padding-bottom: 9px; padding-left: 36px; border-top: 1px dashed var(--line); }
.branch-row .cust-name { font-weight: 500; }
.branch-mark { color: var(--muted); }
.context-only > .customer-row .cust-name { color: var(--muted); font-weight: 500; }

.brand-pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.02em; }
.brand-pill-rbrs { background: #E6E9FB; color: #1A2C8F; }
.brand-pill-automateav { background: #EEF0DD; color: #4D5420; }
.tag { display: inline-block; padding: 0 8px; border-radius: 4px; background: #ECEEF3; color: var(--muted); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.grid-2 > * { min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.details.wide { grid-template-columns: 105px 1fr; }
.internal-note { background: #FFF8E6; border-left: 3px solid #E0B44C; padding: 10px 12px; border-radius: 0; font-size: 0.95rem; }
.simple-list { list-style: none; margin: 0; padding: 0; }
.simple-list li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.simple-list li:last-child { border-bottom: 0; }

.people-table td { vertical-align: top; }
.row-left td { color: var(--muted); }
.row-actions { text-align: right; white-space: nowrap; }
.access-pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; margin: 0 4px 2px 0; }
.access-none { background: #ECEEF3; color: var(--muted); }
.access-own { background: #E3F1FA; color: #155A82; }
.access-all { background: var(--success-bg); color: var(--success-ink); }
.access-manage { background: #FFF1D6; color: #7A4E00; }

.placeholder { border-style: dashed; background: transparent; }
.danger-zone { margin-top: 8px; padding: 0 4px; display: flex; gap: 10px; align-items: center; }
.danger-zone form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.link-button.danger { color: var(--error-ink); }

/* Forms (wider pages) */
.form-card { max-width: 720px; }
.field textarea { width: 100%; padding: 10px 12px; border: 1px solid #C7CDDA; border-radius: var(--radius); font: inherit; color: var(--ink); resize: vertical; }
.field textarea:focus, .field select:focus, .filter-bar input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
fieldset.field { border: 0; padding: 0; margin: 0 0 16px; }
fieldset.field legend { font-weight: 600; font-size: 0.95rem; margin-bottom: 8px; padding: 0; }
.check-row { display: flex; gap: 20px; flex-wrap: wrap; }
.address-row { grid-template-columns: 2fr 1fr; }
.opt { font-weight: 400; color: var(--muted); }
.has-error input, .has-error textarea { border-color: var(--error-ink); }
.field-error { color: var(--error-ink); font-size: 0.88rem; margin: 6px 0 0; }
.form-actions { display: flex; gap: 16px; align-items: center; margin-top: 8px; }
.radio-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer; font-weight: 400 !important; }
.radio-card input, .field .radio-card input { width: auto; padding: 0; margin: 4px 0 0; flex: 0 0 auto; accent-color: var(--brand); }
.field .check input { width: 17px; padding: 0; }
.people-table + p, .table + p { margin-top: 12px; }
.topnav a, .topnav .link-button { white-space: nowrap; }
.radio-card:has(input:checked) { border-color: var(--brand); background: var(--info-bg); }

/* ---------- Customer details (R3-style) ---------- */
[hidden] { display: none !important; }
.segmented { display: inline-flex; border: 1px solid #C7CDDA; border-radius: var(--radius); overflow: hidden; }
.segmented label { display: inline-flex; align-items: center; gap: 0; margin: 0; padding: 9px 18px; cursor: pointer; font-weight: 500; background: #fff; border-right: 1px solid #C7CDDA; }
.segmented label:last-child { border-right: 0; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label:has(input:checked) { background: var(--brand); color: #fff; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.name-row { grid-template-columns: 110px 1fr 1fr; }
.phone-row { grid-template-columns: 1.4fr 1fr; }
.form-section { font-size: 1rem; margin: 24px 0 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.upper { text-transform: uppercase; }
.upper::placeholder { text-transform: none; }
.acct { font-family: var(--mono); font-weight: 600; letter-spacing: 0.02em; }
.acct-col { display: inline-block; min-width: 92px; color: var(--muted); font-weight: 500; font-size: 0.9rem; }
.acct-line { margin: 0 0 6px; }
.account-badge { background: var(--bg); padding: 10px 14px; border-radius: var(--radius); }
.letter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 20px; }
.letter-cell { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.letter-cell label { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.letter-cell .letter { font-weight: 700; font-size: 1.1rem; }
.letter-cell input { width: 100%; padding: 7px 9px; border: 1px solid #C7CDDA; border-radius: 6px; font: inherit; }
.letter-cell.has-error input { border-color: var(--error-ink); }

/* ---------- Stage 3: ADD builder ---------- */
.wide-form { max-width: 860px; }
.type-desc { font-weight: 400; }
.req { color: var(--error-ink); }
.private-tag { display: inline-block; padding: 0 6px; border-radius: 4px; background: #FFF1D6; color: #7A4E00; font-size: 0.72rem; font-weight: 600; vertical-align: middle; }
.person-tag { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; background: #E3F1FA; color: #155A82; font-size: 0.78rem; font-weight: 600; }

/* Type designer */
.field-defs { list-style: none; margin: 0 0 12px; padding: 0; }
.field-def { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: #fff; }
.field-def.has-error { border-color: var(--error-ink); }
.field-def.is-removed { opacity: 0.5; background: var(--bg); }
.field-def.is-removed .fd-label input { text-decoration: line-through; }
.fd-main { display: grid; grid-template-columns: 34px 1fr 210px; gap: 10px; align-items: center; }
.fd-move { display: flex; flex-direction: column; gap: 2px; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 4px; font-size: 0.65rem; line-height: 1; padding: 3px 0; width: 30px; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--brand); border-color: var(--brand); }
.fd-label input, .fd-kind select, .fd-help { width: 100%; padding: 9px 10px; border: 1px solid #C7CDDA; border-radius: 6px; font: inherit; background: #fff; }
.fd-kind select:disabled { background: var(--bg); color: var(--muted); }
.fd-extra { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin: 10px 0 0 44px; font-size: 0.92rem; }
.fd-help { flex: 1 1 200px; width: auto; padding: 6px 9px; font-size: 0.9rem; }
.fd-remove { margin-left: auto; color: var(--error-ink); }
.fd-options { margin: 10px 0 0 44px; }
.fd-options label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 4px; }
.fd-options textarea { width: 100%; padding: 8px 10px; border: 1px solid #C7CDDA; border-radius: 6px; font: inherit; }
.fd-lock { margin: 6px 0 0 44px; }
.field-def .field-error { margin-left: 44px; }

/* ADD form */
.secret-input { display: flex; gap: 8px; }
.secret-input input { flex: 1; font-family: var(--mono); }
.file-input { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px; border: 1px dashed #C7CDDA; border-radius: var(--radius); background: var(--bg); }
.file-input input[type=file] { font: inherit; font-size: 0.9rem; max-width: 100%; }
.file-name { word-break: break-all; }
.current-file { margin: 0 0 8px; }
.upload-progress { margin: 8px 0 16px; }
.upload-progress .bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.upload-progress .bar span { display: block; height: 100%; width: 0; background: var(--brand); transition: width 0.2s; }
.upload-progress p { margin: 6px 0 0; }
.field.kind-checkbox { margin-top: 4px; }

/* + ADD menu */
.add-menu { position: relative; }
.add-menu summary { list-style: none; cursor: pointer; }
.add-menu summary::-webkit-details-marker { display: none; }
.add-menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 230px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 24px rgba(14, 26, 79, 0.12); padding: 6px 0; }
.add-menu-list a { display: block; padding: 8px 16px; color: var(--ink); text-decoration: none; }
.add-menu-list a:hover { background: var(--bg); }
.add-menu-list .menu-sep { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; }
.add-menu-list .menu-new { color: var(--brand); font-weight: 600; }

/* ADDs on the customer page */
.add-group { margin: 18px 0 8px; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.add-group:first-of-type { margin-top: 4px; }
.add-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.add-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: #fff; min-width: 0; }
.add-item:target { border-color: var(--brand); box-shadow: 0 0 0 2px var(--info-bg); }
.add-item header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.add-values { display: grid; grid-template-columns: minmax(90px, 40%) 1fr; gap: 6px 12px; margin: 0; font-size: 0.93rem; }
.add-values dt { color: var(--muted); }
.add-values dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.secret-value { font-family: var(--mono); letter-spacing: 0.05em; margin-right: 8px; }
.secret-value.revealed { background: #FFF8E6; padding: 0 4px; border-radius: 3px; letter-spacing: 0; user-select: all; }
.secret-actions { white-space: nowrap; font-size: 0.88rem; }
.secret-actions .link-button { color: var(--brand); margin-right: 8px; }
.notes-value { display: block; white-space: normal; }
.file-link { word-break: break-all; }

.foot { color: var(--muted); font-size: 0.85rem; padding: 18px 0 24px; }
.foot a { color: var(--muted); }

@media (max-width: 640px) {
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .who { display: none; }
  .brand img { width: 100px; }
  .card { padding: 18px; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
  .grid-2, .radio-cards, .address-row { grid-template-columns: 1fr; }
  .name-row { grid-template-columns: 1fr; }
  .phone-row { grid-template-columns: 1.4fr 1fr; gap: 10px; }
  .acct-col { display: block; min-width: 0; font-size: 0.8rem; }
  .cust-name { flex-wrap: wrap; }
  .people-table th:nth-child(2), .people-table td:nth-child(2) { display: none; }
  .customer-row { padding: 12px 14px; }
  .branch-row { padding-left: 28px; }
  .topnav { gap: 12px; font-size: 0.88rem; }
  .product { display: none; }
  .nav-types { display: none; }
  .fd-main { grid-template-columns: 34px 1fr; }
  .fd-kind { grid-column: 2; }
  .fd-extra, .fd-options, .fd-lock, .field-def .field-error { margin-left: 0; }
  .add-grid { grid-template-columns: 1fr; }
  .add-menu-list { right: auto; left: auto; right: 0; }
}

/* Phones: ADD labels sit above their values so addresses and passwords aren't split mid-word */
@media (max-width: 560px) {
  .add-values { grid-template-columns: 1fr; gap: 0; }
  .add-values dt { font-size: 0.8rem; margin-top: 8px; }
  .add-values dt:first-child { margin-top: 0; }
  .add-values dd { overflow-wrap: break-word; }
}

/* ---------- Stage 4: service visits ---------- */
.field .label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; }
.visit-when { grid-template-columns: 1fr 1fr 1fr; }
.duration { display: flex; align-items: center; gap: 6px; }
.duration input { width: 64px; text-align: center; }
.duration select { padding: 10px 8px; }
.duration span { color: var(--muted); }
.client-check { margin-top: 8px; }
.foc-reason { margin-top: 8px; }
#invoice-box input[type=text] { margin-top: 8px; }
.charge-box { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 16px; flex-wrap: wrap;
  background: var(--bg); border-radius: var(--radius); padding: 12px 14px; margin: 4px 0 8px; }
.charge-box strong { font-size: 1.05rem; }

.money-input { display: flex; align-items: center; border: 1px solid #C7CDDA; border-radius: var(--radius); background: #fff; }
.money-input span { padding: 0 2px 0 12px; color: var(--muted); }
.field .money-input input { border: 0; padding-left: 4px; }
.money-input:focus-within { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.has-error .money-input { border-color: var(--error-ink); }

.rate-dialog { border: 0; border-radius: 12px; padding: 24px; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(14, 26, 79, 0.25); color: var(--ink); }
.rate-dialog::backdrop { background: rgba(14, 26, 79, 0.45); }
.rate-dialog:not([open]) { display: none; }
form .rate-dialog[open]:not(:modal) { position: static; width: auto; margin: 12px 0; border: 2px solid var(--brand); box-shadow: none; }

.rate-rows { display: grid; gap: 4px; }
.rate-row { display: grid; grid-template-columns: 1fr 150px 150px; gap: 12px; align-items: end; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rate-row:last-child { border-bottom: 0; }
.rate-row .field { margin-bottom: 0; }
.rate-type { display: flex; flex-direction: column; gap: 2px; align-self: center; }
.rate-type .vpill { align-self: flex-start; }
.no-callout { display: block; padding: 11px 0; }

.rates-line { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-bottom: 12px; }
.rate-chip { font-size: 0.85rem; background: var(--bg); border-radius: 999px; padding: 2px 10px; }
.rate-chip.rate-missing { background: #FFF1D6; color: #7A4E00; }
.to-invoice-note { background: var(--info-bg); color: var(--info-ink); padding: 8px 12px; border-radius: var(--radius); }

.vpill { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.vpill-open { background: #E3F1FA; color: #155A82; }
.vpill-foc { background: #ECEEF3; color: var(--muted); }
.vpill-invoiced { background: var(--success-bg); color: var(--success-ink); }
.vpill-due { background: #FFF1D6; color: #7A4E00; }
.vpill-follow { background: var(--error-bg); color: var(--error-ink); }
.vpill-callout { background: #EEF0DD; color: #4D5420; }

.visit-list { list-style: none; margin: 0; padding: 0; }
.visit-list.in-card { margin: 0 -8px; }
.visit-row { display: flex; align-items: flex-start; gap: 10px; border-bottom: 1px solid var(--line); }
.visit-row:last-child { border-bottom: 0; }
.visit-row > input[type=checkbox] { width: 18px; height: 18px; margin: 16px 0 0 14px; accent-color: var(--brand); flex: 0 0 auto; }
.visit-link { flex: 1; min-width: 0; display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; color: var(--ink); text-decoration: none; }
.visit-list.in-card .visit-link { padding: 10px 8px; }
.visit-link:hover { background: var(--bg); }
.visit-row:target .visit-link { background: var(--info-bg); }
.visit-main { display: flex; flex-direction: column; min-width: 0; }
.visit-date { font-weight: 600; }
.visit-cust { font-weight: 600; color: var(--brand); }
.visit-summary { color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.visit-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; flex: 0 0 auto; }
.visit-charge { font-weight: 600; white-space: nowrap; }
.visit-pills { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.visit-files li { gap: 12px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--brand); }
.tab-count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: #ECEEF3; font-size: 0.78rem; text-align: center; }
.tab-count.warn { background: var(--error-bg); color: var(--error-ink); }
.visit-group-head { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 12px 14px; background: var(--bg); border-bottom: 1px solid var(--line); }
.group-total { font-size: 0.92rem; }
.invoice-bar .inline-row input { flex: 1 1 200px; padding: 9px 12px; border: 1px solid #C7CDDA; border-radius: var(--radius); font: inherit; }
.type-row { display: flex; align-items: center; }
.type-row .fd-move { padding-left: 12px; }
.type-row .customer-row { flex: 1; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

@media (max-width: 700px) {
  .visit-when { grid-template-columns: 1fr 1fr; column-gap: 12px; }
  .visit-when .field:last-child { grid-column: 1 / -1; }
  .rate-row { grid-template-columns: 1fr 1fr; }
  .rate-type { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .visit-link { flex-direction: column; gap: 6px; }
  .visit-side { flex-direction: row; align-items: center; justify-content: space-between; text-align: left; }
}
.field .money-input input:focus { outline: none; border: 0; }
.check.client-check { align-items: flex-start; }
.check.client-check input { margin-top: 3px; flex: 0 0 auto; }

/* Price tiers (stage 4+) */
.sub-head { font-size: 1.05rem; margin: 20px 0 4px; }
.assign-row { display: grid; grid-template-columns: 1fr 200px auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.assign-row:last-child { border-bottom: 0; }
.assign-name { display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.assign-row select { padding: 8px 10px; border: 1px solid #C7CDDA; border-radius: var(--radius); font: inherit; background: #fff; color: var(--ink); width: 100%; }
.assign-actions { padding: 14px; border-top: 1px solid var(--line); margin: 0; }
@media (max-width: 560px) {
  .assign-row { grid-template-columns: 1fr auto; }
  .assign-name { grid-column: 1 / -1; }
}

/* Test copy banner */
.test-banner { background: #B42318; color: #fff; text-align: center; font-weight: 600; padding: 6px 12px; font-size: 0.9rem; }

/* Jobs and invoices (stage 4c) */
.job-no { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); margin-right: 4px; }
.job-title { font-size: 1.1rem; margin: 2px 0 4px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.inv-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.credit-row td { color: var(--muted); }
.inv-lines tfoot td { border-bottom: 0; padding-top: 4px; padding-bottom: 4px; }
.inv-lines tfoot tr.grand td, .inv-table tfoot tr.grand td { font-weight: 700; border-top: 2px solid var(--ink); }
.table-wrap { overflow-x: auto; }
.month-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.search-inline { display: flex; gap: 6px; }
.search-inline input { padding: 8px 10px; border: 1px solid #C7CDDA; border-radius: var(--radius); font: inherit; min-width: 0; }
.pre { white-space: pre-line; }
.small-seg { margin-bottom: 8px; }
.invoice-doc { max-width: 820px; }
.inv-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 24px; }
.inv-logo { display: block; margin-bottom: 8px; height: auto; }
.inv-title { margin: 0 0 8px; letter-spacing: 0.06em; font-size: 1.3rem; }
.inv-meta-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 2px 12px 2px 0; }
.inv-meta-table td { padding: 2px 0; }
.inv-to { margin-bottom: 20px; }
.inv-to h3, .inv-pay h3 { margin: 0 0 4px; }
.inv-pay { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line); }
.inv-foot { margin-top: 24px; }
@media print {
  .topbar, .foot, .no-print, .test-banner, .notice { display: none !important; }
  body { background: #fff; }
  main.wrap { max-width: none; padding: 0; }
  .card.invoice-doc { border: 0; padding: 0; margin: 0; max-width: none; }
  a { color: inherit; text-decoration: none; }
}
/* Phone: more nav links since jobs and invoices, so let the nav wrap under the logo */
@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; row-gap: 8px; }
  .topnav { flex-wrap: wrap; row-gap: 6px; column-gap: 14px; }
}
.who { white-space: nowrap; }
@media (max-width: 1180px) { .who { display: none; } }

.inv-pay { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line); border-collapse: collapse; }
.inv-pay th { text-align: left; color: var(--muted); font-weight: 500; padding: 3px 18px 3px 0; vertical-align: top; white-space: nowrap; }
.inv-pay td { padding: 3px 0; }
@media (max-width: 560px) { .inv-lines th:nth-child(2), .inv-lines td:nth-child(2), .inv-lines th:nth-child(3), .inv-lines td:nth-child(3) { display: none; } .inv-lines tfoot td[colspan] { text-align: right; } }
