/* Clientes Rio Claro — mobile. Paleta oficial da marca:
   Turquesa #45C1C6 · Petróleo #09344c · Navy #025A72 · Cinza #485054 · Branco. */

:root {
  --turquoise: #45c1c6;
  --turquoise-dark: #2ba3a8;
  --petroleum: #09344c;
  --navy: #025a72;
  --grey: #485054;
  --grey-soft: #6b757a;
  --line: #e3eaed;
  --bg: #f4f7f8;
  --card: #ffffff;
  --turquoise-soft: rgba(69, 193, 198, 0.10);
  --turquoise-soft2: rgba(69, 193, 198, 0.18);
  --danger: #c0392b;
  --ok: #1e8f6b;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(9, 52, 76, 0.08);
  --shadow-lg: 0 8px 28px rgba(9, 52, 76, 0.16);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--grey);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: contain;
}

body { padding-top: env(safe-area-inset-top); }

a { color: var(--navy); }

.hidden { display: none !important; }
.muted { color: var(--grey-soft); }
.small { font-size: 0.82rem; }
.center { text-align: center; }

/* ---------- Topbar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 8px;
  padding-top: env(safe-area-inset-top);
  background: var(--petroleum);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-title {
  flex: 1; display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 1.05rem;
}
.topbar-logo { height: 22px; width: auto; filter: brightness(0) invert(1); opacity: 0.95; }
.icon-btn {
  background: transparent; border: 0; color: inherit;
  font-size: 1.5rem; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.15); }
#topbar .icon-btn { color: #fff; }

/* ---------- Estrutura de telas ---------- */
#app { min-height: 100dvh; }
.screen { display: none; padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.screen.active { display: block; }

/* ---------- Botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 10px;
  padding: 13px 16px; border-radius: 12px;
  border: 1.5px solid var(--turquoise);
  background: #fff; color: var(--navy);
  font-family: inherit; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: transform .05s ease, background .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--turquoise); border-color: var(--turquoise); color: var(--petroleum); }
.btn-primary:active { background: var(--turquoise-dark); }
.btn-lg { padding: 15px; font-size: 1.05rem; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-link { background: none; border: 0; color: var(--navy); text-decoration: underline; cursor: pointer; margin-top: 12px; font-size: 0.95rem; }

.field, .pin-input {
  width: 100%; margin-top: 8px;
  padding: 13px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff;
  font-family: inherit; font-size: 1rem; color: var(--grey);
}
.field:focus, .pin-input:focus { outline: none; border-color: var(--turquoise); }
.field-label { display: block; margin-top: 12px; font-size: 0.85rem; font-weight: 600; color: var(--navy); }
select.field { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' stroke='%23025a72' stroke-width='1.6' fill='none' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

.status-line { min-height: 1.2em; margin: 8px 0 0; font-size: 0.88rem; }
.status-line.ok { color: var(--ok); }
.status-line.err { color: var(--danger); }
.error-text { color: var(--danger); min-height: 1.2em; margin-top: 12px; font-size: 0.9rem; }

/* ---------- Tela de trava ---------- */
#screen-lock { display: none; }
#screen-lock.active { display: flex; }
.lock-wrap {
  margin: auto; max-width: 340px; width: 100%;
  min-height: 90dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 6px;
}
.lock-logo { width: 88px; height: 88px; border-radius: 22px; box-shadow: var(--shadow-lg); }
.lock-title { margin: 18px 0 2px; color: var(--petroleum); font-size: 1.4rem; }
.lock-sub { margin: 0 0 22px; color: var(--grey-soft); }
.ico-finger { font-size: 1.2rem; }
#lock-pin-area { width: 100%; }
.pin-input { text-align: center; font-size: 1.6rem; letter-spacing: 0.3em; }
#lock-pin-area .btn { margin-top: 14px; }

/* ---------- Onboarding / cards roláveis ---------- */
.card-scroll { max-width: 520px; margin: 0 auto; }
.ob-step {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.ob-step.locked { opacity: 0.5; pointer-events: none; }
.ob-h { margin: 0 0 8px; color: var(--petroleum); font-size: 1.15rem; }
.ob-step .muted { margin: 0 0 4px; font-size: 0.92rem; }

/* ---------- Busca ---------- */
.search-bar { display: flex; gap: 8px; align-items: center; }
.search-field { margin-top: 0; }
.search-bar .icon-btn { flex: 0 0 auto; color: var(--navy); border: 1.5px solid var(--line); border-radius: 12px; width: 46px; height: 46px; }
.result-list { list-style: none; margin: 14px 0 0; padding: 0; }
.result-item {
  background: var(--card); border-radius: 12px; box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
  border-left: 4px solid var(--turquoise);
}
.result-item:active { background: var(--turquoise-soft); }
.result-name { font-weight: 600; color: var(--petroleum); font-size: 1.05rem; }
.result-meta { font-size: 0.85rem; color: var(--grey-soft); }
.empty-state { text-align: center; color: var(--grey-soft); margin-top: 40px; }

/* ---------- Detalhe / edição ---------- */
.detail-head { margin-bottom: 6px; }
#detail-name { margin: 0; color: var(--petroleum); font-size: 1.4rem; }
#detail-sub { margin: 2px 0 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--turquoise-soft2); color: var(--navy);
  font-size: 0.85rem; font-weight: 600; text-decoration: none;
}
.detail-form { margin-top: 14px; }
.f-group { margin-bottom: 14px; }
.f-group label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--navy); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.02em; }
.f-group input, .f-group textarea, .f-group select {
  width: 100%; padding: 12px 13px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff;
  font-family: inherit; font-size: 1rem; color: var(--grey);
}
.f-group textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.f-group input:focus, .f-group textarea:focus, .f-group select:focus { outline: none; border-color: var(--turquoise); }
.f-group.dirty input, .f-group.dirty textarea, .f-group.dirty select { border-color: var(--turquoise); background: var(--turquoise-soft); }
.detail-actions {
  position: sticky; bottom: 0;
  padding: 12px 0 calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* ---------- Configurações ---------- */
.set-block { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.set-label { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--navy); margin-bottom: 6px; }

/* ---------- Editor do "Painel do dia" (Configurações) ---------- */
.home-layout-list { margin-top: 4px; }
.hl-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.hl-row:last-child { border-bottom: 0; }
.hl-row.off .hl-name { color: var(--grey-soft); }
.hl-move { display: flex; gap: 4px; flex: 0 0 auto; }
.hl-move button {
  width: 34px; height: 34px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff; color: var(--navy);
  font-size: 1rem; font-weight: 600; cursor: pointer; line-height: 1;
}
.hl-move button:active { background: var(--turquoise-soft); }
.hl-move button:disabled { opacity: 0.3; cursor: default; }
.hl-name { flex: 1; min-width: 0; font-size: 0.88rem; font-weight: 600; color: var(--petroleum); }
.hl-count {
  flex: 0 0 auto; width: auto; margin: 0;
  padding: 7px 26px 7px 10px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff;
  font-family: inherit; font-size: 0.85rem; color: var(--navy);
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' stroke='%23025a72' stroke-width='1.6' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 8px center;
}
.hl-count:focus { outline: none; border-color: var(--turquoise); }
/* Interruptor de mostrar/ocultar: trilho cinza que fica turquesa quando ligado. */
.hl-switch { position: relative; flex: 0 0 auto; width: 44px; height: 26px; cursor: pointer; }
.hl-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.hl-slider {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--line); transition: background 0.15s ease;
  pointer-events: none;
}
.hl-slider::before {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(9, 52, 76, 0.25);
  transition: transform 0.15s ease;
}
.hl-switch input:checked + .hl-slider { background: var(--turquoise); }
.hl-switch input:checked + .hl-slider::before { transform: translateX(18px); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--petroleum); color: #fff;
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-lg);
  font-size: 0.9rem; z-index: 100; max-width: 90%; text-align: center;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ---------- Spinner ---------- */
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: sp 0.7s linear infinite; vertical-align: middle; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ===== Magnetis: central de tarefas, cliente e formulário ===== */
.tasks-shortcut { width: 100%; margin: 10px 0 2px; }
.tasks-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tasks-view { flex: 1; }
.tasks-new-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.tasks-new-row .btn { flex: 1; min-width: 100px; text-align: center; }
.tasks-list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 24px; }
.mtask {
  background: var(--card, #ffffff10);
  border: 1px solid var(--line, #ffffff22);
  border-left: 3px solid var(--ok, #2e7d52);
  border-radius: 10px;
  padding: 10px 12px;
}
.mtask.overdue { border-left-color: var(--danger, #c0392b); }
.mtask-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mtask-name { font-weight: 600; font-size: 14px; }
.mtask-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #2e7d5226;
  white-space: nowrap;
}
.mtask-pill.overdue { background: #c0392b26; }
.mtask-title { font-size: 13px; margin-top: 3px; }
.mtask-obs { font-size: 12px; opacity: 0.75; margin-top: 3px; }
.mtask-actions { display: flex; gap: 8px; margin-top: 8px; }
.btn-mini { padding: 6px 12px; font-size: 13px; text-decoration: none; text-align: center; }
.mag-sec { font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; opacity: 0.7; margin: 14px 0 4px; }
.pick-contact { display: block; width: 100%; text-align: left; margin: 6px 0; }
.chip-btn { border: 1px solid var(--line, #ffffff33); background: transparent; cursor: pointer; }

/* ---------- Remarcar vencimento (editor de data dentro do cartão) ---------- */
.mag-date-editor { display: flex; gap: 8px; align-items: center; margin-top: 8px; width: 100%; }
.mag-date-editor input[type="date"] {
  flex: 1; min-width: 0; margin: 0;
  padding: 8px 10px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff;
  font-family: inherit; font-size: 0.95rem; color: var(--grey);
}
.mag-date-editor input[type="date"]:focus { outline: none; border-color: var(--turquoise); }
.mag-date-editor .btn { width: auto; margin-top: 0; flex: 0 0 auto; }
.mtask-actions { flex-wrap: wrap; }

/* ---------- Painel do dia (busca vazia) ---------- */
#home-panel { margin-top: 12px; padding-bottom: 24px; }
.home-sec { margin-top: 16px; }
.home-sec-h {
  display: flex; align-items: center; gap: 8px; margin: 0 0 8px;
  font-size: 0.82rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--navy);
}
.home-count {
  background: var(--turquoise-soft2); color: var(--navy);
  border-radius: 999px; padding: 1px 9px; font-size: 0.75rem;
}
.home-sec .result-item { margin-bottom: 8px; }
.home-bday .result-item { border-left-color: #e6a23c; }
.home-sec .mtask { margin-bottom: 8px; }

/* Termômetro: mostrador semicircular de calor (verde → vermelho). */
.heat-row { display: flex; gap: 10px; margin-top: 12px; }
.heat-row:empty { display: none; }
.heat-card {
  flex: 1; min-width: 0;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 10px 10px; text-align: center;
}
.heat-svg { width: 100%; max-width: 140px; display: block; margin: 0 auto; }
.heat-arc { transition: stroke-dashoffset 0.9s ease; }
.heat-value { font-size: 1.45rem; font-weight: 700; line-height: 1; margin-top: -40px; }
.heat-word { font-size: 0.78rem; font-weight: 700; margin-top: 14px; }
.heat-label { font-size: 0.72rem; color: var(--grey-soft); margin-top: 2px; }
