:root {
  --green: #1D9E75;
  --green-light: #E1F5EE;
  --green-dark: #0F6E56;
  --purple: #534AB7;
  --purple-light: #EEEDFE;
  --amber: #BA7517;
  --amber-light: #FAEEDA;
  --blue: #185FA5;
  --blue-light: #E6F1FB;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --text-hint: #9b9b9b;
  --border: rgba(0,0,0,0.08);
  --border-med: rgba(0,0,0,0.13);
  --surface: #ffffff;
  --bg: #f7f6f3;
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* Header */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 32px; height: 32px;
  background: var(--text);
  color: #fff;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
}
.logo-text { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.header-right { display: flex; align-items: center; gap: 10px; }

.mode-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.mode-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 12px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.mode-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.icon-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  border: 1px solid var(--border-med);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s;
  white-space: nowrap;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn.primary {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.icon-btn.primary:hover { opacity: 0.85; }

/* Progress bar */
.progress-track { height: 3px; background: var(--border); }
.progress-fill {
  height: 100%;
  background: var(--green);
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
  width: 0%;
}

/* App */
#app { max-width: 900px; margin: 0 auto; padding: 28px 20px 60px; }

/* Loading */
.loading-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px; padding: 80px 20px;
  color: var(--text-muted); font-size: 14px;
}
.spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Staff Dashboard ── */
.dashboard-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.dashboard-title {
  font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
}
.dashboard-sub { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.client-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.cc-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.cc-avatar {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--green-light);
  color: var(--green-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px; flex-shrink: 0;
}
.cc-pct { font-size: 20px; font-weight: 600; color: var(--text); }
.cc-name { font-size: 15px; font-weight: 600; margin-bottom: 2px; letter-spacing: -0.01em; }
.cc-am { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.cc-bar { height: 4px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-bottom: 10px; }
.cc-bar-fill { height: 100%; background: var(--green); border-radius: 4px; transition: width 0.3s; }
.cc-sections { display: flex; flex-wrap: wrap; gap: 5px; }
.cc-sect-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 500;
}
.cc-date { font-size: 11px; color: var(--text-hint); margin-top: 10px; }

.empty-state {
  text-align: center; padding: 80px 20px;
  color: var(--text-muted);
}
.empty-icon {
  font-size: 40px; margin-bottom: 16px;
}
.empty-state h3 { font-size: 17px; font-weight: 500; margin-bottom: 6px; }
.empty-state p { font-size: 14px; color: var(--text-hint); }

/* ── Checklist View ── */
.checklist-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 6px; flex-wrap: wrap;
}
.back-btn {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--text-muted);
  background: none; border: none; cursor: pointer;
  padding: 4px 0; font-family: 'DM Sans', sans-serif;
}
.back-btn:hover { color: var(--text); }

.info-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.info-inner {
  max-width: 900px; margin: 0 auto;
  padding: 12px 20px;
  display: flex; gap: 28px; flex-wrap: wrap; align-items: center;
}
.info-field { display: flex; flex-direction: column; gap: 1px; }
.info-label {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-hint); font-weight: 500;
}
.info-val { font-size: 14px; font-weight: 500; color: var(--text); }
.info-input {
  font-size: 14px; font-weight: 500; font-family: 'DM Sans', sans-serif;
  color: var(--text); background: transparent; border: none;
  border-bottom: 1.5px solid var(--green); outline: none;
  padding: 1px 0; width: 160px;
}

.sections { display: flex; flex-direction: column; gap: 10px; }

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: fadeIn 0.2s ease both;
}
@keyframes fadeIn { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }
.section:nth-child(1) { animation-delay: 0.04s; }
.section:nth-child(2) { animation-delay: 0.08s; }
.section:nth-child(3) { animation-delay: 0.12s; }
.section:nth-child(4) { animation-delay: 0.16s; }

