/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--color-black);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* === Palette === */
:root {
  --color-black: #111;
  --color-white: #fff;
  --color-bg: #f5f5f5;
  --color-grey-light: #e0e0e0;
  --color-grey-mid: #999;
  --color-grey-dark: #555;
  --color-border: #d0d0d0;
}

/* === Screen routing === */
.screen { display: none; min-height: 100vh; padding: 16px; }
.screen.active { display: block; }

/* === Typography === */
h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 16px; }
h2 { font-size: 1.15rem; font-weight: 600; margin-bottom: 12px; }
p { margin-bottom: 8px; }
.text-muted { color: var(--color-grey-mid); font-size: 0.85rem; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary {
  background: var(--color-black);
  color: var(--color-white);
  width: 100%;
}
.btn-secondary {
  background: var(--color-white);
  color: var(--color-black);
  border: 2px solid var(--color-border);
  width: 100%;
}
.btn-sm {
  min-height: 40px;
  padding: 8px 16px;
  font-size: 0.85rem;
}

/* === Text inputs === */
input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--color-black);
  background: var(--color-white);
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus { border-color: var(--color-grey-dark); }
textarea { resize: vertical; min-height: 80px; }

.input-error { border-color: #b00; }
.error-msg { color: #b00; font-size: 0.85rem; margin-top: 4px; display: none; }
.error-msg.visible { display: block; }

/* === Cards === */
.card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.card:active { background: var(--color-bg); }

/* === Progress bar === */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--color-grey-light);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-bar__fill {
  height: 100%;
  background: var(--color-black);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* === Status badges === */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge--progress { background: var(--color-grey-light); color: var(--color-grey-dark); }
.badge--done { background: var(--color-black); color: var(--color-white); }

/* === Avatar === */
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-black);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.avatar__initials {
  color: var(--color-white);
  font-size: 0.55rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}
.avatar--large {
  width: 56px;
  height: 56px;
}
.avatar--large .avatar__initials {
  font-size: 1.1rem;
}

/* === Home screen === */
.home-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.home-topbar h1 { margin-bottom: 0; }
.home-header {
  margin-bottom: 16px;
}
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--color-grey-mid);
}
.installation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.installation-item__info { flex: 1; }
.installation-item__serial { font-weight: 600; font-size: 1.05rem; }
.installation-item__date { font-size: 0.8rem; color: var(--color-grey-mid); }

/* === Serial entry screen === */
#screen-serial { display: none; }
#screen-serial.active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.serial-form { width: 100%; max-width: 320px; }
.serial-form input {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.25em;
  margin: 16px 0 4px;
}
.serial-form .btn { margin-top: 16px; }

/* === Checklist screen === */
.checklist-header {
  position: sticky;
  top: 0;
  background: var(--color-bg);
  padding: 0 0 12px;
  z-index: 10;
}
.step-counter { font-size: 0.85rem; color: var(--color-grey-mid); margin-top: 4px; }
.step-card { margin-bottom: 16px; }
.step-card__title { font-size: 1.15rem; font-weight: 700; margin-bottom: 4px; }
.step-card__desc { color: var(--color-grey-dark); margin-bottom: 16px; font-size: 0.95rem; }

.step-actions { margin-bottom: 16px; }

/* Checkbox action */
.check-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-white);
  font-size: 1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, background 0.15s;
}
.check-btn.checked {
  border-color: var(--color-black);
  background: var(--color-black);
  color: var(--color-white);
}
.check-btn__icon {
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-grey-mid);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
  transition: border-color 0.15s, background 0.15s;
}
.check-btn.checked .check-btn__icon {
  border-color: var(--color-white);
  background: transparent;
}

/* Photo area */
.photo-area { margin-bottom: 16px; }
.photo-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.photo-thumb {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}
.photo-thumb__delete {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: var(--color-white);
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-input { display: none; }

.btn-add-photo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Notes */
.notes-area { margin-bottom: 20px; }
.notes-area label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--color-grey-dark);
}

/* Navigation buttons */
.nav-buttons {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.nav-buttons .btn { flex: 1; }

.back-home-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  color: var(--color-grey-mid);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}

/* === Summary screen === */
.summary-meta {
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}
.summary-meta dt { font-size: 0.8rem; color: var(--color-grey-mid); text-transform: uppercase; letter-spacing: 0.04em; }
.summary-meta dd { font-weight: 600; margin-bottom: 8px; }
.summary-step { margin-bottom: 16px; }
.summary-step__title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.summary-step__photos {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0;
}
.summary-step__photos img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  cursor: pointer;
}
.summary-step__notes {
  font-size: 0.85rem;
  color: var(--color-grey-dark);
  font-style: italic;
}
.summary-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
.summary-actions .btn { flex: 1; }

/* === Settings screen === */
.settings-header { margin-bottom: 24px; }
.settings-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.settings-profile__name {
  font-size: 1.15rem;
  font-weight: 600;
}
.settings-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--color-white);
  border-radius: 10px;
  border: 1px solid var(--color-border);
  overflow: hidden;
}
.settings-menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: var(--color-white);
  border: none;
  border-bottom: 1px solid var(--color-bg);
  font-size: 1rem;
  font-family: inherit;
  color: var(--color-black);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
}
.settings-menu__item:last-child { border-bottom: none; }
.settings-menu__item:active { background: var(--color-bg); }
.settings-menu__item--danger { color: #b00; }
.settings-menu__icon { font-size: 1.1rem; flex-shrink: 0; width: 24px; text-align: center; }
.settings-menu__arrow { margin-left: auto; color: var(--color-grey-mid); font-size: 1.2rem; }

/* === Lightbox === */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.lightbox[hidden] { display: none; }
.lightbox-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  color: var(--color-white);
  font-size: 2rem;
  cursor: pointer;
}
.lightbox-img {
  max-width: 95vw;
  max-height: 90vh;
  border-radius: 4px;
}
