body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f6f8;
    color: #1f2937;
}
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: #1f2937;
    color: #fff;
}
.topbar .brand {
    font-size: 1.2rem;
    font-weight: bold;
}
.topbar .nav-links a {
    color: #ddd;
    margin-left: 1rem;
    text-decoration: none;
}
.nav-dropdown { position: relative; display: inline-flex; align-items: center; }
.nav-dropdown-trigger { display: inline-block; padding: 0.25rem 0; }
.nav-dropdown-menu { display: none; position: absolute; top: 100%; left: 0; z-index: 1001; min-width: 170px; padding: 0.35rem 0; background: #000; border: 1px solid #374151; border-radius: 4px; box-shadow: 0 6px 16px rgba(0,0,0,0.3); }
.nav-dropdown:hover .nav-dropdown-menu, .nav-dropdown:focus-within .nav-dropdown-menu { display: block; }
.topbar .nav-links .nav-dropdown-menu a { display: block; margin: 0; padding: 0.65rem 0.9rem; color: #fff; white-space: nowrap; }
.topbar .nav-links .nav-dropdown-menu a:hover, .topbar .nav-links .nav-dropdown-menu a:focus { background: #262626; color: #fff; }
.nav-toggle { display: none; }
.job-action-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0 0 1rem; padding: 0.6rem; background: #fff; border: 1px solid #d1d5db; border-radius: 6px; }
.job-action-bar form { margin: 0; }
.job-action-bar .button, .job-action-bar button { margin: 0; }
.summary-mobile { display: none; }
@media (max-width: 800px) {
    .summary-desktop { display: none; }
    .summary-mobile { display: grid; }
    .topbar { flex-wrap: wrap; padding: 0.75rem 1rem; }
    .nav-toggle { display: inline-block; background: #374151; color: #fff; border: 0; border-radius: 4px; padding: 0.5rem 0.9rem; font-size: 1rem; cursor: pointer; }
    .topbar .nav-links { display: none; flex-basis: 100%; flex-direction: column; margin-top: 0.75rem; }
    .topbar.nav-open .nav-links { display: flex; }
    .topbar .nav-links a { display: block; margin: 0; padding: 0.8rem 0.5rem; border-top: 1px solid #374151; }
    .nav-dropdown { display: block; }
    .nav-dropdown-trigger { display: block; padding: 0; }
    .nav-dropdown-menu { display: block; position: static; min-width: 0; padding: 0; background: transparent; border: 0; box-shadow: none; }
    .topbar .nav-links .nav-dropdown-menu a { padding: 0.8rem 0.5rem 0.8rem 1.5rem; color: #ddd; white-space: normal; }
}
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}
h1, h2 {
    margin: 0 0 1rem;
}
.card {
    background: #fff;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
body.jobcard-page .container > section.card:nth-of-type(9n + 1) { background: #eef5ff; border-left: 5px solid #6b9de8; }
body.jobcard-page .container > section.card:nth-of-type(9n + 2) { background: #edf8f1; border-left: 5px solid #62a77b; }
body.jobcard-page .container > section.card:nth-of-type(9n + 3) { background: #fff8e7; border-left: 5px solid #d5a845; }
body.jobcard-page .container > section.card:nth-of-type(9n + 4) { background: #fff0eb; border-left: 5px solid #d98468; }
body.jobcard-page .container > section.card:nth-of-type(9n + 5) { background: #eaf6f5; border-left: 5px solid #58a19a; }
body.jobcard-page .container > section.card:nth-of-type(9n + 6) { background: #f1f4f7; border-left: 5px solid #8492a2; }
body.jobcard-page .container > section.card:nth-of-type(9n + 7) { background: #fdf0f3; border-left: 5px solid #ce8295; }
body.jobcard-page .container > section.card:nth-of-type(9n + 8) { background: #f2f7e9; border-left: 5px solid #90a85e; }
body.jobcard-page .container > section.card:nth-of-type(9n) { background: #edf6fa; border-left: 5px solid #5d9db5; }
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.summary-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1rem;
}
.summary-card-button { width: 100%; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.summary-card-button:hover { border-color: #93c5fd; background: #eff6ff; }
.summary-card strong {
    display: block;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.location-list { display: grid; gap: 0.75rem; }
.location-panel { border: 1px solid #d1d5db; border-radius: 8px; overflow: hidden; }
.location-panel summary { padding: 1rem; background: #f9fafb; color: #1d4ed8; font-weight: 600; cursor: pointer; list-style-position: inside; }
.location-panel summary:hover { background: #eff6ff; }
.location-panel[open] summary { border-bottom: 1px solid #d1d5db; }
.location-panel .table-wrapper { padding: 0 1rem 1rem; }
.table-wrapper {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}
table th, table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}
table th {
    background: #f9fafb;
}
tr.job-unread td,
tr.job-unread td a {
    color: #dc2626;
    font-weight: 600;
}
a { color: #2563eb; }
button {
    border: none;
    background: #2563eb;
    color: #fff;
    padding: 0.9rem 1.4rem;
    border-radius: 8px;
    cursor: pointer;
}
button.button-secondary {
    background: #10b981;
}
button:hover { opacity: 0.95; }
input, select, textarea {
    width: 100%;
    padding: 0.9rem;
    margin-top: 0.4rem;
    margin-bottom: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
}
.autocomplete-field { position: relative; }
.autocomplete-results { display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 20; background: #fff; border: 1px solid #d1d5db; border-radius: 0 0 8px 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.12); max-height: 220px; overflow-y: auto; }
.autocomplete-results.show { display: block; }
.autocomplete-option { display: block; width: 100%; padding: 0.75rem 0.9rem; border: 0; border-radius: 0; background: #fff; color: #1f2937; text-align: left; }
.autocomplete-option:hover, .autocomplete-option:focus { background: #eff6ff; color: #1d4ed8; }
.inventory-item-thumb { width: 36px; height: 36px; object-fit: cover; vertical-align: middle; margin-right: 0.5rem; border-radius: 4px; }
.inventory-item-photo { display: block; width: 140px; height: 140px; object-fit: cover; margin: 0.5rem 0 1rem; border-radius: 8px; border: 1px solid #d1d5db; }
label { display: block; font-weight: 600; margin-top: 1rem; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
}
.alert-error { background: #fee2e2; color: #b91c1c; }
.alert-success { background: #d1fae5; color: #065f46; }
.personal-entry { padding: 1rem; margin: 1rem 0; border: 1px solid #d1d5db; border-radius: 8px; }
.personal-entry + .personal-entry { margin-top: 1rem; }
.personal-completed { display: flex; align-items: center; gap: 0.5rem; }
.personal-completed input { width: auto; margin: 0; }
.personal-entry-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.personal-entry-actions button { margin: 0; }
.personal-entry-actions .personal-delete-button { background: #dc2626; }
.personal-entry-actions form { margin: 0; }
.personal-entry-actions button { padding: 0.5rem 0.9rem; }
.personal-done td:not(:last-child) { color: #6b7280; text-decoration: line-through; }
.personal-done td:nth-child(4) { text-decoration: none; }
table td .personal-entry-actions { flex-wrap: nowrap; }
.invoice-number { color: #15803d; font-weight: 700; }
.invoice-mark-form { display: flex; align-items: end; gap: 1rem; flex-wrap: wrap; }
.invoice-mark-form > div { flex: 1 1 240px; }
.invoice-mark-form input { margin-bottom: 0; }
.repeatable-item-list { display: grid; gap: 0.75rem; margin-bottom: 1rem; }
.repeatable-item-row { align-items: end; padding: 0.75rem; border: 1px solid #d1d5db; border-radius: 6px; }
.repeatable-item-row > button { align-self: end; margin-bottom: 1rem; }
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}
.hidden { display: none; }
.inventory-section-launcher { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.inventory-section-button { min-height: 72px; text-align: left; font-size: 1rem; font-weight: 600; background: #fff; color: #1f2937; border: 1px solid #d1d5db; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.inventory-section-button:hover { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
.inventory-modal { display: none; position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center; padding: 1rem; background: rgba(15, 23, 42, 0.55); }
.inventory-modal.show { display: flex; }
.inventory-modal-content { position: relative; width: min(1200px, 100%); max-height: calc(100vh - 2rem); overflow-y: auto; margin: 0; }
.inventory-modal-content > h2 { padding-right: 2.5rem; }
.inventory-modal-close { position: absolute; top: 0.75rem; right: 0.75rem; z-index: 1; }
body.inventory-modal-open { overflow: hidden; }
.radio-group label { display: inline-flex; margin-right: 1rem; align-items: center; }
.radio-group input { margin-right: 0.4rem; }
.notes-list { margin-top: 1rem; }
.note-item { background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }
.note-meta { font-size: 0.95rem; color: #4b5563; margin-bottom: 0.75rem; }
.attachments a { display: inline-block; margin-right: 0.75rem; color: #2563eb; }
.calendar-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.calendar-nav { display: flex; align-items: center; gap: 1rem; }
.calendar-nav button { padding: 0.5rem 1rem; }
#current-period { font-weight: bold; font-size: 1.1rem; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: #e5e7eb; border: 1px solid #e5e7eb; }
.calendar-header { background: #f9fafb; padding: 1rem; text-align: center; font-weight: bold; border: 1px solid #e5e7eb; }
.calendar-day { background: #fff; min-height: 120px; padding: 0.5rem; border: 1px solid #e5e7eb; position: relative; }
.calendar-day.other-month { background: #f9fafb; color: #9ca3af; }
.day-number { font-weight: bold; margin-bottom: 0.5rem; }
.calendar-job { position: relative; background: #2563eb; color: white; padding: 0.25rem 1.8rem 0.25rem 0.5rem; margin-bottom: 0.25rem; border-radius: 4px; font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; display: block; }
.calendar-job:hover { opacity: 0.8; text-decoration: none; color: white; }
.calendar-invoice-check { position: absolute; top: 0.35rem; right: 0.4rem; z-index: 1; display: inline-flex; align-items: center; justify-content: center; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: #dcfce7; color: #166534; font-size: 0.85rem; font-weight: 700; line-height: 1; }
.calendar-job .calendar-invoice-check { top: 50%; transform: translateY(-50%); }
.calendar-job.completed { opacity: 0.6; }
.calendar-todo { background: #ffffff; color: #1f2937; border: 1px dashed #7c3aed; }
.calendar-todo:hover { color: #1f2937; opacity: 0.8; }
.calendar-todo.completed { text-decoration: line-through; }
.calendar-todo-swatch { background: #ffffff; border: 1px dashed #7c3aed; }
.calendar-job-card.calendar-todo-card { border-style: dashed; border-color: #7c3aed; }
.calendar-job-card.completed { opacity: 0.7; background-color: #f3f4f6; }
.calendar-week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: #e5e7eb; border: 1px solid #e5e7eb; }
.calendar-week-day { background: #fff; min-height: 400px; padding: 0.5rem; border: 1px solid #e5e7eb; }
.week-day-header { font-weight: bold; text-align: center; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid #e5e7eb; }
.calendar-day-view { background: #fff; padding: 2rem; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.calendar-job-card { position: relative; border: 1px solid #e5e7eb; border-radius: 8px; padding: 1rem 2.5rem 1rem 1rem; margin-bottom: 1rem; display: flex; justify-content: space-between; align-items: center; text-decoration: none; color: inherit; }
.calendar-job-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); text-decoration: none; color: inherit; }
.calendar-job-card h3 { margin: 0 0 0.5rem 0; }
.job-color { width: 20px; height: 20px; border-radius: 50%; }
.legend { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.legend-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; }
.legend-swatch { display: inline-block; width: 16px; height: 16px; border-radius: 4px; }
.section-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.section-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.search-form { display: flex; align-items: center; gap: 0.5rem; }
.search-input { padding: 0.5rem; border: 1px solid #d1d5db; border-radius: 4px; width: 200px; }
.option-search-input { width: 100%; padding: 0.65rem 0.75rem; margin: 0.4rem 0 0.25rem; border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.95rem; }
.stock-search-input { width: min(320px, 100%); padding: 0.65rem 0.75rem; margin: 0 0 0.75rem; border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.95rem; }
.search-button { padding: 0.5rem 1rem; background: #2563eb; color: white; border: none; border-radius: 4px; cursor: pointer; }
.search-button:hover { opacity: 0.9; }
.clear-search { color: #6b7280; text-decoration: none; font-size: 0.9rem; }
.clear-search:hover { color: #374151; }

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: bold;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
    padding: 0.25rem;
    border-radius: 4px;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.modal-body {
    margin-bottom: 1.5rem;
}
.jobcard-pdf-modal-content { max-width: 900px; }
.signature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.signature-canvas { display: block; width: 100%; height: 150px; border: 1px solid #9ca3af; border-radius: 6px; background: #fff; touch-action: none; }
.signature-pad-modal-content { max-width: 850px; }
.signature-pad-canvas { display: block; width: 100%; height: min(300px, 45vh); border: 2px solid #374151; border-radius: 6px; background: #fff; touch-action: none; }
.clear-signature { margin-bottom: 1rem; padding: 0.5rem 0.75rem; }
.transaction-actions-button { padding: 0.55rem 0.85rem; }
.transaction-actions-modal-content { max-width: 440px; }
.xero-invoice-modal-content { max-width: 1100px; }
.transaction-delete-form { margin-top: 1rem; }
.map-picker-button { margin: 0.25rem 0 1rem; }
.map-picker-modal-content { max-width: 900px; }
.client-location-search { margin-bottom: 0.75rem; }
.client-location-search-controls { display: flex; align-items: center; gap: 0.5rem; }
.client-location-search-controls input { flex: 1; min-width: 0; margin: 0; }
.client-location-search-controls button { flex: 0 0 auto; }
#client-location-search-status { min-height: 1.4rem; margin-top: 0.4rem; color: #4b5563; font-size: 0.9rem; }
.client-location-search-results { display: grid; gap: 0.35rem; max-height: 150px; overflow-y: auto; }
.client-location-search-result { padding: 0.6rem 0.75rem; background: #f3f8f5; color: #1f2937; border: 1px solid #d1e5d8; border-radius: 4px; text-align: left; font-size: 0.9rem; }
.client-location-search-result:hover { background: #e5f1e9; }
.stock-location-modal-content { max-width: 1100px; }
.transaction-history-modal-content { max-width: 1100px; }
#client-map { width: 100%; height: min(55vh, 500px); border: 1px solid #d1d5db; border-radius: 8px; }
.map-picker-modal-content .leaflet-control-layers { font-size: 0.9rem; }
@media (max-width: 700px) { .signature-grid { grid-template-columns: 1fr; } .client-location-search-controls { align-items: stretch; flex-direction: column; } .client-location-search-controls button { width: 100%; } }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.btn-secondary {
    background: #6b7280;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-primary {
    background: #2563eb;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.current-user {
    background-color: #f0f9ff;
    border-left: 4px solid #3b82f6;
}

/* Attachments and Thumbnails */
.attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
}

.attachment-thumbnail {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 120px;
}

.thumbnail-image {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    transition: border-color 0.2s ease;
}

.thumbnail-image:hover {
    border-color: #3b82f6;
}

.thumbnail-caption {
    font-size: 0.8rem;
    color: #6b7280;
    text-align: center;
    margin-top: 0.25rem;
    word-break: break-all;
    max-width: 100px;
}

.attachment-link {
    display: flex;
    align-items: center;
}

.attachment-file {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f3f4f6;
    border-radius: 6px;
    text-decoration: none;
    color: #374151;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.attachment-file:hover {
    background: #e5e7eb;
    text-decoration: none;
    color: #111827;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 1rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.quick-actions .button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.quick-actions .button-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.quick-actions .button-primary {
    background: #2563eb;
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.quick-actions .button-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.quick-actions .button:hover {
    text-decoration: none;
}
.sort-links a { margin-left: 0.75rem; color: #374151; text-decoration: none; }
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { width: 100%; max-width: 420px; }
.status-completed { background-color: #10b981; color: white; padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.8rem; }

/* Viewer role: job card is read-only */
.view-only form[method="post"], .view-only [data-modal], .view-only .modal-overlay { display: none !important; }
