:root {
  --teal: #0f766e;
  --teal-dark: #115e59;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --blue: #2563eb;
  --gray: #94a3b8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

/* ---------- Login ---------- */
#login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--teal), var(--teal-dark));
}
.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 36px 28px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.login-card .logo { font-size: 56px; }
.login-card h1 { margin: 8px 0 2px; font-size: 22px; }
.login-card p { margin: 0 0 24px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
}
.btn-google { background: #fff; color: #3c4043; border: 1px solid var(--border); }
.btn-google .g {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: #4285f4; color: #fff; font-weight: 700;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:active { background: var(--teal-dark); }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-link { background: none; border: none; color: var(--teal); font-weight: 600; cursor: pointer; padding: 4px 0 10px; font-size: 14px; }
.alert { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; border-radius: 10px; padding: 10px; margin-bottom: 16px; font-size: 14px; }

/* ---------- App ---------- */
#app { max-width: 640px; margin: 0 auto; padding: 0 16px 48px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 4px;
  background: var(--bg);
}
.brand { font-weight: 700; font-size: 18px; }
.user { display: flex; align-items: center; gap: 8px; }
.user img { width: 30px; height: 30px; border-radius: 50%; background: var(--border); }
.user span { font-size: 14px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-icon { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); padding: 4px; }

/* ---------- Abas ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab {
  flex: 1; padding: 10px; border: none; border-radius: 10px;
  background: var(--card); color: var(--muted); font-weight: 600; font-size: 15px;
  cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.06);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.tab.active { background: var(--teal); color: #fff; }
.badge-count {
  background: var(--red); color: #fff; border-radius: 999px;
  font-size: 12px; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center;
}
.tab.active .badge-count { background: #fff; color: var(--red); }

/* ---------- Cards / form ---------- */
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  margin-bottom: 22px;
}
.card h2, .list-title { font-size: 16px; margin: 0 0 14px; }
.list-title { margin: 0 4px 12px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, textarea {
  width: 100%; padding: 12px; font-size: 16px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text);
  font-family: inherit;
}
.row { display: flex; gap: 12px; }
.row .field { flex: 1; }

.segmented { display: flex; gap: 8px; }
.segmented button {
  flex: 1; padding: 12px 8px; font-size: 15px;
  border: 1px solid var(--border); background: #fff; border-radius: 10px;
  cursor: pointer; font-weight: 600; color: var(--muted);
}
.segmented button.active { background: var(--teal); color: #fff; border-color: var(--teal); }

.weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.weekdays .wd {
  flex: 1; min-width: 40px; padding: 10px 4px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  font-weight: 600; cursor: pointer; font-size: 13px;
}
.weekdays .wd.active { background: var(--teal); color: #fff; border-color: var(--teal); }

/* ---------- Lista ---------- */
.rides { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.ride {
  background: var(--card); border-radius: 14px; padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  border-left: 5px solid var(--gray);
}
.ride.pending { border-left-color: var(--amber); }
.ride.accepted { border-left-color: var(--green); }
.ride.refused { border-left-color: var(--red); }
.ride.cancelled { border-left-color: var(--gray); opacity: .7; }

.ride-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.ride-date { font-weight: 700; font-size: 15px; }
.ride-value { margin-left: auto; font-weight: 700; font-size: 15px; color: var(--teal); }
.badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.badge.dir { background: #f1f5f9; color: var(--muted); }
.badge.status-pending { background: #fef3c7; color: var(--amber); }
.badge.status-accepted { background: #dcfce7; color: var(--green); }
.badge.status-refused { background: #fee2e2; color: var(--red); }
.badge.status-cancelled { background: #e2e8f0; color: var(--muted); }
.ride-people { font-size: 14px; }
.ride-people b { font-weight: 600; }
.ride-notes { font-size: 14px; margin-top: 6px; color: var(--muted); }
.ride-refusal { font-size: 13px; margin-top: 6px; color: var(--red); background: #fef2f2; padding: 6px 8px; border-radius: 8px; }
.ride-actions { display: flex; gap: 8px; margin-top: 12px; }
.ride-actions button { flex: 1; padding: 10px; border-radius: 10px; border: none; font-weight: 600; font-size: 14px; cursor: pointer; }
.act-accept { background: var(--green); color: #fff; }
.act-refuse { background: #fef2f2; color: var(--red); border: 1px solid #fecaca !important; }
.act-cancel { background: #fef2f2; color: var(--red); border: 1px solid #fecaca !important; }

/* ---------- Relatório ---------- */
.summary { display: flex; gap: 12px; margin-bottom: 18px; }
.stat {
  flex: 1; background: var(--card); border-radius: 14px; padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06); text-align: center;
}
.stat-primary { background: var(--teal); color: #fff; }
.stat-label { display: block; font-size: 12px; opacity: .85; margin-bottom: 6px; }
.stat-value { display: block; font-size: 22px; font-weight: 700; }
.bp-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.bp-row:last-child { border-bottom: none; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 30; padding: 20px; }
.modal-card { background: var(--card); border-radius: 16px; padding: 22px; width: 100%; max-width: 400px; }
.modal-card h3 { margin: 0 0 6px; }
.modal-card textarea { margin-top: 10px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 999px;
  font-size: 14px; z-index: 40; box-shadow: 0 8px 20px rgba(0,0,0,.25); max-width: 90%; text-align: center;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --card: #131c2e; --text: #e2e8f0; --muted: #94a3b8; --border: #26334a;
  }
  .field input, .field select, textarea, .segmented button, .weekdays .wd { background: #0f1829; }
  .btn-google { background: #131c2e; color: #e2e8f0; }
  .alert, .ride-refusal { background: #2a1414; border-color: #542020; }
  .badge.dir { background: #0f1829; }
}
