/* ===== CSS Variables ===== */
:root {
    --primary: #478fca;
    --primary-dark: #3a7bb8;
    --success: #87b87f;
    --warning: #f0ad4e;
    --danger: #d15b47;
    --info: #6fb3e0;
    --gray-100: #f7f7f7;
    --gray-200: #e8e8e8;
    --gray-300: #d5d5d5;
    --gray-400: #aaa;
    --gray-500: #888;
    --gray-600: #555;
    --gray-700: #393939;
    --white: #fff;
    --body-bg: #f1f1f1;
    --card-bg: #fff;
    --text: #333;
    --text-muted: #888;
    --shadow: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --radius: 8px;
    --radius-lg: 12px;
    --navbar-height: 56px;
    --topbar-height: 52px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

/* ===== Reset ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--body-bg);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ===== App Layout ===== */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-container {
    flex: 1;
    padding-top: var(--topbar-height);
    padding-bottom: calc(var(--navbar-height) + var(--safe-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.page-content {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
}

/* ===== Topbar ===== */
.topbar {
    position: fixed;
    top: 0;
    inset-inline: 0;
    height: var(--topbar-height);
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    padding: 0 16px;
    padding-top: var(--safe-top);
    z-index: 100;
    box-shadow: var(--shadow);
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

.topbar-btn {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.3rem;
    padding: 8px;
    cursor: pointer;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Left-side placeholder when there is no back button, so the title stays
   centred. Matches the width of .topbar-btn. */
.topbar-slot {
    min-width: 40px;
}


/* Version chip on the right of the topbar. Subtle so it doesn't compete
   with the page title. */
.topbar-version {
    min-width: 40px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-align: center;
    white-space: nowrap;
}

.topbar-version:empty { background: transparent; }

/* ===== Bottom Navbar ===== */
.navbar {
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    height: calc(var(--navbar-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -1px 6px rgba(0,0,0,0.1);
    z-index: 100;
}

.navbar.hidden { display: none; }

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 6px 0;
    color: var(--gray-400);
    font-size: 0.7rem;
    cursor: pointer;
    transition: color 0.2s;
    background: none;
    border: none;
    -webkit-tap-highlight-color: transparent;
}

.nav-item.active { color: var(--primary); }
.nav-item svg { width: 24px; height: 24px; margin-bottom: 2px; }

/* Center + FAB nested inside the navbar. Raised above the bar so it visually
   "pops" — the target route depends on the signed-in user's role. */
.nav-center-fab {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    border: 4px solid var(--white);
    box-shadow: 0 6px 18px rgba(71,143,202,0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 8px;
    transform: translateY(-18px);
    transition: transform 0.12s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
    /* Slow colour wave: primary blue -> success green -> back. */
    animation: nav-center-wave 6s ease-in-out infinite;
}

@keyframes nav-center-wave {
    0%   { background: var(--primary); box-shadow: 0 6px 18px rgba(71,143,202,0.45); }
    50%  { background: var(--success); box-shadow: 0 6px 18px rgba(76,175,80,0.5); }
    100% { background: var(--primary); box-shadow: 0 6px 18px rgba(71,143,202,0.45); }
}

@media (prefers-reduced-motion: reduce) {
    .nav-center-fab { animation: none; }
}

.nav-center-fab:active {
    transform: translateY(-16px) scale(0.96);
}

.nav-center-fab-plus {
    font-size: 32px;
    line-height: 1;
    font-weight: 900;
    margin-top: -2px;
}

/* ===== Center + chooser bottom-sheet ===== */
.nav-chooser {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.nav-chooser[hidden] { display: none; }

.nav-chooser-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
}

.nav-chooser-panel {
    position: relative;
    width: 100%;
    max-width: 520px;
    background: var(--white);
    border-top-left-radius: 22px;
    border-top-right-radius: 22px;
    padding: 12px 18px calc(20px + var(--safe-bottom));
    box-shadow: 0 -12px 40px rgba(0,0,0,0.25);
    animation: nav-chooser-in 0.2s ease-out;
}

@keyframes nav-chooser-in {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.nav-chooser-handle {
    width: 40px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 999px;
    margin: 4px auto 12px;
}

.nav-chooser-title {
    margin: 0 0 12px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    text-align: center;
}

.nav-chooser-opt {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    border: 1px solid var(--gray-200);
    background: var(--white);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
    text-align: start;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.nav-chooser-opt:active {
    transform: scale(0.98);
    border-color: var(--primary);
}

.nav-chooser-opt-ico {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
}

.nav-chooser-opt-ico-repair { background: var(--primary); }
.nav-chooser-opt-ico-insp   { background: var(--success); }

.nav-chooser-opt-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.nav-chooser-opt-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.nav-chooser-opt-sub {
    font-size: 0.8rem;
    color: var(--gray-600);
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    overflow: hidden;
}

.card-body { padding: 14px 16px; }

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-clickable {
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.card-clickable:active {
    transform: scale(0.98);
}

/* ===== Summary Cards (Home) ===== */
.summary-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
}

.summary-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.summary-icon.repairs { background: #e8f4fd; color: var(--primary); }
.summary-icon.inspections { background: #e8f5e9; color: var(--success); }

.summary-info h3 { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.summary-info .count { font-size: 1.6rem; font-weight: 700; color: var(--text); }

/* ===== Status Badges ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-pending { background: #fff3cd; color: #856404; }
.badge-progress { background: #cce5ff; color: #004085; }
.badge-completed { background: #d4edda; color: #155724; }
.badge-closed { background: var(--gray-200); color: var(--gray-600); }

/* ===== Forms ===== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(71,143,202,0.15);
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23555' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-inline-end: 32px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

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

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
}

.btn-block { width: 100%; }
.btn-lg { padding: 14px 24px; font-size: 1.05rem; }

/* ===== FAB (Floating Action Button) ===== */
.fab {
    position: fixed;
    bottom: calc(var(--navbar-height) + var(--safe-bottom) + 16px);
    inset-inline-end: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    border: none;
    font-size: 1.8rem;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: transform 0.2s;
}

.fab:active { transform: scale(0.9); }

/* ===== Filter Tabs ===== */
.filter-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 0 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-tabs::-webkit-scrollbar { display: none; }

.filter-tab {
    padding: 6px 16px;
    border-radius: 20px;
    background: var(--white);
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
    white-space: nowrap;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

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

/* ===== Repairs page-size toolbar ===== */
.repairs-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 0 10px;
    font-size: 0.85rem;
    color: var(--gray-600);
}

.repairs-toolbar-label {
    font-weight: 600;
}

.repairs-toolbar-count {
    margin-inline-start: auto;
    font-size: 0.8rem;
    color: var(--gray-600);
}

.repairs-toolbar-count.is-truncated {
    color: var(--primary);
    font-weight: 600;
}

.page-size-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.page-size-tab {
    padding: 4px 12px;
    border-radius: 16px;
    background: var(--white);
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

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

/* ===== Inspection dashboard charts (non-technician) ===== */
.insp-charts {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.insp-chart-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
}

.insp-chart-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 10px;
}

.insp-donut-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.insp-donut { flex-shrink: 0; }

.insp-donut-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.insp-donut-frac {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.insp-donut-label {
    font-size: 0.85rem;
    color: var(--gray-600);
}

.insp-donut-sub {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-top: 4px;
}

.insp-bars {
    display: block;
    width: 100%;
    height: auto;
    max-height: 160px;
}

.insp-type-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.insp-type-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.insp-type-head {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text);
}

.insp-type-name { font-weight: 600; }

.insp-type-frac { color: var(--gray-600); }

.insp-type-track {
    width: 100%;
    height: 6px;
    background: var(--gray-200, #e5e7eb);
    border-radius: 999px;
    overflow: hidden;
}

.insp-type-fill {
    height: 100%;
    background: var(--success, #4caf50);
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* ===== New-inspection modal ===== */
.insp-modal {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.insp-modal[hidden] { display: none; }

.insp-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.insp-modal-panel {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 88vh;
    background: var(--white);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -12px 40px rgba(0,0,0,0.25);
    animation: insp-modal-in 0.2s ease-out;
}

@keyframes insp-modal-in {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.insp-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-200);
}
.insp-modal-head h3 { margin: 0; font-size: 1.05rem; }

.insp-modal-close {
    border: 0;
    background: transparent;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--gray-600);
    cursor: pointer;
    padding: 4px 8px;
}

.insp-modal-body {
    padding: 14px 18px;
    overflow-y: auto;
    flex: 1;
}

.insp-modal-foot {
    display: flex;
    gap: 10px;
    padding: 12px 18px;
    border-top: 1px solid var(--gray-200);
    background: var(--white);
}
.insp-modal-foot .btn { flex: 1; }

.insp-modal-list {
    margin-top: 6px;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px;
}

.insp-modal-opt {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: start;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.insp-modal-opt:hover { background: var(--gray-100, #f2f5f8); }
.insp-modal-opt.is-selected {
    background: rgba(71,143,202,0.12);
    color: var(--primary);
}

.insp-modal-opt-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}
.insp-modal-opt.is-selected .insp-modal-opt-name { color: var(--primary); }

.insp-modal-opt-meta {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-top: 2px;
}

.insp-modal-empty {
    padding: 14px;
    text-align: center;
    font-size: 0.9rem;
}

/* ===== Repair detail: edit form ===== */
.req {
    color: var(--danger);
    font-weight: 700;
    margin-inline-start: 2px;
}

.field-error {
    border-color: var(--danger) !important;
    background: rgba(220, 38, 38, 0.04);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-top: 6px;
}

.form-hint-center {
    text-align: center;
    margin: 8px 0 4px;
}

/* ===== Dashboard technician picker ===== */
.dash-tech-picker {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 16px;
    margin-bottom: 16px;
}

/* ===== Vital consumables gauges ===== */
.vital-section {
    margin-bottom: 16px;
}

.vital-section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 4px 8px;
}

.vital-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.vital-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 8px 10px;
    text-align: center;
}

.vital-gauge {
    width: 100%;
    max-width: 180px;
    margin: 0 auto;
    line-height: 0;
}

.vital-gauge svg,
.vital-gauge .gauge-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.vital-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-top: 4px;
    line-height: 1.2;
}

.vital-label {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-top: 2px;
}

.vital-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
    min-height: 0.9rem;
}

/* Older-than-today readings get a warm accent so they're not mistaken for
   a fresh measurement. */
.vital-date.vital-date-stale {
    color: var(--warning);
    font-weight: 600;
}

/* ===== Repair-create photo attachments ===== */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.photo-grid:empty { display: none; }

.photo-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    background: var(--gray-100, #f2f5f8);
    box-shadow: var(--shadow);
}

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

.photo-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 0;
    background: rgba(15, 23, 42, 0.75);
    color: var(--white);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}


.day-hour-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.day-hour-row {
    display: grid;
    grid-template-columns: 22px 1fr 1fr;
    gap: 8px;
    align-items: center;
}

.day-hour-idx {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
}

.executor-block {
    padding: 10px 0;
    border-bottom: 1px dashed var(--gray-200, #e5e7eb);
}
.executor-block:last-child { border-bottom: 0; }

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text);
    margin-top: 4px;
}

.checkbox-inline input {
    width: 18px;
    height: 18px;
}

/* Repair-done pill — big tap target, closes the ticket when tapped */
.repair-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin: 14px 0 4px;
    padding: 14px 20px;
    border-radius: 999px;
    border: 2px solid var(--gray-300);
    background: var(--white);
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.repair-pill:active { transform: scale(0.98); }

.repair-pill-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--gray-300);
    box-shadow: inset 0 0 0 2px var(--white);
    transition: background 0.15s ease;
}

.repair-pill.is-on {
    background: var(--success);
    border-color: var(--success);
    color: var(--white);
}

.repair-pill.is-on .repair-pill-dot {
    background: var(--white);
    box-shadow: inset 0 0 0 2px var(--success);
}

.page-size-select {
    padding: 4px 24px 4px 10px;
    border-radius: 16px;
    background: var(--white);
    border: 1px solid var(--gray-300);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%23555' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

/* ===== Search Bar ===== */
.search-bar {
    position: relative;
    margin-bottom: 12px;
}

.search-bar input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    font-size: 0.95rem;
}

.search-bar svg {
    position: absolute;
    inset-inline-start: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--gray-400);
}

/* ===== Repair Card ===== */
.repair-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.repair-card-id {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.95rem;
}

.repair-card-desc {
    font-size: 0.9rem;
    color: var(--gray-600);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.repair-card-meta {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== Detail Sections ===== */
.detail-section {
    margin-bottom: 20px;
}

.detail-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--primary);
}

.detail-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}

.detail-label {
    flex: 0 0 40%;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.detail-value {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text);
}

/* ===== Inspection Items ===== */
.inspection-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
}

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

.inspection-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #e8f5e9;
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.inspection-info { flex: 1; }
.inspection-info h4 { font-size: 0.95rem; font-weight: 600; }
.inspection-info p { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.inspection-arrow {
    color: var(--gray-400);
    font-size: 1.2rem;
}

/* ===== Checklist ===== */
.checklist-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 10px;
}

.checklist-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 10px;
    color: var(--text);
}

.checklist-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.checklist-fields .form-group { margin-bottom: 0; }

.checklist-fields .full-width {
    grid-column: 1 / -1;
}

/* ===== Facility Selector ===== */
.facility-selector {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 16px;
    margin-bottom: 16px;
}

.facility-selector select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.95rem;
}

/* ===== Facility Picker (searchable) ===== */
.fac-picker {
    position: relative;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 16px;
    margin-bottom: 16px;
}

.fac-picker-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
}

.fac-picker-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--text);
    font-size: 1rem;
    text-align: start;
    cursor: pointer;
    transition: border-color 0.2s;
}

.fac-picker-toggle:focus,
.fac-picker-toggle:hover {
    outline: none;
    border-color: var(--primary);
}

.fac-picker-current {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fac-picker-caret {
    color: var(--gray-600);
    font-size: 0.9rem;
}

.fac-picker-panel {
    position: absolute;
    inset-inline-start: 16px;
    inset-inline-end: 16px;
    top: calc(100% - 6px);
    z-index: 1000;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    padding: 8px;
    max-height: 320px;
    display: flex;
    flex-direction: column;
}

.fac-picker-panel[hidden] { display: none; }

.fac-picker-search {
    margin-bottom: 8px;
    padding: 8px 10px;
    font-size: 0.95rem;
}

.fac-picker-list {
    overflow-y: auto;
    max-height: 240px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.fac-picker-opt {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 0.95rem;
    text-align: start;
    cursor: pointer;
    border-radius: 6px;
}

.fac-picker-current.is-placeholder {
    color: var(--gray-400, #9ca3af);
}

.fac-picker-opt-sub {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-top: 2px;
}

.fac-picker-opt:hover {
    background: var(--gray-100, #f2f5f8);
}

.fac-picker-opt.is-selected {
    background: rgba(71,143,202,0.12);
    color: var(--primary);
    font-weight: 600;
}

.fac-picker-opt[hidden] { display: none; }

.fac-picker-empty {
    padding: 12px;
    text-align: center;
    font-size: 0.9rem;
}

.fac-picker-static .fac-picker-value {
    padding: 8px 0;
    font-size: 1rem;
    font-weight: 500;
}

/* ===== Loading ===== */
.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-center {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ===== Toast ===== */
#toast-container {
    position: fixed;
    top: calc(var(--topbar-height) + 8px);
    inset-inline: 16px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toastIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast-success { background: var(--success); color: var(--white); }
.toast-error { background: var(--danger); color: var(--white); }
.toast-info { background: var(--info); color: var(--white); }
.toast-warning { background: var(--warning); color: #333; }

@keyframes toastIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.toast-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to { transform: translateY(-20px); opacity: 0; }
}

/* ===== Sync Indicator ===== */
.sync-bar {
    position: fixed;
    top: var(--topbar-height);
    inset-inline: 0;
    height: 3px;
    background: var(--warning);
    z-index: 101;
    animation: syncPulse 1.5s ease-in-out infinite;
}

@keyframes syncPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.offline-banner {
    position: fixed;
    top: var(--topbar-height);
    inset-inline: 0;
    background: var(--danger);
    color: var(--white);
    text-align: center;
    padding: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 101;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 300;
    display: flex;
    align-items: flex-end;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } }

.modal-content {
    background: var(--white);
    width: 100%;
    max-height: 80vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--white);
}

.modal-header h3 { font-size: 1.1rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-500);
    cursor: pointer;
    padding: 4px;
}

.modal-body { padding: 16px; }

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    background: linear-gradient(160deg, #3a7bb8 0%, #478fca 40%, #5ba0d9 100%);
    position: relative;
    overflow: hidden;
}

.login-top {
    text-align: center;
    margin-bottom: 28px;
    flex-shrink: 0;
}

.login-icon {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    color: var(--white);
}

.login-logo {
    display: block;
    width: 96px;
    height: 96px;
    margin: 0 auto 14px;
    border-radius: 22px;
    background: rgba(255,255,255,0.95);
    padding: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    object-fit: contain;
}

.login-title {
    font-size: 2rem;
    color: var(--white);
    font-weight: 800;
    letter-spacing: 2px;
}

.login-subtitle {
    color: rgba(255,255,255,0.8);
    font-size: 0.85rem;
    margin-top: 4px;
}

.login-card {
    background: var(--white);
    border-radius: 16px;
    padding: 28px 22px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    flex-shrink: 0;
}

.login-input-wrap {
    position: relative;
}

.login-input-icon {
    position: absolute;
    inset-inline-start: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

.login-input {
    padding-inline-start: 44px !important;
    height: 48px;
    border-radius: 10px !important;
    font-size: 0.95rem !important;
    background: var(--gray-100) !important;
    border-color: transparent !important;
}

.login-input:focus {
    background: var(--white) !important;
    border-color: var(--primary) !important;
}

.login-input::placeholder {
    color: var(--gray-400);
}

.login-btn {
    height: 50px;
    border-radius: 12px !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.login-error {
    background: #fde8e8;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: none;
}

.login-footer {
    margin-top: 24px;
    flex-shrink: 0;
}

.login-lang-btn {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.3);
    color: var(--white);
    padding: 8px 24px;
    border-radius: 24px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.login-lang-btn:active {
    background: rgba(255,255,255,0.25);
}

/* ===== Install Banner ===== */
.install-banner {
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    padding: 0 16px max(16px, env(safe-area-inset-bottom));
    z-index: 200;
    animation: slideUp 0.4s ease;
}

.install-banner-content {
    background: var(--white);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    max-width: 400px;
    margin: 0 auto;
}

.install-banner-content svg {
    color: var(--primary);
    flex-shrink: 0;
}

.install-banner-content span {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
}

.install-btn {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 8px 18px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.install-btn:active {
    transform: scale(0.95);
}

.install-dismiss {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0 4px;
    flex-shrink: 0;
}

/* ===== Settings ===== */
.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
}

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

.settings-label {
    font-size: 0.95rem;
    font-weight: 500;
}

.settings-value {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

/* iOS-style disclosure chevron drawn from two borders — sharp at any zoom,
   flips automatically in RTL because the container is [dir="rtl"]. */
.settings-chevron {
    width: 8px;
    height: 8px;
    border-top: 2px solid var(--gray-400);
    border-right: 2px solid var(--gray-400);
    transform: rotate(45deg);
    display: inline-block;
    flex-shrink: 0;
    margin-inline-end: 2px;
}

[dir="rtl"] .settings-chevron {
    transform: rotate(-135deg);
    margin-inline-end: 2px;
}

.settings-item[data-clickable]:active .settings-chevron {
    border-color: var(--primary);
}

/* Inline progress pill used in Settings rows that run a long action
   (e.g. Prepare for offline). Stays compact so the row height doesn't jump. */
.settings-progress {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.settings-progress.ok {
    background: var(--success);
    color: var(--white);
}


.toggle-switch {
    position: relative;
    width: 48px;
    height: 28px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--gray-300);
    border-radius: 28px;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    inset-inline-start: 3px;
    bottom: 3px;
    background: var(--white);
    border-radius: 50%;
    transition: transform 0.3s;
}

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

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

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

.settings-hint {
    padding: 4px 16px 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.35;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.empty-state p { font-size: 0.95rem; }

/* ===== Pull to Refresh ===== */
.ptr-indicator {
    text-align: center;
    padding: 12px;
    color: var(--primary);
    display: none;
}

/* ===== Home status breakdown ===== */
/* Mobile-first: vertical stack of full-width rows. Each row is a large tap
   target with a colored left accent bar, full-width label, and big count on
   the right. On wider screens (>=540px) we switch to a 2-column grid. */
.status-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.status-chip {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px 16px 14px 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.status-chip::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: var(--status-color, var(--gray-400));
}

.status-chip:active {
    transform: scale(0.98);
}

.status-chip-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.status-chip-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--status-color, var(--text));
    line-height: 1;
    flex-shrink: 0;
    min-width: 32px;
    text-align: end;
}

.status-chip[data-status="1"] { --status-color: var(--warning); }
.status-chip[data-status="2"] { --status-color: var(--info); }
.status-chip[data-status="3"] { --status-color: #d1a34a; }
.status-chip[data-status="4"] { --status-color: var(--danger); }
.status-chip[data-status="5"] { --status-color: var(--success); }

/* Two columns from ~540px so tablets don't waste horizontal space. */
@media (min-width: 540px) {
    .status-breakdown {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
}

/* ===== Install Prompt ===== */
#install-prompt {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--navbar-height) + var(--safe-bottom) + 12px);
    z-index: 250;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 12px 14px;
    display: none;
    align-items: center;
    gap: 12px;
    animation: installIn 0.35s ease;
}

#install-prompt.show { display: flex; }

#install-prompt .install-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--white);
    flex: 0 0 auto;
    object-fit: contain;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

#install-prompt .install-text {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.3;
}

#install-prompt .install-text small {
    display: block;
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 2px;
}

#install-prompt .install-btn {
    flex: 0 0 auto;
    background: var(--primary);
    color: var(--white);
    border: 0;
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

#install-prompt .install-btn:active { background: var(--primary-dark); }

#install-prompt .install-close {
    flex: 0 0 auto;
    background: transparent;
    border: 0;
    color: var(--gray-500);
    font-size: 1.3rem;
    line-height: 1;
    padding: 4px 6px;
    cursor: pointer;
}

@keyframes installIn {
    from { transform: translateY(120%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* iOS instructions sheet */
#install-ios-sheet {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: flex-end;
    justify-content: center;
}

#install-ios-sheet.show { display: flex; }

#install-ios-sheet .sheet {
    background: var(--card-bg);
    width: 100%;
    max-width: 480px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 20px 20px calc(20px + var(--safe-bottom));
    text-align: center;
    animation: sheetUp 0.3s ease;
}

#install-ios-sheet .sheet h3 {
    margin-bottom: 8px;
    color: var(--primary);
}

#install-ios-sheet .sheet p {
    color: var(--gray-600);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 12px;
}

#install-ios-sheet .sheet .close {
    margin-top: 8px;
    background: var(--gray-200);
    color: var(--text);
    border: 0;
    border-radius: 999px;
    padding: 10px 24px;
    font-weight: 600;
    cursor: pointer;
}

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

/* ===== Utility ===== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none !important; }
