:root {
  --bg: #eef0ea;
  --paper: #f8f9f5;
  --ink: #17241d;
  --ink-soft: #4c5750;
  --line: #d7dcd0;
  --accent: #2f6f52;
  --accent-soft: #e2ece4;
  --accent-2: #9a6a24;
  --ok: #2f8f5b;
  --ok-bg: #e3f3e9;
  --warn: #b8791f;
  --warn-bg: #faf0dd;
  --crit: #b8443a;
  --crit-bg: #fbe7e4;
  --shadow: 0 1px 2px rgba(23,36,29,0.06), 0 4px 14px rgba(23,36,29,0.05);
  --radius: 10px;
  --sidebar-w: 232px;
}
:root[data-theme="dark"] {
  --bg: #101512; --paper: #161d19; --ink: #e7ece6; --ink-soft: #a3ada4; --line: #263029;
  --accent: #59ac82; --accent-soft: #1c2b22; --accent-2: #cf9d4e;
  --ok: #59ac82; --ok-bg: #17281f; --warn: #d6a03f; --warn-bg: #2c2313;
  --crit: #dd7368; --crit-bg: #2f1a17; --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101512; --paper: #161d19; --ink: #e7ece6; --ink-soft: #a3ada4; --line: #263029;
    --accent: #59ac82; --accent-soft: #1c2b22; --accent-2: #cf9d4e;
    --ok: #59ac82; --ok-bg: #17281f; --warn: #d6a03f; --warn-bg: #2c2313;
    --crit: #dd7368; --crit-bg: #2f1a17; --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.35);
  }
}
* { box-sizing: border-box; }
html, body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.5;
}
h1, h2, h3 { font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif; font-weight: 600; text-wrap: balance; margin: 0; color: var(--ink); }
.mono, .num, td.num, input[type="number"] { font-family: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums; }
button, input, select { font-family: inherit; font-size: 14px; color: var(--ink); }
a { color: var(--accent); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); width: 100%; max-width: 380px; padding: 32px 30px;
}
.login-card .mark {
  width: 42px; height: 42px; border-radius: 10px;
  background: linear-gradient(155deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: Georgia, serif; font-weight: 700; font-size: 20px; margin-bottom: 16px;
}
.login-card h1 { font-size: 21px; margin-bottom: 4px; }
.login-card p.sub { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 22px; }
.link-btn {
  display: block; width: 100%; text-align: center; background: none; border: none;
  color: var(--accent); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 12px 0 0;
}
.link-btn:hover { text-decoration: underline; }

.aviso-membro {
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 14px; font-size: 12.5px; font-weight: 600;
  margin-bottom: 18px;
}
.login-error {
  background: var(--crit-bg); color: var(--crit); border-radius: 8px; padding: 9px 12px;
  font-size: 13px; margin-bottom: 14px; display: none;
}
.login-error.show { display: block; }

.app { display: none; flex: 0; min-height: 100vh; }
.app.active { display: flex; width: 100%; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--paper); border-right: 1px solid var(--line);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; position: relative; }
.brand-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(155deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: Georgia, serif; font-weight: 700; font-size: 17px;
}
.brand h1 { font-size: 17px; letter-spacing: 0.2px; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }

.bell-btn {
  position: relative; background: none; border: 1px solid var(--line); border-radius: 8px;
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 15px;
}
.bell-btn:hover { background: var(--accent-soft); }
.bell-badge {
  position: absolute; top: -5px; right: -5px; background: var(--crit); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
  font-family: ui-monospace, monospace;
}

