@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: #f0f4f1;
    overflow: hidden;
    height: 100vh;
}

#header {
    background: linear-gradient(135deg, #228B22 0%, #2d6b2d 100%);
    color: white;
    padding: 0.6rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#header h1 {
    font-size: 1.3rem;
    font-weight: 600;
}

.header-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 0.2rem 0.3rem;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.6rem;
    transition: all 0.2s;
    width: 32px;
}

.header-btn:hover {
    background: rgba(255,255,255,0.3);
}

.header-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: #fff;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: 700;
    line-height: 1;
    border: 1px solid #fff;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    min-width: 200px;
    z-index: 1500;
    overflow: hidden;
}

.dropdown-item {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid #eee;
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
    color: #2c3e50;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: #eaf5ea;
}

#container {
    display: flex;
    height: calc(100vh - 52px);
    position: relative; /* anchors #ticketPreviewCard to the container's top-right corner */
}

#sidebar {
    width: 380px;
    background: white;
    box-shadow: 2px 0 8px rgba(34,139,34,0.1);
    overflow-y: auto;
    padding: 1rem;
}

#map {
    flex: 1;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: linear-gradient(135deg, #228B22 0%, #2d6b2d 100%);
    color: white;
    padding: 0.6rem;
    border-radius: 6px;
    text-align: center;
}

.stat-card .value {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.1rem;
}

.stat-card .label {
    font-size: 0.7rem;
    opacity: 0.9;
}

.travel-stats {
    background: #e8f5e9;
    padding: 0.8rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    border: 1px solid #c8e6c9;
}

.travel-stats-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #228B22;
    margin-bottom: 0.5rem;
}

.travel-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    margin-bottom: 0.3rem;
}

.travel-stat-row strong {
    color: #2d6b2d;
}

.week-days {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.3rem;
    margin-bottom: 1rem;
}

.day-btn {
    font-family: inherit;
    margin: 0;
    padding: 0.5rem 0.2rem;
    background: #f0f4f1;
    border: 1px solid #d0e0d5;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.75rem;
    text-align: center;
    transition: all 0.2s;
    color: #2d6b2d;
}

.day-btn:hover {
    background: #e0ebe5;
}

.day-btn.active {
    background: linear-gradient(135deg, #228B22 0%, #2d6b2d 100%);
    color: white;
    border-color: #228B22;
}

.day-only-control {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.day-only-label {
    font-size: 0.65rem;
    font-weight: 500;
    color: #666;
    white-space: nowrap;
}

.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d5d5d5;
    transition: 0.2s;
    border-radius: 20px;
}

.switch .slider::before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.switch input:checked + .slider {
    background-color: #1DD1A1;
}

.switch input:checked + .slider::before {
    transform: translateX(14px);
}

.report-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.3rem;
    margin-top: 0.5rem;
}

.report-day-btn {
    padding: 0.4rem 0.2rem;
    background: #f0f4f1;
    border: 1px solid #d0e0d5;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.7rem;
    text-align: center;
    transition: all 0.2s;
    color: #2d6b2d;
}

.report-day-btn:hover:not(:disabled) {
    background: #228B22;
    color: white;
    transform: translateY(-1px);
}

.report-day-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.section {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #228B22;
    margin-bottom: 0.6rem;
}

.filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.filter-group {
    margin-bottom: 0.5rem;
}

.filter-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: #2d6b2d;
    margin-bottom: 0.25rem;
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 0.4rem;
    border: 1px solid #d0e0d5;
    border-radius: 4px;
    font-size: 0.8rem;
    background: white;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: #228B22;
    box-shadow: 0 0 0 2px rgba(34, 139, 34, 0.1);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    padding: 0.3rem 0.4rem;
    background: #f0f4f1;
    border: 1px solid #d0e0d5;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.checkbox-label:hover {
    background: #e0ebe5;
}

.checkbox-label input {
    margin-right: 0.3rem;
    cursor: pointer;
}

.checkbox-label input:checked + span {
    font-weight: 600;
    color: #228B22;
}

.workdays-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
    margin-top: 0.4rem;
}

