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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --white: #ffffff;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Auth ── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.auth-logo p {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

.auth-step {
  display: none;
}

.auth-step.active {
  display: block;
}

.auth-step h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-step p {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 24px;
}

/* ── Form ── */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

input[type="email"],
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s;
}

input:focus {
  border-color: var(--primary);
}

.otp-input {
  text-align: center;
  font-size: 24px !important;
  font-weight: 700;
  letter-spacing: 8px;
}

/* ── Button ── */
.btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-cancel {
  background: #fef2f2;
  color: var(--danger);
  border: 1.5px solid #fecaca;
}

.btn-cancel:hover {
  background: #fee2e2;
}

/* ── Chat ── */
.chat-fullscreen {
  position: fixed;
  top: 90px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  z-index: 100;
}

.chat-topbar {
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-actions {
  background: var(--white);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-empty {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 30px 0;
}

.chat-msg {
  max-width: 80%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-mine {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-mine span {
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
  border-radius: 12px 12px 2px 12px;
  font-size: 14px;
  word-break: break-word;
}

.chat-theirs span {
  background: var(--white);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px 12px 12px 2px;
  font-size: 14px;
  word-break: break-word;
  border: 1px solid var(--border);
}

.chat-img {
  max-width: 220px;
  border-radius: 10px;
  cursor: pointer;
}

.chat-time {
  font-size: 11px;
  color: var(--muted);
  padding: 0 4px;
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--white);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.chat-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 6px;
  flex-shrink: 0;
}

.chat-icon-btn:hover {
  color: var(--primary);
}

.chat-text {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  font-size: 15px;
  outline: none;
  background: var(--bg);
}

.chat-text:focus {
  border-color: var(--primary);
}

.chat-send {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-send:hover {
  background: var(--primary-dark);
}

.btn-link {
  background: none;
  color: var(--primary);
  font-size: 13px;
  padding: 8px 0;
  text-decoration: underline;
  cursor: pointer;
  border: none;
  display: block;
  margin-top: 12px;
}

/* ── Alert ── */
.alert {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.alert.show {
  display: block;
}

.alert-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

/* ── Dashboard ── */
.app-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  z-index: 200;
}

.app-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.app-header h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
}

.app-header span {
  font-size: 13px;
  color: var(--muted);
}

.btn-logout {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.app-body {
  padding: 20px;
  max-width: 500px;
  margin: 0 auto;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.task-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.task-type {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.task-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.task-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 14px;
}

.status-solicitado { background: #fef9c3; color: #854d0e; }
.status-aceito { background: #dbeafe; color: #1e40af; }
.status-em_execucao { background: #fce7f3; color: #9d174d; }
.status-concluido { background: #dcfce7; color: #166534; }
.status-recebido { background: #f3f4f6; color: #374151; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state p {
  margin-top: 8px;
  font-size: 14px;
}

.task-observation {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  background: #f8fafc;
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  padding: 6px 10px;
  margin-bottom: 14px;
}

.chat-observation {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  background: #f8fafc;
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  padding: 6px 10px;
}

/* ── QR Scanner ── */
.qr-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.qr-modal-box {
  background: var(--white);
  border-radius: 16px;
  overflow: hidden;
  width: 100%;
  max-width: 340px;
}

.qr-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}

.qr-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
}

.qr-viewfinder {
  position: relative;
  background: #000;
  aspect-ratio: 1;
}

.qr-viewfinder video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.qr-frame {
  position: absolute;
  inset: 18%;
  border: 3px solid var(--primary);
  border-radius: 10px;
  pointer-events: none;
}

.qr-hint {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 14px 16px;
}
