:root {
  /* Identidade visual Veredas: verde-musgo, rosé e creme */
  --veredas-green: #505e4f; --veredas-green-dark: #434f42; --veredas-rose: #eec9c0; --veredas-cream: #f7ebe3;
  --bg: #f8f3ef; --surface: #ffffff; --surface-2: #fbf7f4; --ink: #2f372e; --muted: #6f756c; --line: #ebe1da;
  --brand: #505e4f; --brand-ink: #ffffff; --brand-soft: #e7ece5; --accent: #eec9c0; --accent-soft: #f8e6e1;
  --warn: #a0662a; --warn-soft: #f9ecdc; --danger: #a8483f; --danger-soft: #f8e2de; --ok: #4f7a4c; --ok-soft: #e4efe1;
  --info: #56707f; --info-soft: #e5edf1;
  --radius: 12px; --shadow: 0 1px 2px rgba(80, 94, 79, .06), 0 4px 14px rgba(80, 94, 79, .05);
  --serif: "EB Garamond", "Cormorant Garamond", Garamond, Georgia, "Times New Roman", serif;
  --sans: "Open Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-family: var(--sans); color: var(--ink); font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.45; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.2; font-family: var(--serif); font-weight: 600; color: var(--veredas-green-dark); }
h1 { font-size: 1.9rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.12rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* layout */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--veredas-green); color: var(--veredas-cream); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { text-align: center; padding: 6px 10px 18px; color: var(--veredas-cream); border-bottom: 1px solid rgba(238,201,192,.25); margin-bottom: 6px; }
.side .brand img { width: 92px; height: auto; display: block; margin: 0 auto 6px; }
.side .brand small { display: block; color: var(--veredas-rose); font-size: .78rem; letter-spacing: .04em; }
.side nav a { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--veredas-cream); text-decoration: none; margin-bottom: 2px; }
.side nav a:hover { background: rgba(238,201,192,.12); }
.side nav a.active { background: var(--veredas-rose); color: var(--veredas-green-dark); font-weight: 600; }
.side .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(238,201,192,.75); margin: 14px 10px 6px; }
.side .user { border-top: 1px solid rgba(238,201,192,.25); margin-top: 16px; padding: 12px 10px 0; font-size: .85rem; color: var(--veredas-cream); }
.side .user button { margin-top: 8px; }
.main { padding: 24px 28px 60px; min-width: 0; }
.topbar { display: none; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.export-bar { display: flex; gap: 6px; margin-left: auto; }
.export-bar button { font-size: 13px; padding: 6px 12px; }
.page-head .toolbar + .export-bar, .page-head button + .export-bar { margin-left: 0; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid.k4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); }
@media (max-width: 520px) { .grid.c2 { grid-template-columns: 1fr; } }
.kpi .label { color: var(--muted); font-size: .82rem; }
.kpi .value { font-size: 1.7rem; font-weight: 600; font-family: var(--serif); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--brand); }
.card.accent { border-top: 4px solid var(--accent); }

/* tabela */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* formulários */
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 7px 12px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: #c9c6bc; }
button.primary, .btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.primary:hover { filter: brightness(1.07); }
button.danger { color: var(--danger); }
button.ok { color: var(--ok); }
button.sm, .btn.sm { padding: 3px 8px; font-size: .85rem; }
button:disabled { opacity: .5; cursor: default; }
.side button { background: transparent; color: var(--veredas-cream); border-color: rgba(238,201,192,.4); }
.side button:hover { border-color: var(--veredas-rose); }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
label > input, label > select, label > textarea { margin-top: 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--brand); }
input[type=checkbox] { width: auto; margin-right: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > * { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 2px; margin: 0 0 12px; }
legend { font-size: .82rem; color: var(--muted); padding: 0 4px; }

/* badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--line); color: var(--ink); white-space: nowrap; }
.b-pendente { background: var(--warn-soft); color: var(--warn); }
.b-confirmada { background: var(--brand-soft); color: var(--brand); }
.b-realizada, .b-ok, .b-pago { background: var(--ok-soft); color: var(--ok); }
.b-faltou, .b-comprar, .b-vencido { background: var(--danger-soft); color: var(--danger); }
.b-cancelada, .b-recusada, .b-expirada { background: #ecebe7; color: #7b7a74; }
.b-atencao, .b-aberto { background: var(--warn-soft); color: var(--warn); }
.nav-count { background: var(--veredas-rose); color: var(--veredas-green-dark); border-radius: 99px; padding: 0 7px; font-size: .75rem; font-weight: 700; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(47, 55, 46, .5); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; border-top: 5px solid var(--accent); width: 100%; max-width: 640px; padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.modal .actions .spacer { flex: 1; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--veredas-green); color: var(--veredas-cream); padding: 10px 16px; border-radius: 8px; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--danger); }

/* agenda semanal */
.week { display: grid; grid-template-columns: 56px repeat(var(--days), minmax(110px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.week-scroll { overflow-x: auto; }
.week .wh { padding: 8px 6px; text-align: center; font-size: .82rem; font-weight: 600; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.week .wh.today { color: var(--veredas-green-dark); background: var(--accent-soft); }
.week .wh small { display: block; color: var(--muted); font-weight: 400; }
.week .times { position: relative; border-right: 1px solid var(--line); }
.week .times div { position: absolute; right: 6px; font-size: .72rem; color: var(--muted); transform: translateY(-50%); }
.week .col { position: relative; border-right: 1px solid var(--line); background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour) - 1px), var(--line) calc(var(--hour) - 1px), var(--line) var(--hour)); cursor: copy; }
.week .col:last-child { border-right: 0; }
.ev { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 3px 6px; font-size: .76rem; color: #fff; overflow: hidden; cursor: pointer; line-height: 1.25; border-left: 4px solid rgba(0,0,0,.18); }
.ev.pendente { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.28) 0 6px, transparent 6px 12px); outline: 2px dashed #c98b7d; }
.ev.cancelada, .ev.recusada, .ev.expirada { opacity: .4; text-decoration: line-through; }
.ev.faltou { opacity: .7; }
.ev.block { background: repeating-linear-gradient(45deg, #d9cfc8 0 6px, #e8dfd9 6px 12px); color: #4a4a44; cursor: default; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #c98b7d; z-index: 2; pointer-events: none; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--veredas-green); }
.login .logo { display: block; width: 150px; margin: 0 auto 18px; }
.login h1 { text-align: center; }
.login .card { width: 100%; max-width: 380px; padding: 28px; border: 0; border-top: 5px solid var(--accent); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; height: 100vh; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--veredas-green); color: var(--veredas-cream); font-family: var(--serif); font-size: 1.15rem; position: sticky; top: 0; z-index: 30; }
  .topbar button { background: transparent; color: var(--veredas-cream); border-color: rgba(238,201,192,.4); font-family: var(--sans); }
  .topbar img { height: 28px; }
  .main { padding: 16px 16px 60px; }
}
@media print {
  .side, .topbar, .toolbar, button { display: none !important; }
  .app { display: block; } .card { box-shadow: none; }
}

/* abas e prontuário */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 16px; text-decoration: none; color: var(--muted); border-radius: 8px 8px 0 0; margin-bottom: -2px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); background: var(--surface-2); }
.tabs a.active { color: var(--veredas-green-dark); border-bottom-color: var(--accent); font-weight: 600; background: var(--surface); }
.evo { border-left: 3px solid var(--accent); padding: 8px 12px; margin-bottom: 12px; background: var(--surface-2); border-radius: 0 8px 8px 0; }
.evo-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.evo-head button { margin-left: auto; }
.evo-body { white-space: normal; }
