/* ==========================================================================
   Reffo – área logada (clientes e administração)
   Mesma identidade visual do site institucional
   ========================================================================== */
:root {
  --navy-950: #12142E;
  --navy-900: #1A1D3F;
  --navy: #2A2C53;
  --logo-navy: #212A59;
  --blue: #0E67A5;
  --sky: #1E9AD6;
  --lime: #A8C838;
  --yellow: #EBCE36;
  --orange: #E28526;
  --red: #E15B27;
  --brand-gradient: linear-gradient(90deg, var(--red), var(--orange) 22%, var(--yellow) 42%, var(--lime) 62%, var(--sky) 82%, var(--blue));

  --bg: #F3F5FA;
  --surface: #FFFFFF;
  --surface-2: #F7F8FC;
  --line: #E4E8F1;
  --line-soft: #EEF1F6;
  --text: #1A1D3F;
  --text-soft: #545A7A;
  --text-faint: #7E849F;

  /* Gráficos (validados para daltonismo e contraste) */
  --series-1: #0E67A5;
  --series-2: #D9701A;
  --grid: #E9ECF3;
  --seq-0: #EEF1F6;
  --seq-1: #D3E4F2;
  --seq-2: #9CC3E3;
  --seq-3: #5597CB;
  --seq-4: #0E67A5;

  /* Status (sempre com ícone + texto) */
  --good: #1F8A4C;
  --good-bg: #E6F4EC;
  --warn: #A86A00;
  --warn-bg: #FCF1DC;
  --crit: #C2352A;
  --crit-bg: #FBE8E6;
  --info: #0E67A5;
  --info-bg: #E5F0F9;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(26, 29, 63, .05), 0 2px 8px rgba(26, 29, 63, .04);
  --shadow: 0 10px 30px -12px rgba(26, 29, 63, .22);
  --shadow-lg: 0 30px 60px -20px rgba(26, 29, 63, .35);
  --font-head: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-logo: "Montserrat", var(--font-head);
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --bottomnav-h: 68px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-body); font-size: 15px; line-height: 1.55; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; margin: 0; color: var(--navy-900); letter-spacing: -.015em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.ico { width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -0.2em; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); }
.small { font-size: .85rem; }
.tnum { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack { display: grid; gap: 16px; }
.grow { flex: 1; min-width: 0; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font-family: var(--font-head); font-weight: 600; font-size: .9rem; line-height: 1.2;
  padding: .7em 1.15em; border-radius: 999px; border: 1.5px solid transparent;
  cursor: pointer; white-space: nowrap; background: transparent; text-decoration: none !important;
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--blue), var(--navy)); box-shadow: 0 8px 20px -10px rgba(14, 103, 165, .8); }
.btn-primary:hover { box-shadow: 0 12px 24px -10px rgba(14, 103, 165, .9); }
.btn-ghost { color: var(--navy); border-color: var(--line); background: var(--surface); }
.btn-ghost:hover { border-color: var(--navy); }
.btn-soft { color: var(--blue); background: var(--info-bg); }
.btn-soft:hover { background: #d6e7f5; }
.btn-danger { color: var(--crit); border-color: #f0c9c5; background: var(--surface); }
.btn-danger:hover { background: var(--crit-bg); }
.btn-wa { color: #fff; background: #1FAF55; }
.btn-wa:hover { background: #1a9a4a; }
.btn-sm { padding: .5em .9em; font-size: .82rem; }
.btn-xs { padding: .35em .7em; font-size: .78rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; border: 1px solid transparent;
  background: transparent; color: var(--text-soft); cursor: pointer; position: relative; flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--navy); }
.icon-btn .ico { width: 20px; height: 20px; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn.sm .ico { width: 17px; height: 17px; }

/* ---------- Formulários ---------- */
.field { display: grid; gap: 6px; }
.field > span, .label { font-size: .82rem; font-weight: 600; color: var(--text-soft); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease; min-height: 42px;
}
.textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 4px rgba(30, 154, 214, .15); }
.input-sm { padding: 6px 10px; min-height: 34px; border-radius: 10px; font-size: .88rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.hint { font-size: .8rem; color: var(--text-faint); }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: .92rem; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--blue); flex-shrink: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: #CDD3E0; position: relative; transition: background .2s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .track { background: var(--blue); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--sky); outline-offset: 2px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-wrap .icon-btn { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); }
.error-box { padding: 10px 14px; border-radius: 12px; background: var(--crit-bg); color: var(--crit); font-size: .9rem; }

/* Segmentado (escolha única) */
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  font-family: var(--font-head); font-weight: 600; font-size: .82rem; color: var(--text-soft);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--navy-900); box-shadow: var(--shadow-sm); }

/* Escala 1–5 */
.scale { display: flex; gap: 6px; }
.scale button {
  flex: 1; min-width: 0; height: 40px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
  cursor: pointer; font-size: 1.15rem; transition: all .15s ease;
}
.scale button[aria-pressed="true"] { border-color: var(--blue); background: var(--info-bg); transform: translateY(-1px); }

/* ---------- Layout do app ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 50;
  background: var(--navy-950); color: rgba(255,255,255,.78); display: flex; flex-direction: column;
  padding: 18px 14px; overflow-y: auto;
}
.sidebar::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--brand-gradient); }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; color: #fff; text-decoration: none !important; }
.brand img { height: 40px; width: auto; }
.brand-text { display: grid; line-height: 1; font-family: var(--font-logo); }
.brand-text .b1 { font-size: .72rem; font-weight: 500; opacity: .8; }
.brand-text .b2 { font-size: 1.3rem; font-weight: 600; letter-spacing: .02em; margin: 1px 0 2px; }
.brand-text .b3 { font-size: .6rem; font-weight: 500; opacity: .7; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  color: rgba(255,255,255,.72); font-family: var(--font-head); font-weight: 500; font-size: .92rem; text-decoration: none;
  position: relative;
}
.nav a .ico { width: 20px; height: 20px; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a[aria-current="page"] { background: rgba(255,255,255,.1); color: #fff; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand-gradient); }
.nav .badge { margin-left: auto; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: rgba(255,255,255,.4); padding: 18px 12px 6px; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 10px; }
.sidebar-foot .who { min-width: 0; flex: 1; font-size: .85rem; line-height: 1.3; }
.sidebar-foot .who strong { display: block; color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .icon-btn { color: rgba(255,255,255,.7); }
.sidebar-foot .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: rgba(243, 245, 250, .86); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar .title { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; color: var(--navy-900); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .menu-btn, .topbar .mobile-brand { display: none; }
.content { padding: 8px 28px 48px; width: 100%; max-width: 1280px; }
.content.narrow { max-width: 880px; }

.bottom-nav { display: none; }

/* ---------- Cartões ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 10px; }
.card-head h2 .ico { color: var(--blue); }
.card-head .sub { font-size: .85rem; color: var(--text-soft); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 18px 20px 0; }
.card-dark {
  background: linear-gradient(150deg, var(--navy) 0%, var(--navy-950) 100%); color: #fff; border: 0; position: relative; overflow: hidden;
}
.card-dark h2, .card-dark h3 { color: #fff; }
.card-dark::after { content: ""; position: absolute; width: 260px; height: 260px; right: -100px; top: -120px; border-radius: 50%; background: radial-gradient(circle, rgba(30,154,214,.45), transparent 65%); pointer-events: none; }
.card-dark > * { position: relative; z-index: 1; }

.grid { display: grid; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.span-2 { grid-column: span 2; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 14px 0 22px; }
.page-head p { color: var(--text-soft); margin-top: 4px; }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

/* ---------- Indicadores (stat tiles) ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm);
  display: grid; gap: 4px; align-content: start; text-decoration: none !important; color: inherit; position: relative;
}
a.stat:hover { border-color: #c9d1e2; box-shadow: var(--shadow); }
.stat .label { font-size: .8rem; color: var(--text-soft); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .label .ico { color: var(--text-faint); }
.stat .value { font-family: var(--font-head); font-size: 1.7rem; font-weight: 700; color: var(--navy-900); line-height: 1.15; }
.stat .value small { font-size: .9rem; font-weight: 600; color: var(--text-soft); margin-left: 2px; }
.stat .foot { font-size: .8rem; color: var(--text-faint); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: .78rem; font-weight: 600; }
.delta .ico { width: 13px; height: 13px; }
.delta.good { color: var(--good); } .delta.bad { color: var(--crit); } .delta.flat { color: var(--text-faint); }
.stat.alert { border-color: #f1d7a3; background: linear-gradient(180deg, #fffaf0, #fff); }

/* Medidor (meter) */
.meter { height: 8px; border-radius: 999px; background: var(--seq-1); overflow: hidden; min-width: 60px; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--blue); }
.meter.warn { background: #F6E3BF; } .meter.warn > span { background: #D99A1C; }
.meter.crit { background: #F5D3CF; } .meter.crit > span { background: var(--crit); }
.meter-row { display: flex; align-items: center; gap: 10px; }
.meter-row .meter { flex: 1; }
.meter-row .tnum { min-width: 38px; text-align: right; font-weight: 600; font-size: .85rem; }

/* ---------- Badges e chips ---------- */
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--red); color: #fff; font-size: .72rem; font-weight: 700; font-family: var(--font-head);
}
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--line);
}
.pill .ico { width: 14px; height: 14px; }
.pill.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.crit { background: var(--crit-bg); color: var(--crit); border-color: transparent; }
.pill.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.avatar {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  font-family: var(--font-head); font-weight: 700; font-size: .85rem; color: #fff; background: var(--c, var(--blue));
}
.avatar.lg { width: 56px; height: 56px; font-size: 1.15rem; }
.avatar.sm { width: 30px; height: 30px; font-size: .72rem; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2);
}
.table th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.table th button:focus-visible { outline: 2px solid var(--sky); border-radius: 4px; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person .nm { font-weight: 600; color: var(--navy-900); }
.person .sub { font-size: .8rem; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

/* ---------- Abas ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 10px 14px; font-family: var(--font-head); font-weight: 600; font-size: .9rem; color: var(--text-soft);
  border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important;
}
.tabs a:hover { color: var(--navy); }
.tabs a[aria-current="page"] { color: var(--navy-900); border-bottom-color: var(--blue); }

/* ---------- Listas ---------- */
.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow .t { font-weight: 600; color: var(--navy-900); }
.list-item .grow .s { font-size: .83rem; color: var(--text-soft); }
a.list-item { color: inherit; text-decoration: none !important; }
a.list-item:hover .t { color: var(--blue); }
.empty { text-align: center; padding: 28px 16px; color: var(--text-faint); font-size: .92rem; }
.empty .ico { width: 34px; height: 34px; color: #c3c9d8; margin: 0 auto 8px; display: block; }

/* ---------- Refeições (cliente) ---------- */
.meal { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.meal:last-child { border-bottom: 0; }
.meal .time { font-family: var(--font-head); font-weight: 700; font-size: .82rem; color: var(--blue); background: var(--info-bg); border-radius: 10px; padding: 6px 8px; min-width: 56px; text-align: center; }
.meal .nm { font-weight: 600; color: var(--navy-900); }
.meal .meta { font-size: .8rem; color: var(--text-faint); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.meal .meta .ico { width: 14px; height: 14px; }
.meal-actions { display: flex; gap: 6px; }
.status-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--text-faint); cursor: pointer; transition: all .15s ease;
}
.status-btn .ico { width: 18px; height: 18px; }
.status-btn:hover { border-color: #c1c8d8; color: var(--navy); }
.status-btn[data-s="feito"][aria-pressed="true"] { background: var(--good); border-color: var(--good); color: #fff; }
.status-btn[data-s="parcial"][aria-pressed="true"] { background: #D99A1C; border-color: #D99A1C; color: #fff; }
.status-btn[data-s="nao"][aria-pressed="true"] { background: var(--crit); border-color: var(--crit); color: #fff; }
.meal-extra { grid-column: 2 / -1; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.thumb { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); cursor: zoom-in; }
.comment { grid-column: 1 / -1; font-size: .85rem; background: var(--info-bg); color: var(--navy); padding: 8px 12px; border-radius: 10px; }
.comment strong { color: var(--blue); }

.progress-ring { position: relative; width: 74px; height: 74px; flex-shrink: 0; }
.progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.progress-ring .v { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: .95rem; color: var(--navy-900); }

/* Água */
.water { display: flex; align-items: center; gap: 18px; }
.water-glass { width: 64px; height: 86px; border: 3px solid #BFD8EC; border-top: 0; border-radius: 0 0 16px 16px; position: relative; overflow: hidden; flex-shrink: 0; background: #F4F9FD; }
.water-glass span { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(180deg, #5FB8E6, var(--sky)); transition: height .5s cubic-bezier(.2,.7,.2,1); }
.water .amount { font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; color: var(--navy-900); }

/* Semana (mini calendário) */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week .d { text-align: center; font-size: .72rem; color: var(--text-faint); display: grid; gap: 4px; justify-items: center; }
.week .d .cell { width: 100%; max-width: 44px; aspect-ratio: 1; border-radius: 10px; background: var(--seq-0); display: grid; place-items: center; font-weight: 700; font-size: .78rem; color: var(--navy-900); position: relative; }
.week .d.today .cell { box-shadow: 0 0 0 2px var(--navy) inset; }
.week .d .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--series-2); }
.week .d .dot.off { background: transparent; }

/* Heatmap (constância) */
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; }
.heat-wrap { display: flex; gap: 8px; align-items: stretch; overflow-x: auto; padding-bottom: 4px; }
.heat-days { display: grid; grid-template-rows: repeat(7, 1fr); gap: 3px; font-size: .68rem; color: var(--text-faint); }
.heat-days span { height: 16px; line-height: 16px; }
.heat i { width: 16px; height: 16px; border-radius: 4px; background: var(--seq-0); display: block; }
.heat i[data-l="1"] { background: var(--seq-1); } .heat i[data-l="2"] { background: var(--seq-2); }
.heat i[data-l="3"] { background: var(--seq-3); } .heat i[data-l="4"] { background: var(--seq-4); }
.heat i.future { background: transparent; }
.heat i:hover { outline: 2px solid var(--navy); outline-offset: 1px; }
.heat-legend { display: flex; align-items: center; gap: 4px; font-size: .72rem; color: var(--text-faint); margin-top: 10px; }
.heat-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---------- Gráficos ---------- */
.chart { position: relative; width: 100%; min-height: 60px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--font-body); font-size: 11px; fill: var(--text-faint); }
.chart .axis-label { fill: var(--text-faint); }
.chart .value-label { fill: var(--text); font-weight: 600; font-size: 11.5px; }
.chart .target-label { fill: var(--text-soft); font-weight: 600; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .bar-hit { fill: transparent; cursor: pointer; }
.chart .bar-hit:hover + .bar, .chart .bar.hover { filter: brightness(1.15); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8rem; color: var(--text-soft); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; background: var(--c); display: inline-block; }
.legend i.box { width: 10px; height: 10px; border-radius: 3px; }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); }
.tooltip {
  position: fixed; z-index: 1000; pointer-events: none; background: var(--navy-950); color: #fff; padding: 8px 11px;
  border-radius: 10px; font-size: .8rem; line-height: 1.4; box-shadow: var(--shadow); max-width: 240px; opacity: 0; transition: opacity .1s;
}
.tooltip.show { opacity: 1; }
.tooltip .tt-title { color: rgba(255,255,255,.65); font-size: .74rem; margin-bottom: 2px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-row i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.tooltip .tt-row b { font-weight: 700; }

/* Barras horizontais (HTML) */
.hbars { display: grid; gap: 12px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 32%) 1fr 48px; gap: 12px; align-items: center; font-size: .88rem; }
.hbar .track { background: var(--line-soft); border-radius: 4px; }
.hbar .nm { font-weight: 500; color: var(--navy-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .track { height: 14px; border-radius: 0 4px 4px 0; position: relative; }
.hbar .track span { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.hbar .v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.hbar .sub { grid-column: 2 / -1; font-size: .76rem; color: var(--text-faint); margin-top: -6px; }
.segbar { display: flex; gap: 2px; height: 10px; border-radius: 999px; overflow: hidden; background: transparent; }
.segbar span { display: block; height: 100%; }
.segbar span:first-child { border-radius: 999px 0 0 999px; }
.segbar span:last-child { border-radius: 0 999px 999px 0; }
.segbar span:only-child { border-radius: 999px; }
.sw-feito, .legend i.sw-feito { background: var(--good); }
.sw-parcial, .legend i.sw-parcial { background: #E2A93B; }
.sw-nao, .legend i.sw-nao { background: var(--crit); }
.sw-sem, .legend i.sw-sem { background: #DADFEA; }

.insight { display: flex; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: .9rem; }
.insight .ico { color: var(--blue); width: 20px; height: 20px; margin-top: 1px; }
.insight.warn .ico { color: var(--warn); }
.insight strong { color: var(--navy-900); }

/* ---------- Mensagens ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 120px); min-height: 420px; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.bubble { max-width: 78%; padding: 9px 13px; border-radius: 16px; font-size: .93rem; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; box-shadow: var(--shadow-sm); }
.bubble.me { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 5px; }
.bubble.them { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble .at { display: block; font-size: .7rem; margin-top: 4px; opacity: .65; text-align: right; }
.day-sep { align-self: center; font-size: .72rem; color: var(--text-faint); background: var(--surface); border: 1px solid var(--line); padding: 2px 10px; border-radius: 999px; margin: 8px 0; }
.chat-form { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); background: var(--surface); align-items: flex-end; }
.chat-form .textarea { min-height: 44px; max-height: 140px; border-radius: 22px; padding: 11px 16px; resize: none; }
.chat-form .btn { height: 44px; width: 44px; padding: 0; border-radius: 50%; }
.inbox { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - var(--topbar-h) - 70px); min-height: 480px; }
.inbox-list { border-right: 1px solid var(--line); overflow-y: auto; }
.inbox-list a { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); color: inherit; text-decoration: none; align-items: center; }
.inbox-list a:hover { background: var(--surface-2); }
.inbox-list a[aria-current="page"] { background: var(--info-bg); }
.inbox-list .preview { font-size: .82rem; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-list .nm { font-weight: 600; color: var(--navy-900); }
.inbox-thread { display: flex; flex-direction: column; min-width: 0; }
.inbox-thread .chat { height: 100%; min-height: 0; }
.thread-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }

/* ---------- Dieta ---------- */
.diet-meal { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.diet-meal-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.diet-meal-head h3 { flex: 1; }
.diet-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 12px 18px; border-bottom: 1px solid var(--line-soft); }
.diet-item:last-child { border-bottom: 0; }
.diet-item .food { font-weight: 600; color: var(--navy-900); }
.diet-item .qty { color: var(--text-soft); font-size: .9rem; text-align: right; }
.diet-item details { grid-column: 1 / -1; font-size: .85rem; }
.diet-item summary { cursor: pointer; color: var(--blue); font-weight: 600; font-size: .8rem; list-style: none; display: inline-flex; align-items: center; gap: 4px; }
.diet-item summary::-webkit-details-marker { display: none; }
.diet-item details p { margin-top: 6px; padding: 8px 12px; background: var(--surface-2); border-radius: 10px; color: var(--text-soft); }
.macros { display: flex; gap: 10px; flex-wrap: wrap; }
.macro { padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); min-width: 88px; }
.macro b { display: block; font-family: var(--font-head); font-size: 1.2rem; }
.macro span { font-size: .75rem; opacity: .75; }
.guidelines { white-space: pre-line; color: var(--text-soft); line-height: 1.7; }
.shop-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.shop-item input:checked + span { text-decoration: line-through; color: var(--text-faint); }

/* Editor de dieta */
.editor-meal { border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--surface-2); display: grid; gap: 10px; }
.editor-meal-head { display: grid; grid-template-columns: 1fr 120px auto; gap: 10px; align-items: center; }
.editor-items { display: grid; gap: 8px; }
.editor-item { display: grid; grid-template-columns: 1.3fr .8fr 1.5fr auto; gap: 8px; align-items: start; background: var(--surface); padding: 8px; border-radius: 12px; border: 1px solid var(--line); }
.editor-item .input { min-height: 36px; padding: 7px 10px; font-size: .88rem; }
.editor-actions { display: flex; gap: 2px; }

/* Rotina semanal */
.routine { display: grid; grid-template-columns: repeat(7, minmax(118px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.routine .act b { overflow-wrap: anywhere; }
.routine .day { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px; min-height: 96px; display: grid; align-content: start; gap: 6px; }
.routine .day.today { border-color: var(--blue); background: var(--info-bg); }
.routine .day h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); }
.routine .act { background: var(--surface); border-radius: 10px; padding: 6px 8px; font-size: .8rem; border: 1px solid var(--line); }
.routine .act b { display: block; color: var(--navy-900); font-size: .82rem; }
.routine .rest { font-size: .78rem; color: var(--text-faint); }

/* Ranking */
.rank { display: grid; gap: 6px; }
.rank-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.rank-row.me { background: var(--info-bg); outline: 1.5px solid var(--blue); }
.rank-row .pos { font-family: var(--font-head); font-weight: 800; color: var(--text-faint); text-align: center; }
.rank-row:nth-child(1) .pos { color: #C99A06; } .rank-row:nth-child(2) .pos { color: #8A93A6; } .rank-row:nth-child(3) .pos { color: #B06A2C; }
.rank-row .pts { font-family: var(--font-head); font-weight: 700; color: var(--navy-900); }

/* Diário (admin) */
.day-block { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.day-block summary { display: flex; align-items: center; gap: 12px; padding: 14px 18px; cursor: pointer; list-style: none; }
.day-block summary::-webkit-details-marker { display: none; }
.day-block[open] summary { border-bottom: 1px solid var(--line); }
.day-block .body { padding: 14px 18px; display: grid; gap: 12px; }
.log-line { display: flex; align-items: flex-start; gap: 10px; font-size: .9rem; }
.log-line .grow .s { font-size: .82rem; color: var(--text-soft); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 500; background: rgba(18, 20, 46, .55); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 16px; animation: fade .15s ease;
}
.modal {
  width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: pop .18s cubic-bezier(.2,.7,.2,1);
}
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-body { padding: 20px 22px; display: grid; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; flex-wrap: wrap; }
.photo-view { max-height: 75vh; margin: 0 auto; border-radius: 12px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: 900; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); }
.toast {
  background: var(--navy-950); color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px; font-size: .9rem; animation: pop .2s ease;
}
.toast .ico { width: 18px; height: 18px; color: var(--lime); }
.toast.error .ico { color: #FF8A7A; }

/* ---------- Login ---------- */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
}
.auth-side {
  position: relative; overflow: hidden; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-950) 100%); color: #fff;
  padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side::before { content: ""; position: absolute; width: 520px; height: 520px; right: -200px; top: -220px; border-radius: 50%; background: radial-gradient(circle, rgba(30,154,214,.45), transparent 65%); }
.auth-side::after { content: ""; position: absolute; width: 420px; height: 420px; left: -160px; bottom: -200px; border-radius: 50%; background: radial-gradient(circle, rgba(226,133,38,.35), transparent 65%); }
.auth-side > * { position: relative; z-index: 1; }
.auth-side .bar { position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--brand-gradient); z-index: 2; }
.auth-side h1 { color: #fff; font-size: clamp(1.8rem, 3vw, 2.6rem); font-weight: 800; letter-spacing: -.03em; margin: 28px 0 16px; max-width: 460px; }
.auth-side p { color: rgba(255,255,255,.75); max-width: 440px; font-size: 1.02rem; }
.auth-feats { display: grid; gap: 12px; margin-top: 32px; }
.auth-feats li { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,.85); }
.auth-feats .ico { width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: rgba(255,255,255,.1); color: var(--yellow); }
.auth-main { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; display: grid; gap: 18px; }
.auth-card h2 { font-size: 1.6rem; }
.back-site { font-size: .88rem; color: var(--text-soft); }

/* ---------- Diversos ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: .9rem; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; color: var(--navy-900); font-weight: 500; }
.code-box { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--surface-2); border: 1px dashed #c8cfdf; padding: 12px 14px; border-radius: 12px; font-size: 1.05rem; letter-spacing: .04em; user-select: all; }
.msg-preview { white-space: pre-wrap; background: #E7F7EC; border: 1px solid #c9ebd3; border-radius: 12px; padding: 12px 14px; font-size: .9rem; }
.var-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.var-chips button { border: 1px dashed #b9c3d8; background: var(--surface); border-radius: 8px; padding: 2px 8px; font-size: .76rem; cursor: pointer; font-family: ui-monospace, Consolas, monospace; color: var(--navy); }
.loading { display: grid; place-items: center; padding: 60px 0; color: var(--text-faint); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.refetching { opacity: .55; transition: opacity .15s; pointer-events: none; }
.date-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.date-nav span { font-family: var(--font-head); font-weight: 600; font-size: .88rem; padding: 0 8px; min-width: 120px; text-align: center; }
.hero-trophy { width: 72px; height: 72px; color: var(--yellow); opacity: .9; }
.hero-num { font-family: var(--font-head); font-size: 3rem; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--info-bg); color: var(--navy); font-size: .9rem; }
.callout .ico { color: var(--blue); width: 20px; height: 20px; margin-top: 1px; }
.callout.warn { background: var(--warn-bg); } .callout.warn .ico { color: var(--warn); }

/* ==========================================================================
   Responsivo
   ========================================================================== */
@media (max-width: 1100px) {
  .grid-main { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(18,20,46,.45); z-index: 45; }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .topbar .menu-btn { display: inline-grid; }
  .content { padding: 4px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .inbox-list { border-right: 0; max-height: none; }
  .inbox.has-thread .inbox-list { display: none; }
  .inbox:not(.has-thread) .inbox-thread { display: none; }
  .inbox-thread .chat { height: calc(100vh - var(--topbar-h) - 140px); }
  .routine { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 32px 24px; }
  .auth-side h1 { margin: 20px 0 10px; }
  .auth-feats { display: none; }
}

/* Área do cliente: navegação inferior no celular */
@media (max-width: 900px) {
  .client-app .sidebar { display: none; }
  .client-app .topbar .menu-btn { display: none; }
  .client-app .topbar .mobile-brand { display: inline-flex; }
  .client-app .content { padding-bottom: calc(var(--bottomnav-h) + 28px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255,255,255,.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  }
  .bottom-nav a {
    display: grid; justify-items: center; align-content: center; gap: 3px; color: var(--text-faint); font-size: .7rem; font-weight: 600;
    font-family: var(--font-head); text-decoration: none; position: relative;
  }
  .bottom-nav a .ico { width: 23px; height: 23px; }
  .bottom-nav a[aria-current="page"] { color: var(--blue); }
  .bottom-nav a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand-gradient); }
  .bottom-nav .badge { position: absolute; top: 8px; left: calc(50% + 6px); }
  .chat { height: calc(100vh - var(--topbar-h) - var(--bottomnav-h) - 90px); }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  h1 { font-size: 1.35rem; }
  .card { padding: 16px; border-radius: 14px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .value { font-size: 1.35rem; }
  .meal { grid-template-columns: 1fr auto; }
  .meal .time { display: none; }
  .meal-extra { grid-column: 1 / -1; }
  .status-btn { width: 38px; height: 38px; }
  .editor-meal-head { grid-template-columns: 1fr 100px; }
  .editor-meal-head .editor-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .editor-item { grid-template-columns: 1fr 1fr; }
  .editor-item .subs { grid-column: 1 / -1; }
  .editor-item .editor-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .hbar { grid-template-columns: 96px 1fr 44px; gap: 8px; font-size: .82rem; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { max-height: 92vh; border-radius: 22px 22px 0 0; }
  .page-head { margin: 8px 0 16px; }
  .bubble { max-width: 88%; }
  .hero-num { font-size: 2.4rem; }
  .hero-trophy { display: none; }
}

/* ---------- Impressão (relatórios e plano alimentar) ---------- */
@media print {
  body { background: #fff; font-size: 12px; }
  .sidebar, .topbar, .bottom-nav, .no-print, .toasts, .btn, .icon-btn, .tabs, .filters { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; border-color: #ddd; }
  .print-only { display: block !important; }
  .diet-meal { break-inside: avoid; }
  .card-dark { background: #fff !important; color: var(--text); border: 1px solid #ddd; }
  .card-dark h2, .card-dark h3 { color: var(--navy-900); }
  .macro { border-color: #ddd; }
}
.print-only { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
