/* PropInspect - Component Styles */

/* ========================================
   CARDS
   ======================================== */

.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

.card-title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    margin: 0;
    word-break: break-word;
    overflow-wrap: break-word;
}

.card-body {
    padding: var(--space-4);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    padding: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.stat-card.alert {
    border-color: var(--color-error);
    background: rgba(239, 68, 68, 0.1);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon.blue {
    background: rgba(67, 97, 238, 0.15);
    color: var(--color-primary);
}

.stat-icon.yellow {
    background: rgba(250, 204, 21, 0.15);
    color: #facc15;
}

.stat-icon.red {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-error);
}

.stat-icon.green {
    background: rgba(34, 197, 94, 0.15);
    color: var(--color-success);
}

.stat-icon.purple {
    background: rgba(114, 9, 183, 0.15);
    color: #7209b7;
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    line-height: 1;
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-top: var(--space-1);
    word-break: break-word;
}

/* ========================================
   LISTS
   ======================================== */

.list {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.list-item {
    display: flex;
    align-items: center;
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border);
    text-decoration: none;
    color: inherit;
    transition: background var(--transition-fast);
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:hover {
    background: var(--color-surface-hover);
}

.list-item-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--color-surface-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: var(--space-3);
    flex-shrink: 0;
}

.list-item-icon svg {
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-weight: var(--font-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-subtitle {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-arrow {
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    margin-left: var(--space-2);
    flex-shrink: 0;
}

.list-item-badge {
    font-size: var(--text-xs);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--color-surface-hover);
    text-transform: capitalize;
    margin-left: var(--space-2);
    flex-shrink: 0;
}

.list-item-badge.completed, .list-item-badge.resolved, .list-item-badge.active {
    background: rgba(34, 197, 94, 0.15);
    color: var(--color-success);
}

.list-item-badge.in_progress, .list-item-badge.assigned {
    background: rgba(67, 97, 238, 0.15);
    color: var(--color-primary);
}

.list-item-badge.pending, .list-item-badge.open, .list-item-badge.draft {
    background: rgba(250, 204, 21, 0.15);
    color: #ca8a04;
}

/* Status Dots */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-text-muted);
}

.status-dot.green { background: var(--color-success); }
.status-dot.yellow { background: #facc15; }
.status-dot.orange { background: #f97316; }
.status-dot.red { background: var(--color-error); }
.status-dot.gray { background: var(--color-text-muted); }

/* Priority Indicator */
.priority-indicator {
    width: 4px;
    height: 24px;
    border-radius: 2px;
    background: var(--color-text-muted);
}

.priority-indicator.critical { background: var(--color-error); }
.priority-indicator.high { background: #f97316; }
.priority-indicator.medium { background: #facc15; }
.priority-indicator.low { background: var(--color-success); }

.priority-badge {
    font-size: var(--text-xs);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    text-transform: capitalize;
}

.priority-badge.critical { background: rgba(239, 68, 68, 0.15); color: var(--color-error); }
.priority-badge.high { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.priority-badge.medium { background: rgba(250, 204, 21, 0.15); color: #ca8a04; }
.priority-badge.low { background: rgba(34, 197, 94, 0.15); color: var(--color-success); }

/* ========================================
   BUTTONS
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    /* Allow text to wrap on long buttons, truncate if needed */
    word-break: break-word;
    overflow-wrap: break-word;
    text-align: center;
    min-width: 0;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.1);
}

.btn-secondary {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-border);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.btn-outline {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-outline:hover:not(:disabled) {
    background: var(--color-surface-hover);
    border-color: var(--color-text-secondary);
}

.btn-danger {
    background: var(--color-error);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    min-width: 44px;
    min-height: 44px;
    padding: 6px;
}

.btn-icon.btn-sm {
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
}

.btn-round {
    border-radius: 50%;
    width: 64px;
    height: 64px;
}

/* ========================================
   FORMS
   ======================================== */

.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-2);
}

.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    transition: all var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-muted);
}

.form-input::placeholder {
    color: var(--color-text-muted);
}

.form-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-input[type="date"],
.form-input[type="time"],
.form-input[type="datetime-local"] {
    min-height: 48px;
    -webkit-appearance: none;
    appearance: none;
}

.input-with-action {
    display: flex;
    gap: var(--space-2);
}

.input-with-action .form-input {
    flex: 1;
}

/* Option Buttons */
.option-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.option-btn {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex: 1;
    min-width: 80px;
    text-align: center;
}

.option-btn:hover {
    border-color: var(--color-primary);
}

.option-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.option-btn.green.active { background: var(--color-success); border-color: var(--color-success); }
.option-btn.yellow.active { background: #facc15; border-color: #facc15; color: #000; }
.option-btn.orange.active { background: #f97316; border-color: #f97316; }
.option-btn.red.active { background: var(--color-error); border-color: var(--color-error); }

/* Toggle */
.toggle-label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
}

.toggle-label input {
    display: none;
}

.toggle-switch {
    width: 48px;
    height: 28px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    position: relative;
    transition: background var(--transition-fast);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.toggle-label input:checked + .toggle-switch {
    background: var(--color-primary);
}

.toggle-label input:checked + .toggle-switch::after {
    transform: translateX(20px);
}

/* Checkbox */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
}

.checkbox-label input {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.checkbox-label input:checked + .checkbox-custom {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.checkbox-label input:checked + .checkbox-custom::after {
    content: '✓';
    color: white;
    font-size: 12px;
}

/* Slider */
.slider-container {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.form-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    outline: none;
}

.form-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
}

.slider-value {
    font-weight: var(--font-semibold);
    min-width: 40px;
    text-align: center;
}

/* ========================================
   QUICK ACTIONS
   ======================================== */

.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
    padding: var(--space-4);
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4);
    background: var(--color-surface-hover);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-text);
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--color-border);
}

