:root {
    --blue: #2d3e82;
    --yellow: #ffd800;
    --dark: #222;
    --gray: #6b6b6b;
    --light: #f5f6fa;
    --border: #d9dce5;
    --success: #188038;
    --danger: #b3261e;
    --warning: #b7791f;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; color: var(--dark); background: var(--light); }
a { color: var(--blue); text-decoration: none; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: white; border-right: 1px solid var(--border); padding: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 12px; align-items: center; justify-content: center; margin-bottom: 24px; }
.brand img { width: 170px; height: auto; object-fit: contain; background: white; display: block; }
.brand strong { display: block; color: var(--blue); font-size: 20px; }
.brand span { color: var(--gray); font-size: 12px; }
.brand.logo-only { justify-content: center; }
.sidebar nav a { display: block; padding: 11px 12px; border-radius: 10px; color: #333; margin-bottom: 4px; font-weight: 600; }
.sidebar nav a:hover { background: var(--blue); color: white; }

.sidebar nav a.nav-approval,
.sidebar nav a.nav-notification { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sidebar nav a.nav-approval.urgent,
.sidebar nav a.nav-notification.urgent { background: var(--danger); color: white; box-shadow: 0 3px 10px rgba(179,38,30,.22); }
.sidebar nav a.nav-approval.urgent:hover,
.sidebar nav a.nav-notification.urgent:hover { background: #921f19; color: white; opacity: 1; }
.nav-count { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: white; color: var(--danger); font-size: 12px; font-weight: 800; line-height: 1; }
.main { flex: 1; min-width: 0; }
.topbar { background: white; border-bottom: 1px solid var(--border); padding: 18px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.topbar h1 { margin: 0; font-size: 24px; color: var(--blue); }
.topbar p { margin: 3px 0 0; color: var(--gray); }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.content { padding: 24px; }
.footer { padding: 15px 24px 30px; color: var(--gray); font-size: 12px; }
.card { background: white; border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin-bottom: 18px; box-shadow: 0 2px 4px rgba(0,0,0,.03); }
.card h2, .card h3 { margin-top: 0; color: var(--blue); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stat { background: white; border: 1px solid var(--border); border-left: 6px solid var(--blue); border-radius: 14px; padding: 18px; }
.stat strong { display: block; font-size: 30px; color: var(--blue); }
.stat span { color: var(--gray); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: #eef1fb; color: var(--blue); font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #fbfcff; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-row.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
label { display: block; font-weight: 700; color: #333; margin: 0 0 6px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; background: white; }
textarea { min-height: 86px; }

.field-emphasis label { font-size: 15px; color: var(--blue); letter-spacing: .02em; }
.field-emphasis input, .field-emphasis textarea { border-width: 2px; background: #fbfcff; }
.service-job-title-field input { font-weight: 700; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.btn, button { display: inline-block; border: 0; background: var(--blue); color: white; padding: 10px 14px; border-radius: 10px; font-weight: 700; cursor: pointer; line-height: 1.2; }
.btn:hover, button:hover { opacity: .92; }
.btn.secondary, button.secondary { background: #575f72; }
.btn.success, button.success { background: var(--success); }
.btn.warning, button.warning { background: var(--warning); }
.btn.danger, button.danger { background: var(--danger); }
.approval-quick-action { display: inline-flex; align-items: center; gap: 8px; }
.approval-quick-action.urgent { box-shadow: 0 3px 10px rgba(179,38,30,.22); }
.btn-count { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: white; color: var(--danger); font-size: 12px; font-weight: 800; line-height: 1; }
.btn.light { background: #f1f3f8; color: #222; }
.btn.small, button.small { padding: 7px 10px; font-size: 13px; }
.alert { padding: 12px 14px; border-radius: 10px; margin: 16px 24px 0; background: #eef1fb; border: 1px solid var(--border); }
.alert.success { background: #e9f7ef; color: #0b5a2a; }
.alert.danger { background: #fdecec; color: var(--danger); }
.alert.warning { background: #fff8e1; color: var(--warning); }
.badge { display: inline-block; border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 700; background: #eee; color: #333; }
.badge.success { background: #e6f4ea; color: var(--success); }
.badge.danger { background: #fdecec; color: var(--danger); }
.badge.warning { background: #fff4d6; color: var(--warning); }
.badge.muted { background: #eee; color: #555; }
.searchbar { display:flex; gap:10px; align-items:flex-end; flex-wrap:wrap; }
.searchbar > div { min-width: 180px; }
.print-logo { max-width: 180px; }
.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #eef1fb, #fffbea); padding: 20px; }
.login-card { width: 100%; max-width: 420px; background: white; border-radius: 18px; border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,.08); padding: 28px; }
.login-card img { display: block; max-width: 250px; margin: 0 auto 16px; }
.login-card h1 { text-align: center; color: var(--blue); margin: 0 0 6px; }
.login-card p { text-align: center; color: var(--gray); margin-top: 0; }
.muted { color: var(--gray); font-size: 13px; }
/* Business document modules: Job Orders and Delivery Receipts */
.doc-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; border-bottom: 2px solid var(--blue); padding-bottom: 14px; margin-bottom: 18px; }
.doc-header h1, .doc-header h2 { margin: 6px 0; color: var(--blue); }
.doc-header p { margin: 3px 0; color: var(--gray); }
.doc-number-box { text-align: right; min-width: 240px; }
.doc-number-box strong { display: inline-block; font-size: 24px; color: var(--danger); margin: 4px 0 8px; }
.doc-section { margin: 18px 0; }
.doc-box { border: 1px solid var(--border); border-radius: 10px; padding: 14px; min-height: 90px; background: #fff; white-space: normal; }
.muted-box { background: #fbfcff; color: #333; }
.entry-table input { min-width: 100px; }
.signature-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 24px; margin-top: 60px; }
.signature-row div { text-align: center; }
.signature-row span { display: block; border-top: 1px solid #333; height: 1px; margin-bottom: 8px; }
.signature-row small { display: block; color: var(--gray); margin-top: 4px; }
.printable-doc { max-width: 1100px; margin-left: auto; margin-right: auto; }
@media print {
    .printable-doc { max-width: none; margin: 0; font-size: 12px; }
    .doc-header { border-bottom: 1.5px solid #000; }
    .doc-number-box strong { color: #000; }
    .doc-box { border: 1px solid #000; }
    .signature-row { break-inside: avoid; }
    .print-table th, .print-table td { border: 1px solid #000; }
}



.delivery-number-highlight { border: 2px solid #111; background: #fbfbfb; padding: 6px 8px; font-weight: 700; }
.delivery-number-highlight strong { text-transform: uppercase; letter-spacing: .03em; }

/* Uploaded Delivery Receipt sample format */
.dr-sample-format {
    max-width: 7.2in;
    padding: .18in .22in .22in;
    color: #111;
}
.manual-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; margin-left: 10px; }
.dr-print-header { text-align: center; margin: 0 auto 6px; }
.dr-logo { display: block; width: 2in; height: 1in; max-width: 2in; max-height: 1in; object-fit: contain; margin: 0 auto 6px; }
.dr-company-lines { font-size: 11px; line-height: 1.2; }
.dr-title { text-align: center; margin: 10px 0 12px; font-size: 22px; letter-spacing: .04em; color: #000 !important; font-weight: 900; }
.dr-meta-box, .dr-client-box {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 12px;
    margin: 0 0 8px;
    font-size: 11px;
}
.dr-client-box { grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid #333; padding: 6px 8px; margin-top: 4px; }
.dr-client-box .full { grid-column: 1 / -1; }
.dr-format-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin-top: 8px; }
.dr-format-table th, .dr-format-table td { border: 1px solid #333; padding: 4px 5px; color: #111; background: white; }
.dr-format-table th { background: #f0f0f0; color: #111; text-align: center; text-transform: none; letter-spacing: 0; font-size: 10.5px; font-weight: 800; }
.dr-format-table td { height: 22px; font-size: 10px; }
.dr-format-table .item-no { width: 10%; }
.dr-format-table .unit-col { width: 8%; }
.dr-format-table .description-col { width: 40%; }
.dr-format-table .qty-col { width: 10%; }
.dr-format-table .price-col { width: 14%; }
.dr-format-table .total-col { width: 18%; }
.dr-format-table .center { text-align: center; }
.dr-format-table .right { text-align: right; }
.dr-format-table .blank-row td { height: 20px; }
.dr-format-table .nothing-follows-row td { height: 22px; }
.dr-format-table .thank-you { font-size: 12px; font-weight: 700; font-style: italic; text-align: center; height: 28px; }
.dr-format-table .total-label { font-size: 11px; font-weight: 900; text-align: center; }
.dr-format-table .total-amount { font-size: 11px; font-weight: 900; }
.dr-remarks { margin: 8px 0 0; font-size: 10px; }
.dr-signature-block { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 26px; margin: 18px 0 10px; }
.dr-signature-card { break-inside: avoid; }
.dr-signature-card .sig-label { font-size: 11px; font-weight: 700; margin-bottom: 16px; }
.dr-signature-card .sig-line span { display: block; border-bottom: 1px solid #333; min-height: 18px; width: 100%; }
.dr-signature-card .sig-caption { text-align: center; font-size: 10px; margin-top: 4px; }
.dr-signature-card .sig-date-row { margin-top: 10px; font-size: 11px; }
.dr-signature-card .sig-date-row span { display: inline-block; border-bottom: 1px solid #333; min-width: 90px; min-height: 16px; vertical-align: bottom; margin-left: 6px; }
.dr-footer-note { margin-top: 4px; font-size: 9.5px; line-height: 1.2; text-align: center; }
.dr-sample-format.manual-copy .manual-fill { color: transparent !important; }
.dr-sample-format.manual-copy .inline-fill { display: inline-block; min-width: 120px; }
@media (max-width: 900px) {
    .dr-sample-format { padding: 18px; }
    .dr-meta-box, .dr-client-box, .dr-signature-block { grid-template-columns: 1fr; }
    .dr-title { font-size: 20px; }
    .dr-company-lines { font-size: 11px; }
}
@media print {
    @page { size: A4 portrait; margin: 6mm; }
    html, body { background: #fff; }
    .dr-sample-format { max-width: none; padding: 0; font-size: 10px; page-break-after: avoid; }
    .dr-logo { width: 2in; height: 1in; max-width: 2in; max-height: 1in; }
    .dr-company-lines { font-size: 10px; }
    .dr-title { font-size: 20px; margin: 8px 0 10px; }
    .dr-meta-box, .dr-client-box { font-size: 10px; }
    .dr-format-table th { font-size: 9.5px; padding: 4px; }
    .dr-format-table td { font-size: 9.5px; padding: 3px 4px; height: 20px; }
    .dr-format-table .blank-row td { height: 18px; }
    .dr-format-table .nothing-follows-row td { height: 20px; }
    .dr-format-table .thank-you { font-size: 11px; height: 24px; }
    .dr-format-table .total-label, .dr-format-table .total-amount { font-size: 10px; }
    .dr-signature-block { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 24px; margin: 14px 0 8px; }
    .dr-signature-card .sig-label { font-size: 10px; margin-bottom: 12px; }
    .dr-signature-card .sig-line span { min-height: 16px; }
    .dr-signature-card .sig-caption { font-size: 9px; }
    .dr-signature-card .sig-date-row { margin-top: 8px; font-size: 10px; }
    .dr-signature-card .sig-date-row span { min-width: 72px; min-height: 14px; }
    .dr-footer-note { font-size: 8.5px; text-align: center; }
}


/* Print fallback: when a document page is printed from inside the dashboard, remove all app chrome. */
@media print {
    body { background: #fff !important; }
    .sidebar, .topbar, .footer, .no-print, .alert { display: none !important; }
    .app-shell, .main, .content { display: block !important; width: 100% !important; margin: 0 !important; padding: 0 !important; background: #fff !important; }
    .card.printable-doc { border: 0 !important; box-shadow: none !important; background: #fff !important; margin: 0 !important; }
}

.doc-number-label { display:block; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color:#111; margin-top: 6px; }

/* Client masterlist and repeat-client selector */
.client-picker-box {
    border: 1px solid var(--border);
    border-left: 5px solid var(--blue);
    background: #fbfcff;
    border-radius: 12px;
    padding: 14px;
    margin: 12px 0 18px;
}
.client-picker-box small { display: block; margin-top: 6px; line-height: 1.35; }
.checkline { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; margin: 4px 0 4px; }
.checkline input { width: auto; }

/* Professional UI refinement: cleaner dashboard cards, better spacing, and audit-friendly data views */
:root {
    --surface: #ffffff;
    --surface-soft: #f8faff;
    --ink: #172033;
    --ink-soft: #657083;
    --brand-deep: #21316f;
    --ring: rgba(45, 62, 130, .18);
    --shadow-sm: 0 8px 22px rgba(23, 32, 51, .06);
    --shadow-md: 0 16px 42px rgba(23, 32, 51, .10);
}
body { color: var(--ink); background: radial-gradient(circle at top left, rgba(45,62,130,.08), transparent 32rem), linear-gradient(180deg, #f6f8fc 0%, #eef2f7 100%); }
.sidebar { background: rgba(255,255,255,.94); box-shadow: 8px 0 28px rgba(23,32,51,.05); backdrop-filter: blur(10px); }
.sidebar nav a { display: flex; align-items: center; justify-content: space-between; border: 1px solid transparent; transition: background .18s ease, color .18s ease, transform .18s ease, border-color .18s ease; }
.sidebar nav a:hover { transform: translateX(3px); border-color: rgba(45,62,130,.18); }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.88); backdrop-filter: blur(12px); box-shadow: 0 8px 22px rgba(23,32,51,.05); }
.topbar h1 { color: var(--brand-deep); letter-spacing: -.02em; }
.content { max-width: 1680px; width: 100%; }
.card { border: 1px solid rgba(217,220,229,.86); box-shadow: var(--shadow-sm); background: rgba(255,255,255,.96); }
.card h2, .card h3 { letter-spacing: -.01em; }
.stat { position: relative; overflow: hidden; border-left: 0; box-shadow: var(--shadow-sm); background: linear-gradient(145deg, #fff, #f8faff); }
.stat::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 5px; background: linear-gradient(180deg, var(--blue), #5f73c8); }
.stat strong { color: var(--brand-deep); letter-spacing: -.03em; }
.stat span { color: var(--ink-soft); font-weight: 700; }
.warning-stat::before { background: linear-gradient(180deg, var(--warning), #e4a82f); }
.danger-stat::before { background: linear-gradient(180deg, var(--danger), #dc5b54); }
.professional-stat strong { font-size: 34px; }
.professional-card { border-radius: 18px; }
.module-hero { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 22px; margin-bottom: 18px; border-radius: 20px; border: 1px solid rgba(45,62,130,.14); background: linear-gradient(135deg, rgba(45,62,130,.98), rgba(31,42,94,.95)); color: white; box-shadow: var(--shadow-md); }
.module-hero h2 { color: white; margin: 4px 0 8px; font-size: 28px; letter-spacing: -.03em; }
.module-hero p { max-width: 900px; margin: 0; color: rgba(255,255,255,.82); line-height: 1.55; }
.module-hero .eyebrow { display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.14); color: rgba(255,255,255,.9); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.hero-actions { margin: 0; justify-content: flex-end; }
.module-hero .btn.light { background: rgba(255,255,255,.14); color: white; border: 1px solid rgba(255,255,255,.28); }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--ring); border-color: var(--blue); box-shadow: 0 0 0 1px rgba(45,62,130,.12); }
.searchbar, .professional-filter { background: var(--surface-soft); border: 1px solid rgba(217,220,229,.78); border-radius: 16px; padding: 12px; }
.professional-filter > div { flex: 1 1 180px; }
.btn, button { box-shadow: 0 6px 14px rgba(45,62,130,.14); transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease; }
.btn:hover, button:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(45,62,130,.18); }
.btn.light { border: 1px solid rgba(217,220,229,.92); background: #fff; color: var(--ink); box-shadow: 0 4px 12px rgba(23,32,51,.05); }
.table-wrap { border-radius: 14px; border: 1px solid rgba(217,220,229,.7); background: white; }
table { border-collapse: separate; border-spacing: 0; }
th { position: sticky; top: 0; z-index: 1; background: #f0f4ff; color: var(--brand-deep); }
th:first-child { border-top-left-radius: 12px; }
th:last-child { border-top-right-radius: 12px; }
td { color: var(--ink); }
tr:last-child td { border-bottom: 0; }
.professional-table td, .professional-table th { padding: 12px 14px; }
.audit-table details summary { cursor: pointer; color: var(--blue); font-weight: 800; }
.audit-snapshot { margin-top: 10px; padding: 12px; border-radius: 12px; background: #f8faff; border: 1px solid var(--border); line-height: 1.5; min-width: 320px; }
.raw-snapshot { margin-top: 10px; }
.raw-snapshot pre { max-height: 260px; overflow: auto; padding: 12px; border-radius: 12px; background: #111827; color: #e5e7eb; font-size: 12px; white-space: pre-wrap; }
.actions form { margin: 0; }
.pos-tax-form.actions { align-items: flex-start; }
.pos-tax-form.actions input, .pos-tax-form.actions select { min-width: 120px; }
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .module-hero { align-items: flex-start; flex-direction: column; }
    .hero-actions { justify-content: flex-start; }
}
@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { width: 100%; height: auto; position: relative; }
    .sidebar nav { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px; }
    .topbar { position: relative; align-items: flex-start; flex-direction: column; }
    .content { padding: 16px; }
    .grid-2, .grid-3, .grid-4, .form-row, .form-row.three { grid-template-columns: 1fr; }
    .module-hero h2 { font-size: 22px; }
    .stat strong { font-size: 24px; }
}
@media print {
    body { background: white !important; }
    .topbar { position: static; box-shadow: none; }
    th { position: static; }
}