.alertas-panel {
  display: none; position: fixed; top: 16px; left: 250px; z-index: 60;
  width: 340px; max-height: 70vh; overflow-y: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.alertas-panel.open { display: block; }
.alertas-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.alertas-head h3 { font-size: 14.5px; }
.alertas-body { padding: 6px 0; }
.alerta-item { display: flex; flex-direction: column; gap: 3px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.alerta-item:last-child { border-bottom: none; }
.alerta-item .linha1 { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.alerta-item .cliente { font-weight: 600; }
.alerta-item .titulo { color: var(--ink-soft); font-size: 12.5px; }
@media (max-width: 880px) { .alertas-panel { left: 16px; right: 16px; width: auto; } }

.setor-atual {
  margin: 4px 10px 10px; padding: 5px 10px; border-radius: 7px;
  background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px; text-align: center;
}
nav { display: flex; flex-direction: column; gap: 2px; }
.nav-btn {
  display: flex; align-items: center; gap: 10px; text-align: left; background: none; border: none;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--ink-soft); font-size: 13.5px; font-weight: 500;
}
.nav-btn .ico { width: 17px; text-align: center; opacity: 0.9; }
.nav-btn:hover { background: var(--accent-soft); color: var(--ink); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-btn .count { margin-left: auto; font-size: 11px; font-family: ui-monospace, monospace; background: var(--line); color: var(--ink-soft); padding: 1px 6px; border-radius: 20px; }
.nav-btn.active .count { background: var(--accent); color: #fff; }

.sidebar-footer { margin-top: auto; padding: 0 10px; font-size: 11.5px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 10px; }
.who { display: flex; align-items: center; gap: 8px; padding: 8px; background: var(--bg); border-radius: 8px; }
.who .initials {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.who .info { overflow: hidden; }
.who .name { font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .role { font-size: 10.5px; color: var(--ink-soft); }
.theme-toggle { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.theme-toggle button { flex: 1; border: none; background: none; padding: 5px 0; border-radius: 6px; cursor: pointer; font-size: 11.5px; color: var(--ink-soft); }
.theme-toggle button.on { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }

main { flex: 1; padding: 30px 38px 60px; max-width: 1180px; }
.page { display: none; }
.page.active { display: block; }
/* Página que embute uma ferramenta cheia (com seu próprio layout/rolagem) —
   anula o padding e o max-width do <main> pra ela ocupar o espaço inteiro. */
.page.page-iframe.active { display: flex; margin: -30px -38px -60px; height: 100%; }
.page-iframe-frame { flex: 1; width: 100%; height: 100%; border: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h2 { font-size: 24px; }
.page-head .sub { color: var(--ink-soft); font-size: 13.5px; margin-top: 4px; }

.btn { background: var(--accent); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; font-weight: 600; font-size: 13.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { filter: brightness(1.06); }
.btn.secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost { background: none; border: 1px solid var(--line); color: var(--ink-soft); padding: 6px 10px; font-size: 12.5px; }
.btn.danger { background: var(--crit); }
.btn.block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: 0.6; cursor: default; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.stat-card .label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-family: ui-monospace, monospace; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-card .value.crit { color: var(--crit); } .stat-card .value.warn { color: var(--accent-2); } .stat-card .value.ok { color: var(--ok); }
.stat-card .hint { font-size: 12px; color: var(--ink-soft); }

.overview-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.panel-head h3 { font-size: 14.5px; }
.panel-body { padding: 4px 0; }
.empty-state { padding: 32px 18px; text-align: center; color: var(--ink-soft); font-size: 13.5px; }
.empty-state .big { font-size: 26px; display: block; margin-bottom: 8px; }

.row-item { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.row-item:last-child { border-bottom: none; }
.row-item .name { font-weight: 600; }
.row-item .meta { color: var(--ink-soft); font-size: 12px; margin-left: auto; text-align: right; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.crit { background: var(--crit-bg); color: var(--crit); }
.pill.neutral { background: var(--line); color: var(--ink-soft); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search { flex: 1; min-width: 180px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
select.filter { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--ink-soft); padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--bg); white-space: nowrap; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--accent-soft); }
tr.grupo-linha td { background: var(--bg); font-weight: 700; font-size: 12.5px; color: var(--ink-soft); padding: 8px 14px; }
tr.grupo-linha:hover { background: var(--bg); }
tr.grupo-linha .count { font-weight: 600; color: var(--accent); }
td.actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 12px; color: var(--ink-soft); }
.icon-btn:hover { color: var(--ink); border-color: var(--ink-soft); }
.icon-btn.danger:hover { color: var(--crit); border-color: var(--crit); }

.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 20, 17, 0.45); align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--paper); border-radius: 14px; border: 1px solid var(--line); width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.modal.modal-wide { max-width: 720px; }
.tabs { display: flex; gap: 2px; padding: 0 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab-btn { background: none; border: none; border-bottom: 2px solid transparent; padding: 11px 12px; font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer; white-space: nowrap; }
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; flex-direction: column; gap: 14px; }
.tab-content.active { display: flex; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--ink-soft); line-height: 1; }
.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: var(--bg); color: var(--ink); }
.field textarea { resize: vertical; min-height: 60px; font-family: inherit; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-hint { font-size: 11.5px; color: var(--ink-soft); }
.field-hint-warn { color: var(--warn); font-weight: 600; }
.checklist { display: flex; flex-direction: column; gap: 9px; }
.checklist label { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink); font-weight: 400; }
.checklist input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.data-limite-box {
  background: var(--accent-soft); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; font-size: 13px;
}
.data-limite-box .valor { font-family: ui-monospace, monospace; font-weight: 700; color: var(--accent); font-size: 14px; }
.modal-foot { padding: 16px 22px 20px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); }

.toast-wrap { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); }
:root[data-theme="dark"] .toast, @media (prefers-color-scheme: dark) { }
.toast.error { background: var(--crit); color: #fff; }

/* Calendário */
.cal-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cal-titulo { font-size: 14px; min-width: 150px; text-align: center; }
.cal-legend { display: flex; gap: 14px; margin-bottom: 14px; }
.cal-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }
.cal-tag::before { content: ""; width: 9px; height: 9px; border-radius: 3px; }
.cal-tag.prazo::before { background: var(--accent); }
.cal-tag.documento::before { background: var(--accent-2); }
.cal-tag.honorario::before { background: var(--crit); }
.cal-tag.rescisao::before { background: #6a5acd; }
.cal-tag.ferias::before { background: #1a9e7a; }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.cal-dow { background: var(--bg); padding: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--ink-soft); text-align: center; }
.cal-day {
  background: var(--paper); min-height: 92px; padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.cal-day.out { background: var(--bg); opacity: 0.5; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day .num { font-size: 11.5px; font-family: ui-monospace, monospace; color: var(--ink-soft); font-weight: 600; }
.cal-day.today .num { color: var(--accent); }
.cal-event {
  font-size: 10.5px; padding: 2px 5px; border-radius: 5px; color: #fff; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; cursor: default;
}
.cal-event.prazo { background: var(--accent); }
.cal-event.documento { background: var(--accent-2); }
.cal-event.honorario { background: var(--crit); }
.cal-event.rescisao { background: #6a5acd; }
.cal-event.ferias { background: #1a9e7a; }
.cal-more { font-size: 10.5px; color: var(--ink-soft); }
@media (max-width: 880px) {
  .cal-grid { grid-template-columns: repeat(7, minmax(60px,1fr)); overflow-x: auto; }
}

/* Botão flutuante de rescisão rápida */
.fab-rescisao {
  position: fixed;
  bottom: 22px;
  right: 26px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: 30px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0,0,0,0.22);
}
.fab-rescisao:hover { filter: brightness(1.07); transform: translateY(-1px); }
.fab-rescisao .fab-ico { font-size: 14px; }
@media (max-width: 880px) {
  .fab-rescisao { bottom: 14px; right: 14px; padding: 11px 16px; font-size: 12.5px; }
}

::placeholder { color: var(--ink-soft); opacity: 0.7; }

@media (max-width: 880px) {
  .sidebar { position: static; height: auto; width: 100%; flex-direction: row; overflow-x: auto; }
  .app.active { flex-direction: column; }
  nav { flex-direction: row; }
  .sidebar-footer { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .overview-cols { grid-template-columns: 1fr; }
  main { padding: 20px; }
}