.sec-header {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px; cursor: pointer; user-select: none; transition: background 0.1s;
}
.sec-header:hover { background: #fafaf9; }
.sec-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 18px;
}
.sec-titles { flex: 1; min-width: 0; }
.sec-title { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.sec-sub { font-size: 12px; color: var(--text-hint); margin-top: 1px; }
.sec-badges { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.badge { font-size: 12px; padding: 3px 10px; border-radius: 20px; font-weight: 500; white-space: nowrap; }
.badge-done { background: #E1F5EE; color: #0F6E56; }
.badge-partial { background: #FAEEDA; color: #854F0B; }
.badge-todo { background: var(--bg); color: var(--text-muted); }
.badge-staff { background: var(--purple-light); color: var(--purple); font-size: 11px; }
.chevron { color: var(--text-hint); transition: transform 0.2s; flex-shrink: 0; }
.chevron.open { transform: rotate(180deg); }

.sec-body { display: none; border-top: 1px solid var(--border); }
.sec-body.open { display: block; }
.items-list { padding: 4px 18px 8px; }
.item {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.item:last-child { border-bottom: none; }
.item input[type="checkbox"] {
  width: 17px; height: 17px; flex-shrink: 0;
  margin-top: 2px; accent-color: var(--green); cursor: pointer;
}
.item-label { cursor: pointer; flex: 1; }
.item-text { font-size: 14px; color: var(--text); line-height: 1.5; transition: color 0.15s; }
.item-note { font-size: 12px; color: var(--text-hint); margin-top: 2px; }
.item.checked .item-text { color: var(--text-hint); text-decoration: line-through; }

.staff-panel {
  margin: 0 18px 14px;
  background: #f8f7ff;
  border: 1px solid rgba(83,74,183,0.15);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.staff-panel-label {
  font-size: 11px; font-weight: 600; color: var(--purple);
  text-transform: uppercase; letter-spacing: 0.07em;
  display: flex; align-items: center; gap: 5px; margin-bottom: 10px;
}
.staff-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 10px;
}
@media (max-width: 560px) { .staff-fields { grid-template-columns: 1fr; } }
.sf { display: flex; flex-direction: column; gap: 4px; }
.sf-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.sf select, .sf textarea {
  font-family: 'DM Sans', sans-serif; font-size: 13px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-med); border-radius: 7px;
  padding: 6px 9px; outline: none; transition: border-color 0.15s; resize: vertical;
}
.sf select:focus, .sf textarea:focus { border-color: var(--purple); }
.sf textarea { min-height: 58px; }

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 1000; display: flex; align-items: center;
  justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 36px 32px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-logo {
  width: 48px; height: 48px; background: var(--text); color: #fff;
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-family: 'DM Serif Display', serif; font-size: 26px; margin-bottom: 4px;
}
.link-icon {
  width: 48px; height: 48px; background: var(--green-light);
  color: var(--green-dark); border-radius: 12px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 4px;
}
.modal-title { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.modal-sub { font-size: 14px; color: var(--text-muted); text-align: center; margin-bottom: 6px; }
.pin-input {
  width: 100%; padding: 12px 16px; font-size: 22px;
  font-family: 'DM Sans', sans-serif; letter-spacing: 0.2em;
  text-align: center; border: 1.5px solid var(--border-med);
  border-radius: var(--radius); outline: none; transition: border-color 0.15s;
}
.pin-input:focus { border-color: var(--purple); }
.pin-error { font-size: 13px; color: #c0392b; text-align: center; }
.form-field { width: 100%; display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.form-input {
  width: 100%; padding: 10px 12px; font-size: 14px;
  font-family: 'DM Sans', sans-serif; color: var(--text);
  border: 1.5px solid var(--border-med); border-radius: var(--radius);
  outline: none; transition: border-color 0.15s; background: var(--bg);
}
.form-input:focus { border-color: var(--green); background: var(--surface); }
.link-box {
  width: 100%; background: var(--bg); border: 1px solid var(--border-med);
  border-radius: var(--radius); padding: 10px 12px;
  font-size: 12px; color: var(--text-muted); word-break: break-all;
  font-family: monospace; line-height: 1.5;
}
.btn-primary {
  width: 100%; padding: 11px; background: var(--text); color: #fff;
  border: none; border-radius: var(--radius); font-family: 'DM Sans', sans-serif;
  font-size: 14px; font-weight: 500; cursor: pointer; transition: opacity 0.15s; margin-top: 4px;
}
.btn-primary:hover { opacity: 0.85; }
.btn-ghost {
  background: none; border: none; font-family: 'DM Sans', sans-serif;
  font-size: 13px; color: var(--text-muted); cursor: pointer; padding: 4px;
}
.btn-ghost:hover { color: var(--text); }

/* Toast */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--text); color: #fff; font-size: 14px;
  font-family: 'DM Sans', sans-serif; padding: 10px 20px;
  border-radius: 20px; opacity: 0; transition: opacity 0.2s, transform 0.2s;
  pointer-events: none; z-index: 999; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer {
  text-align: center; padding: 20px; font-size: 12px;
  color: var(--text-hint); border-top: 1px solid var(--border);
}

.sync-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  display: inline-block; margin-right: 5px;
  animation: pulse 2s ease infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
