/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { background: #f8fafc; color: #1e293b; overscroll-behavior-y: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
a { color: #0d9488; text-decoration: none; }

/* ── App shell ── */
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 480px; margin: 0 auto; position: relative; background: #fff; box-shadow: 0 0 0 1px #e2e8f0; }

/* ── Top bar ── */
.top-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: #0f172a; color: #fff; flex-shrink: 0; }
.top-bar-logo { display: flex; align-items: center; }
.top-bar-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.top-bar-subtitle { font-size: 11px; color: #94a3b8; margin-top: 1px; }
.top-bar-spacer { flex: 1; }
.top-bar-action { background: none; border: none; color: #94a3b8; font-size: 20px; padding: 4px; border-radius: 6px; }
.top-bar-action:hover { color: #fff; }

/* ── Page content ── */
.page-content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page-inner { padding: 16px; }

/* ── Bottom nav ── */
.bottom-nav { display: flex; background: #0f172a; border-top: 1px solid #1e293b; flex-shrink: 0; }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 4px 10px; color: #64748b; text-decoration: none; font-size: 10px; gap: 3px; border: none; background: none; transition: color .15s; }
.nav-item:hover { color: #94a3b8; }
.nav-item.active { color: #0d9488; }
.nav-item .nav-icon { font-size: 20px; line-height: 1; }

/* ── Spinner ── */
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-ring { width: 36px; height: 36px; border: 3px solid #e2e8f0; border-top-color: #0d9488; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-loading { display: flex; justify-content: center; align-items: center; padding: 60px 0; }

/* ── Login ── */
.login-wrap { display: flex; flex-direction: column; align-items: center; padding: 40px 20px 24px; min-height: 100%; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.login-wordmark { font-size: 20px; font-weight: 800; color: #0f172a; }
.login-tag { font-size: 12px; color: #64748b; font-weight: 500; }
.login-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 16px; padding: 28px 24px; width: 100%; max-width: 380px; box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.login-title { font-size: 20px; font-weight: 700; color: #0f172a; margin-bottom: 4px; }
.login-subtitle { font-size: 13px; color: #64748b; margin-bottom: 24px; }
.login-alert { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.login-field { margin-bottom: 16px; }
.login-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.login-input { width: 100%; padding: 10px 14px; border: 1.5px solid #d1d5db; border-radius: 10px; font-size: 16px; outline: none; transition: border-color .15s; background: #f9fafb; }
.login-input:focus { border-color: #0d9488; background: #fff; }
.login-input.error { border-color: #ef4444; }
.login-field-hint { font-size: 11px; color: #9ca3af; margin-top: 4px; }
.login-error-text { font-size: 11px; color: #ef4444; margin-top: 4px; }
.login-btn { width: 100%; padding: 12px; background: #0d9488; color: #fff; border: none; border-radius: 10px; font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; transition: background .15s; }
.login-btn:hover:not(:disabled) { background: #0f766e; }
.login-btn:disabled { opacity: .6; cursor: not-allowed; }
.login-help { font-size: 12px; color: #9ca3af; text-align: center; margin-top: 16px; }

/* ── Dashboard ── */
.dashboard { padding: 16px; }
.dash-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.dash-greeting { font-size: 18px; font-weight: 700; color: #0f172a; }
.dash-sub { font-size: 12px; color: #64748b; margin-top: 2px; }
.dash-date { font-size: 12px; color: #64748b; padding-top: 4px; }
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 24px; }
.stat-card { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 12px 8px; text-align: center; cursor: pointer; transition: transform .1s; }
.stat-card:active { transform: scale(.97); }
.stat-number { font-size: 22px; font-weight: 800; color: #0f172a; }
.stat-label { font-size: 10px; color: #64748b; margin-top: 2px; font-weight: 500; }
.stat-teal   { border-color: #99f6e4; background: #f0fdfa; }
.stat-teal .stat-number { color: #0d9488; }
.stat-amber  { border-color: #fcd34d; background: #fffbeb; }
.stat-amber .stat-number { color: #d97706; }
.stat-red    { border-color: #fca5a5; background: #fef2f2; }
.stat-red .stat-number { color: #dc2626; }
.section-title { font-size: 13px; font-weight: 700; color: #374151; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 24px; }
.qa-btn { display: flex; flex-direction: column; align-items: center; gap: 5px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px 4px; font-size: 11px; font-weight: 600; color: #374151; transition: background .12s; }
.qa-btn:hover { background: #f0fdfa; border-color: #99f6e4; }
.qa-icon { font-size: 22px; }

/* ── Job cards ── */
.job-list { display: flex; flex-direction: column; gap: 10px; }
.job-row { display: flex; align-items: center; justify-content: space-between; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; cursor: pointer; }
.job-row-left { display: flex; align-items: center; gap: 10px; }
.job-title { font-size: 14px; font-weight: 600; color: #0f172a; }
.job-meta { font-size: 11px; color: #64748b; margin-top: 2px; }
.job-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px; cursor: pointer; transition: box-shadow .15s; }
.job-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.job-card.card-overdue { border-color: #fca5a5; background: #fef2f2; }
.job-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.job-card-ref { font-size: 11px; color: #64748b; font-weight: 500; }
.job-card-title { font-size: 15px; font-weight: 700; color: #0f172a; margin-bottom: 6px; }
.job-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: #64748b; }
.job-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.job-due { font-size: 12px; color: #64748b; }
.overdue-text { color: #dc2626; font-weight: 600; }
.job-arrow { color: #64748b; font-size: 18px; }

/* ── Status badges ── */
.job-status { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.status-open     { background: #dbeafe; color: #1d4ed8; }
.status-progress { background: #fef3c7; color: #b45309; }
.status-done     { background: #d1fae5; color: #065f46; }
.status-overdue  { background: #fee2e2; color: #b91c1c; }
.status-hold     { background: #f3f4f6; color: #6b7280; }
.job-priority-badge { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.priority-urgent { background: #fee2e2; color: #b91c1c; }
.priority-high   { background: #fed7aa; color: #c2410c; }
.priority-medium { background: #fef3c7; color: #b45309; }
.priority-low    { background: #f3f4f6; color: #6b7280; }
.job-priority { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }

/* ── Filter chips ── */
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 5px 12px; border: 1px solid #d1d5db; border-radius: 20px; font-size: 12px; font-weight: 500; background: #f8fafc; color: #374151; }
.chip-active { background: #0d9488; border-color: #0d9488; color: #fff; }
.chip-green.chip-active { background: #059669; border-color: #059669; }
.chip-red.chip-active   { background: #dc2626; border-color: #dc2626; }

/* ── Page title row ── */
.page-title-row { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.page-title { font-size: 18px; font-weight: 800; color: #0f172a; }
.page-subtitle-text { font-size: 13px; color: #64748b; margin-bottom: 12px; }

/* ── Detail page ── */
.detail-card { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.detail-ref   { font-size: 12px; color: #64748b; margin-bottom: 4px; }
.detail-title { font-size: 18px; font-weight: 700; color: #0f172a; margin-bottom: 8px; }
.detail-meta-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: #64748b; margin-bottom: 6px; }
.detail-due  { font-size: 13px; color: #64748b; margin-bottom: 8px; }
.detail-desc { font-size: 13px; color: #374151; margin-top: 8px; line-height: 1.5; }
.action-row  { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.back-btn    { background: none; border: none; color: #0d9488; font-size: 14px; font-weight: 600; padding: 0; }

/* ── Section card (job detail sub-sections) ── */
.section-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.section-card-title { font-size: 13px; font-weight: 700; color: #374151; margin-bottom: 10px; }
.inline-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-end; }
.hours-list  { margin-top: 10px; border-top: 1px solid #f1f5f9; padding-top: 8px; }
.hours-row   { display: flex; justify-content: space-between; font-size: 12px; color: #374151; padding: 3px 0; }
.hours-total { display: flex; justify-content: flex-end; font-size: 12px; font-weight: 700; color: #0f172a; margin-top: 6px; border-top: 1px solid #e2e8f0; padding-top: 4px; }
.expense-list  { margin-top: 10px; border-top: 1px solid #f1f5f9; padding-top: 8px; }
.expense-row   { display: flex; justify-content: space-between; font-size: 12px; color: #374151; padding: 3px 0; }
.expense-total { display: flex; justify-content: flex-end; font-size: 12px; font-weight: 700; color: #0f172a; margin-top: 6px; border-top: 1px solid #e2e8f0; padding-top: 4px; }
.notes-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.note-row   { background: #f8fafc; border-radius: 8px; padding: 8px 10px; }
.note-meta  { font-size: 11px; color: #9ca3af; margin-bottom: 3px; }
.note-body  { font-size: 13px; color: #374151; }

/* ── Schedules / Inspections ── */
.inspection-header { background: #f0fdfa; border: 1px solid #99f6e4; border-radius: 12px; padding: 14px; margin-bottom: 16px; }
.inspection-title  { font-size: 16px; font-weight: 700; color: #0f172a; margin-bottom: 4px; }
.inspection-meta   { font-size: 12px; color: #64748b; }
.checklist         { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.checklist-item    { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; }
.checklist-name    { font-size: 13px; font-weight: 600; color: #0f172a; margin-bottom: 8px; }
.checklist-controls { display: flex; gap: 6px; }

/* ── Forms ── */
.form-field    { margin-bottom: 14px; }
.form-label    { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.form-input    { width: 100%; padding: 10px 12px; border: 1.5px solid #d1d5db; border-radius: 10px; font-size: 14px; outline: none; transition: border-color .15s; }
.form-input:focus { border-color: #0d9488; }
.form-input-sm { padding: 8px 10px; border: 1.5px solid #d1d5db; border-radius: 8px; font-size: 13px; outline: none; max-width: 120px; }
.form-input-sm:focus { border-color: #0d9488; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }

/* ── Buttons ── */
.btn-primary { background: #0d9488; color: #fff; border: none; border-radius: 10px; padding: 10px 18px; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; transition: background .15s; }
.btn-primary:hover:not(:disabled) { background: #0f766e; }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-success { background: #059669; color: #fff; border: none; border-radius: 10px; padding: 10px 18px; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-outline { background: transparent; color: #0d9488; border: 1.5px solid #0d9488; border-radius: 10px; padding: 10px 18px; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn-outline:hover:not(:disabled) { background: #f0fdfa; }
.btn-outline:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; border: none; }
.btn-teal { background: #0d9488; color: #fff; }
.btn-teal:hover:not(:disabled) { background: #0f766e; }
.btn-teal:disabled { opacity: .55; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; }

/* ── Alerts ── */
.alert-success { background: #d1fae5; border: 1px solid #6ee7b7; color: #065f46; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 10px; }
.alert-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #b91c1c; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 10px; }

/* ── Empty / error states ── */
.empty-state  { display: flex; flex-direction: column; align-items: center; padding: 48px 16px; gap: 10px; }
.empty-icon   { font-size: 40px; }
.empty-text   { font-size: 14px; color: #64748b; text-align: center; }
.error-state  { display: flex; flex-direction: column; align-items: center; padding: 40px 16px; gap: 12px; text-align: center; font-size: 14px; color: #64748b; }

/* ── Work log ── */
.summary-card  { background: #f0fdfa; border: 1px solid #99f6e4; border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.summary-label { font-size: 12px; color: #0f766e; font-weight: 600; }
.summary-value { font-size: 20px; font-weight: 800; color: #0d9488; }

/* ── Profile ── */
.profile-section       { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.profile-section-title { font-size: 13px; font-weight: 700; color: #374151; margin-bottom: 12px; text-transform: uppercase; letter-spacing: .04em; }
.profile-row   { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
.profile-row:last-child { border-bottom: none; }
.profile-label { font-size: 13px; color: #64748b; }
.profile-value { font-size: 13px; font-weight: 600; color: #0f172a; text-align: right; max-width: 60%; }
.pin-change-banner { display: flex; gap: 12px; background: #fffbeb; border: 1px solid #fcd34d; border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.pin-change-banner-icon  { font-size: 24px; }
.pin-change-banner-title { font-size: 14px; font-weight: 700; color: #78350f; }
.pin-change-banner-sub   { font-size: 12px; color: #92400e; margin-top: 3px; }
.pin-hint { font-size: 12px; color: #64748b; margin-bottom: 12px; }
