:root {
  --bg: #f7f2ee;
  --surface: #ffffff;
  --surface-2: #fbf8f6;
  --ink: #2a2220;
  --ink-2: #5c4f4a;
  --muted: #8d7f79;
  --line: #ebe2dc;
  --primary: #9a5f4e;
  --primary-ink: #ffffff;
  --primary-soft: #f3e6e0;
  --primary-dark: #7d4a3c;
  --gold: #b8935f;
  --ok: #3f7d5c;
  --ok-soft: #e3f0e8;
  --warn: #b07a1f;
  --warn-soft: #f8edd8;
  --bad: #b2453b;
  --bad-soft: #f8e1de;
  --info: #3d6a8c;
  --info-soft: #e1ecf4;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(60, 35, 25, .05), 0 6px 24px rgba(60, 35, 25, .06);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; margin: 0; color: var(--ink); }
h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

/* ---------- Botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 9px 15px; border-radius: 999px; cursor: pointer; font-weight: 500; font-size: 14px; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: #d9cbc3; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: #eac3be; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.wa { background: #1f9e5b; border-color: #1f9e5b; color: #fff; }
.btn.wa:hover { background: #188049; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.icon-btn { border: 0; background: transparent; padding: 6px; border-radius: 8px; cursor: pointer; color: var(--ink-2); display: inline-flex; }
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }

/* ---------- Formulários ---------- */
label { display: block; font-size: 13px; color: var(--ink-2); font-weight: 500; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=search], input[type=month], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; min-height: 42px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); font-weight: 400; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid .field { margin-bottom: 0; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------- Layout do app ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; font-family: var(--serif); font-size: 19px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), var(--gold)); display: grid; place-items: center; color: #fff; font-size: 16px; flex: none; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 14.5px; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--primary-soft); color: var(--primary-dark); }
.nav svg { width: 19px; height: 19px; flex: none; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.side-foot strong { color: var(--ink); display: block; font-weight: 600; }
.main { min-width: 0; padding: 26px 32px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.banner { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-radius: var(--radius); background: var(--warn-soft); color: #6b4a12; margin-bottom: 18px; font-size: 14px; flex-wrap: wrap; }
.banner.info { background: var(--info-soft); color: #234a66; }
.banner.bad { background: var(--bad-soft); color: #7a2b23; }
.mobile-top, .bottom-nav { display: none; }

/* ---------- Cartões ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { font-size: 16.5px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-family: var(--serif); font-size: 26px; margin-top: 4px; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; font-size: 14px; }

/* ---------- Listas e tabelas ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; }
.list-item .meta { font-size: 13px; color: var(--muted); }
.time-pill { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; min-width: 56px; text-align: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.rank { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--ink-2); }
tr.sel td { background: var(--primary-soft) !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.tag.agendado { background: var(--info-soft); color: var(--info); border-color: transparent; }
.tag.confirmado { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.realizado { background: #ece6f3; color: #5d4a80; border-color: transparent; }
.tag.faltou { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.cancelado { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.tag.pago { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.pendente { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.atrasado { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 340px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { white-space: nowrap; border: 0; background: transparent; padding: 6px 13px; border-radius: 999px; cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.seg button.on { background: var(--primary); color: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; cursor: pointer; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--primary-dark); border-bottom-color: var(--primary); }

/* ---------- Agenda ---------- */
.cal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-title { font-family: var(--serif); font-size: 20px; min-width: 200px; }
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cal-scroll { overflow: auto; max-height: calc(100vh - 210px); }
.cal-grid { display: grid; position: relative; min-width: 720px; }
.cal-grid.day { min-width: 0; }
.cal-dayhead { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: center; font-size: 12.5px; color: var(--muted); text-transform: capitalize; }
.cal-dayhead b { display: block; font-family: var(--serif); font-size: 19px; color: var(--ink); font-weight: 500; }
.cal-dayhead.today b { color: #fff; background: var(--primary); border-radius: 50%; width: 32px; height: 32px; line-height: 32px; margin: 1px auto 0; }
.cal-hours { border-right: 1px solid var(--line); }
.cal-hour { height: 56px; font-size: 11.5px; color: var(--muted); text-align: right; padding: 2px 8px 0 0; font-variant-numeric: tabular-nums; }
.cal-col { position: relative; border-right: 1px solid var(--line); }
.cal-col:last-child { border-right: 0; }
.cal-slot { height: 28px; border-bottom: 1px dashed #f1e9e4; cursor: pointer; }
.cal-slot:nth-child(2n) { border-bottom: 1px solid var(--line); }
.cal-slot:hover { background: var(--primary-soft); }
.cal-col.today { background: #fdf9f7; }
.appt { position: absolute; left: 3px; right: 3px; border-radius: 8px; padding: 4px 7px; font-size: 12px; line-height: 1.3; overflow: hidden; cursor: pointer; color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15); border-left: 4px solid rgba(0,0,0,.18); z-index: 2; }
.appt b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt span { opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.appt.cancelado { opacity: .45; text-decoration: line-through; }
.appt.faltou { opacity: .6; }
.appt.realizado::after { content: '✓'; position: absolute; top: 3px; right: 6px; font-weight: 700; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); z-index: 4; pointer-events: none; }
.now-line::before { content: ''; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(42, 30, 26, .38); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; animation: fade .15s ease; backdrop-filter: blur(2px); }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(40, 20, 10, .25); animation: rise .18s ease; }
.modal.wide { max-width: 880px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 22px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.section-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 6px; margin-bottom: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); animation: rise .2s ease; }
.toast.err { background: var(--bad); }

/* ---------- Autocompletar ---------- */
.ac { position: relative; }
.ac-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 10; max-height: 260px; overflow-y: auto; }
.ac-list div { padding: 9px 12px; cursor: pointer; font-size: 14px; }
.ac-list div:hover, .ac-list div.on { background: var(--primary-soft); }
.ac-list small { color: var(--muted); margin-left: 6px; }

/* ---------- Ficha ---------- */
.profile-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); display: grid; place-items: center; font-family: var(--serif); font-size: 22px; flex: none; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.photo { position: relative; border-radius: 12px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); aspect-ratio: 3/4; cursor: pointer; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; background: linear-gradient(transparent, rgba(0,0,0,.6)); color: #fff; font-size: 12px; }
.photo input[type=checkbox] { position: absolute; top: 8px; left: 8px; width: 20px; height: 20px; accent-color: var(--primary); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare img { width: 100%; border-radius: 10px; }

/* ---------- Assinatura do termo ---------- */
.term-text { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 18px; font-size: 14.5px; max-height: 42vh; overflow-y: auto; line-height: 1.6; }
.sig-pad { border: 2px dashed #d8c7bd; border-radius: 12px; background: #fff; touch-action: none; width: 100%; height: 190px; display: block; cursor: crosshair; }

/* ---------- Gráfico simples ---------- */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 160px; padding-top: 10px; }
.bar-g { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-pair { display: flex; gap: 4px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bar { width: 40%; max-width: 26px; border-radius: 5px 5px 0 0; min-height: 2px; }
.bar.r { background: var(--primary); }
.bar.d { background: #d9c3b8; }
.bar-g small { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }
.vbars { display: flex; gap: 14px; align-items: flex-end; height: 260px; overflow-x: auto; padding-top: 4px; }
.vbar { flex: 1; min-width: 74px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.vbar-val { font-size: 12.5px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vbar-val small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; }
.vbar-col { flex: 1; width: 60%; max-width: 54px; display: flex; align-items: flex-end; margin: 6px 0; }
.vbar-col div { width: 100%; border-radius: 7px 7px 0 0; }
.vbar-lbl { font-size: 12px; color: var(--ink-2); text-align: center; line-height: 1.25; height: 30px; overflow: hidden; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: flex; align-items: center; gap: 10px; font-size: 13.5px; margin-bottom: 9px; }
.hbar .lbl { width: 42%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.hbar .track { flex: 1; background: var(--surface-2); border-radius: 99px; height: 8px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--primary); border-radius: 99px; }
.hbar.wide .v { width: 150px; white-space: nowrap; }
.hbar .v { width: 92px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-art { background: linear-gradient(160deg, #e9d6cc 0%, #c9a28f 55%, #9a5f4e 100%); position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; padding: 48px; color: #fff; }
.auth-art h2 { color: #fff; font-size: 34px; max-width: 420px; line-height: 1.15; }
.auth-art p { max-width: 400px; opacity: .92; }
.auth-art .orb { position: absolute; border-radius: 50%; background: rgba(255,255,255,.18); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form .box { width: 100%; max-width: 380px; }
.auth-form h1 { margin-bottom: 6px; }
.auth-form p.sub { color: var(--muted); margin: 0 0 24px; }
.err-box { background: var(--bad-soft); color: #7a2b23; padding: 10px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 14px 96px; }
  .mobile-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 9px; font-size: 11px; color: var(--muted); text-decoration: none; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav svg { width: 22px; height: 22px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .g2.keep { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 24px; }
  .kpi .value { font-size: 22px; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: 18px 18px 0 0; max-height: 94vh; overflow-y: auto; }
  .cal-scroll { max-height: calc(100vh - 250px); }
  .hide-m { display: none !important; }
}
@media print {
  .side, .mobile-top, .bottom-nav, .no-print { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
}