.action-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-icon svg {
    width: 24px;
    height: 24px;
}

.action-icon.blue { background: rgba(67, 97, 238, 0.15); color: var(--color-primary); }
.action-icon.yellow { background: rgba(250, 204, 21, 0.15); color: #ca8a04; }
.action-icon.green { background: rgba(34, 197, 94, 0.15); color: var(--color-success); }

.action-btn span {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

/* ========================================
   FILTER TABS
   ======================================== */

.filter-tabs {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    padding-bottom: var(--space-2);
    -webkit-overflow-scrolling: touch;
}

.filter-tab {
    padding: var(--space-3) var(--space-4);
    min-height: 44px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.filter-tab:hover {
    border-color: var(--color-primary);
}

.filter-tab.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

/* ========================================
   TIMELINE
   ======================================== */

.timeline-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--color-border);
}

.timeline-item-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timeline-item-body {
    flex: 1;
    min-width: 0;
}

.timeline-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.timeline-item-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-item-subtitle {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.timeline-item-date {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* ========================================
   EMPTY STATES
   ======================================== */

.empty-state {
    text-align: center;
    padding: var(--space-10) var(--space-4);
}

.empty-state-small {
    text-align: center;
    padding: var(--space-6) var(--space-4);
    color: var(--color-text-muted);
}

.empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-4);
    background: var(--color-surface-hover);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-icon svg {
    width: 32px;
    height: 32px;
    color: var(--color-text-muted);
}

.empty-state h4,
.empty-state .empty-title {
    margin-bottom: var(--space-2);
    font-size: var(--text-xl);
    font-weight: 600;
}

.empty-state p {
    margin-bottom: var(--space-4);
}

/* ========================================
   TOASTS
   (Container defined in layout.css)
   ======================================== */

.toast {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-10px);
    transition: all var(--transition-base);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-info { border-left: 4px solid var(--color-primary); }
.toast-success { border-left: 4px solid var(--color-success); }
.toast-warning { border-left: 4px solid #f97316; }
.toast-error { border-left: 4px solid var(--color-error); }

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: var(--font-semibold);
}

.toast-message {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-top: 2px;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.toast-action {
    display: inline-block;
    margin-top: var(--space-2);
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-primary);
    background: none;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.toast-action:hover {
    background: var(--color-primary);
    color: #fff;
}

/* ========================================
   MODALS
   ======================================== */

.modal-container.hidden {
    display: none;
}

.modal-container.modal-top {
    align-items: flex-start;
    padding-top: 64px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.modal {
    position: relative;
    background: var(--color-bg);
    border-radius: var(--radius-xl);
    max-width: 500px;
    width: calc(100% - 32px);
    max-height: calc(100vh - 48px);
    overflow: auto;
    box-shadow: var(--shadow-xl);
}

.modal.fullscreen {
    max-width: none;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
}

.modal.fullscreen .modal-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
}

.modal.fullscreen .modal-body .camera-container {
    height: 100%;
}

.quote-viewer {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: stretch;
    justify-content: center;
    background: var(--color-bg-elevated, #000);
}

.quote-viewer-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

.quote-viewer-img {
    max-width: 100%;
    max-height: 100%;
    margin: auto;
    object-fit: contain;
    display: block;
}

.quote-viewer-fallback {
    margin: auto;
    padding: var(--space-6);
    text-align: center;
    color: var(--color-text);
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    align-items: center;
}

/* PDF.js canvas viewer. Hosted inside .quote-viewer (which is a flex
   row); we override to a column scroll container that fills the modal
   body, so pages stack vertically and the user can scroll/pinch-zoom
   without the native iOS PDF viewer taking over the layer. */
.pdf-viewer-host {
    width: 100%;
    height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: #525659;
    display: flex;
    flex-direction: column;
}

.pdf-viewer-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.pdf-viewer-page {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    max-width: 100%;
    height: auto;
}

.pdf-viewer-status,
.pdf-viewer-error,
.pdf-viewer-page-error {
    margin: auto;
    padding: var(--space-6);
    text-align: center;
    color: #fff;
}

.pdf-viewer-error p,
.pdf-viewer-status {
    margin: 0;
}

.quote-camera-btn svg {
    vertical-align: -2px;
    margin-right: 4px;
}

.quote-view-btn {
    color: var(--color-primary, #6366f1);
    flex-shrink: 0;
}

.quote-view-btn:hover:not(:disabled) {
    color: var(--color-primary-hover, var(--color-primary, #6366f1));
}

/* Always-visible escape hatch for the fullscreen file-viewer modal.
   Reason this exists: on iOS PWA standalone, embedded PDFs are
   rendered by iOS's native PDF viewer which paints over the modal
   header — the × button there becomes unreachable and the only
   recourse is force-quitting the app. This button is `position:
   fixed` with a z-index above the iframe stacking context and
   safe-area-aware top inset, so it remains tappable regardless of
   how iOS chooses to paint the iframe contents. */
.viewer-floating-close {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    right: calc(env(safe-area-inset-right, 0px) + 8px);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    border: 0;
    font-size: 26px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    z-index: calc(var(--z-modal) + 100);
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.viewer-floating-close:hover,
.viewer-floating-close:focus {
    background: rgba(0, 0, 0, 0.9);
    outline: none;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
    margin: 0;
    font-size: var(--text-lg);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-body {
    padding: var(--space-4);
}

.modal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4);
    border-top: 1px solid var(--color-border);
}

/* Footer buttons sit in a flex row with `min-width: 0` and `word-break:
   break-word` from `.btn`, which on narrow viewports collapses labels
   character-by-character when total content width exceeds the row. Pin
   labels to a single line and let the row wrap instead. */
.modal-footer .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.modal-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    margin-top: var(--space-4);
}

.modal-actions .btn {
    min-width: 100px;
}

/* Restore Prompt (for resuming in-progress inspections) */
.restore-prompt {
    text-align: center;
    padding: var(--space-4) 0;
}

.restore-prompt .restore-icon {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-4);
    color: var(--color-primary);
}

.restore-prompt h3,
.restore-prompt .empty-title {
    margin: 0 0 var(--space-2);
    font-size: var(--text-xl);
    font-weight: 600;
}

.restore-prompt p {
    color: var(--color-text-muted);
    margin: 0 0 var(--space-4);
}

.restore-prompt .restore-details {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.restore-prompt .restore-details span {
    background: var(--color-surface);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

/* ========================================
   AVATARS
   ======================================== */

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    flex-shrink: 0;
}

.avatar.large {
    width: 80px;
    height: 80px;
    font-size: var(--text-2xl);
}

/* ========================================
   BADGES
   ======================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    border-radius: var(--radius-full);
    background: var(--color-surface-hover);
    text-transform: capitalize;
}

.badge.completed, .badge.resolved, .badge.active {
    background: rgba(34, 197, 94, 0.15);
    color: var(--color-success);
}

.badge.in_progress, .badge.assigned {
    background: rgba(67, 97, 238, 0.15);
    color: var(--color-primary);
}

.badge.pending, .badge.open, .badge.draft {
    background: rgba(250, 204, 21, 0.15);
    color: #ca8a04;
}

.badge.cancelled, .badge.closed {
    background: var(--color-surface-hover);
    color: var(--color-text-muted);
}

/* ========================================
   LOADING
   ======================================== */

.loading-placeholder {
    text-align: center;
    padding: var(--space-10);
    color: var(--color-text-muted);
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   DETAIL CARDS
   ======================================== */

.detail-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    margin-bottom: var(--space-4);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    gap: var(--space-3);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    flex-shrink: 0;
}

.detail-value {
    min-width: 0;
    text-align: right;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* ========================================
   TEMPLATES
   ======================================== */

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--space-3);
}

.template-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    text-decoration: none;
    color: inherit;
    transition: all var(--transition-fast);
}

.template-card:hover {
    border-color: var(--color-primary);
}

.template-icon {
    width: 48px;
    height: 48px;
    background: var(--color-surface-hover);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-3);
}

.template-icon svg {
    width: 24px;
    height: 24px;
    color: var(--color-primary);
}

.template-name {
    font-weight: var(--font-semibold);
    margin-bottom: 4px;
}

.template-desc {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.template-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.template-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.template-item .template-info {
    flex: 1;
    min-width: 0;
}

.template-item .template-name,
.template-item .template-desc {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.template-actions {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex-shrink: 0;
}

.template-actions .template-delete-btn {
    color: var(--color-error);
}

/* ========================================
   CAMERA & PHOTO
   ======================================== */

.camera-container {
    position: relative;
    background: #000;
    width: 100%;
    height: 100%;
    min-height: 300px;
}

.camera-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-controls {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
}

.photo-capture {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.photo-preview {
    min-height: 100px;
    background: var(--color-surface-hover);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.photo-preview img {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: cover;
}

.photo-buttons {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.photo-buttons .btn {
    flex: 1;
    min-width: 120px;
}

.photo-buttons label.btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.photo-upload {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* Scanner */
.scanner-container {
    position: relative;
    background: #000;
    height: calc(100vh - 60px);
}

.scanner-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanner-frame {
    width: 250px;
    height: 250px;
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-lg);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.scanner-result {
    position: absolute;
    bottom: 24px;
    left: 24px;
    right: 24px;
    background: var(--color-surface);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
}

/* ========================================
   SIGNATURE PAD
   ======================================== */

.signature-pad-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3);
}

.signature-canvas {
    display: block;
    width: 100%;
    height: 150px;
    min-height: 150px;
    background: var(--color-surface-hover, #2a2a3e);
    border: 2px dashed var(--color-border-hover, rgba(255,255,255,0.15));
    border-radius: var(--radius-md);
    touch-action: none;
    cursor: crosshair;
}

/* ========================================
   QUESTION TYPE PICKER
   ======================================== */

.question-type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
}

.question-type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.question-type-btn:hover {
    border-color: var(--color-primary);
    background: var(--color-surface-hover);
}

.type-icon {
    font-size: 24px;
}

.type-name {
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
}

/* ========================================
   CHARTS
   ======================================== */

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    padding: var(--space-4);
}

.chart-container {
    position: relative;
    height: 200px;
    width: 100%;
}

/* ========================================
   TOGGLE SWITCH
   ======================================== */

.toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-border);
    transition: var(--transition-fast);
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition-fast);
    border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
    background-color: var(--color-primary);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.toggle input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   ACTION BUTTONS
   ======================================== */

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}

.action-buttons .btn {
    flex: 1;
    min-width: 120px;
}

.action-buttons .btn svg {
    margin-right: var(--space-2);
}

/* ========================================
   RESPONSES LIST
   ======================================== */

.responses-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.response-item {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    padding: var(--space-3);
}

.response-item.flagged {
    border-left: 3px solid var(--color-error);
}

.response-question {
    font-weight: var(--font-medium);
    margin-bottom: var(--space-2);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

.response-value {
    font-size: var(--text-base);
    word-break: break-word;
    overflow-wrap: break-word;
}

.response-note {
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    font-style: italic;
}

/* ========================================
   ISSUE & WORK ORDER HEADERS
   ======================================== */

.issue-header,
.wo-header {
    margin-bottom: var(--space-4);
}

.issue-header h2,
.wo-header h2 {
    margin: var(--space-2) 0;
    font-size: var(--text-xl);
}

.issue-desc,
.wo-desc {
    color: var(--color-text-muted);
    margin-bottom: var(--space-4);
    line-height: 1.6;
}

/* ========================================
   RESPONSIVE FIXES
   ======================================== */

@media (max-width: 480px) {
    .question-type-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }
}

@media (max-width: 320px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   CHIPS / TAGS (Multi-issue linking)
   ======================================== */

.linked-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 28px;
    align-items: center;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(67, 97, 238, 0.15);
    color: var(--color-primary);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    max-width: 200px;
}

.chip-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-remove {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.7;
}

.chip-remove:hover {
    opacity: 1;
}

/* ========================================
   ISSUE PICKER (WO form)
   ======================================== */

.issue-picker {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
}

.issue-pick-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    font-size: var(--text-sm);
}

.issue-pick-item:last-child {
    border-bottom: none;
}

.issue-pick-item:hover {
    background: var(--color-surface-hover);
}

.issue-pick-item input[type="checkbox"] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin-top: 1px;
    padding: 0;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.issue-pick-title {
    flex: 1;
    min-width: 0;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.issue-pick-item .priority-badge {
    flex-shrink: 0;
    font-size: 0.7rem;
    margin-left: auto;
}

/* ========================================
   WORK ORDER TIMELINE
   ======================================== */

.wo-timeline {
    padding: var(--space-3) var(--space-4);
}

.wo-timeline-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
}

.wo-timeline-item:last-child {
    border-bottom: none;
}

.wo-timeline-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--color-surface-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-text-muted);
}

