* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0fafb;
  color: #454545;
  min-height: 100dvh;
}
.header {
  background: #014044;
  color: white;
  padding: 16px 20px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
}
.header small {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: #7fd3da;
  margin-top: 2px;
}
.container { max-width: 480px; margin: 0 auto; padding: 20px; }

/* Auth */
.auth-card {
  background: white;
  border-radius: 12px;
  padding: 32px 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-top: 40px;
}
.auth-card h2 { font-size: 22px; margin-bottom: 8px; color: #014044; }
.auth-card p { color: #6a7677; font-size: 14px; margin-bottom: 24px; }
.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #6a7677; }
.input-group input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid #e5e5e5;
  border-radius: 10px;
  font-size: 18px;
  outline: none;
  background: #fdfdfd;
  transition: border-color 0.2s;
}
.input-group input::placeholder { color: #c5cdce; }
.input-group input:focus { border-color: #19949e; }
.btn {
  width: 100%;
  padding: 14px;
  background: #19949e;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:hover:not(:disabled) { background: #147881; }
.error { color: #d44027; font-size: 13px; margin-top: 8px; }
.back-link { color: #19949e; font-size: 14px; cursor: pointer; margin-bottom: 16px; display: inline-block; }

/* Day groups */
.day-group { margin-bottom: 24px; }
.date-header {
  font-size: 16px;
  font-weight: 700;
  color: #014044;
  padding: 10px 22px;
  margin: 0 -22px 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  background: #f0fafb;
  z-index: 10;
}
.date-header.stuck {
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.date-header.today { color: #19949e; }

/* Appointment cards */
.appt-card {
  background: white;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border-left: 4px solid #19949e;
}
.appt-time {
  font-size: 18px;
  font-weight: 700;
  color: #014044;
  margin-bottom: 4px;
}
.appt-address { font-size: 15px; color: #6a7677; }
.appt-address a { color: #19949e; text-decoration: none; }
.appt-address a:hover { text-decoration: underline; }
.appt-meta { font-size: 13px; color: #9ba7a8; margin-top: 6px; }
.appt-meta .with-provider { color: #6a7677; }
.appt-field-notes {
  font-size: 13px;
  color: #6a7677;
  margin-top: 8px;
  padding: 8px 12px;
  background: #f0fafb;
  border-radius: 8px;
  font-style: italic;
}
.appt-members { margin-top: 8px; }
.member-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  padding: 4px 0;
}
.member-name { color: #454545; }
.member-phone { color: #19949e; text-decoration: none; font-size: 13px; }
.tap-hint { font-size: 12px; color: #9ba7a8; margin-top: 8px; text-align: right; }

/* Tasks */
.tasks-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e5e5;
}
.tasks-header {
  font-size: 13px;
  font-weight: 600;
  color: #6a7677;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.task-item {
  padding: 10px 0;
  border-bottom: 1px solid #f0fafb;
}
.task-item:last-child { border-bottom: none; }
.task-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.task-title {
  font-size: 15px;
  font-weight: 600;
  color: #014044;
  flex: 1;
}
.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.status-todo { background: #e5e5e5; color: #6a7677; }
.status-inprogress { background: #fef3c7; color: #92400e; }
.status-completed { background: #d1fae5; color: #065f46; }
.status-archived { background: #e5e5e5; color: #9ba7a8; }
.parts-badge { background: #dc2626; color: white; margin-right: 4px; }
.task-appt-date { font-size: 12px; color: #9ba7a8; margin-top: 2px; padding-left: 2px; }
.task-desc {
  font-size: 13px;
  color: #6a7677;
  margin-top: 6px;
  line-height: 1.4;
}
.detail-section-label {
  font-size: 13px;
  font-weight: 600;
  color: #6a7677;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 16px 0 8px;
}

/* Parts */
.parts-section { margin-top: 8px; }
.part-item {
  font-size: 13px;
  padding: 10px 12px;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 6px;
  border: 1px solid #e5e5e5;
}
.part-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.part-name { color: #014044; font-weight: 600; font-size: 14px; }
.part-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.part-status-researching { background: #e0e7ff; color: #3730a3; }
.part-status-ordered { background: #fef3c7; color: #92400e; }
.part-status-shipped { background: #dbeafe; color: #1e40af; }
.part-status-delivered { background: #d1fae5; color: #065f46; }
.part-status-installed { background: #d1fae5; color: #065f46; }
.part-status-default { background: #e5e5e5; color: #6a7677; }
.part-status-buy { background: #dc2626; color: white; }
.part-detail-row {
  font-size: 12px;
  color: #6a7677;
  margin-top: 3px;
}
.part-detail-row strong { color: #454545; font-weight: 500; }

/* Update logs */
.logs-section { margin-top: 10px; }
.log-item {
  font-size: 13px;
  padding: 8px 10px;
  background: #f9fafb;
  border-radius: 6px;
  margin-bottom: 6px;
}
.log-meta { color: #9ba7a8; font-size: 12px; margin-bottom: 4px; }
.log-notes { color: #454545; line-height: 1.4; }
.log-attachments, .task-attachments {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.att-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: #f0f0f0;
  border-radius: 8px;
  border: 1px solid #e5e5e5;
  overflow: hidden;
}
.att-wrap::after {
  content: '';
  position: absolute;
  top: calc(50% - 12px); left: calc(50% - 12px);
  width: 24px; height: 24px;
  border: 3px solid #d1d5db;
  border-top-color: #9ba7a8;
  border-radius: 50%;
  animation: att-spin 0.8s linear infinite;
}
.att-wrap.loaded::after { display: none; }
.att-wrap.loaded { background: none; }
@keyframes att-spin { to { transform: rotate(360deg); } }
.log-attachments img, .task-attachments img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.att-wrap.loaded img { opacity: 1; }
.log-attachments video, .task-attachments video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}
.att-play-icon {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.5);
  color: white;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  pointer-events: none;
}

/* Home todo link */
.home-todo-link {
  display: block;
  text-align: center;
  color: #19949e;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 10px 7px;
  margin-top: 8px;
  cursor: pointer;
}
.home-todo-link:hover { text-decoration: underline; }

/* Home data page */
.home-page-header {
  font-size: 22px;
  font-weight: 700;
  color: #014044;
  margin: 16px 0 4px;
}
.home-page-address {
  margin-bottom: 20px;
}
.home-page-address a {
  color: #19949e;
  text-decoration: none;
  font-size: 15px;
}
.home-page-address a:hover { text-decoration: underline; }
.home-section-label {
  font-size: 13px;
  font-weight: 600;
  color: #6a7677;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 20px 0 8px;
}
.home-notes-card, .home-members-card, .home-tasks-card {
  background: white;
  border-radius: 12px;
  padding: 12px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.home-notes-card {
  color: #454545;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Task detail modal */
body.modal-open { overflow: hidden; position: fixed; width: 100%; }
.todo-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: background 0.3s ease;
}
.todo-overlay.visible { background: rgba(0,0,0,0.4); }
.todo-sheet {
  background: white;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  border-radius: 16px 16px 0 0;
  overflow-y: auto;
  overscroll-behavior: none;
  padding: 20px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.todo-overlay.visible .todo-sheet { transform: translateY(0); }
.todo-sheet.dragging { transition: none; }
.todo-sheet-handle {
  width: 36px;
  height: 4px;
  background: #d1d5db;
  border-radius: 2px;
  margin: 0 auto 12px;
}
.todo-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.todo-sheet-header h3 { font-size: 18px; color: #014044; }
.todo-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #9ba7a8;
  cursor: pointer;
}

/* General */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #9ba7a8;
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.loading { text-align: center; padding: 60px 20px; color: #9ba7a8; }
.spinner { display: inline-block; width: 28px; height: 28px; border: 3px solid #d1d5db; border-top-color: #19949e; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.logout-btn {
  background: none;
  border: 1px solid #e5e5e5;
  color: #6a7677;
  padding: 10px 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 24px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
.logout-btn:hover { border-color: #9ba7a8; }

/* Image lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
  cursor: pointer;
}
.lightbox.visible { background: rgba(0,0,0,0.9); }
.lightbox-inner {
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.lightbox.visible .lightbox-inner { opacity: 1; transform: scale(1); }
.lightbox-inner img {
  max-width: 95vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
}
.lightbox-caption {
  background: rgba(0,0,0,0.8);
  color: white;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 0 0 4px 4px;
  width: 100%;
  text-align: center;
  line-height: 1.4;
}
.lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: white;
  font-size: 32px;
  cursor: pointer;
  z-index: 201;
  opacity: 0.7;
}
.lightbox-close:hover { opacity: 1; }

/* Token login */
.token-login-icon {
  display: block;
  margin: 40px auto 0;
  background: none;
  border: none;
  cursor: pointer;
  color: #9ba7a8;
  transition: color 0.2s;
}
.token-login-icon:hover { color: #6a7677; }
.token-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
}
.token-modal.visible { background: rgba(0,0,0,0.4); }
.token-modal-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  transform: scale(0.9);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.token-modal.visible .token-modal-card { transform: scale(1); opacity: 1; }
