:root {
  --blue: #0a55f0;
  --blue-dark: #0b3fb8;
  --cyan: #00c8f0;
  --ink: #13233f;
  --muted: #63708a;
  --line: #e2e8f2;
  --bg: #f4f7fc;
  --card: #ffffff;
  --ok: #138a5b;
  --warn: #b7791f;
  --danger: #c2333c;
  --app: var(--blue);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(19, 35, 63, .06), 0 4px 16px rgba(19, 35, 63, .05);
  font-family: Lato, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--blue); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; }
.brand-logo { height: 30px; width: auto; }
.brand-app { font-weight: 700; font-size: 1.15rem; color: var(--app); border-left: 1px solid var(--line); padding-left: .6rem; }
.appnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.appnav a {
  display: flex; align-items: center; gap: .4rem; padding: .4rem .7rem; border-radius: 10px;
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem;
}
.appnav a:hover { background: var(--bg); }
.appnav a.active { background: color-mix(in srgb, var(--app) 12%, white); color: var(--app); }
.nav-icon { width: 22px; height: 22px; border-radius: 6px; }

/* ---------- Layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; }
.split { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 1rem; align-items: start; }
@media (max-width: 820px) { .split { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: .75rem; }

/* ---------- Controls ---------- */
.btn {
  font: inherit; font-weight: 600; font-size: .92rem; padding: .55rem .95rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; gap: .35rem; text-decoration: none;
}
.btn:hover { border-color: #c5d0e2; }
.btn-primary { background: var(--app); border-color: var(--app); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--app); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: .3rem .6rem; font-size: .82rem; }
.btn-link { border: 0; background: none; color: var(--app); padding: .2rem; }
input, select, textarea {
  font: inherit; width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--app) 45%, white); outline-offset: 1px; }
.search { max-width: 320px; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  padding: .75rem .8rem; border-radius: 10px; cursor: pointer; border: 1px solid transparent;
}
.list-item:hover { background: var(--bg); }
.list-item.selected { border-color: color-mix(in srgb, var(--app) 40%, white); background: color-mix(in srgb, var(--app) 6%, white); }
.list-item .title { font-weight: 700; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--app), var(--cyan));
}
.row { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; background: color-mix(in srgb, var(--app) 12%, white); color: var(--app); margin: 0 .25rem .25rem 0; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: .2rem .55rem; border-radius: 999px; background: #eef2f8; color: var(--muted); white-space: nowrap; }
.badge-rascunho { background: #eef2f8; color: #52607a; }
.badge-enviado, .badge-marcada { background: #e6f0ff; color: #1d4fbf; }
.badge-aprovado, .badge-confirmada, .badge-concluida { background: #e2f5ec; color: var(--ok); }
.badge-recusado, .badge-cancelada, .badge-falta { background: #fbe9ea; color: var(--danger); }

.kpi.selected { border-color: var(--app); box-shadow: 0 0 0 2px color-mix(in srgb, var(--app) 25%, white); }

dl.details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
dl.details dt { color: var(--muted); font-size: .88rem; }
dl.details dd { margin: 0; overflow-wrap: anywhere; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; white-space: nowrap; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--bg); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty p { margin-bottom: 1rem; }

/* ---------- Dialogs & toasts ---------- */
.dialog { border: 0; border-radius: var(--radius); padding: 1.3rem; width: min(440px, 94vw); box-shadow: 0 20px 60px rgba(19, 35, 63, .25); }
.dialog-wide { width: min(640px, 96vw); }
.dialog::backdrop { background: rgba(19, 35, 63, .4); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: 1rem 0; }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 600; color: var(--muted); }
.field.full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.form-error { color: var(--danger); font-weight: 600; min-height: 1.2em; margin: 0; }
.actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); z-index: 100;
  background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow);
}
.toast-error { background: var(--danger); }

/* ---------- Print (quote PDF) ---------- */
.print-only { display: none; }
@media print {
  @page { margin: 16mm; }
  body { background: #fff; }
  .topbar, .no-print, .toast, dialog { display: none !important; }
  .print-only { display: block; }
  main { padding: 0; max-width: none; }
}