.workday-input {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.65rem;
}

.workday-input label {
    margin-bottom: 0.15rem;
    color: #2d6b2d;
    font-weight: 500;
}

.workday-input input {
    width: 100%;
    padding: 0.2rem;
    border: 1px solid #d0e0d5;
    border-radius: 3px;
    font-size: 0.7rem;
    text-align: center;
}

.workday-input input:focus {
    outline: none;
    border-color: #228B22;
}

.legend {
    background: #f0f4f1;
    border-radius: 4px;
    padding: 0.6rem;
    border: 1px solid #d0e0d5;
}

.legend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 0.75rem;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: 0.4rem;
    border: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
}

button {
    width: 100%;
    padding: 0.5rem;
    background: linear-gradient(135deg, #228B22 0%, #2d6b2d 100%);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(34, 139, 34, 0.3);
}

button:disabled {
    background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
    cursor: not-allowed;
    transform: none;
    color: rgba(255,255,255,0.9);
}

/* Help Toggle Styling */
#help-toggle {
    background: rgba(255,255,255,0.3);
    font-weight: bold;
}

/* File selector styling */
#currentFile {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

label[for="excelFileInput"] {
    display: inline-block;
    padding: 0.2rem 0.4rem;
}

label[for="excelFileInput"]:hover {
    background: rgba(255,255,255,0.4);
}

/* Tooltip Styling */
.help-tooltip {
    position: absolute;
    background: rgba(45, 107, 45, 0.95);
    color: white;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-size: 0.75rem;
    line-height: 1.4;
    max-width: 250px;
    z-index: 10000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: none;
}

.help-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid rgba(45, 107, 45, 0.95);
}

.help-tooltip.show {
    display: block;
    animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

[data-help-nl]:hover,
[data-help-en]:hover {
    cursor: help;
}

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.spinner {
    border: 4px solid #c8e6c9;
    border-top: 4px solid #228B22;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: #228B22;
    font-weight: 600;
    font-size: 1rem;
}

.loading-subtext {
    color: #666;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.loading-elapsed {
    color: #999;
    font-size: 0.75rem;
    margin-top: 0.6rem;
    font-variant-numeric: tabular-nums;
}

.progress-bar {
    width: 220px;
    height: 6px;
    background: #e6e6e6;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.9rem;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #228B22, #2d6b2d);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 2% auto;
    padding: 1.5rem;
    border-radius: 8px;
    width: 95%;
    max-width: 1100px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid #228B22;
}

.modal-header h2 {
    color: #228B22;
    font-size: 1.2rem;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #000;
}

.tech-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.tech-card {
    background: #f0f4f1;
    border-radius: 6px;
    padding: 0.8rem;
    border: 2px solid #d0e0d5;
}

.tech-card.disabled {
    opacity: 0.5;
}

.tech-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}

.tech-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.tech-checkbox {
    cursor: pointer;
}

.tech-field {
    margin-bottom: 0.5rem;
}

.tech-field label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: #2d6b2d;
    margin-bottom: 0.2rem;
}

.tech-field input {
    width: 100%;
    padding: 0.3rem;
    border: 1px solid #d0e0d5;
    border-radius: 3px;
    font-size: 0.75rem;
}

.modal-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-top: 1rem;
}

.guide-steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.guide-step {
    display: flex;
    gap: 0.9rem;
    align-items: flex-start;
}

.guide-step-num {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #228B22;
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.guide-step-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.2rem;
    font-size: 0.9rem;
}

.guide-step-text {
    font-size: 0.8rem;
    color: #555;
    line-height: 1.4;
}

.guide-concepts {
    margin-top: 1.4rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
}

.guide-concepts-title {
    font-weight: 600;
    color: #228B22;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.guide-concepts ul {
    margin: 0;
    padding-left: 1.2rem;
    font-size: 0.8rem;
    color: #555;
    line-height: 1.6;
}

.guide-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 1.4rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
}

.guide-tooltip-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: #555;
    cursor: pointer;
}

.guide-footer-hint {
    font-size: 0.72rem;
    color: #999;
    text-align: right;
    margin-top: 0.4rem;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    margin-top: 1rem;
}

