﻿/* Inspection InProgress Styles */

/* ========== Timer Bar ========== */

.timer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    margin-top: 8px;
}

.timer-display-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.timer-icon { font-size: 16px; color: #059669; }

#timerDisplay {
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #065f46;
}

#timerDisplay.timer-running { color: #059669; }
#timerDisplay.timer-paused { color: #94a3b8; }

.timer-actions { display: flex; gap: 8px; }

.timer-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pause-btn { background: #fef3c7; color: #92400e; }
.pause-btn:hover { background: #fde68a; }
.resume-btn { background: #059669; color: #ffffff; }
.resume-btn:hover { background: #047857; }
.timer-btn:active { transform: scale(0.97); }

/* ========== Sticky Overview Bar ========== */

.inspection-sticky-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #ffffff;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    padding: 10px 14px;
}

.sticky-bar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sticky-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.sticky-bar-left .service-title {
    font-size: 14px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sticky-bar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* ========== Section Navigation ========== */

.inspection-section-nav {
    display: flex;
    gap: 4px;
    margin-top: 10px;
}

.section-nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.section-nav-btn:hover { background: #e2e8f0; color: #334155; }
.section-nav-btn:active { transform: scale(0.97); }

.section-nav-btn.active {
    background: #059669;
    color: #ffffff;
    border-color: #059669;
}

.section-nav-btn:disabled {
    color: #cbd5e1;
    cursor: not-allowed;
    opacity: 0.5;
}

.section-nav-btn:disabled:hover { background: #f8fafc; color: #cbd5e1; }

.section-nav-btn i { font-size: 11px; }

.section-nav-back {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
    flex: 0 0 auto;
    padding-left: 10px;
    padding-right: 10px;
}

.section-nav-back:hover { background: #e2e8f0; color: #1e293b; }

/* ========== System Selection Cards ========== */

.system-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    padding: 16px;
}

.system-select-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.system-select-card:hover {
    border-color: #059669;
    background: #f0fdf4;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.1);
}

.system-select-card:active { transform: translateY(0); }

.system-card-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    border-radius: 10px;
    flex-shrink: 0;
}

.system-card-icon i { font-size: 18px; color: #ffffff; }

.system-card-info { flex: 1; min-width: 0; }

.system-card-name {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.system-card-type {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

.system-card-meta {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.system-card-asset-count {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    background: #e2e8f0;
    padding: 2px 8px;
    border-radius: 10px;
}

.system-card-deficiency-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #ffffff;
    background: #dc2626;
    padding: 2px 8px;
    border-radius: 10px;
}

.system-card-status {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.system-status-pending { background: #fef3c7; color: #92400e; }
.system-status-complete { background: #d1fae5; color: #065f46; }

/* Complete card variant */
.system-select-card.is-complete {
    border-color: #10b981;
    background: #f0fdf4;
}

.system-select-card.is-complete .system-card-icon {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.system-select-card.is-complete:hover {
    border-color: #059669;
    background: #dcfce7;
}

/* ========== Scoped System Bar ========== */

.scoped-system-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: #ffffff;
    border-radius: 10px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border-left: 4px solid #059669;
}

.scoped-system-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.scoped-system-info > i {
    color: #059669;
    font-size: 16px;
}

.scoped-system-info > span:not(.scoped-system-complete-badge) {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scoped-system-complete-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #d1fae5;
    color: #065f46;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.btn-mark-complete {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #ffffff;
    color: #059669;
    border: 1.5px solid #059669;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-mark-complete:hover:not([disabled]) {
    background: #f0fdf4;
}

.btn-mark-complete:active:not([disabled]) { transform: scale(0.97); }

.btn-mark-complete[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-mark-complete.is-complete {
    background: #059669;
    color: #ffffff;
}

.btn-mark-complete.is-complete:hover:not([disabled]) {
    background: #047857;
}

/* ========== Inspection Sections ========== */

.inspection-section {
    background: #ffffff;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.inspection-section-header {
    padding: 14px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.inspection-section-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.inspection-section-header h3 i { color: #059669; }

.inspection-section-empty {
    padding: 24px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
}

/* ========== Form Cards ========== */

.form-card {
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.form-card:last-child { border-bottom: none; }

.form-card-title {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 12px;
}

/* ========== Form Group Cards (Collapsible) ========== */

.form-group-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.form-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.form-group-chevron {
    font-size: 11px;
    color: #94a3b8;
    transition: transform 0.2s;
}

.form-group-card.collapsed .form-group-chevron { transform: rotate(-90deg); }
.form-group-card.collapsed .form-group-body { display: none; }

.form-group-scope-badge {
    margin-left: auto;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.scope-inspection { background: #fef3c7; color: #b45309; }
.scope-system { background: #dbeafe; color: #1d4ed8; }
.scope-subsystem { background: #dcfce7; color: #166534; }

.form-group-retain-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    background: #eff6ff;
    color: #3b82f6;
    letter-spacing: 0.3px;
}

.form-group-body { padding: 8px 12px; }

/* ========== Question Rows ========== */

.question-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

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

.question-label {
    flex: 0 0 200px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    padding-top: 6px;
}

.question-control { flex: 1; min-width: 0; }

/* ========== Toggle Buttons ========== */

.answer-toggle-group { display: flex; gap: 4px; flex-wrap: wrap; }

.answer-toggle-btn {
    padding: 5px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #ffffff;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.answer-toggle-btn:hover { border-color: #94a3b8; }
.answer-toggle-btn.active { border-color: #3b82f6; background: #eff6ff; color: #1d4ed8; }
.answer-toggle-btn.active.toggle-pass { border-color: #059669; background: #ecfdf5; color: #065f46; }
.answer-toggle-btn.active.toggle-fail { border-color: #dc2626; background: #fef2f2; color: #991b1b; }
.answer-toggle-btn.active.toggle-na { border-color: #94a3b8; background: #f1f5f9; color: #475569; }

/* ========== Text/Numeric/Time/Date/Select Inputs ========== */

.answer-text-input,
.answer-numeric-input,
.answer-time-input,
.answer-date-input,
.answer-select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    color: #1e293b;
    background: #ffffff;
    transition: border-color 0.2s;
    font-family: inherit;
    line-height: 1.4;
    box-sizing: border-box;
}

.answer-text-input:focus,
.answer-numeric-input:focus,
.answer-time-input:focus,
.answer-date-input:focus,
.answer-select:focus {
    outline: none;
    border-color: #059669;
}

.answer-numeric-input { width: 120px; }
.answer-time-input { width: 140px; }
.answer-date-input { width: 180px; cursor: pointer; }

/* ========== AutoComplete (suggestions styled like the office Customer autocomplete) ========== */

.autocomplete-input {
    position: relative;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.autocomplete-item {
    padding: 8px 10px;
    font-size: 13px;
    color: #1e293b;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.15s ease;
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: #f9fafb;
}

/* ========== Quick Tips ========== */
/* The question label is the trigger: it renders as a standard hyperlink and opens the
   list under the answer. The list reuses .autocomplete-results/-item. No icons. */

.quick-tip-wrap .answer-text-input { display: block; width: 100%; }

.quick-tip-link,
.quick-tip-link:visited {
    color: #2563eb;
    text-decoration: none;
    cursor: pointer;
}

.quick-tip-link:hover,
.quick-tip-link.active { color: #1d4ed8; text-decoration: underline; }

.quick-tip-results { border-top: 1px solid #e2e8f0; border-radius: 6px; margin-top: 4px; box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12); }

.quick-tip-header {
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    color: #1e40af;
    background: #eff6ff;
    border-bottom: 1px solid #bfdbfe;
}

.quick-tip-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.quick-tip-count { font-size: 11px; color: #94a3b8; white-space: nowrap; }

.autocomplete-no-results {
    padding: 8px 10px;
    font-size: 13px;
    color: #94a3b8;
    font-style: italic;
}

/* ========== Compound: SystemCheck ========== */

.compound-answer {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.compound-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.compound-label {
    flex: 0 0 80px;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
}

.sc-toggle-group,
.nc-toggle-group { display: flex; gap: 4px; }

.sc-toggle-btn,
.nc-toggle-btn {
    padding: 4px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    background: #ffffff;
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.sc-toggle-btn:hover,
.nc-toggle-btn:hover { border-color: #94a3b8; }
.sc-toggle-btn.active,
.nc-toggle-btn.active { border-color: #3b82f6; background: #eff6ff; color: #1d4ed8; }
.sc-toggle-btn.active.toggle-pass { border-color: #059669; background: #ecfdf5; color: #065f46; }
.sc-toggle-btn.active.toggle-fail { border-color: #dc2626; background: #fef2f2; color: #991b1b; }

.sc-comments {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 12px;
    color: #1e293b;
    resize: none;
}

.sc-comments:focus { outline: none; border-color: #059669; }

/* ========== Compound: NotificationCheck ========== */

.nc-who-input,
.nc-time-input {
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 12px;
    color: #1e293b;
}

.nc-who-input { width: 120px; }
.nc-time-input { width: 110px; }
.nc-who-input:focus,
.nc-time-input:focus { outline: none; border-color: #059669; }

/* ========== Asset Cards ========== */

.asset-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin: 8px 16px;
    overflow: hidden;
}

.asset-card.fully-answered { border-color: #bbf7d0; }

.asset-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #f8fafc;
    cursor: pointer;
    gap: 8px;
}

.asset-card.fully-answered .asset-card-header { background: #f0fdf4; }

.asset-card-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.asset-card-chevron {
    font-size: 11px;
    color: #94a3b8;
    transition: transform 0.2s;
}

.asset-card.collapsed .asset-card-chevron { transform: rotate(-90deg); }
.asset-card.collapsed .asset-card-body { display: none; }

.asset-card-type {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.asset-card-detail {
    font-size: 11px;
    color: #64748b;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 3px;
}

.asset-progress-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: #f1f5f9;
    color: #64748b;
    white-space: nowrap;
}

/* ========== Asset Reorder Controls ========== */

.asset-reorder {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.asset-reorder-btn {
    width: 22px;
    height: 22px;
    min-height: 22px;
    line-height: 1;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: #ffffff;
    color: #475569;
    font-size: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.asset-reorder-btn:hover { background: #f1f5f9; }
.asset-reorder-btn:active { background: #e2e8f0; }

.asset-reorder-input {
    width: 44px;
    height: 22px;
    min-height: 22px;
    box-sizing: border-box;
    line-height: 20px;
    font-size: 12px;
    padding: 0 4px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #1e293b;
    background: #ffffff;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
}

.asset-reorder-input:focus {
    outline: none;
    border-color: #059669;
}

.asset-reorder-input::-webkit-outer-spin-button,
.asset-reorder-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.asset-progress-badge.complete { background: #d1fae5; color: #065f46; }

.asset-card-body { padding: 8px 12px; }

/* ========== Asset Question Grid ========== */

.asset-question-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

.asset-question-grid:last-child { border-bottom: none; }

.asset-question-cell { text-align: center; }

.asset-question-label {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
}

.asset-question-cell .answer-toggle-group { justify-content: center; }

.asset-question-grid-2 { grid-template-columns: repeat(2, 1fr); }
.asset-question-grid-1 { grid-template-columns: 1fr; }

.asset-question-cell .answer-text-input,
.asset-question-cell .answer-numeric-input,
.asset-question-cell .answer-time-input,
.asset-question-cell .answer-select {
    width: 100%;
}

/* ========== Asset Filter Bar ========== */

.asset-toolbar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.asset-toolbar-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.asset-toolbar-label {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex: 0 0 auto;
    min-width: 40px;
}

.asset-filter-select {
    padding: 5px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    color: #334155;
    background: #ffffff;
}

.asset-sort-dir-btn {
    width: 30px;
    height: 28px;
    min-height: 28px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #ffffff;
    color: #334155;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.asset-sort-dir-btn:hover { background: #f1f5f9; }
.asset-sort-dir-btn:active { background: #e2e8f0; }

.asset-progress {
    margin-left: auto;
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ========== Asset Card Detail Button ========== */

.asset-card-detail-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px;
    margin-top: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.asset-card-detail-btn:hover { background: #e2e8f0; color: #334155; }

/* ========== No Access ========== */

.asset-card.no-access { border-color: #fca5a5; opacity: 0.7; }
.asset-card.no-access .asset-card-header { background: #fef2f2; }

.no-access-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    background: #fef2f2;
    color: #dc2626;
    text-transform: uppercase;
}

.no-access-reason {
    padding: 8px 12px;
    font-size: 12px;
    color: #94a3b8;
    font-style: italic;
}

.no-access-reason i { margin-right: 4px; }

.no-access-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #ffffff;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.no-access-toggle-btn:hover { border-color: #dc2626; color: #dc2626; }
.no-access-toggle-btn.active { background: #fef2f2; border-color: #dc2626; color: #dc2626; }

.no-access-detail-banner {
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    color: #991b1b;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

.no-access-detail-banner i { margin-right: 6px; }

/* ========== Modal Components ========== */

/* Centered modal: the overlay is a viewport-fixed backdrop, and the
   modal-container inside is absolutely centered via transform. We don't rely
   on flex-centering here because jQuery's fadeIn toggles inline `display`
   and the base `.modal-overlay` rule from index.css can get clobbered. */
.modal-overlay.modal-overlay-centered {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    padding: 0 !important;
}

/* Preserve hidden state — jQuery sets inline `display: none` on fadeOut. */
.modal-overlay.modal-overlay-centered[style*="display: none"],
.modal-overlay.modal-overlay-centered[style*="display:none"] {
    display: none !important;
}

/* Dead-center the modal-container directly to the viewport with
   `position: fixed`. Using `absolute` (relative to the overlay) fails on
   iOS/iPad when the overlay's computed height doesn't match the visual
   viewport — fixed positioning sidesteps that because the container then
   references the viewport itself, not the overlay's box. */
.modal-overlay.modal-overlay-centered > .modal-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Sticky header/footer with scrollable body so buttons stay reachable */
.modal-container-flex {
    display: flex;
    flex-direction: column;
}

.modal-container-flex .modal-header,
.modal-container-flex .modal-footer {
    flex-shrink: 0;
}

.modal-container-flex .modal-body-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}

.modal-container {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
}

.modal-container.modal-container-flex { overflow: hidden; }

/* Device Detail modal — large, near-full-height; header fixed, body scrolls. */
.device-detail-modal-container {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    max-width: 760px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    padding: 0;
}

.device-detail-modal-container .device-modal-header {
    flex-shrink: 0;
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
    border-radius: 16px 16px 0 0;
}

.device-detail-modal-container .device-modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

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

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:active { background: #e2e8f0; color: #1e293b; }

.modal-body { padding: 16px; }

.modal-footer {
    padding: 12px 16px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ========== Form Fields ========== */

.form-group { margin-bottom: 12px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
}

.form-label .required { color: #dc2626; }

.form-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: #1e293b;
    background: #ffffff;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-input:focus { outline: none; border-color: #059669; }

textarea.form-input { resize: vertical; }

/* ========== Buttons ========== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: #059669; color: #ffffff; }
.btn-primary:hover { background: #047857; }

.btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }

.btn-danger { background: #dc2626; color: #ffffff; }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ========== Device Detail ========== */

.back-to-assets-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.back-to-assets-btn:hover { background: #f1f5f9; }

.device-detail-body { padding: 16px; }

.device-info-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.device-info-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 12px;
    color: #475569;
    font-weight: 500;
}

.device-info-item i { color: #94a3b8; font-size: 11px; }

.device-info-reorder { padding: 2px 8px; gap: 8px; }
.device-info-reorder .asset-reorder { gap: 2px; }

.device-detail-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
}

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

.device-detail-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ========== Device Photos ========== */

.device-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    padding: 8px 0;
}

.device-photo-item {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    background: #f8fafc;
}

.device-photo-thumb {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #f1f5f9;
}

.device-photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.device-photo-actions {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 4px;
    border-top: 1px solid #e2e8f0;
}

/* ========== Bulk Action Toolbar ========== */

.bulk-action-toolbar {
    position: fixed;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    z-index: 100;
    background: #1e293b;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.bulk-toolbar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    max-width: 800px;
}

.bulk-count {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
}

.bulk-actions {
    display: flex;
    gap: 8px;
    flex: 1;
    /* flex-end, not center: the answer fields carry a label above the input, so
       centring would float the Apply button above the controls it acts on. */
    align-items: flex-end;
}

.bulk-select {
    padding: 6px 8px;
    border: 1px solid #475569;
    border-radius: 6px;
    background: #334155;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
}

.bulk-apply-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: #059669;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.bulk-apply-btn:hover { background: #047857; }

.bulk-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: #475569;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
}

.bulk-clear-btn:hover { background: #64748b; color: #ffffff; }

.asset-select-cb {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #059669;
    flex-shrink: 0;
}

/* ========== Responsive ========== */

@media (max-width: 640px) {
    .question-row {
        flex-direction: column;
        gap: 4px;
    }

    .question-label {
        flex: none;
        padding-top: 0;
    }

    .compound-row {
        flex-wrap: wrap;
    }

    .compound-label {
        flex: 0 0 100%;
    }

    .asset-toolbar-row {
        align-items: stretch;
    }

    .asset-progress {
        margin-left: 0;
        text-align: center;
        width: 100%;
    }

    .asset-question-grid {
        grid-template-columns: 1fr;
    }

    .section-nav-btn span { display: none; }
}

/* ============================
   Deficiency UI
   ============================ */
.question-row.has-deficiency {
    background: #fef2f2;
    border-left: 3px solid #dc2626;
    padding-left: 9px;
}

.question-row.has-deficiency .question-label {
    color: #7f1d1d;
}

.deficiency-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    margin-left: 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.deficiency-btn:hover {
    background: #fee2e2;
}

.deficiency-btn i {
    font-size: 10px;
}

.asset-question-cell.has-deficiency {
    border-left: 3px solid #dc2626;
    padding-left: 8px;
    background: #fef2f2;
    border-radius: 4px;
}

.asset-question-cell.has-deficiency .asset-question-label {
    color: #7f1d1d;
    font-weight: 600;
}

.asset-card.has-deficiency {
    border-color: #fecaca;
}

.asset-card.has-deficiency .asset-card-header::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dc2626;
    margin-left: 8px;
}

.prior-deficiency-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    margin-left: 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.prior-deficiency-btn:hover {
    background: #fef3c7;
}

.prior-deficiency-btn i {
    font-size: 10px;
}

/* Bell after this visit recorded a verdict: no longer a call to action */
.prior-deficiency-btn.observed {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}

.prior-deficiency-btn.observed.outcome-Corrected {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

.prior-deficiency-btn.observed.outcome-StillDeficient,
.prior-deficiency-btn.observed.outcome-ConditionChanged {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

/* ===== Prior deficiency modal: outcome picker ===== */
.prior-outcome-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.prior-outcome-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    min-height: 44px;
}

.prior-outcome-btn.active.outcome-corrected { background: #ecfdf5; border-color: #10b981; color: #047857; }
.prior-outcome-btn.active.outcome-still { background: #fef2f2; border-color: #ef4444; color: #b91c1c; }
.prior-outcome-btn.active.outcome-changed { background: #fff7ed; border-color: #f97316; color: #c2410c; }
.prior-outcome-btn.active.outcome-unable { background: #f1f5f9; border-color: #64748b; color: #334155; }

.prior-outcome-hint {
    font-size: 12px;
    color: #64748b;
    margin-top: 6px;
    min-height: 16px;
}

/* ===== Prior section on the Deficiencies tab ===== */
.deficiency-group-prior .deficiency-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.prior-pending-count {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: #fef3c7;
    color: #92400e;
}

.prior-pending-count.prior-pending-done {
    background: #ecfdf5;
    color: #047857;
}

.prior-outcome-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: #f1f5f9;
    color: #475569;
}

.prior-outcome-badge.outcome-Corrected { background: #ecfdf5; color: #047857; }
.prior-outcome-badge.outcome-StillDeficient { background: #fef2f2; color: #b91c1c; }
.prior-outcome-badge.outcome-ConditionChanged { background: #fff7ed; color: #c2410c; }
.prior-outcome-badge.outcome-UnableToVerify { background: #f1f5f9; color: #334155; }

.section-nav-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 4px;
    background: #dc2626;
    color: #ffffff;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
}

.deficiency-group {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.deficiency-group-header {
    padding: 10px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.deficiency-group-body {
    padding: 0;
}

.deficiency-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
}

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

.deficiency-item-main {
    flex: 1;
    min-width: 0;
}

.deficiency-item-question {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
}

.deficiency-item-meta {
    font-size: 12px;
    color: #dc2626;
    margin-bottom: 4px;
}

.deficiency-item-meta i {
    margin-right: 3px;
}

.deficiency-item-notes {
    font-size: 12px;
    color: #475569;
    line-height: 1.4;
}

.deficiency-item-notes-empty {
    color: #94a3b8;
    font-style: italic;
}

.deficiency-item-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #ffffff;
    color: #059669;
    border: 1px solid #a7f3d0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.deficiency-item-edit-btn:hover {
    background: #ecfdf5;
}

.deficiency-photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.deficiency-photo-thumb {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.deficiency-photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.deficiency-photo-thumb .thumb-loading {
    color: #94a3b8;
    font-size: 14px;
}

.deficiency-photo-thumb-delete {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    padding: 0;
}

.deficiency-photo-thumb-delete:hover {
    background: #dc2626;
}


/* Add System modal — New / Existing segmented tabs */
.modal-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.modal-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 12px;
    margin-bottom: -1px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
}

.modal-tab:hover {
    color: #1e293b;
}

.modal-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* ===== Bulk answer fields (in the selection bar) =====
   Built from the tenant's default asset questions, so the count varies — the row
   wraps rather than assuming three. */

.bulk-answer-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: flex-end;
}

.bulk-answer-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 130px;
    flex: 1 1 130px;
}

.bulk-answer-label {
    font-size: 11px;
    font-weight: 600;
    /* Light: the toolbar is #1e293b, so slate-500 was all but invisible on it. */
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Left as an ordinary light control on purpose. Styling the select dark to match the
   toolbar makes the browser render its dropdown dark too, and the OS hover highlight
   then paints dark text on a light bar — the hovered option becomes unreadable, and
   that is not something CSS can reliably fix. A plain white control sits fine against
   the dark bar and its dropdown behaves like every other select on the page. */
.bulk-answer-input {
    width: 100%;
    min-height: 34px;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #0f172a;
    font-size: 13px;
}

.bulk-answer-empty {
    font-size: 12px;
    color: #94a3b8;
    padding-bottom: 8px;
}
