/* ─── RESET & BASE ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:        #1D9E75;
  --green-dark:   #0F6E56;
  --green-light:  #E1F5EE;
  --green-mid:    #9FE1CB;
  --amber:        #BA7517;
  --amber-light:  #FAEEDA;
  --red:          #A32D2D;
  --red-light:    #FCEBEB;
  --blue:         #185FA5;
  --blue-light:   #E6F1FB;
  --gray:         #5F5E5A;
  --gray-light:   #F1EFE8;
  --gray-border:  rgba(0,0,0,0.12);
  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 1px 3px rgba(0,0,0,0.08);
  --font:         'DM Sans', system-ui, sans-serif;
  --font-mono:    'DM Mono', monospace;
  --bg:           #F7F6F1;
  --surface:      #FFFFFF;
  --text:         #1a1a18;
  --text-muted:   #6b6b66;
  --text-hint:    #999992;
}

html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; padding-bottom: 100px; }

/* ─── HEADER ─────────────────────────────────────────────────── */
.site-header { background: var(--green-dark); color: #fff; padding: 0; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.header-inner { max-width: 860px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.header-brand { display: flex; align-items: center; gap: 10px; flex: 1; }
.brand-mark { width: 38px; height: 38px; background: rgba(255,255,255,0.2); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; letter-spacing: 0.5px; flex-shrink: 0; }
.header-brand h1 { font-size: 18px; font-weight: 600; line-height: 1.2; }
.header-sub { font-size: 12px; opacity: 0.75; font-weight: 400; }
.header-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.date-display { font-size: 12px; opacity: 0.85; font-family: var(--font-mono); white-space: nowrap; }
.shift-selector select, .cleaner-id input {
  font-family: var(--font); font-size: 12px; padding: 5px 10px; border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.15); color: #fff; outline: none;
}
.shift-selector select option { background: var(--green-dark); }
.cleaner-id input::placeholder { color: rgba(255,255,255,0.6); }
.cleaner-id input { width: 130px; }

/* ─── STATS ──────────────────────────────────────────────────── */
.stats-bar { max-width: 860px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; background: var(--surface); border-bottom: 1px solid var(--gray-border); }
.stat-item { padding: 10px 8px; text-align: center; border-right: 1px solid var(--gray-border); }
.stat-item:last-child { border-right: none; }
.stat-item.stat-highlight .stat-val { color: var(--green-dark); }
.stat-val { display: block; font-size: 22px; font-weight: 600; line-height: 1.1; color: var(--text); }
.stat-lbl { display: block; font-size: 10px; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; }