.wo-timeline-body {
    flex: 1;
    min-width: 0;
}

.wo-timeline-desc {
    font-size: var(--text-sm);
    line-height: 1.4;
}

.wo-timeline-desc strong {
    font-weight: var(--font-semibold);
}

.wo-timeline-note {
    margin-top: 4px;
    padding: 8px 12px;
    background: var(--color-surface-hover);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    word-break: break-word;
}

.wo-timeline-date {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* ========================================
   DOCUMENT LIST (Property documents)
   ======================================== */

.doc-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.doc-item .list-item-icon {
    background: transparent;
}

.doc-item .list-item-content {
    cursor: pointer;
}

/* ========================================
   INSTALL BANNER
   ======================================== */

#install-banner {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-surface, #2a2a3e);
    border-top: 1px solid var(--color-border, #3a3a4e);
    padding: var(--space-3, 12px) var(--space-4, 16px);
    z-index: var(--z-toast, 400);
    animation: slideUp 0.3s ease-out;
}

#install-banner .install-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3, 12px);
    max-width: 600px;
    margin: 0 auto;
    font-size: var(--font-sm, 0.875rem);
    color: var(--color-text, #e0e0e0);
}

#install-banner .install-banner-actions {
    display: flex;
    gap: var(--space-2, 8px);
    flex-shrink: 0;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ========================================
   CSP-SAFE REPLACEMENTS FOR INLINE STYLES
   ======================================== */

/* Header right-side spacer (mirrors 44px back-button width) */
.nav-spacer { width: 44px; }

/* Full-width list-style ghost button used in overflow menus */
.menu-item-btn {
    width: 100%;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 16px;
}

/* 404 page oversized code */
.big-code { font-size: 64px; margin-bottom: 16px; }

/* Sync-errors list row tweaks */
.sync-error-row { flex-wrap: wrap; gap: var(--space-2); }
.sync-error-content { min-width: 0; }
.sync-error-message { word-break: break-all; }
.sync-error-detail { padding: var(--space-3) var(--space-4); }

/* Inspection list “(pending sync)” hint */
.pending-sync-hint { color: var(--warning-color); }

/* Inline alerts with an icon + text + trailing button */
.alert-inline { display: flex; align-items: center; gap: 12px; }
.alert-inline-sm { display: flex; align-items: center; gap: 8px; }
.alert-inline-action { margin-left: auto; }

/* Photo modal image */
.modal-photo-wrap { text-align: center; }
.modal-photo {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-md);
}

