/* ---------------------------------------------------------------------------
   Estilo base do sistema. Sem framework — variáveis CSS + layout simples.
   --------------------------------------------------------------------------- */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2f6f7e;
  --primary-d: #285f6c;
  --primary-soft: #e6f0f1;
  --ok: #2e7d5b;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* -- Topbar / nav -- */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 1.25rem; height: 56px; position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.mainnav a {
  color: var(--muted); padding: .4rem .7rem; border-radius: 8px; font-weight: 500;
}
.mainnav a:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.mainnav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.userbox { display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.user-nome { font-weight: 600; }
.user-papel {
  background: var(--bg); color: var(--muted); padding: .1rem .5rem;
  border-radius: 999px; font-size: .72rem; text-transform: capitalize;
}

.content { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem; }

/* -- Cabeçalho de página -- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.4rem; margin: 0; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* -- Botões -- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .5rem .9rem; border-radius: 8px; font-size: .9rem; font-weight: 600;
  font-family: inherit; line-height: 1; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-d); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--ghost { background: transparent; }
.btn--sm { padding: .3rem .6rem; font-size: .8rem; }

/* -- Cards / tabelas -- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card-pad { padding: 1.1rem; }

table.grid { width: 100%; border-collapse: collapse; background: var(--surface); }
table.grid th, table.grid td { padding: .65rem .8rem; text-align: left; border-bottom: 1px solid var(--border); }
table.grid th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: #fafbfd; }
.text-right { text-align: right !important; }
.muted { color: var(--muted); }

/* -- Stat cards -- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.stat .label { font-size: .8rem; color: var(--muted); }
.stat .value { font-size: 1.5rem; font-weight: 700; margin-top: .2rem; }
.value--ok { color: var(--ok); } .value--danger { color: var(--danger); }

/* -- Badges de status / pago -- */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .73rem; font-weight: 600; }
.badge--agendado { background: #eef2ff; color: #4338ca; }
.badge--confirmado { background: #ecfeff; color: #0e7490; }
.badge--realizado { background: #f0fdf4; color: #15803d; }
.badge--faltou { background: #fef2f2; color: #b91c1c; }
.badge--cancelado { background: #f1f5f9; color: #64748b; }
.badge--pago { background: #dcfce7; color: #166534; }
.badge--readonly { background: #f1f5f9; color: #64748b; }

/* -- Forms -- */
.form-row { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
label { font-size: .82rem; font-weight: 600; color: #334155; }
.input, select.input, textarea.input {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px;
  font-size: .9rem; font-family: inherit; background: #fff; color: var(--text);
}
.input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea.input { resize: vertical; min-height: 70px; }

/* -- Dialog / drawer -- */
dialog {
  border: none; border-radius: 12px; padding: 0; box-shadow: 0 20px 50px rgba(2,6,23,.25);
  width: min(560px, 94vw); color: var(--text);
}
dialog::backdrop { background: rgba(15,23,42,.4); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); }
.dialog-head h3 { margin: 0; font-size: 1.05rem; }
.dialog-body { padding: 1.2rem; }
.dialog-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.2rem; border-top: 1px solid var(--border); }
.x { cursor: pointer; border: none; background: none; font-size: 1.3rem; color: var(--muted); line-height: 1; }

/* -- Toast -- */
.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%) translateY(2rem);
  background: #0f172a; color: #fff; padding: .7rem 1.1rem; border-radius: 8px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: 90vw;
}
.toast--show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--erro { background: var(--danger); }
.toast--ok { background: var(--ok); }

/* -- Auth -- */
.auth-body { display: grid; place-items: center; min-height: 100vh; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 2rem; width: min(380px, 92vw); }
.auth-card h1 { font-size: 1.3rem; margin: 0 0 1.25rem; text-align: center; }
.auth-error { color: var(--danger); font-size: .85rem; margin: .2rem 0 0; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: .4rem; }

/* -- Calendário (agenda) -- */
.cal { display: grid; grid-template-columns: 56px repeat(6, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cal-head { background: #f8fafc; border-bottom: 1px solid var(--border); padding: .5rem; text-align: center; font-size: .8rem; font-weight: 600; }
.cal-head .dow { color: var(--muted); font-weight: 500; text-transform: uppercase; font-size: .68rem; }
.cal-hour { border-right: 1px solid var(--border); border-bottom: 1px solid #f1f5f9; font-size: .72rem; color: var(--muted); text-align: right; padding: 2px 6px; height: 44px; }
.cal-cell { border-right: 1px solid #f1f5f9; border-bottom: 1px solid #f1f5f9; height: 44px; position: relative; cursor: pointer; }
.cal-cell:hover { background: #f8fafc; }
.cal-ev {
  position: absolute; left: 2px; right: 2px; border-radius: 6px; padding: 2px 5px; overflow: hidden;
  font-size: .73rem; color: #fff; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.15); z-index: 2;
}
.cal-ev .ev-pac { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev .ev-proc { opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev .ev-pago { position: absolute; top: 2px; right: 3px; font-size: .7rem; }
.cal-ev[data-status="cancelado"] { opacity: .45; text-decoration: line-through; }

.flex { display: flex; gap: .5rem; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .cal { grid-template-columns: 44px repeat(6, 1fr); font-size: .9em; }
}