.progress-track { height: 4px; background: #E8E6E0; }
.progress-fill { height: 100%; background: var(--green); transition: width 0.5s ease; width: 0%; }

/* ─── FILTER BAR ─────────────────────────────────────────────── */
.filter-bar { background: var(--surface); border-bottom: 1px solid var(--gray-border); position: sticky; top: 63px; z-index: 90; }
.filter-scroll { max-width: 860px; margin: 0 auto; padding: 8px 12px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.filter-scroll::-webkit-scrollbar { display: none; }
.filter-btn { font-family: var(--font); font-size: 12px; font-weight: 500; padding: 5px 14px; border-radius: 20px; border: 1px solid var(--gray-border); background: transparent; color: var(--text-muted); cursor: pointer; white-space: nowrap; transition: all 0.15s; }
.filter-btn:hover { background: var(--gray-light); color: var(--text); }
.filter-btn.active { background: var(--green-dark); color: #fff; border-color: var(--green-dark); }

/* ─── MAIN CONTENT ───────────────────────────────────────────── */
.main-content { max-width: 860px; margin: 0 auto; padding: 16px 12px; }

.section-header { display: flex; align-items: center; gap: 8px; padding: 8px 4px 4px; margin-top: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--gray-border); }
.section-header:first-child { margin-top: 0; }
.sec-name { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); flex: 1; }
.sec-pill { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 10px; background: var(--gray-light); color: var(--text-muted); }
.sec-pill-green { background: var(--green-light); color: var(--green-dark); }

/* ─── TASK CARD ──────────────────────────────────────────────── */
.task-card { background: var(--surface); border: 1px solid var(--gray-border); border-radius: var(--radius); margin-bottom: 6px; overflow: hidden; transition: border-color 0.2s, opacity 0.2s; }
.task-card.done { opacity: 0.65; }
.task-card.done.verified { opacity: 1; border-color: var(--green); border-left: 3px solid var(--green); }

.task-row { display: flex; align-items: center; gap: 10px; padding: 11px 12px; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.task-row:hover { background: #FAFAF7; }
.task-row:active { background: var(--gray-light); }

.check-box { width: 20px; height: 20px; border: 2px solid #C8C7C0; border-radius: 5px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.15s; }
.check-box.checked { background: var(--green); border-color: var(--green); }
.chk { width: 11px; height: 11px; opacity: 0; transition: opacity 0.1s; }
.check-box.checked .chk { opacity: 1; }

.task-body { flex: 1; min-width: 0; }
.task-text { display: block; font-size: 14px; line-height: 1.45; color: var(--text); }
.task-card.done .task-text { text-decoration: line-through; color: var(--text-muted); }
.task-card.done.verified .task-text { color: var(--text-muted); }

.task-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; align-items: center; }

.freq-badge { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 8px; text-transform: uppercase; letter-spacing: 0.03em; }
.freq-daily  { background: var(--green-light);  color: var(--green-dark); }
.freq-mwf    { background: var(--blue-light);   color: var(--blue); }
.freq-weekly { background: var(--amber-light);  color: var(--amber); }
.freq-other  { background: var(--gray-light);   color: var(--gray); }

.pri-badge { font-size: 10px; padding: 2px 7px; border-radius: 8px; text-transform: uppercase; letter-spacing: 0.03em; }
.pri-critical { background: #FCEBEB; color: var(--red); font-weight: 700; }
.pri-high     { background: #FFF0E0; color: #8B4000; }
.pri-medium   { background: var(--amber-light); color: var(--amber); }
.pri-low      { background: var(--gray-light);  color: var(--gray); }

.verified-tag { font-size: 10px; padding: 2px 7px; border-radius: 8px; background: var(--green-light); color: var(--green-dark); font-weight: 600; }
.check-time   { font-size: 10px; color: var(--text-hint); font-family: var(--font-mono); }
.geo-tag      { font-size: 10px; color: var(--text-hint); font-family: var(--font-mono); }

.task-actions { display: flex; gap: 2px; flex-shrink: 0; }
.icon-act { font-size: 16px; padding: 4px 6px; border: none; background: none; cursor: pointer; border-radius: 6px; line-height: 1; color: var(--text-muted); transition: background 0.12s; }
.icon-act:hover { background: var(--gray-light); }

/* ─── EXTRAS (notes + photos) ────────────────────────────────── */
.extras { display: none; border-top: 1px solid var(--gray-border); }
.extras.open { display: block; }

.note-wrap { padding: 8px 12px; border-bottom: 1px solid var(--gray-border); }
.note-input { width: 100%; font-family: var(--font); font-size: 13px; color: var(--text); background: transparent; border: none; outline: none; resize: vertical; min-height: 38px; line-height: 1.5; }
.note-input::placeholder { color: var(--text-hint); }

.photo-wrap { padding: 10px 12px; }
.photo-ctrl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-btn { font-family: var(--font); font-size: 12px; font-weight: 500; padding: 6px 14px; border: 1px solid var(--gray-border); border-radius: var(--radius-sm); background: var(--gray-light); color: var(--text); cursor: pointer; transition: all 0.12s; display: inline-flex; align-items: center; gap: 5px; }
.upload-btn:hover { background: var(--surface); border-color: var(--green); color: var(--green-dark); }
.photo-hint { font-size: 12px; color: var(--text-hint); }

.photos-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-thumb { position: relative; width: 78px; height: 78px; border-radius: 8px; overflow: hidden; border: 1px solid var(--gray-border); flex-shrink: 0; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; display: block; transition: opacity 0.15s; }
.photo-thumb img:hover { opacity: 0.85; }
.del-photo { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; background: rgba(0,0,0,0.6); border: none; border-radius: 50%; color: #fff; font-size: 9px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; }
.photo-timestamps { font-size: 10px; color: var(--text-hint); font-family: var(--font-mono); margin-top: 6px; line-height: 1.6; }

/* ─── LIGHTBOX ───────────────────────────────────────────────── */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.88); z-index: 9999; display: none; align-items: center; justify-content: center; padding: 16px; }
.lightbox.open { display: flex; }
.lb-close { position: absolute; top: 16px; right: 20px; background: none; border: none; color: #fff; font-size: 26px; cursor: pointer; z-index: 1; }
.lb-content { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 90vw; }
.lb-content img { max-width: 100%; max-height: 75vh; border-radius: 8px; object-fit: contain; }
.lb-meta { color: #fff; font-size: 13px; text-align: center; }
.lb-geo  { color: rgba(255,255,255,0.65); font-size: 11px; font-family: var(--font-mono); text-align: center; }

/* ─── ACTION BAR ─────────────────────────────────────────────── */
.action-bar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--gray-border); padding: 10px 12px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; z-index: 200; box-shadow: 0 -2px 12px rgba(0,0,0,0.08); }
.act-btn { font-family: var(--font); font-size: 13px; font-weight: 500; padding: 9px 18px; border-radius: var(--radius-sm); border: 1px solid var(--gray-border); background: var(--surface); color: var(--text); cursor: pointer; transition: all 0.15s; }
.act-btn:hover { background: var(--gray-light); }
.act-btn.act-primary { background: var(--green-dark); color: #fff; border-color: var(--green-dark); }
.act-btn.act-primary:hover { background: var(--green); }

/* ─── MODAL ──────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9000; display: flex; align-items: flex-end; justify-content: center; padding: 0; }
@media (min-width: 600px) { .modal-overlay { align-items: center; padding: 20px; } }
.modal { background: var(--surface); border-radius: 16px 16px 0 0; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; box-shadow: 0 -4px 32px rgba(0,0,0,0.2); }
@media (min-width: 600px) { .modal { border-radius: 16px; } }
.modal-title { font-size: 17px; font-weight: 600; padding: 20px 20px 0; }
.modal-body { padding: 16px 20px; }
.modal-footer { padding: 12px 20px 20px; display: flex; gap: 8px; justify-content: flex-end; }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.sum-item { background: var(--gray-light); border-radius: 8px; padding: 10px 8px; text-align: center; }
.sum-val { display: block; font-size: 20px; font-weight: 600; color: var(--green-dark); }
.sum-lbl { display: block; font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.pending-list { font-size: 13px; background: var(--red-light); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; color: var(--red); }
.pending-list ul { padding-left: 16px; margin-top: 6px; }
.pending-list li { margin-bottom: 3px; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 6px; }
.form-hint { font-size: 11px; color: var(--text-hint); margin-top: 4px; }

.sig-canvas { display: block; width: 100%; height: 120px; border: 1px solid var(--gray-border); border-radius: 8px; background: #FAFAF7; cursor: crosshair; touch-action: none; }
.sig-clear { font-size: 12px; color: var(--text-muted); background: none; border: none; cursor: pointer; margin-top: 4px; text-decoration: underline; }

.pin-input { font-family: var(--font-mono); font-size: 20px; letter-spacing: 8px; padding: 8px 14px; border: 1px solid var(--gray-border); border-radius: 8px; width: 140px; outline: none; text-align: center; }
.pin-input:focus { border-color: var(--green); }

.final-notes { width: 100%; font-family: var(--font); font-size: 13px; padding: 8px 12px; border: 1px solid var(--gray-border); border-radius: 8px; resize: vertical; outline: none; line-height: 1.5; }
.final-notes:focus { border-color: var(--green); }

/* ─── TOAST ──────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1a1a18; color: #fff; font-size: 13px; font-weight: 500; padding: 10px 20px; border-radius: 20px; opacity: 0; transition: all 0.25s; pointer-events: none; white-space: nowrap; z-index: 9999; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── EMPTY STATE ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); font-size: 14px; }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 500px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .stat-item:nth-child(2) { border-right: none; }
  .header-meta { gap: 6px; }
  .cleaner-id input { width: 110px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

@media print {
  .action-bar, .filter-bar, .site-header { display: none; }
  body { padding-bottom: 0; }
  .task-card { break-inside: avoid; }
}