.report-table th {
    background: #228B22;
    color: white;
    padding: 0.5rem;
    text-align: left;
    font-weight: 600;
}

.report-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.report-table tr:hover {
    background: #f0f4f1;
}

.tech-section {
    margin-bottom: 1.5rem;
}

.tech-section-header {
    background: #f0f4f1;
    padding: 0.6rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
}

.techmap-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.techmap-btn {
    /* The base `button { width: 100% }` rule (for full-width action buttons like "Reset
       Filters") otherwise wins here since this rule never sets width itself — without this
       override the button stretches to fill its row instead of sizing to its own content. */
    width: auto;
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    background: #228B22;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.techmap-btn:hover {
    background: #1b6f1b;
}

.techmap-status {
    font-size: 0.75rem;
    color: #666;
    word-break: break-all;
}

.route-legend {
    margin-top: 1rem;
    padding: 0.8rem;
    background: #f0f4f1;
    border-radius: 6px;
}

.route-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
}

.route-color {
    width: 20px;
    height: 3px;
    margin-right: 0.6rem;
    border-radius: 2px;
}

.priority-badge {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
}

.priority-1 { background: #228B22; }
.priority-2 { background: #ffc107; }
.priority-3 { background: #fd7e14; }
.priority-4 { background: #dc3545; }
.priority-5, .priority-6, .priority-7 { background: #6f42c1; }

.prd-badge {
    display: inline-block;
    padding: 0 0.25rem;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1.3;
    vertical-align: middle;
    cursor: help;
}

/* FR-17: leave/availability calendar */
.leave-badge {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
}

.leave-leave { background: #3b82c4; }
.leave-sick { background: #dc3545; }
.leave-holiday { background: #17a2b8; }
.leave-training { background: #6c757d; }
.leave-unavailable { background: #495057; }

.leave-add-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid #ddd;
}

.leave-add-row select,
.leave-add-row input {
    font-size: 0.8rem;
    padding: 0.3rem;
}

/* FR-18: manual planning dispatch board */
.dispatch-day-label {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #228B22;
    background: #eaf5ea;
    border-radius: 4px;
    padding: 0.2rem 0.6rem;
    margin-bottom: 0.8rem;
}

/* Three-pane layout inside #manualPlanningModal: pick a technician (left) -> see/edit their
   route (middle) -> search all tickets and add matches (right). Replaced an earlier
   side-by-side kanban (drag between columns) that had no way to add a not-yet-scheduled
   ticket — only to shuffle ones already visible that day. */
.dispatch-layout {
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

.dispatch-tech-list {
    flex: 0 0 190px;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-height: 65vh;
    overflow-y: auto;
    padding-right: 0.2rem;
}

.dispatch-tech-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    background: #fafafa;
    border: 1px solid #e6e6e6;
    border-radius: 6px;
    padding: 0.45rem 0.55rem;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.dispatch-tech-item:hover {
    background: #f0f0f0;
}

.dispatch-tech-item.active {
    background: #eaf5ea;
    border-color: #228B22;
}

.dispatch-column-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dispatch-column-meta {
    font-size: 0.68rem;
    font-weight: 400;
    color: #888;
    white-space: nowrap;
}

.dispatch-tech-item-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: #2c3e50;
}

.dispatch-tech-item-meta {
    width: 100%;
    font-size: 0.66rem;
    color: #888;
}

.dispatch-route-panel,
.dispatch-search-panel {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.dispatch-route-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: #2c3e50;
    flex-shrink: 0;
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid #e6e6e6;
}

.dispatch-reoptimizing {
    font-size: 0.7rem;
    font-weight: 400;
    font-style: italic;
    color: #856404;
}

.dispatch-route-list,
.dispatch-search-results {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 65vh;
    overflow-y: auto;
    padding-right: 0.2rem;
}

.dispatch-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.4rem 0.55rem;
    font-size: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.dispatch-search-input:focus {
    outline: none;
    border-color: #228B22;
}

.dispatch-card,
.dispatch-search-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-left: 3px solid var(--dispatch-accent, #999);
    border-radius: 5px;
    padding: 0.35rem 0.5rem;
    font-size: 0.72rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.dispatch-card-order {
    flex-shrink: 0;
    width: 1.3rem;
    height: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eee;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    color: #555;
}

.dispatch-move {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.dispatch-move-btn {
    width: auto;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0 0.2rem;
    font-size: 0.55rem;
    line-height: 1.3;
    color: #999;
}

.dispatch-move-btn:hover:not(:disabled) {
    color: #2c3e50;
}

.dispatch-move-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

.dispatch-card-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.dispatch-card-id {
    font-weight: 700;
    color: #2c3e50;
    font-size: 0.7rem;
}

.dispatch-card-location {
    color: #666;
    font-size: 0.68rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dispatch-card-worktime {
    color: #888;
    font-size: 0.65rem;
}

.dispatch-card.pinned {
    border-color: #e9c46a;
    background: #fffaf0;
}

.dispatch-pin-badge {
    font-size: 0.85rem;
    flex-shrink: 0;
}

.dispatch-unpin {
    /* Same fix as .techmap-btn above — without an explicit width these small icon buttons
       inherit the base `button { width: 100% }` rule instead of sizing to their own content.
       Confirmed live: without this, .dispatch-unpin/.dispatch-remove rendered ~219px wide and
       overflowed the card, crushing .dispatch-card-main next to them down to 0 width. */
    width: auto;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0.1rem 0.25rem;
    font-size: 0.85rem;
    line-height: 1;
    color: #999;
    border-radius: 3px;
    flex-shrink: 0;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.dispatch-unpin:hover {
    color: #dc3545;
    background: #fbeaea;
}

.dispatch-remove {
    width: auto;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0.1rem 0.3rem;
    font-size: 0.8rem;
    line-height: 1;
    opacity: 0.55;
    border-radius: 3px;
    flex-shrink: 0;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.dispatch-remove:hover {
    opacity: 1;
    background: #fbeaea;
}

.dispatch-unpin:disabled,
.dispatch-remove:disabled {
    opacity: 0.25;
    cursor: default;
    background: none;
}

.dispatch-search-status {
    font-size: 0.65rem;
    color: #856404;
}

.dispatch-search-status.muted {
    color: #999;
}

.dispatch-search-status.crew {
    color: #999;
    font-style: italic;
}

.dispatch-add-btn {
    flex-shrink: 0;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    border: none;
    background: #228B22;
    color: #fff;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dispatch-add-btn:hover:not(:disabled) {
    background: #1b6f1b;
}

.dispatch-add-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.dispatch-search-more {
    font-size: 0.66rem;
    color: #999;
    text-align: center;
    padding: 0.3rem 0;
}

.dispatch-empty {
    font-size: 0.7rem;
    color: #aaa;
    font-style: italic;
    padding: 0.3rem 0.1rem;
}

.popup-assign {
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px solid #ddd;
    font-size: 0.75rem;
}

.popup-assign select {
    font-size: 0.75rem;
    margin: 0.25rem 0.4rem 0.25rem 0;
}

.popup-assign button {
    /* Same base `button { width: 100% }` leak as .techmap-btn/.dispatch-unpin above — without
       this the "Assign" button stretched to the full popup width instead of sitting compactly
       next to the technician <select>. */
    width: auto;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
}

.leaflet-popup-content-wrapper {
    border-radius: 6px;
}

.leaflet-popup-content {
    margin: 0.8rem;
    min-width: 250px;
}

.popup-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #228B22;
}

.popup-field {
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
}

.popup-field strong {
    color: #2d6b2d;
    display: inline-block;
    min-width: 90px;
}

.impact-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
}

.impact-1 { background: #228B22; }
.impact-2 { background: #ffc107; }
.impact-3 { background: #fd7e14; }
.impact-4 { background: #dc3545; }
.impact-5, .impact-6, .impact-7 { background: #6f42c1; }

.planning-info {
    background: #e8f5e9;
    padding: 0.6rem;
    margin-top: 0.6rem;
    border-radius: 4px;
    border-left: 3px solid #228B22;
}

.planning-info-title {
    font-weight: 600;
    color: #228B22;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f0f4f1;
}

::-webkit-scrollbar-thumb {
    background: #228B22;
    border-radius: 3px;
}

/* ---- toast notifications (showToast, ui.js) -------------------------------- */

#toastContainer {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: #2c3e50;
    color: #fff;
    padding: 0.55rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    background: #dc3545;
}

.omitted-row {
    border-radius: 4px;
    transition: background-color 0.15s ease;
}

.omitted-row:hover {
    background: #f0f4f1;
}

/* ---- map preview highlight (previewTicketOnMap, map.js) --------------------- */

.preview-pin {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
    animation: previewPulse 1s ease-in-out infinite;
}

@keyframes previewPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}

/* ---- ticket preview/plan card (renderTicketPreviewCard, map.js) ------------- */

.ticket-preview-card {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 320px;
    max-height: calc(100% - 30px);
    overflow-y: auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    z-index: 900; /* above Leaflet's own panes/controls, well below modals (2000+) */
    padding: 0;
}

.tpc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #228B22 0%, #2d6b2d 100%);
    color: #fff;
    padding: 0.7rem 0.9rem;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    font-size: 0.9rem;
}

.tpc-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    width: auto;
    padding: 0;
    opacity: 0.85;
}

.tpc-close:hover {
    opacity: 1;
}

.tpc-body {
    padding: 0.8rem 0.9rem;
}

.tpc-field {
    font-size: 0.78rem;
    margin-bottom: 0.4rem;
    color: #333;
}

.tpc-field strong {
    color: #2d6b2d;
    display: inline-block;
    min-width: 80px;
}

.tpc-prd-box {
    margin: 0.5rem 0;
    padding: 0.4rem 0.5rem;
    background: #fff8e6;
    border-radius: 4px;
    font-size: 0.75rem;
}

.tpc-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.7rem;
}

.tpc-actions button {
    width: auto;
    flex: 1;
    font-size: 0.78rem;
    padding: 0.4rem 0.6rem;
}

.tpc-btn-secondary {
    background: #f0f4f1 !important;
    color: #555 !important;
    background-image: none !important;
}

.tpc-plan-form {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid #e0e0e0;
}

.tpc-plan-form label {
    display: block;
    font-size: 0.72rem;
    font-weight: 500;
    color: #2d6b2d;
    margin-bottom: 0.2rem;
}

.tpc-plan-form select {
    width: 100%;
    padding: 0.35rem;
    border: 1px solid #d0e0d5;
    border-radius: 4px;
    font-size: 0.78rem;
    margin-bottom: 0.5rem;
}

.tpc-route-box {
    margin-top: 0.6rem;
    padding: 0.5rem 0.6rem;
    background: #e8f5e9;
    border-radius: 4px;
    border-left: 3px solid #228B22;
    font-size: 0.78rem;
}

.tpc-route-box.stale {
    background: #fff3cd;
    border-left-color: #856404;
}

.tpc-insertion-loading {
    margin: 0.5rem 0;
    font-size: 0.75rem;
    color: #666;
    font-style: italic;
}

.tpc-insertion-box {
    margin: 0.5rem 0;
    padding: 0.5rem 0.6rem;
    background: #f5f7f5;
    border-radius: 4px;
    border-left: 3px solid #7a9e7a;
    font-size: 0.75rem;
    max-height: 220px;
    overflow-y: auto;
}

.tpc-insertion-title {
    font-weight: 600;
    color: #2d6b2d;
    margin-bottom: 0.35rem;
}

.tpc-insertion-row {
    color: #555;
    padding: 0.15rem 0;
}

.tpc-insertion-row.best {
    color: #1a5c1a;
    font-weight: 700;
}

.tpc-insertion-stop {
    padding: 0.1rem 0 0.1rem 0.6rem;
    color: #333;
    border-left: 2px solid #d0d8d0;
    margin-left: 0.15rem;
}

.tpc-insertion-empty {
    color: #666;
    font-style: italic;
}

.tpc-insertion-error {
    color: #c0392b;
}
