:root {
  --navy: #0050AA; --navy-dark: #003d82; --navy-light: #e6f0ff;
  --yellow: #ffffff; --yellow-dark: #f3f4f6;
  --red: #dc2626; --green: #16a34a; --orange: #ea580c;
  --bg: #f3f4f6; --surface: #ffffff; --surface-2: #f9fafb;
  --text: #111827; --text-secondary: #6b7280; --text-muted: #9ca3af;
  --border: #e5e7eb; --border-light: #f3f4f6;
  --radius-sm: 10px; --radius: 14px; --radius-lg: 20px; --radius-xl: 28px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04); --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08); --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }
html, body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; overflow-x: hidden; }

/* ===== LOGIN ===== */
.login-screen { position: fixed; inset: 0; z-index: 5000; background: linear-gradient(165deg, #0050AA 0%, #003d82 60%, #002a5c 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; transition: opacity 0.5s, transform 0.5s; }
.login-screen.hidden { opacity: 0; pointer-events: none; transform: scale(1.02); }
.login-card { background: var(--surface); border-radius: var(--radius-xl); padding: 36px 32px 28px; width: 100%; max-width: 360px; box-shadow: var(--shadow-lg); text-align: center; }
.login-logo-wrap { width: fit-content; min-width: 170px; background: #ffffff; border-radius: 18px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; padding: 12px 18px; box-shadow: 0 10px 24px rgba(15,23,42,0.16); border: 1px solid rgba(17,24,39,0.06); }
.login-logo-wrap img { width: 130px; height: auto; display: block; }

.login-title { font-size: 1.35rem; font-weight: 800; color: var(--text); margin-bottom: 2px; letter-spacing: -0.5px; }
.login-subtitle { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 24px; }
.login-field { margin-bottom: 14px; }
.login-field input { width: 100%; padding: 14px 16px; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text); font-size: 1rem; font-weight: 500; transition: all 0.2s; }
.password-wrap { position: relative; width: 100%; display: flex; align-items: center; }
.password-wrap input { padding-right: 52px; }
.eye-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: none; border-radius: 10px; background: transparent; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 2; }
.eye-btn:active { background: var(--border-light); transform: translateY(-50%) scale(0.94); }
.eye-btn:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.login-field input::placeholder { color: var(--text-muted); }
.login-field input:focus { outline: none; border-color: var(--navy); background: var(--surface); box-shadow: 0 0 0 4px rgba(0,80,170,0.08); }
.login-btn { width: 100%; padding: 15px; background: #ffffff; color: #000000; border: 2px solid #000000; border-radius: var(--radius); font-size: 1rem; font-weight: 800; cursor: pointer; box-shadow: var(--shadow-sm); transition: all 0.15s; }
.login-btn:active { transform: scale(0.98); background: #f3f4f6; }
.login-error { color: var(--red); font-size: 0.82rem; font-weight: 600; margin-top: 12px; text-align: center; opacity: 0; transition: opacity 0.3s; }
.login-error.show { opacity: 1; }
.login-footer { position: absolute; bottom: 24px; color: rgba(255,255,255,0.35); font-size: 0.72rem; font-weight: 500; }

/* ===== APP HEADER ===== */
.app-header { position: sticky; top: 0; z-index: 100; background: var(--navy); color: white; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow-md); }
.app-header h1 { font-size: 1.05rem; font-weight: 800; display: flex; align-items: center; gap: 10px; letter-spacing: -0.3px; }
.header-logo { min-width: 64px; height: 34px; background: #ffffff; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 4px 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.18); }
.header-logo img { width: 48px; height: auto; display: block; }

.header-right { display: flex; align-items: center; gap: 10px; }
.save-badge { font-size: 0.68rem; font-weight: 700; padding: 5px 12px; border-radius: 20px; background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.7); transition: all 0.3s; }
.save-badge.saved { background: rgba(22,163,74,0.25); color: #86efac; }
.btn-icon { width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,0.1); border: none; color: white; font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.btn-icon:active { background: rgba(255,255,255,0.2); transform: scale(0.95); }

/* Progress */
.progress-bar { height: 4px; background: var(--border-light); position: sticky; top: 62px; z-index: 99; }
.progress-fill { height: 100%; background: #ffffff; box-shadow: 0 0 10px rgba(255,255,255,0.55); width: 0%; transition: width 0.5s cubic-bezier(0.4,0,0.2,1); }

.container { max-width: 640px; margin: 0 auto; padding: 18px 16px 150px; }

/* ===== SECTION CARDS ===== */
.section { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); margin-bottom: 16px; border: 1px solid var(--border); overflow: hidden; animation: slideUp 0.4s ease both; }
.section:nth-child(1) { animation-delay: 0s; } .section:nth-child(2) { animation-delay: 0.05s; } .section:nth-child(3) { animation-delay: 0.1s; }
.section:nth-child(4) { animation-delay: 0.15s; } .section:nth-child(5) { animation-delay: 0.2s; } .section:nth-child(6) { animation-delay: 0.25s; }
.section:nth-child(7) { animation-delay: 0.3s; }

.section-header { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; border-bottom: 1px solid transparent; transition: all 0.2s; background: var(--surface); }
.section-header:hover { background: var(--navy-light); }
.section.collapsed .section-header { border-bottom-color: var(--border); }

.section-title { display: flex; align-items: center; gap: 12px; font-size: 0.95rem; font-weight: 800; }
.section-num { width: 30px; height: 30px; border-radius: 10px; background: var(--navy); color: white; display: flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 800; flex-shrink: 0; }
.section-status { width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex-shrink: 0; transition: all 0.3s; }
.section-status.complete { background: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,0.2); }
.section-status.partial { background: var(--orange); }

.chevron { width: 28px; height: 28px; border-radius: 8px; background: var(--border-light); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; transition: all 0.25s; }
.section.collapsed .chevron { transform: rotate(-90deg); }

.section-body { padding: 20px; }
.section.collapsed .section-body { display: none; }

/* ===== FORM ===== */
.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }
.field-label { display: block; font-size: 0.75rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.6px; }
.field-label.required::after { content: " *"; color: var(--red); }

input, select, textarea {
  width: 100%; padding: 14px 16px; border: 2px solid var(--border); border-radius: var(--radius-sm);
  font-size: 1rem; font-family: inherit; background: var(--surface); color: var(--text);
  transition: all 0.2s; -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 4px rgba(0,80,170,0.08); }
textarea { min-height: 100px; resize: vertical; line-height: 1.6; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }

/* Toggles */
.toggle-group { display: flex; gap: 8px; flex-wrap: wrap; }
.toggle-btn {
  padding: 11px 18px; border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 0.85rem; font-weight: 700;
  color: var(--text-secondary); cursor: pointer; transition: all 0.15s;
}
.toggle-btn.active { background: var(--navy); color: white; border-color: var(--navy); box-shadow: 0 2px 8px rgba(0,80,170,0.2); }
.toggle-btn:active { transform: scale(0.96); }

/* Pills */
.pill-group { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; border: 2px solid var(--border); border-radius: 24px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.15s;
  background: var(--surface); color: var(--text-secondary);
}
.pill input { display: none; }
.pill.checked { background: var(--navy); color: white; border-color: var(--navy); }

/* ===== PHOTO SECTION ===== */
.photo-section { background: var(--surface-2); border-radius: var(--radius); padding: 16px; border: 2px dashed var(--border); }
.photo-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.photo-title { font-size: 0.9rem; font-weight: 800; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.photo-count { font-size: 0.78rem; color: var(--text-muted); font-weight: 700; background: var(--border-light); padding: 4px 10px; border-radius: 12px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.photo-slot {
  aspect-ratio: 1; border: 2px dashed #d1d5db; border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 0.65rem; cursor: pointer;
  position: relative; overflow: hidden; background: var(--surface);
  transition: all 0.2s;
}
.photo-slot:hover { border-color: var(--navy); background: var(--navy-light); }
.photo-slot.has-image { border-style: solid; border-color: var(--navy); border-width: 2px; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; position: absolute; top: 0; left: 0; }
.photo-slot .remove-btn {
  position: absolute; top: 5px; right: 5px; width: 24px; height: 24px;
  background: var(--red); color: white; border-radius: 50%; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; cursor: pointer; z-index: 3; opacity: 0; transition: opacity 0.2s;
}
.photo-slot:hover .remove-btn { opacity: 1; }
.photo-slot .meta {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: white; font-size: 0.62rem; padding: 18px 6px 5px;
  z-index: 2; text-align: center; font-weight: 600;
}

/* ===== FAB CAMERA ===== */
.fab-camera {
  position: fixed; bottom: 96px; right: 20px; z-index: 90;
  width: 60px; height: 60px; border-radius: 50%;
  background: #ffffff; color: var(--text); border: 1px solid rgba(17,24,39,0.08);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(15,23,42,0.18);
  transition: all 0.2s;
}
.fab-camera:active { transform: scale(0.92); background: #f3f4f6; }
.fab-camera svg { width: 28px; height: 28px; }
.fab-camera .badge {
  position: absolute; top: -3px; right: -3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--red); color: white; font-size: 0.7rem;
  font-weight: 800; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* ===== PHOTO SOURCE + SAVED LIBRARY ===== */
body.modal-open{overflow:hidden;touch-action:none}
.photo-source-overlay[hidden],.photo-library-overlay[hidden]{display:none!important}
.photo-source-overlay,.photo-library-overlay{position:fixed;inset:0;z-index:999;background:rgba(10,18,30,.68);display:none;align-items:flex-end;justify-content:center;padding:18px;backdrop-filter:blur(5px)}
.photo-source-overlay.active,.photo-library-overlay.active{display:flex}
.photo-source-sheet{width:min(520px,100%);background:var(--surface);border-radius:22px;padding:18px;box-shadow:0 24px 70px rgba(0,0,0,.3)}
.photo-source-head,.photo-library-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:15px}
.photo-source-head strong,.photo-library-head strong{display:block;font-size:1.05rem;color:var(--text)}
.photo-source-head span,.photo-library-head span{display:block;margin-top:4px;color:var(--text-muted);font-size:.8rem;line-height:1.35}
.photo-source-close{width:38px;height:38px;border:0;border-radius:50%;background:var(--surface-2);color:var(--text);font-size:1.45rem;line-height:1;cursor:pointer;flex:0 0 auto}
.photo-source-actions{display:grid;gap:10px}
.photo-source-btn{display:flex;align-items:center;gap:13px;width:100%;padding:14px;border:1.5px solid var(--border);border-radius:14px;background:#fff;text-align:left;color:var(--text);cursor:pointer}
.photo-source-btn:active{background:var(--navy-light);border-color:var(--navy)}
.photo-source-btn>span:last-child{display:block;min-width:0}
.photo-source-btn strong{display:block;font-size:.9rem}
.photo-source-btn small{display:block;margin-top:3px;color:var(--text-muted);font-size:.74rem;line-height:1.35}
.photo-source-icon{width:42px;height:42px;border-radius:12px;background:var(--navy-light);display:flex;align-items:center;justify-content:center;font-size:1.25rem;flex:0 0 auto}
.photo-library-overlay{z-index:1000;align-items:stretch;padding:12px}
.photo-library-panel{width:min(920px,100%);max-height:calc(100vh - 24px);margin:auto;background:var(--surface);border-radius:20px;padding:17px;display:flex;flex-direction:column;box-shadow:0 24px 70px rgba(0,0,0,.3)}
.photo-library-status{padding:18px;border:1px dashed var(--border);border-radius:12px;color:var(--text-muted);text-align:center;font-size:.85rem}
.photo-library-status[hidden]{display:none}
.photo-library-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:11px;overflow:auto;padding:2px 2px 10px}
.photo-library-card{border:1px solid var(--border);border-radius:13px;background:#fff;overflow:hidden;text-align:left;padding:0;cursor:pointer;min-width:0}
.photo-library-card:active{transform:scale(.985)}
.photo-library-thumb{display:block;width:100%;aspect-ratio:4/3;object-fit:cover;background:var(--surface-2)}
.photo-library-copy{display:block;padding:9px 10px}
.photo-library-copy strong{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:.78rem}
.photo-library-copy small{display:block;margin-top:3px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:.68rem}
.photo-library-card.loading .photo-library-thumb{opacity:.45}
@media(max-width:560px){.photo-source-overlay{padding:0}.photo-source-sheet{border-radius:22px 22px 0 0;padding:18px 16px 24px}.photo-library-overlay{padding:0}.photo-library-panel{max-height:100vh;border-radius:0;padding:14px}.photo-library-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* ===== CAMERA OVERLAY ===== */
.camera-overlay { position: fixed; inset: 0; z-index: 1000; background: #000; display: none; flex-direction: column; }
.camera-overlay.active { display: flex; }
.camera-preview { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.camera-preview video { width: 100%; height: 100%; object-fit: cover; }
.camera-preview canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; }
.camera-frame { position: absolute; inset: 80px 24px 140px; border: 2px solid rgba(255,255,255,0.35); border-radius: 20px; pointer-events: none; }
.camera-frame::before, .camera-frame::after { content: ''; position: absolute; width: 28px; height: 28px; border-color: #ffffff; border-style: solid; }
.camera-frame::before { top: -2px; left: -2px; border-width: 4px 0 0 4px; border-radius: 16px 0 0 0; }
.camera-frame::after { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; border-radius: 0 0 16px 0; }
.camera-hud { position: absolute; top: 20px; left: 0; right: 0; display: flex; justify-content: space-between; padding: 0 24px; color: white; font-size: 0.82rem; font-weight: 700; text-shadow: 0 1px 4px rgba(0,0,0,0.5); pointer-events: none; }
.camera-hud .res-badge { background: rgba(0,0,0,0.45); padding: 5px 14px; border-radius: 20px; backdrop-filter: blur(8px); font-weight: 700; }
.camera-controls { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(transparent, rgba(0,0,0,0.85)); padding: 24px 32px 44px; display: flex; align-items: center; justify-content: center; gap: 44px; }
.btn-shutter { width: 76px; height: 76px; border-radius: 50%; border: 4px solid white; background: rgba(255,255,255,0.15); cursor: pointer; position: relative; transition: transform 0.1s; }
.btn-shutter::after { content: ''; position: absolute; inset: 5px; border-radius: 50%; background: white; transition: all 0.15s; }
.btn-shutter:active { transform: scale(0.9); }
.btn-shutter:active::after { background: #f3f4f6; }
.btn-cam-action { width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,0.12); border: none; color: white; font-size: 1.3rem; cursor: pointer; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px); transition: all 0.15s; }
.btn-cam-action:active { background: rgba(255,255,255,0.25); }

/* Review Overlay */
.review-overlay { position: fixed; inset: 0; z-index: 1001; background: #000; display: none; flex-direction: column; }
.review-overlay.active { display: flex; }
.review-img { flex: 1; object-fit: contain; background: #0a0a0a; }
.review-bar { background: var(--surface); padding: 18px 22px; display: flex; gap: 14px; border-top: 1px solid var(--border); }

/* Parts Table */
.parts-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.parts-table th { text-align: left; padding: 10px 8px; color: var(--text-muted); font-weight: 700; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--border); }
.parts-table td { padding: 8px; border-bottom: 1px solid var(--border-light); }
.parts-table input { width: 100%; padding: 10px 12px; border: 2px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; background: var(--surface); }
.parts-table input:focus { outline: none; border-color: var(--navy); }
.btn-add { width: 100%; padding: 14px; margin-top: 12px; border: 2px dashed var(--navy); border-radius: var(--radius); background: transparent; color: var(--navy); font-weight: 800; font-size: 0.88rem; cursor: pointer; transition: all 0.15s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-add:active { background: rgba(0,80,170,0.05); }
.btn-del { background: var(--red); color: white; border: none; border-radius: var(--radius-sm); width: 30px; height: 30px; cursor: pointer; font-size: 0.85rem; display: flex; align-items: center; justify-content: center; }

/* Signature */
.sig-wrap { position: relative; }
.sig-pad { width: 100%; height: 140px; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface-2); touch-action: none; cursor: crosshair; transition: all 0.2s; }
.sig-pad:focus { border-color: var(--navy); outline: none; }
.sig-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.9rem; pointer-events: none; opacity: 0.4; font-weight: 500; }
.sig-actions { display: flex; gap: 10px; margin-top: 10px; }
.sig-actions button { flex: 1; padding: 11px; border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 0.82rem; font-weight: 700; color: var(--text-secondary); cursor: pointer; transition: all 0.15s; }
.sig-actions button:active { background: var(--border-light); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 24px; border-radius: var(--radius-sm); font-size: 0.92rem; font-weight: 800; border: none; cursor: pointer; transition: all 0.15s; }
.btn-primary { background: var(--navy); color: white; box-shadow: 0 2px 8px rgba(0,80,170,0.25); }
.btn-primary:active { background: var(--navy-dark); transform: scale(0.97); }
.btn-yellow { background: #ffffff; color: #000000; border: 1px solid rgba(17,24,39,0.1); box-shadow: 0 4px 14px rgba(15,23,42,0.12); }
.btn-yellow:active { background: #f3f4f6; transform: scale(0.97); }
.btn-success { background: var(--green); color: white; }
.btn-success:active { transform: scale(0.97); }
.btn-outline { background: var(--surface); border: 2px solid var(--border); color: var(--text); }
.btn-outline:active { background: var(--border-light); }
.btn-danger { background: var(--red); color: white; }
.btn-sm { padding: 11px 18px; font-size: 0.85rem; }
.btn-full { width: 100%; }

/* Bottom Bar */
.bottom-bar { position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255,255,255,0.96); backdrop-filter: blur(20px); border-top: 1px solid var(--border); padding: 14px 16px; display: flex; gap: 10px; z-index: 100; box-shadow: 0 -4px 20px rgba(0,0,0,0.06); }
.bottom-bar .btn { flex: 1; }

/* Send failure recovery */
.send-failure-panel { position: fixed; left: 14px; right: 14px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 180; max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 12px; padding: 16px; border: 2px solid #b91c1c; border-radius: 18px; background: #fff1f2; color: #7f1d1d; box-shadow: 0 16px 38px rgba(127,29,29,.24); }
.send-failure-panel[hidden] { display: none; }
.send-failure-icon { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--red); color: #fff; font-size: 1.35rem; font-weight: 900; }
.send-failure-copy strong { display: block; font-size: 1rem; }
.send-failure-copy p { margin: 4px 0 5px; color: #7f1d1d; font-size: .88rem; line-height: 1.35; }
.send-failure-copy small { display: block; color: #991b1b; font-weight: 650; line-height: 1.35; }
.send-failure-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.send-failure-actions .btn { flex: 1 1 150px; padding: 11px 14px; font-size: .84rem; }
.send-failure-dismiss { flex: 0 0 auto; border: 0; background: transparent; color: #7f1d1d; padding: 10px 8px; font-weight: 800; cursor: pointer; }
@media (max-width: 480px) { .send-failure-panel { grid-template-columns: 36px minmax(0,1fr); padding: 13px; bottom: calc(88px + env(safe-area-inset-bottom)); } .send-failure-icon { width: 36px; height: 36px; } .send-failure-actions .btn { flex-basis: 100%; } .send-failure-dismiss { width: 100%; } }

/* Toast */
.toast { position: fixed; top: 76px; left: 50%; transform: translateX(-50%) translateY(-20px); background: var(--text); color: white; padding: 14px 28px; border-radius: var(--radius-lg); font-size: 0.92rem; font-weight: 700; opacity: 0; transition: all 0.35s cubic-bezier(0.4,0,0.2,1); z-index: 300; pointer-events: none; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.35); backdrop-filter: blur(6px); display: none; align-items: flex-end; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal-sheet { background: var(--surface); width: 100%; max-width: 640px; border-radius: 28px 28px 0 0; padding: 32px 24px 52px; animation: slideUpModal 0.35s ease; position: relative; }
.modal-close { position: absolute; top: 20px; right: 20px; width: 40px; height: 40px; border-radius: 50%; background: var(--bg); border: none; font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); transition: all 0.15s; }
.modal-close:active { background: var(--border); }
.modal-title { font-size: 1.2rem; font-weight: 800; margin-bottom: 24px; display: flex; align-items: center; gap: 10px; }

/* Animations */
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUpModal { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Print */
@media print {
  .app-header, .progress-bar, .bottom-bar, .send-failure-panel, .fab-camera, .camera-overlay, .review-overlay, .photo-source-overlay, .photo-library-overlay, .modal-overlay, .section-header, .btn, .sig-actions, .login-screen { display: none !important; }
  .section { border: 1px solid #ccc; box-shadow: none; page-break-inside: avoid; margin-bottom: 20px; }
  .section-body { display: block !important; padding: 20px; }
  body { background: white; }
  .container { max-width: 100%; padding: 0; }
  .sig-pad { border: 1px solid #ccc; height: 100px; }
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* ===== SERVER / PWA ADDITIONS ===== */
body { padding-bottom: env(safe-area-inset-bottom); }
.app-header { padding-top: calc(14px + env(safe-area-inset-top)); }
.progress-bar { top: calc(62px + env(safe-area-inset-top)); }
.container { padding-bottom: calc(168px + env(safe-area-inset-bottom)); }
.bottom-bar {
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(72px, .8fr) repeat(3, minmax(84px, 1fr));
}
.bottom-bar .btn { min-width: 0; padding-left: 12px; padding-right: 12px; }
.btn-send { background: var(--navy); color: #fff; box-shadow: 0 2px 8px rgba(0,80,170,0.25); }
.btn-send:active { background: var(--navy-dark); transform: scale(0.97); }
.btn[disabled], .login-btn[disabled] { opacity: .6; cursor: wait; transform: none !important; }
.install-card { background: var(--navy-light); border: 1px solid rgba(0,80,170,.18); border-radius: var(--radius); padding: 16px; }
.install-card p { color: var(--text-secondary); font-size: .86rem; margin: 8px 0 14px; }
.install-instructions { color: var(--text-secondary); line-height: 1.65; font-size: .92rem; }
.install-instructions strong { color: var(--text); }
.install-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.store-link { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 12px; border: 1px solid rgba(0,80,170,.28); border-radius: var(--radius-sm); background: #fff; color: var(--navy); font-size: .82rem; font-weight: 800; text-align: center; text-decoration: none; }
.store-link:active { transform: scale(.98); background: var(--navy-light); }
@media (max-width: 390px) { .install-links { grid-template-columns: 1fr; } }
.app-version { margin-top: 18px; text-align: center; color: var(--text-muted); font-size: .72rem; }
.config-alert { display: none; margin-top: 14px; padding: 12px; border-radius: var(--radius-sm); background: #fef2f2; color: #991b1b; font-size: .8rem; font-weight: 650; text-align: left; }
.config-alert.show { display: block; }
.submission-note { margin-top: 8px; font-size: .78rem; color: var(--text-muted); text-align: center; }
.native-badge { display: none; font-size: .66rem; font-weight: 800; padding: 4px 8px; border-radius: 12px; background: rgba(255,255,255,.16); color: white; }
body.is-native .native-badge { display: inline-flex; }
body.is-native #installBtn, body.is-native #settingsInstallBtn { display: none !important; }
.online-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px rgba(22,163,74,.2); }
.online-indicator.offline { background: var(--orange); box-shadow: 0 0 0 2px rgba(234,88,12,.2); }
@media (max-width: 520px) {
  .bottom-bar { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding-left: 8px; padding-right: 8px; }
  .bottom-bar .btn { flex-direction: column; gap: 3px; padding: 9px 4px; font-size: .69rem; line-height: 1.1; }
  .bottom-bar .btn svg { width: 17px; height: 17px; }
  .save-badge { display: none; }
  .header-right { gap: 6px; }
}
@media print {
  .config-alert, .submission-note, #installBtn, .native-badge, .online-indicator { display: none !important; }
}

body.is-native .admin-icon { display: none !important; }

/* ===== SERVICE FORM V1.2 ===== */
.section-head-right { display:flex; align-items:center; gap:10px; }
.job-control-buttons { display:grid; grid-template-columns:1fr; gap:10px; margin-bottom:10px; }
.job-control-buttons .btn { width:100%; }
.job-start-btn { margin-bottom: 0; }
.btn-break { background:#fff7ed; color:#9a3412; border:1px solid #fdba74; }
.btn-break:hover { background:#ffedd5; }
.job-time-summary { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--navy-light); color: var(--navy-dark); font-size: .82rem; font-weight: 700; text-align: center; }
.job-break-summary { margin:8px 0 18px; color:var(--text-muted); font-size:.75rem; font-weight:700; text-align:center; }
.time-entry { display:grid; grid-template-columns: minmax(82px,1fr) minmax(82px,1fr) auto; gap:8px; align-items:center; }
.btn-time { padding: 12px 10px; font-size: .75rem; white-space:nowrap; }
.conditional-input { background: #fff; }
.fixed-value-note { margin: -2px 0 18px; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-secondary); font-size: .84rem; }
.field-help { margin-top: 6px; color: var(--text-muted); font-size: .74rem; }
.admin-fixed-field { background: #f8fafc; color: #475569; }
.work-step-list { display: grid; gap: 10px; }
.work-step-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:12px; align-items:center; padding:12px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--surface-2); }
.work-step-label { font-size:.88rem; font-weight:700; line-height:1.35; }
.work-step-choice { display:flex; gap:6px; }
.work-step-choice button { min-width:48px; padding:8px 10px; border:2px solid var(--border); border-radius:9px; background:#fff; font-size:.76rem; font-weight:800; cursor:pointer; }
.work-step-choice button.active-yes { border-color:var(--green); background:#ecfdf5; color:#166534; }
.work-step-choice button.active-no { border-color:var(--red); background:#fef2f2; color:#991b1b; }
.empty-config { padding:14px; border:1px dashed var(--border); border-radius:var(--radius-sm); color:var(--text-muted); font-size:.82rem; text-align:center; }
.photo-section { margin-top: 18px; margin-bottom: 20px; }
.parts-field { margin-top: 20px; }
.parts-table-wrap { width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; border:1px solid var(--border-light); border-radius:var(--radius-sm); }
.parts-table { min-width: 610px; }
.parts-table th { color:#4b5563; background:#f8fafc; white-space:nowrap; }
.parts-table .qty-head, .parts-table td:nth-child(3) { width:76px; min-width:76px; text-align:center; }
.parts-table td:nth-child(4) { width:100px; min-width:100px; }
.parts-table td:nth-child(5) { width:48px; min-width:48px; }
.parts-table .part-qty { min-width:60px; text-align:center; }
.optional-switch { display:flex; align-items:center; gap:10px; padding:12px 14px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--surface-2); color:var(--text-secondary); font-size:.84rem; font-weight:750; cursor:pointer; margin-bottom:14px; }
.optional-switch input { position:absolute; width:1px; height:1px; opacity:0; pointer-events:none; }
.optional-switch > span { position:relative; display:flex; align-items:center; min-height:22px; padding-left:32px; flex:1 1 auto; }
.optional-switch > span::before { content:""; position:absolute; left:0; top:50%; width:22px; height:22px; border:2px solid #b7c2cf; border-radius:7px; background:#fff; transform:translateY(-50%); transition:border-color .18s ease,background .18s ease,transform .18s ease,box-shadow .18s ease; }
.optional-switch > span::after { content:""; position:absolute; left:7px; top:50%; width:6px; height:11px; border:solid #fff; border-width:0 3px 3px 0; transform:translateY(-66%) rotate(45deg) scale(0); transform-origin:center; opacity:0; }
.optional-switch input:focus-visible + span::before { outline:3px solid rgba(0,80,170,.22); outline-offset:2px; }
.optional-switch input:checked + span::before { border-color:var(--green); background:var(--green); box-shadow:0 0 0 4px rgba(22,163,74,.12); animation:switch-pop .28s ease both; }
.optional-switch input:checked + span::after { opacity:1; animation:tick-draw .32s cubic-bezier(.2,.85,.3,1.35) both; }
@keyframes switch-pop { 0%{transform:translateY(-50%) scale(.82)} 65%{transform:translateY(-50%) scale(1.12)} 100%{transform:translateY(-50%) scale(1)} }
@keyframes tick-draw { 0%{transform:translateY(-66%) rotate(45deg) scale(0);opacity:0} 60%{transform:translateY(-66%) rotate(45deg) scale(1.18);opacity:1} 100%{transform:translateY(-66%) rotate(45deg) scale(1);opacity:1} }
.optional-panel { padding-top:2px; }
.optional-badge { margin-left:4px; padding:3px 8px; border-radius:999px; background:#f1f5f9; color:#64748b; font-size:.62rem; font-weight:800; text-transform:uppercase; letter-spacing:.5px; }
.optional-section.disabled { opacity:.62; }
.optional-section.disabled .optional-fields { opacity:.35; pointer-events:none; filter:grayscale(.25); }
.optional-section.enabled { opacity:1; }
.recommendation-switch { opacity:1 !important; filter:none !important; pointer-events:auto !important; }
@media (max-width: 560px) {
  .time-entry { grid-template-columns:1fr 1fr; }
  .btn-time { grid-column:1/-1; }
  .work-step-row { grid-template-columns:1fr; }
  .work-step-choice button { flex:1; }
  .work-step-choice { width:100%; }
}

/* ===== SERVICE FORM V1.3 ===== */
.pill.checked { background: var(--green); color: #fff; border-color: var(--green); box-shadow: 0 2px 8px rgba(22,163,74,.2); }
.optional-switch:has(input:checked) { border-color: rgba(22,163,74,.5); background: #ecfdf5; color: #166534; box-shadow: 0 0 0 3px rgba(22,163,74,.07); }
.optional-switch:has(input:checked)::after { content: "✓ Active"; animation:active-badge-pop .3s ease both; margin-left:auto; padding:3px 8px; border-radius:999px; background:var(--green); color:#fff; font-size:.64rem; font-weight:900; letter-spacing:.04em; text-transform:uppercase; }
@keyframes active-badge-pop { 0%{opacity:0;transform:translateX(6px) scale(.8)} 100%{opacity:1;transform:translateX(0) scale(1)} }
.optional-fields[aria-disabled="true"], .optional-inline-fields.disabled { opacity:.34; pointer-events:none; filter:grayscale(.25); }
.optional-fields[aria-disabled="false"], .optional-inline-fields.enabled { opacity:1; pointer-events:auto; filter:none; }
.optional-inline-fields { transition:opacity .2s ease; }
.activation-switch { opacity:1 !important; filter:none !important; pointer-events:auto !important; }

.work-step-list { display:block; overflow:hidden; border:1px solid var(--border); border-radius:var(--radius-sm); background:#fff; }
.work-step-table { width:100%; border-collapse:collapse; table-layout:fixed; }
.work-step-table th { padding:8px 10px; background:#f8fafc; color:#64748b; font-size:.66rem; font-weight:850; letter-spacing:.05em; text-transform:uppercase; border-bottom:1px solid var(--border); }
.work-step-table th:first-child { text-align:left; }
.work-step-table th:nth-child(2), .work-step-table th:nth-child(3) { width:54px; text-align:center; }
.work-step-table .work-step-row { display:table-row; padding:0; border:0; background:#fff; }
.work-step-table td { padding:8px 10px; border-bottom:1px solid var(--border-light); vertical-align:middle; }
.work-step-table tr:last-child td { border-bottom:0; }
.work-step-table .work-step-label { font-size:.82rem; font-weight:700; line-height:1.25; }
.work-step-table td:nth-child(2), .work-step-table td:nth-child(3) { width:54px; text-align:center; }
.step-check { width:30px; height:30px; padding:0; border:2px solid #cbd5e1; border-radius:8px; background:#fff; color:transparent; font-size:1rem; font-weight:950; line-height:1; cursor:pointer; }
.step-check.active { border-color:var(--green); background:var(--green); color:#fff; box-shadow:0 2px 7px rgba(22,163,74,.22); }
.step-no.active { border-color:#b91c1c; background:#b91c1c; box-shadow:0 2px 7px rgba(185,28,28,.18); }

.star-rating { display:flex; align-items:center; flex-wrap:wrap; gap:3px; padding:10px 12px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--surface-2); }
.star-rating button { border:0; background:transparent; color:#cbd5e1; padding:1px 3px; font-size:1.8rem; line-height:1; cursor:pointer; transition:transform .12s,color .12s; }
.star-rating button:active { transform:scale(.9); }
.star-rating button.active { color:#f59e0b; text-shadow:0 1px 2px rgba(146,64,14,.2); }
.star-rating span { margin-left:8px; color:var(--text-secondary); font-size:.82rem; font-weight:800; }

.finish-job-card { margin-top:22px; padding:16px; border:1px solid rgba(22,163,74,.35); border-radius:var(--radius); background:#f0fdf4; display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:14px; }
.finish-job-card strong { display:block; color:#166534; font-size:.95rem; }
.finish-job-card span { display:block; margin-top:3px; color:#52705e; font-size:.75rem; }
.finish-job-controls { display:flex; align-items:center; gap:8px; }
.finish-job-controls input { width:112px; background:#fff; }
.finish-job-controls .btn { padding:12px 14px; white-space:nowrap; }

.manager-switch { margin-top:18px; }
#customerRepresentativeField, #engineerSignatureField, #customerSignatureField { transition:opacity .2s ease; }

@media (max-width:560px) {
  .work-step-table th:nth-child(2), .work-step-table th:nth-child(3), .work-step-table td:nth-child(2), .work-step-table td:nth-child(3) { width:47px; }
  .work-step-table td { padding:7px 8px; }
  .step-check { width:29px; height:29px; }
  .finish-job-card { grid-template-columns:1fr; }
  .finish-job-controls { display:grid; grid-template-columns:1fr 1fr; }
  .finish-job-controls input { width:100%; }
}


/* ===== JSON WORK ORDER V1.4 ===== */
.work-order-field { display:flex; align-items:stretch; width:100%; }
.work-order-prefix { display:flex; align-items:center; justify-content:center; min-width:76px; padding:0 14px; border:2px solid var(--navy); border-right:0; border-radius:var(--radius-sm) 0 0 var(--radius-sm); background:var(--navy); color:#fff; font-size:1rem; font-weight:900; letter-spacing:.04em; }
.work-order-field input { border-radius:0 var(--radius-sm) var(--radius-sm) 0; font-weight:850; letter-spacing:.08em; background:#f8fafc; color:#172033; }
.work-order-field input:read-only { cursor:default; }
.work-order-field.generating input { color:var(--text-muted); }
@media (max-width:420px) { .work-order-prefix { min-width:68px; padding:0 10px; } }


/* ===== PHOTO EXPANSION + SIGN-OFF V1.5 ===== */
.photo-more-btn { margin-top:12px; border-style:solid; background:#fff; }
.photo-more-btn[hidden] { display:none !important; }
.photo-more-btn:disabled { opacity:.5; cursor:default; }

/* v1.6 standards/testing templates */
.standards-table .standard-choice { width:36px; height:32px; border:2px solid var(--border); border-radius:9px; background:#fff; font-size:.72rem; font-weight:850; cursor:pointer; }
.standards-table .standard-choice.active-yes { border-color:var(--green); background:#ecfdf5; color:#166534; box-shadow:0 0 0 3px rgba(22,163,74,.08); }
.standards-table .standard-choice.active-no { border-color:var(--red); background:#fef2f2; color:#991b1b; }
.template-btn { margin-top:9px; padding:8px 12px; border:1px solid #b9cbe0; border-radius:9px; background:#eef6ff; color:#0050aa; font-size:.76rem; font-weight:800; cursor:pointer; }

/* ===== PHOTO LIBRARY SEARCH / STORAGE FORMAT ===== */
.photo-library-filters{display:grid;grid-template-columns:minmax(190px,1.4fr) minmax(150px,.8fr) auto auto;gap:8px;margin-bottom:12px}
.photo-library-filters input{min-width:0;border:1.5px solid var(--border);border-radius:10px;padding:10px 11px;background:#fff;color:var(--text)}
.photo-library-filters input:focus{outline:3px solid rgba(0,80,170,.12);border-color:var(--blue)}
.readonly-setting{display:grid;gap:3px;border:1px solid var(--border);border-radius:12px;padding:12px;background:var(--surface-2)}
.readonly-setting strong{font-size:.92rem;color:var(--text)}
.readonly-setting span{font-size:.75rem;color:var(--text-muted);line-height:1.4}
@media(max-width:650px){.photo-library-filters{grid-template-columns:1fr 1fr}.photo-library-filters .btn{width:100%}}


/* React front performance/status enhancement (v1.10.0) */
.front-react-root{min-height:0;background:#f8fafc;border-bottom:1px solid #dbe4ef}
.front-performance-strip{display:flex;align-items:center;justify-content:space-between;gap:10px;max-width:1120px;margin:0 auto;padding:7px 16px;font-size:.72rem;color:#475569}
.front-performance-left{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.front-cache-chip{display:inline-flex;align-items:center;min-height:24px;padding:3px 8px;border:1px solid #d6e0ec;border-radius:999px;background:#fff;font-weight:700;line-height:1.2;white-space:nowrap}
.front-cache-chip.react{border-color:#8ed8ef;background:#ecfbff;color:#075985}
.front-cache-chip.online{border-color:#9ad8b2;background:#effcf4;color:#166534}
.front-cache-chip.offline{border-color:#f2b4b4;background:#fff1f2;color:#991b1b}
.front-cache-chip.warning{border-color:#f2d27d;background:#fffbeb;color:#92400e}
.front-cache-chip.working{border-color:#b8c8f8;background:#eef2ff;color:#3730a3}
.front-performance-note{white-space:nowrap;color:#64748b}
@media(max-width:760px){.front-performance-strip{padding:6px 10px}.front-performance-note{display:none}.front-cache-chip{font-size:.66rem;padding:3px 7px}.front-performance-left{gap:4px}}

/* v1.12.0 repeatable equipment units */
.equipment-card { border: 1.5px solid #d8e1ec; border-radius: var(--radius); padding: 16px; margin-bottom: 14px; background: #fbfdff; }
.equipment-card-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:14px; color:var(--navy); }
.equipment-card-head strong { font-size:.95rem; }
.equipment-remove { border:0; background:#fff0f0; color:#b42318; border-radius:9px; padding:8px 11px; font-weight:800; cursor:pointer; }
.equipment-remove:active { transform:scale(.98); }


/* ===== REQUIRED WORKFLOW / ENGINEER IDENTITY V1.13 ===== */
.workflow-gate-message { margin-top:10px; padding:10px 12px; border:1px solid #fdba74; border-radius:var(--radius-sm); background:#fff7ed; color:#9a3412; font-size:.78rem; font-weight:800; }
.workflow-gate-message.complete { border-color:#86efac; background:#ecfdf5; color:#166534; }
.section.workflow-locked { opacity:1; }
.section.workflow-locked .section-body { opacity:.42; pointer-events:none; filter:grayscale(.2); }
.section.workflow-locked .section-header { cursor:not-allowed; opacity:.78; }
.section.workflow-locked.optional-section.disabled .optional-fields,
.section.workflow-locked .optional-fields[aria-disabled="true"] { opacity:1; filter:none; }
.section.workflow-locked .recommendation-switch,
.section.workflow-locked .activation-switch { pointer-events:none !important; }
.fab-camera:disabled, .fab-camera.workflow-locked { opacity:.35; cursor:not-allowed; transform:none; }
.engineer-identity-note { margin-top:7px; color:var(--green); font-size:.76rem; font-weight:800; }
#engineerSelect.engineer-locked { background:#f0fdf4; border-color:#86efac; color:#166534; font-weight:800; }
