/* ============================================================
   HOUSEKEEPING INSPECTION SYSTEM
   Design language: field-ops / industrial inspection tool.
   Palette: deep slate + safety amber accent + clear OK/Not-OK colors.
   ============================================================ */

:root {
  --ink:        #1c2230;
  --slate:      #2d3748;
  --slate-soft: #4a5568;
  --paper:      #f6f5f1;
  --card:       #ffffff;
  --line:       #e2e0d8;
  --amber:      #d97b29;
  --amber-dark: #b8631d;
  --ok:         #2f8f5b;
  --ok-bg:      #e7f5ec;
  --notok:      #c2402c;
  --notok-bg:   #fbeae7;
  --na-bg:      #ececec;
  --na:         #6b7280;
  --shadow:     0 1px 3px rgba(28,34,48,0.08), 0 1px 2px rgba(28,34,48,0.06);
  --shadow-lg:  0 8px 24px rgba(28,34,48,0.14);
  --radius:     10px;
  --mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
}
body { padding-bottom: 90px; }

a { color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--ink);
  color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; }
.topbar .brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--amber);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: var(--ink);
  flex-shrink: 0;
}
.topbar h1 { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: 0.2px; }
.topbar .sub { font-size: 11px; color: #aab2c0; margin: 0; }
.topbar nav { display: flex; gap: 6px; }
.topbar nav a, .topbar nav button {
  background: rgba(255,255,255,0.08);
  border: none; color: #fff; font-size: 12.5px; font-weight: 600;
  padding: 8px 12px; border-radius: 7px; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.topbar nav a.active, .topbar nav button.active { background: var(--amber); color: var(--ink); }

.wrap { max-width: 880px; margin: 0 auto; padding: 18px 14px 40px; }

/* ---------- Cards / sections ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--slate-soft); margin: 0 0 14px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.card h2 .num {
  background: var(--ink); color: var(--amber); font-family: var(--mono);
  font-size: 11px; width: 20px; height: 20px; border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- Form fields ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--slate);
  margin-bottom: 6px;
}
.field .req { color: var(--notok); }
input[type=text], input[type=tel], input[type=date], input[type=time], select, textarea {
  width: 100%; padding: 11px 12px; font-size: 15px; font-family: var(--sans);
  border: 1.5px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(217,123,41,0.15);
}
input[readonly] { background: #f3f2ee; color: var(--slate-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.shift-toggle { display: flex; gap: 8px; }
.shift-toggle label {
  flex: 1; text-align: center; padding: 12px 6px; border: 1.5px solid var(--line);
  border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 600;
  color: var(--slate-soft); transition: all .15s; user-select: none;
}
.shift-toggle input { display: none; }
.shift-toggle input:checked + span {}
.shift-toggle label.checked { border-color: var(--amber); background: #fdf2e7; color: var(--amber-dark); }
.shift-toggle .ico { display: block; font-size: 17px; margin-bottom: 3px; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; overflow-x: auto; gap: 6px; padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.tabs::-webkit-scrollbar { height: 4px; }
.tabs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.tab-btn {
  flex-shrink: 0; padding: 9px 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: #fff; color: var(--slate-soft); font-size: 12.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap; position: relative;
}
.tab-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab-btn .count {
  display: inline-block; margin-left: 6px; font-family: var(--mono); font-size: 10.5px;
  opacity: 0.7;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Task row ---------- */
.task {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; background: #fff;
}
.task.is-complete { border-color: #cfe6da; background: #fbfdfc; }
.task-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.task-title { font-size: 14.5px; font-weight: 700; color: var(--ink); margin: 0; }
.task-meta { font-size: 11.5px; color: var(--slate-soft); margin: 2px 0 0; }
.task-sr {
  flex-shrink: 0; font-family: var(--mono); font-size: 11px; color: #fff;
  background: var(--slate); border-radius: 5px; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
}

.status-row { display: flex; gap: 8px; margin-bottom: 10px; }
.status-btn {
  flex: 1; padding: 9px 4px; border-radius: 8px; border: 1.5px solid var(--line);
  background: #fff; font-size: 12.5px; font-weight: 700; cursor: pointer;
  color: var(--slate-soft); text-align: center;
}
.status-btn[data-status="OK"].active { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.status-btn[data-status="Not OK"].active { background: var(--notok-bg); border-color: var(--notok); color: var(--notok); }
.status-btn[data-status="NA"].active { background: var(--na-bg); border-color: var(--na); color: var(--na); }

.task textarea { min-height: 38px; font-size: 13.5px; resize: vertical; }

.photo-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.photo-slot { text-align: center; }
.photo-slot .lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--slate-soft); margin-bottom: 6px; display: block; }
.photo-box {
  position: relative; border: 1.5px dashed var(--line); border-radius: 8px;
  height: 110px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; background: #fafaf8; cursor: pointer;
}
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-box .placeholder { color: #b8b4a8; font-size: 11px; text-align: center; padding: 4px; }
.photo-box .placeholder .ico { font-size: 22px; display: block; margin-bottom: 3px; }
.photo-box .stamp-badge {
  position: absolute; bottom: 3px; left: 3px; right: 3px;
  background: rgba(28,34,48,0.78); color: #fff; font-family: var(--mono);
  font-size: 8.5px; padding: 2px 4px; border-radius: 4px; text-align: center;
}
.photo-box .retake {
  position: absolute; top: 4px; right: 4px; background: rgba(28,34,48,0.7);
  color: #fff; border: none; border-radius: 5px; font-size: 10px; padding: 3px 6px;
  cursor: pointer;
}
.photo-actions { display: flex; gap: 6px; margin-top: 6px; }
.photo-actions button {
  flex: 1; font-size: 10.5px; padding: 6px 4px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--slate-soft); font-weight: 600; cursor: pointer;
}
input[type=file].hidden-input { display: none; }

/* ---------- Bottom submit bar ---------- */
.submit-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: #fff; border-top: 1px solid var(--line);
  padding: 10px 14px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}
.progress-mini { flex: 1; }
.progress-mini .bar { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress-mini .fill { height: 100%; background: var(--amber); transition: width .25s; }
.progress-mini .txt { font-size: 11px; color: var(--slate-soft); margin-top: 4px; font-family: var(--mono); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 20px; border-radius: 9px; border: none; font-size: 14.5px; font-weight: 700;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--amber); color: #fff; }
.btn-primary:hover { background: var(--amber-dark); }
.btn-primary:disabled { background: #d8cbb8; cursor: not-allowed; }
.btn-ghost { background: var(--ink); color: #fff; }
.btn-sm { padding: 8px 12px; font-size: 12.5px; }

/* ---------- Toast / overlay ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(28,34,48,0.55); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.overlay.show { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 26px 22px; max-width: 360px; text-align: center; box-shadow: var(--shadow-lg); }
.modal .ico { font-size: 40px; margin-bottom: 10px; }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0 0 18px; font-size: 13.5px; color: var(--slate-soft); }

.camera-overlay {
  position: fixed; inset: 0; background: #000; z-index: 200; display: none;
  flex-direction: column;
}
.camera-overlay.show { display: flex; }
.camera-overlay video { flex: 1; width: 100%; object-fit: cover; background: #000; }
.camera-overlay canvas { display: none; }
.cam-controls {
  background: #000; padding: 16px; display: flex; align-items: center; justify-content: center;
  gap: 30px;
}
.cam-controls button {
  background: none; border: none; color: #fff; cursor: pointer;
}
.cam-shutter {
  width: 64px; height: 64px; border-radius: 50%; border: 4px solid #fff !important;
  background: rgba(255,255,255,0.15) !important;
}
.cam-close, .cam-switch { font-size: 22px; }

.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; z-index: 300; box-shadow: var(--shadow-lg); display: none;
}
.toast.show { display: block; }
.toast.error { background: var(--notok); }
.toast.success { background: var(--ok); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--slate-soft); }
.empty-state .ico { font-size: 42px; margin-bottom: 10px; }

.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