/* Inline response image thumb */
.response-image-thumb {
    max-width: 200px;
    max-height: 200px;
    border-radius: 6px;
}

/* Centered 2-button action row (dashboard welcome) */
.action-row {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
}

/* Dashboard SW version tag */
.sw-version-tag { color: var(--danger); font-size: 0.5em; }

/* Empty-list placeholder inside cells */
.empty-muted { padding: 12px; color: #888; }
.empty-card {
    text-align: center;
    color: var(--color-text-muted);
    padding: 24px;
}

/* Issue detail action row */
.inline-actions { display: flex; gap: 8px; margin-top: 16px; }
.inline-actions > .btn { flex: 1; }

/* Work-order provider info box */
.wo-provider-info {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--color-surface-hover);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

/* Placeholder text for no-issues / etc. */
.placeholder-muted {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}
.picker-empty { padding: 8px; color: var(--color-text-muted); }
.picker-error { padding: 8px; color: var(--color-error); }

/* Work-order issue priority chip sizing */
.priority-chip-sm { font-size: 0.7rem; }
.badge-gap { margin-left: 4px; }

/* Primary-color link */
.link-primary { color: var(--color-primary); }

/* Service-provider card meta */
.sp-name-suffix {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-left: 4px;
}

/* Star rating pill (admin providers list + card) */
.rating-stars { color: #facc15; font-size: 0.85rem; }
.rating-stars-lg {
    margin-left: auto;
    color: #facc15;
    font-size: 1.1rem;
}

/* Provider header avatar */
.provider-avatar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.provider-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: rgba(67, 97, 238, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}
.provider-name { font-weight: 600; font-size: 1.1rem; }
.provider-category-badge { margin-top: 4px; }
.btn-danger-outline { color: var(--danger); }

/* Property search */
.search-relative { position: relative; }
.search-input-padded { padding-left: 40px; }
.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
}
.icon-faint { opacity: 0.3; }

/* Property detail header / stats */
.property-header-pad { padding: 16px; }
.property-address { font-size: 1.1rem; font-weight: 600; margin-bottom: 4px; }
.property-meta { color: var(--color-text-muted); font-size: 0.875rem; }
.property-meta-sm {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin-top: 2px;
}
.property-stat {
    text-align: center;
    padding: 12px;
}
.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
}
.stat-number--primary { color: var(--color-primary); }
.stat-number--warning { color: var(--color-warning); }
.stat-number--violet { color: #8b5cf6; }
.stat-number--muted { color: var(--color-text-muted); }
.stat-label { font-size: 0.75rem; color: var(--color-text-muted); }
.stat-sub { font-size: 0.7rem; margin-top: 2px; }
.stat-sub--warning { font-size: 0.7rem; color: var(--color-warning); margin-top: 2px; }
.stat-sub--violet { font-size: 0.7rem; color: #8b5cf6; margin-top: 2px; }
.stat-sub-pass { color: var(--color-success); }
.stat-sub-fail { color: var(--color-error); }

/* Document list item (clickable) */
.doc-item-clickable { cursor: pointer; }

/* Timeline badges for property history */
.badge-pass-sm {
    background: var(--color-success);
    color: white;
    font-size: 0.7rem;
}
.badge-fail-sm {
    background: var(--color-error);
    color: white;
    font-size: 0.7rem;
}
.badge-score {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}
.badge-status-sm {
    color: white;
    font-size: 0.7rem;
}
/* Timeline icon: colors injected at runtime via element.style.setProperty */
.timeline-item-icon-dyn {
    background: var(--ti-bg);
    color: var(--ti-fg);
}

/* Solid-fill badge variants (timeline pass/fail/status chips) */
.badge-solid {
    color: #fff;
    font-size: 0.7rem;
}
.badge-solid--success { background: var(--color-success); }
.badge-solid--error { background: var(--color-error); }
.badge-solid--warning { background: var(--color-warning); }
.badge-solid--primary { background: var(--color-primary); }
.badge-solid--muted { background: var(--color-text-muted); }
.badge-solid--violet { background: #8b5cf6; }
