* { box-sizing: border-box; }
html, body { margin: 0; max-width: 100%; min-width: 0; overflow-x: hidden; overflow-x: clip; width: 100%; }
body { background: #f5f7fb; color: #002080; font-family: Arial, sans-serif; font-size: 18px; }
img, video, iframe { max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
.login-body { align-items: center; background: linear-gradient(135deg, #f39a13, #ffe0a8); display: flex; min-height: 100vh; justify-content: center; padding: 24px; }
.login-card { background: #030303; border-radius: 10px; box-shadow: 0 18px 50px rgba(0,0,0,.25); color: #fff; max-width: 520px; padding: 56px 50px 42px; position: relative; width: 100%; }
.login-home-link { align-items: center; background: #ff9f00; border-radius: 999px; color: #fff; display: inline-flex; font-weight: 900; left: 18px; min-height: 34px; padding: 7px 15px; position: absolute; text-decoration: none; top: 16px; }
.login-card h1 { color: #ff9f00; font-size: 40px; font-weight: 400; margin: 0 0 28px; text-align: center; }
.login-card label { display: block; margin: 16px 0 7px; }
.login-card input { background: #eaf2ff; border: 1px solid #cfd8ea; border-radius: 7px; color: #001b65; display: block; padding: 12px 14px; width: 100%; }
.login-card button, .primary-btn { background: linear-gradient(100deg, #f59a13, #0826d9); border: 0; border-radius: 7px; color: #fff; cursor: pointer; font-weight: 800; min-height: 44px; padding: 10px 18px; text-decoration: none; }
.error { background: #ffe9e9; border: 1px solid #ffb6b6; border-radius: 8px; color: #9a1111; margin-bottom: 14px; padding: 10px 12px; }
.success { background: #e8f8ed; border: 1px solid #9ddbb1; border-radius: 8px; color: #12652d; font-weight: 800; margin-bottom: 14px; padding: 10px 12px; }
.app-header { background: #fff; border-bottom: 1px solid #d8dde8; min-height: 190px; overflow: hidden; position: relative; }
.header-logo { display: block; height: auto; margin: 10px auto; max-height: 170px; object-fit: contain; padding: 0; width: min(1082px, calc(100% - 48px)); }
.logout { background: #f20b0b; border-radius: 9px; color: #fff; font-weight: 900; padding: 14px 24px; position: absolute; right: 22px; text-decoration: none; top: 18px; }
.toolbar { align-items: center; display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; padding: 0 16px 12px; }
.toolbar-left, .toolbar-right { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }
.create-invoice-form { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; }
.create-invoice-form select { border: 1px solid #aab4c5; border-radius: 6px; color: #002080; max-width: 100%; min-height: 42px; min-width: min(360px, 100%); padding: 8px 10px; }
.nav-button, .blue-btn, .danger-btn, .green-btn { border: 0; border-radius: 7px; color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; min-height: 34px; padding: 7px 14px; text-decoration: none; }
.nav-button, .blue-btn { background: #062b86; }
.secondary-action { background: #4d74a9; }
.danger-btn { background: #df3044; }
.green-btn { background: #11a05d; }
.search-form { display: grid; grid-template-columns: minmax(0, 420px) 52px; max-width: 100%; }
.search-form input { border: 1px solid #d8dde8; border-radius: 7px 0 0 7px; padding: 11px 14px; }
.search-form button { background: #ff9f00; border: 0; border-radius: 0 7px 7px 0; color: #fff; font-size: 24px; font-weight: 900; }
.page { margin: 30px auto; max-width: 1620px; min-width: 0; padding: 0 18px; width: 100%; }
.panel { background: #fff; border: 1px solid #d8dde8; border-radius: 8px; box-shadow: 0 10px 22px rgba(15,23,42,.07); margin-bottom: 20px; overflow: hidden; }
.panel-header { align-items: center; background: #f0f5fc; display: flex; gap: 12px; justify-content: space-between; padding: 16px 18px; }
.panel-header h2 { margin: 0; }
.panel-body { padding: 18px; }
.table-wrap { max-height: 560px; max-width: 100%; min-width: 0; overflow-y: auto; overflow-x: hidden; }
table { border-collapse: collapse; width: 100%; }
th { background: #ff9f00; color: #002080; font-size: 22px; padding: 14px; text-align: center; }
td { border: 1px solid #d8dde8; padding: 12px; text-align: center; vertical-align: middle; }
.invoice-list td { color: #002080; font-size: 20px; font-weight: 700; }
.actions { align-items: center; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.saved-invoices-header { align-items: flex-end; }
.saved-invoices-header h2 { font-size: 30px; margin: 2px 0 5px; }
.saved-invoices-header p { color: #435979; margin: 0; }
.panel-eyebrow { color: #e17f00; font-size: 13px; font-weight: 900; letter-spacing: .06em; }
.saved-invoice-tools { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }
.saved-count { background: #fff; border: 1px solid #b9cbed; border-radius: 999px; color: #073493; font-size: 14px; font-weight: 900; padding: 8px 12px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(180px, 1fr)); }
.form-grid label, .settings-grid label { color: #002080; font-weight: 800; }
.form-grid input, .form-grid select, .settings-grid input, .settings-grid select, .settings-grid textarea { border: 1px solid #d8dde8; border-radius: 4px; color: #002080; display: block; margin-top: 5px; padding: 10px; width: 100%; }
.invoice-sheet { background: #fff; border: 1px solid #ddd; margin: 18px auto; max-width: 1650px; min-width: 0; overflow: hidden; padding: 12px; width: 100%; }
.invoice-sheet > * { max-width: 100%; min-width: 0; }
.invoice-banner img { display: block; width: 100%; }
.invoice-top { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; padding: 14px 6px; }
.invoice-top .field-row { align-items: center; display: grid; gap: 12px; grid-template-columns: 150px 1fr; margin-bottom: 7px; }
.invoice-top label, .invoice-top span { color: #002080; font-size: 16px; font-weight: 700; }
.invoice-top input, .invoice-top select { border: 1px solid #c7cfdd; color: #002080; font-size: 17px; padding: 9px 12px; width: 100%; max-width: 460px; }
.invoice-for { color: #002080; font-size: 22px; line-height: 1.55; margin-top: 22px; }
.house-moving-invoice { background: #f7fbff; border: 1px solid #d8dde8; border-left: 6px solid #ff9f00; border-radius: 8px; display: grid; gap: 12px; grid-template-columns: repeat(6, minmax(140px, 1fr)); margin: 0 6px 16px; padding: 14px; }
.house-moving-invoice h3 { grid-column: 1 / -1; margin: 0; }
.house-moving-invoice label { color: #002080; font-weight: 800; }
.house-moving-invoice input { border: 1px solid #d8dde8; border-radius: 4px; color: #002080; display: block; margin-top: 5px; padding: 8px; width: 100%; }
.quotation-card { background: #eef6ff; border: 1px solid #b9cbed; border-left: 6px solid #ff9f00; border-radius: 8px; color: #002080; margin: 0 6px 16px; padding: 14px 18px; }
.quotation-card h3 { font-size: 24px; margin: 0 0 8px; }
.quotation-card p { line-height: 1.45; margin: 6px 0; }
.quotation-pricing-card { background: #fff; border: 1px solid #d8dde8; border-left: 6px solid #ff9f00; border-radius: 8px; color: #002080; margin: 0 6px 16px; padding: 14px 18px; }
.quotation-pricing-card h3 { font-size: 24px; margin: 0 0 8px; }
.quotation-pricing-card p { color: #355171; font-size: 16px; margin: 0 0 12px; }
.quotation-pricing-grid { display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(170px, 1fr)); }
.quotation-price-option { background: #f7fbff; border: 1px solid #d8dde8; border-radius: 8px; display: grid; gap: 8px; padding: 10px; }
.quotation-price-option span { align-items: center; display: flex; font-weight: 900; gap: 8px; }
.quotation-price-option input[type=checkbox] { height: 18px; width: 18px; }
.quotation-price-option input[type=number] { border: 1px solid #d8dde8; border-radius: 4px; color: #002080; padding: 8px; width: 100%; }
.quotation-price-option:not(.quotation-selected) input[type=number] { opacity: .55; }
.moving-address-card { background: #f7fbff; border: 1px solid #d8dde8; border-left: 6px solid #ff9f00; border-radius: 8px; display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(240px, 1fr)); margin: 0 6px 16px; padding: 14px; }
.moving-address-card h3 { grid-column: 1 / -1; margin: 0; }
.moving-address-card label { color: #002080; font-weight: 800; }
.moving-address-card textarea { border: 1px solid #d8dde8; border-radius: 4px; color: #002080; display: block; margin-top: 6px; min-height: 76px; padding: 9px; resize: vertical; width: 100%; }
.empty-runsheets { background: #fff8e8; border: 1px solid #ffd289; border-left: 6px solid #ff9f00; border-radius: 8px; color: #002080; font-weight: 800; margin: 8px 6px 16px; padding: 16px; }
.is-hidden { display: none !important; }
.sticky-actions { align-items: center; background: rgba(255,255,255,.95); display: flex; gap: 10px; justify-content: space-between; padding: 14px 8px; position: sticky; top: 0; z-index: 5; }
.invoice-action-right { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.invoice-actions-bottom { border-top: 2px solid #062b86; margin-top: 18px; position: static; }
.saved-location { align-items: center; background: #ecfff2; border: 1px solid #a8e4ba; border-left: 7px solid #23a553; border-radius: 8px; color: #002080; display: flex; gap: 12px; justify-content: space-between; margin: 10px 8px; padding: 12px 14px; }
.saved-location strong { display: block; font-size: 20px; }
.saved-location span { color: #355171; display: block; font-size: 16px; }
.runsheet-title { align-items: center; background: #f4a019; color: #000; display: flex; flex-wrap: wrap; font-size: 23px; font-weight: 900; gap: 18px; min-height: 54px; padding: 7px 10px; text-align: left; }
.runsheet-meta { align-items: center; display: inline-flex; gap: 7px; white-space: nowrap; }
.runsheet-meta strong { background: transparent; border: 0; color: #000; display: inline-block; min-width: 130px; padding: 0 4px; }
.runsheet-actions { align-items: center; display: inline-flex; gap: 8px; margin-left: auto; }
.runsheet-title input { border: 1px solid #d8dde8; font-size: 22px; margin: 0; padding: 6px 8px; width: 190px; }
.charge-table { table-layout: fixed; width: 100%; }
.charge-table th { font-size: 13px; white-space: nowrap; letter-spacing: .2px; padding: 6px 8px; }
.charge-table td { border: 2px solid #111; color: #002080; min-width: 0; overflow-wrap: anywhere; padding: 5px 7px; }
.customer-info input, .amount-cell input, .note-cell textarea, .moving-note-cell textarea, .service-cell input[type=number] { border: 1px solid #d8dde8; color: #002080; padding: 6px; width: 100%; }
.customer-fields { display: grid; gap: 4px; }
.invoice-row-number { background: #073493; border-radius: 5px; color: #fff; font-size: 13px; font-weight: 800; margin-bottom: 7px; padding: 6px 8px; text-align: left; }
.invoice-row-number strong { font-size: 15px; }
.linked-customer-label { background: #eef6ff; border: 1px solid #b9cbed; border-radius: 6px; display: none; gap: 3px; padding: 9px; text-align: left; }
.linked-customer-label strong { color: #073493; font-size: 16px; }
.linked-customer-label span { color: #435979; font-size: 12px; line-height: 1.25; }
.customer-link-toggle { background: transparent; border: 0; color: #073493; cursor: pointer; font-size: 12px; font-weight: 900; margin-top: 7px; padding: 3px 0; text-decoration: underline; }
.customer-link-state { color: #53657f; display: block; font-size: 11px; font-weight: 800; margin: 3px 0 6px; }
.detail-only-row .customer-link-state { color: #157347; }
.detail-only-row .customer-fields { display: none; }
.detail-only-row .linked-customer-label { display: grid; }
.detail-only-row .customer-info { background: #f8fbff; text-align: center; }
.detail-only-row .invoice-row-number { font-size: 15px; margin: 0 auto 8px; text-align: center; }
.detail-only-row .handyman-text-cell,
.detail-only-row .moving-note-cell { border-left-color: #5fa8e4; }
.service-cell { font-size: 16px; min-width: 0; }
.service-cell input[type=checkbox] { height: 18px; width: 18px; }
.service-cell input[type=number] { display: none; margin-top: 6px; }
.service-cell.service-selected input[type=number] { display: block; }
.service-cell input[type=checkbox]:checked ~ input[type=number] { display: block; }
.service-cell.service-unselected { color: #111; }
.pickup-cell select { border: 1px solid #aab4c5; color: #000; padding: 8px; width: 100%; }
.note-cell textarea { min-height: 54px; resize: vertical; }
.moving-note-cell textarea { min-height: 78px; resize: vertical; }
.grouped-customer-bar { background: #f4a019; border: 1px solid #d98500; margin: 16px 0 10px; padding: 12px 16px; }
.grouped-customer-bar label { align-items: center; color: #062b86; display: grid; font-size: 19px; font-weight: 900; gap: 14px; grid-template-columns: auto minmax(240px, 1fr); margin: 0; }
.grouped-customer-bar input { background: #fff; border: 1px solid #c97800; margin: 0; min-width: 0; width: 100%; }
.row-order-actions { display: flex; gap: 5px; justify-content: center; margin: 7px 0; }
.row-order-actions .blue-btn { min-width: 0; padding: 7px 9px; }
.house-moving-table th:nth-child(1), .house-moving-table td:nth-child(1) { text-align: left; width: 86%; }
.house-moving-table th:nth-child(2), .house-moving-table td:nth-child(2) { width: 14%; }
.handyman-table th, .handyman-table td { vertical-align: top; }
.handyman-table th:nth-child(1), .handyman-table td:nth-child(1) { text-align: left; width: 27%; }
.handyman-table th:nth-child(2), .handyman-table td:nth-child(2) { text-align: left; width: 20%; }
.handyman-table th:nth-child(3), .handyman-table td:nth-child(3),
.handyman-table th:nth-child(4), .handyman-table td:nth-child(4) { width: 11%; }
.handyman-table th:nth-child(5), .handyman-table td:nth-child(5) { width: 19%; }
.handyman-table th:nth-child(6), .handyman-table td:nth-child(6) { width: 12%; }
.handyman-text-cell textarea { border: 1px solid #d8dde8; color: #002080; min-height: 72px; padding: 8px; resize: vertical; width: 100%; }
.amount-cell strong { display: block; font-size: 20px; margin-bottom: 8px; }
.invoice-summary-row { display: flex; justify-content: flex-end; margin: 20px 0 14px; }
.invoice-summary-row .totals-table { max-width: 520px; width: 100%; }
.invoice-footer { background: #062b86; color: #ff9f00; margin-top: 0; padding: 24px 28px; text-align: center; }
.invoice-footer h2, .invoice-footer p { margin: 0 0 14px; text-align: center; }
.totals-table td { background: #fff; border: 1px solid #002080; color: #002080; font-size: 21px; font-weight: 800; }
.totals-table td:first-child { background: #f4a019; color: #002080; text-align: center; }
.tax-toggle { align-items: center; display: inline-flex; font-size: 14px; gap: 5px; margin-left: 8px; vertical-align: middle; }
.tax-toggle input { height: 16px; width: 16px; }
.input-with-suffix { align-items: center; display: flex; gap: 8px; }
.input-with-suffix input { margin-top: 5px; }
.input-with-suffix b { color: #002080; font-size: 24px; padding-top: 4px; }
.settings-grid { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(170px, 1fr)); }
.settings-grid label small { color: #435979; display: block; font-size: 13px; margin-top: 5px; }
.settings-wide { grid-column: span 2; }
.service-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-top: 18px; }
.service-chip { align-items: center; background: #f3f7ff; border: 1px solid #d8dde8; border-radius: 8px; display: flex; justify-content: space-between; padding: 10px; }
.service-chip small { color: #435979; display: block; font-size: 14px; margin-top: 4px; }
.department-checks { border: 1px solid #d8dde8; border-radius: 8px; display: grid; gap: 6px; grid-column: span 2; grid-template-columns: repeat(3, minmax(130px, 1fr)); margin: 0; padding: 12px; }
.department-checks legend { color: #002080; font-weight: 900; padding: 0 6px; }
.department-checks label { align-items: center; display: flex; gap: 7px; margin: 0; }
.department-checks input { margin: 0; width: auto; }
.print-only { display: none; }
.invoice-modal[hidden] { display: none; }
.invoice-modal { align-items: center; background: rgba(0,0,0,.55); display: flex; inset: 0; justify-content: center; padding: 20px; position: fixed; z-index: 30; }
.invoice-modal-card { background: #fff; border-radius: 9px; box-shadow: 0 25px 70px rgba(0,0,0,.32); max-width: 620px; padding: 24px; position: relative; width: 100%; }
.invoice-modal-card h2 { color: #002080; font-size: 28px; margin: 0 0 20px; }
.invoice-modal-card label { color: #002080; display: block; font-size: 20px; font-weight: 700; margin: 16px 0; }
.invoice-modal-card input { border: 1px solid #d8dde8; color: #002080; display: block; font-size: 20px; margin-top: 8px; padding: 11px; width: 100%; }
.modal-close { background: transparent; border: 0; color: #777; cursor: pointer; font-size: 40px; line-height: 1; position: absolute; right: 16px; top: 12px; }
.modal-actions { align-items: center; border-top: 1px solid #d8dde8; display: flex; gap: 10px; justify-content: flex-end; margin: 22px -24px -24px; padding: 18px 24px; }
.muted-btn { background: #707780; border: 0; border-radius: 7px; color: #fff; cursor: pointer; font-weight: 800; min-height: 42px; padding: 9px 15px; }
.quick-row-buttons { display: flex; gap: 10px; margin-top: 10px; }
.send-btn { background: #14884b; border: 0; border-radius: 7px; color: #fff; cursor: pointer; display: inline-flex; font-weight: 800; min-height: 42px; padding: 9px 15px; text-decoration: none; }
.view-btn { background: #fff; border: 2px solid #062b86; border-radius: 7px; color: #062b86; cursor: pointer; display: inline-flex; align-items: center; font-weight: 800; min-height: 42px; padding: 7px 15px; text-decoration: none; }
.view-btn:hover { background: #062b86; color: #fff; }
.nav-button.is-active { background: #ff9f00; color: #062b86; }
.settings-hub { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings-tool-card { background: #5fa8e4; border: 1px solid #4291d2; border-left: 7px solid #ff9f00; border-radius: 8px; color: #fff; display: grid; grid-template-columns: 58px 1fr; min-height: 190px; padding: 24px; text-decoration: none; }
.settings-card-icon { align-items: center; align-self: start; background: #fff; border-radius: 6px; color: #073493; display: flex; font-size: 27px; font-weight: 900; grid-row: span 2; height: 48px; justify-content: center; width: 48px; }
.settings-tool-card strong { font-size: 27px; }
.settings-tool-card p { font-size: 17px; line-height: 1.45; margin: 8px 0 18px; }
.settings-open { align-self: end; background: #073493; border-radius: 6px; font-weight: 900; grid-column: 2; justify-self: start; padding: 9px 14px; }
.settings-tool-head { align-items: center; border-bottom: 1px solid #d8dde8; display: flex; justify-content: space-between; margin: -2px 0 20px; padding: 0 0 14px; }
.settings-tool-head h3 { font-size: 28px; margin: 0 0 5px; }
.settings-tool-head p { color: #435979; margin: 0; }
.settings-split { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings-subcard { background: #f7fbff; border: 1px solid #d8dde8; border-radius: 8px; padding: 20px; }
.settings-subcard h3 { font-size: 24px; margin: 0 0 14px; }
.settings-subcard label { display: block; font-weight: 800; margin: 12px 0; }
.settings-subcard input { border: 1px solid #c9d3e3; border-radius: 5px; color: #002080; display: block; margin-top: 6px; padding: 10px; width: 100%; }
.settings-note { background: #fff7e7; border-left: 4px solid #ff9f00; color: #435979; line-height: 1.4; padding: 10px 12px; }
.company-card-grid { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 20px; }
.company-card { background: #f4f8ff; border: 1px solid #cdd8e8; border-left: 5px solid #5fa8e4; border-radius: 7px; display: grid; gap: 6px; padding: 16px; }
.company-card span { color: #426180; font-size: 14px; font-weight: 900; text-transform: uppercase; }
.company-card strong { font-size: 20px; overflow-wrap: anywhere; }
.company-card small { color: #435979; overflow-wrap: anywhere; }
.send-layout { display: grid; gap: 22px; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .7fr); }
.send-form { background: #f7fbff; border: 1px solid #d8dde8; border-radius: 8px; padding: 20px; }
.send-form label { display: block; font-weight: 800; margin-bottom: 16px; }
.send-form input, .send-form textarea { border: 1px solid #c9d3e3; border-radius: 5px; color: #002080; display: block; margin-top: 6px; padding: 11px; resize: vertical; width: 100%; }
.send-form .attach-option { align-items: center; display: flex; gap: 9px; }
.send-form .attach-option input { height: 19px; margin: 0; width: 19px; }
.send-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }
.send-summary { background: #f0f5fc; border: 1px solid #d8dde8; border-radius: 8px; padding: 20px; }
.send-summary h3 { border-bottom: 2px solid #ff9f00; margin: 0 0 12px; padding-bottom: 8px; }
.send-summary dl { display: grid; gap: 8px 12px; grid-template-columns: 100px 1fr; margin: 0 0 24px; }
.send-summary dt { color: #435979; font-weight: 800; }
.send-summary dd { font-weight: 900; margin: 0; overflow-wrap: anywhere; }
.send-history { display: grid; gap: 10px; }
.history-row { background: #fff; border: 1px solid #d8dde8; border-radius: 6px; display: grid; gap: 4px; padding: 12px; }
.history-row small, .muted { color: #52677e; }
.status-pill { border-radius: 999px; font-size: 12px; font-weight: 900; justify-self: start; padding: 4px 8px; text-transform: uppercase; }
.status-pill.is-sent { background: #dcf6e5; color: #12652d; }
.status-pill.is-failed { background: #ffe4e4; color: #9a1111; }
@media screen and (max-width: 1200px) {
    .app-header { min-height: 150px; }
    .header-logo { max-height: 130px; width: min(860px, calc(100% - 36px)); }
    .logout { padding: 10px 14px; right: 12px; top: 10px; }
    .toolbar-left, .toolbar-right { flex: 1 1 100%; }
    .toolbar-right { justify-content: flex-start; }
    .invoice-sheet { margin-top: 10px; }
    .invoice-top { gap: 14px; }
    .invoice-top .field-row { grid-template-columns: 140px minmax(0, 1fr); }
    .invoice-top label, .invoice-top span { font-size: 14px; }
    .invoice-top input, .invoice-top select { font-size: 14px; }
    .house-moving-invoice { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .quotation-pricing-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .charge-table { min-width: 0; }
    .charge-table th { font-size: 12px; white-space: nowrap; padding: 6px 4px; }
    .charge-table td { font-size: clamp(11px, 1.25vw, 15px); padding: 5px 3px; }
    .service-cell { font-size: clamp(10px, 1.15vw, 15px); }
    .customer-info input, .amount-cell input, .note-cell textarea, .moving-note-cell textarea, .service-cell input[type=number] { padding: 6px 3px; }
}
@media screen and (max-width: 900px) {
    body { font-size: 16px; }
    .app-header { min-height: 180px; }
    .invoice-top { grid-template-columns: 1fr; }
    .invoice-summary-row { justify-content: stretch; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .toolbar-left, .toolbar-right, .create-invoice-form { align-items: stretch; flex-direction: column; width: 100%; }
    .create-invoice-form select, .toolbar a, .toolbar button { justify-content: center; width: 100%; }
    .form-grid, .settings-grid { grid-template-columns: 1fr; }
    .house-moving-invoice, .quotation-pricing-grid, .department-checks { grid-template-columns: 1fr; }
    .department-checks { grid-column: auto; }
    .search-form { grid-template-columns: 1fr 52px; }
    .invoice-top .field-row { grid-template-columns: 1fr; }
    .moving-address-card { grid-template-columns: 1fr; }
    .table-wrap { max-height: none; overflow: visible; }
    .charge-table, .charge-table tbody { display: block; width: 100%; }
    .charge-table thead { display: none; }
    .charge-table tr[data-row] { border: 2px solid #111; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0 0 12px; width: 100%; }
    .charge-table tr[data-row] > td { border: 1px solid #c8d0dc; min-width: 0 !important; padding: 8px; width: auto !important; }
    .charge-table .customer-info,
    .charge-table .handyman-text-cell,
    .charge-table .moving-note-cell,
    .charge-table .note-cell,
    .charge-table .amount-cell { grid-column: 1 / -1; }
    .charge-table .amount-cell { background: #f5f8fd; }
    .handyman-table tr[data-row] > td:nth-child(1)::before { content: "Description"; display: block; font-size: 12px; font-weight: 800; margin-bottom: 4px; }
    .handyman-table tr[data-row] > td:nth-child(2)::before { content: "Materials"; display: block; font-size: 12px; font-weight: 800; margin-bottom: 4px; }
    .handyman-table tr[data-row] > td:nth-child(3)::before { content: "Material charges"; display: block; font-size: 12px; font-weight: 800; margin-bottom: 4px; }
    .handyman-table tr[data-row] > td:nth-child(4)::before { content: "Service charges"; display: block; font-size: 12px; font-weight: 800; margin-bottom: 4px; }
    .handyman-table tr[data-row] > td:nth-child(5)::before { content: "Note"; display: block; font-size: 12px; font-weight: 800; margin-bottom: 4px; }
    .handyman-table tr[data-row] > td:nth-child(6)::before { content: "Amount"; display: block; font-size: 12px; font-weight: 800; margin-bottom: 4px; }
    .house-moving-table tr[data-row] > td:nth-child(1)::before { content: "Moving notes / quotation details"; display: block; font-size: 12px; font-weight: 800; margin-bottom: 4px; }
    .house-moving-table tr[data-row] > td:nth-child(2)::before { content: "Amount"; display: block; font-size: 12px; font-weight: 800; margin-bottom: 4px; }
    .grouped-customer-bar label { align-items: stretch; grid-template-columns: 1fr; }
    .sticky-actions { align-items: stretch; flex-direction: column; position: static; }
    .sticky-actions > div, .invoice-action-right { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
    .sticky-actions button, .sticky-actions a { justify-content: center; text-align: center; }
    .saved-location { align-items: stretch; flex-direction: column; }
    .invoice-footer { padding: 20px 16px; }
    .settings-hub, .settings-split, .company-card-grid, .send-layout { grid-template-columns: 1fr; }
    .settings-tool-card { min-height: 160px; }
    .panel-header { align-items: stretch; flex-direction: column; }
    .saved-invoice-tools { align-items: stretch; flex-direction: column; }
    .saved-invoice-tools > * { justify-content: center; text-align: center; width: 100%; }
}
@media screen and (max-width: 600px) {
    html, body { max-width: 100%; overflow-x: hidden; }
    .login-body { padding: 12px; }
    .login-card { padding: 68px 20px 28px; }
    .login-card h1 { font-size: 32px; }
    .app-header { min-height: 112px; }
    .header-logo { margin: 6px auto; max-height: 100px; width: calc(100% - 24px); }
    .logout { font-size: 14px; padding: 7px 10px; }
    .page { margin: 14px auto; padding: 0 8px; }
    .panel-body { padding: 12px; }
    .invoice-sheet { border-left: 0; border-right: 0; margin-left: 0; margin-right: 0; padding: 8px; width: 100%; }
    .invoice-top { padding: 12px 2px; }
    .invoice-for { font-size: 17px; }
    .sticky-actions > div, .invoice-action-right { grid-template-columns: 1fr; }
    .invoice-summary-row .totals-table { max-width: none; }
    .totals-table td { font-size: 17px; padding: 10px 8px; }
    .invoice-modal { padding: 10px; }
    .invoice-modal-card { padding: 20px 16px; }
    .charge-table tr[data-row] { grid-template-columns: minmax(0, 1fr); }
    .charge-table tr[data-row] > td,
    .charge-table .customer-info,
    .charge-table .handyman-text-cell,
    .charge-table .moving-note-cell,
    .charge-table .note-cell,
    .charge-table .amount-cell { grid-column: 1 / -1; }
    .customer-link-toggle, .blue-btn, .danger-btn { min-height: 42px; }
    .invoice-top input, .invoice-top select, .customer-info input,
    .amount-cell input, .note-cell textarea, .moving-note-cell textarea,
    .handyman-text-cell textarea { max-width: 100%; width: 100%; }
    /* Dashboard + Saved PDFs tables: stack each row into a card so the action
       buttons (Edit, Duplicate, Download, View, Send, Delete) are all visible. */
    .invoice-list-wrap .table-wrap, .saved-invoices .table-wrap { overflow-x: visible; max-height: none; }
    .invoice-list thead { display: none; }
    .invoice-list, .invoice-list tbody, .invoice-list tr, .invoice-list td { display: block; width: 100%; box-sizing: border-box; }
    .invoice-list tr { border: 1px solid #d6deee; border-radius: 12px; margin: 0 0 12px; padding: 10px 12px; background: #fff; box-shadow: 0 6px 16px rgba(9,30,84,.06); }
    .invoice-list td { border: 0; padding: 4px 0; text-align: left; font-size: 16px; }
    .invoice-list td.actions, .invoice-list td:last-child { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; }
    .invoice-list td.actions .blue-btn, .invoice-list td.actions .danger-btn, .invoice-list td.actions .view-btn, .invoice-list td.actions .send-btn,
    .invoice-list td:last-child .blue-btn, .invoice-list td:last-child .danger-btn, .invoice-list td:last-child .view-btn, .invoice-list td:last-child .send-btn { flex: 1 1 44%; justify-content: center; text-align: center; min-height: 40px; }
    .invoice-list td.actions form, .invoice-list td:last-child form { flex: 1 1 44%; margin: 0; }
    .invoice-list td.actions form button, .invoice-list td:last-child form button { width: 100%; }
}
@media print {
    body { background: #fff; font-size: 12px; }
    .app-header, .toolbar, .sticky-actions, .no-print, .logout { display: none !important; }
    .page, .invoice-sheet { margin: 0; max-width: none; padding: 0; }
    .panel { border: 0; box-shadow: none; }
    .invoice-top input, .invoice-top select, .customer-info input, .amount-cell input, .note-cell textarea, .moving-note-cell textarea, .handyman-text-cell textarea, .service-cell input[type=number] { border: 0; padding: 0; }
    .charge-table-print .print-unused { display: none !important; }
    .charge-table-print .service-cell input[type=checkbox] { display: none !important; }
    .charge-table-print .service-cell input[type=number] { display: block !important; font-weight: 700; text-align: center; }
    .charge-table-print .pickup-cell select { border: 0; padding: 0; text-align: center; }
    .print-only { display: inline; }
}

/* SMTP active/inactive indicator */
.smtp-status { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; padding: 7px 12px; border-radius: 8px; margin: 4px 0 6px; }
.smtp-status .smtp-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.smtp-status.on { background: #e7f6ee; color: #14884b; }
.smtp-status.on .smtp-dot { background: #14884b; box-shadow: 0 0 0 3px rgba(20,136,75,.18); }
.smtp-status.off { background: #fdecec; color: #c0392b; }
.smtp-status.off .smtp-dot { background: #c0392b; box-shadow: 0 0 0 3px rgba(192,57,43,.18); }

/* Invoice auto-save status */
.autosave-status { font-size: 13px; color: #14884b; font-weight: 700; padding: 2px 0 8px; min-height: 18px; }
.autosave-status:empty { display: none; }

/* Invoice save/truncation error banner */
.invoice-save-error { background: #fdecea; border-left: 5px solid #c0392b; color: #7a1f16; font-weight: 700; padding: 12px 16px; border-radius: 8px; margin: 8px 0 12px; }

/* Company card edit/delete actions */
.company-card { position: relative; }
.company-card-actions { display: flex; gap: 8px; margin-top: 10px; }
.company-card-actions .blue-btn, .company-card-actions .danger-btn { padding: 6px 16px; font-size: 13px; }
.company-card-actions .company-delete-form { display: inline; margin: 0; }

/* Compact buttons + readable inputs inside the runsheet rows */
.charge-table .blue-btn, .charge-table .danger-btn { min-height: 0; padding: 3px 8px; font-size: 11px; font-weight: 700; border-radius: 5px; margin: 1px 0; }
.customer-info { vertical-align: top; }
.customer-info input { font-size: 16px; padding: 9px 10px; margin-bottom: 5px; font-weight: 600; }
.customer-info .blue-btn { display: inline-block; width: 48%; padding: 4px 0; font-size: 12px; min-height: 0; }
.amount-cell .danger-btn { margin-top: 4px; }
/* Runsheet header action buttons a touch smaller */
.runsheet-actions .blue-btn, .runsheet-actions .danger-btn, .runsheet-bar .blue-btn, .runsheet-bar .danger-btn { min-height: 0; padding: 5px 12px; font-size: 13px; }

/* Saved PDFs: inline Delete button */
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions .saved-delete-form { display: inline; margin: 0; }

/* Rich-text email composer (Send page) */
.rich-label { font-weight: 700; color: #002080; margin-bottom: 4px; }
.rich-compose { border: 1px solid #c7cfdd; border-radius: 8px; overflow: hidden; background: #fff; }
.rich-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px; background: #f1f4fb; border-bottom: 1px solid #dbe2ef; }
.rich-toolbar button { min-height: 0; padding: 4px 10px; font-size: 13px; border: 1px solid #cdd6e6; background: #fff; color: #062b86; border-radius: 5px; cursor: pointer; font-weight: 700; }
.rich-toolbar button:hover { background: #eaf0ff; }
.rich-editor { min-height: 190px; padding: 12px 14px; font-size: 15px; line-height: 1.5; color: #0f172a; outline: none; }
.rich-editor:focus { box-shadow: inset 0 0 0 2px rgba(6,43,134,.15); }
.send-remember-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #475569; margin: -4px 0 4px; }
.send-remember-row { flex-direction: row; justify-content: flex-start; }
.send-remember-row input { width: auto; flex: 0 0 auto; margin: 0; }

/* Saved PDFs: status/tracking badges */
.status-cell { white-space: nowrap; }
.status-badge { display: inline-block; margin: 2px 3px 2px 0; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-badge.sent { background: #e3f5ea; color: #14884b; }
.status-badge.notsent { background: #eef1f6; color: #64748b; }
.status-badge.due { background: #eaf0ff; color: #062b86; }
.status-badge.overdue { background: #fdecea; color: #c0392b; }

/* ============ UI polish: invoice app chrome (Poppins + tokens) ============ */
:root { --fab-navy:#062b86; --fab-navy-2:#1746c0; --fab-orange:#ff9f00; --fab-orange-deep:#ec9100; --fab-ink:#14224a; --fab-slate:#5a6a8a; --fab-line:#e6ecf6; --fab-bg:#f4f7fc; --fab-radius:14px; --fab-shadow:0 12px 30px rgba(9,30,84,.07); }
body { font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; background: var(--fab-bg); color: var(--fab-ink); -webkit-font-smoothing: antialiased; }
.panel { border: 1px solid var(--fab-line); border-radius: var(--fab-radius); box-shadow: var(--fab-shadow); }
.panel-header { background: #eef3fc; border-bottom: 1px solid var(--fab-line); }
.panel-header h2, .panel-header h1 { color: var(--fab-navy); font-weight: 700; letter-spacing: -.01em; }
.invoice-sheet { border: 1px solid var(--fab-line); border-radius: var(--fab-radius); box-shadow: var(--fab-shadow); }
/* Dashboard / library section headers */
.library-eyebrow, .pdf-library-eyebrow { color: var(--fab-orange-deep); }
.saved-pdf-head h1, .saved-pdf-head h2 { color: var(--fab-navy); letter-spacing: -.01em; }
/* Blue buttons -> brand navy with subtle depth */
.blue-btn { background: var(--fab-navy); }
.blue-btn:hover { background: #04205f; }
.primary-btn { border-radius: 999px; }
/* Login card refinement */
.login-card { border-radius: var(--fab-radius); box-shadow: var(--fab-shadow); }

/* Compact runsheet rows — smaller service cells, shifted up, to fit more rows */
.charge-table td { padding: 3px 5px; vertical-align: middle; }
.service-cell { font-size: 12px; line-height: 1.15; }
.service-cell input[type=checkbox] { height: 15px; width: 15px; }
.service-cell input[type=number] { margin-top: 3px; padding: 3px 4px; font-size: 13px; }
.customer-info input { padding: 6px 8px; margin-bottom: 4px; }
.note-cell textarea, .moving-note-cell textarea { min-height: 34px; }

/* ===== Invoice charge table: wider customer box + compact so it fits without zooming (crisp) ===== */
.charge-table th:first-child, .charge-table td.customer-info { width: 132px; }
.charge-table td.note-cell, .charge-table th:nth-last-child(2) { width: 92px; }
.charge-table td.amount-cell, .charge-table th:last-child { width: 88px; }
.charge-table th { font-size: 12px; padding: 5px 4px; }
.charge-table td { padding: 4px 5px; }
.service-cell { font-size: 12px; line-height: 1.12; }
.service-cell input[type=checkbox] { height: 17px; width: 17px; }
.customer-info input { font-size: 13px; padding: 5px 6px; }
.customer-info input::placeholder { font-size: 12px; }
.amount-cell input, .service-cell input[type=number] { font-size: 13px; padding: 5px; }
.runsheet-title { font-size: 20px; }
