:root {
  --blue: #0B4C8D;
  --blue2: #123E69;
  --blue3: #EAF3FB;
  --gold: #C89736;
  --gold2: #F7EAD0;
  --ink: #17324D;
  --muted: #688099;
  --line: #DBE6EF;
  --bg: #F5F8FB;
  --white: #FFFFFF;
  --danger: #B42318;
  --danger-bg: #FFF1F0;
  --warn: #A15C00;
  --warn-bg: #FFF7E8;
  --ok: #19703A;
  --ok-bg: #ECF8F0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 62, 105, .06), 0 6px 18px rgba(18, 62, 105, .05);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); font-size: 14px; line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
.hidden { display: none !important; }
.boot { padding: 48px; color: var(--muted); text-align: center; }

/* ---------- botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 6px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--white); color: var(--blue);
  font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--blue3); }
.btn:focus-visible, .field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--white); }
.btn.primary:hover { background: var(--blue2); }
.btn.danger { background: var(--danger-bg); border-color: #F5C8C3; color: var(--danger); }
.btn.danger:hover { background: #FDE2DF; }
.btn.small { min-height: 28px; padding: 3px 11px; font-size: 12px; border-radius: 9px; }
.btn[disabled] { opacity: .55; cursor: progress; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  border: 1px solid #CFDEE9; border-radius: 10px; padding: 9px 11px; background: var(--white); width: 100%;
}
.field textarea { min-height: 84px; resize: vertical; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check input { width: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.status {
  display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--blue3); color: var(--blue); white-space: nowrap;
}
.status.Concluído { background: var(--ok-bg); color: var(--ok); }
.status.Atrasado { background: var(--danger-bg); color: var(--danger); }
.status.Aguardando { background: var(--warn-bg); color: var(--warn); }
.status.Cancelado { background: #F1F1F1; color: #666; }

.bar { height: 6px; border-radius: 6px; background: #E9EFF5; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 6px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(980px, 100%); display: grid; grid-template-columns: 1fr 1.05fr;
  background: var(--white); border: 1px solid var(--line); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow);
}
.login-side { background: var(--blue); color: var(--white); padding: 40px 36px; display: flex; flex-direction: column; gap: 16px; }
.login-side .logo-box { background: var(--white); border-radius: 16px; padding: 14px 18px; align-self: flex-start; }
.login-side .logo-box img { display: block; height: 78px; }
.login-side h1 { font-size: 28px; margin: 18px 0 0; line-height: 1.2; }
.login-side p { color: #DCEAFA; margin: 0; font-size: 15px; }
.login-side .foot { margin-top: auto; color: #E7C982; font-size: 13px; }
.login-form { padding: 44px 40px; display: flex; flex-direction: column; gap: 14px; }
.login-form h2 { margin: 0; font-size: 26px; color: var(--blue2); }
.login-form .sub { margin: 0 0 6px; color: var(--muted); }
.login-form .btn { min-height: 44px; font-size: 15px; margin-top: 6px; }
.alert { padding: 10px 12px; border-radius: 10px; background: var(--danger-bg); color: var(--danger); font-size: 13px; }
.alert.info { background: var(--blue3); color: var(--blue2); }
@media (max-width: 760px) {
  .login-card { grid-template-columns: 1fr; }
  .login-side { padding: 24px; }
  .login-side h1 { font-size: 22px; margin-top: 4px; }
  .login-side .foot { display: none; }
  .login-form { padding: 26px 22px; }
}

/* ---------- estrutura principal ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.shell.collapsed { grid-template-columns: 76px 1fr; }
.sidebar {
  background: var(--white); border-right: 1px solid var(--line); padding: 18px 12px;
  display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-head { display: flex; align-items: flex-start; gap: 8px; padding: 0 4px 6px; }
.side-head .logo { flex: 1; min-width: 0; }
.side-head .logo img { width: 100%; max-width: 168px; display: block; }
.side-head .logo small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.toggle { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--white); color: var(--blue); font-weight: 700; cursor: pointer; flex: none; }
.nav-label { font-size: 11px; color: #8AA0B3; letter-spacing: .06em; padding: 10px 8px 4px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  color: var(--ink); font-weight: 600; text-decoration: none; margin-bottom: 4px;
}
.nav a .ico { width: 20px; text-align: center; flex: none; }
.nav a:hover { background: var(--blue3); }
.nav a.active { background: var(--blue); color: var(--white); }
.side-foot { margin-top: auto; padding: 12px 8px 0; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.side-foot b { color: var(--blue); font-weight: 600; }
.collapsed .side-head .logo, .collapsed .nav-label, .collapsed .nav a .txt, .collapsed .side-foot { display: none; }
.collapsed .nav a { justify-content: center; padding: 10px 0; }
.collapsed .side-head { justify-content: center; }

.main { min-width: 0; padding: 20px 26px 40px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 26px; color: var(--ink); }
.topbar .sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions select { border: 1px solid var(--line); border-radius: 11px; padding: 8px 10px; background: var(--white); color: var(--blue2); max-width: 280px; min-height: 36px; }
.userchip { border: 1px solid var(--line); border-radius: 14px; padding: 7px 12px; background: var(--white); color: var(--muted); font-size: 12px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.userchip:hover { background: var(--blue3); }

.strip {
  margin: 16px 0; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 16px 9px 20px; position: relative; display: flex; align-items: center; gap: 12px;
}
.strip::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; background: var(--gold); border-radius: 0 3px 3px 0; }
.strip .t { flex: 1; min-width: 0; }
.strip b { color: var(--blue); display: block; }
.strip small { color: var(--muted); }
.strip .online { background: var(--ok-bg); color: var(--ok); border-radius: 10px; padding: 6px 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }

.mobile-top { display: none; }
@media (max-width: 860px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; bottom: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .shell.menu-open .sidebar { transform: none; }
  .shell.collapsed .side-head .logo, .shell.collapsed .nav-label, .shell.collapsed .nav a .txt, .shell.collapsed .side-foot { display: revert; }
  .shell.collapsed .nav a { justify-content: flex-start; padding: 10px 12px; }
  .main { padding: 14px 14px 32px; }
  .mobile-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
  .mobile-top img { height: 34px; }
  .strip .online { display: none; }
  .actions select { max-width: 100%; flex: 1; }
}

/* ---------- conteúdo ---------- */
.section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 22px 0 12px; flex-wrap: wrap; }
.section-title h2 { margin: 0; font-size: 18px; color: var(--blue2); }
.section-title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.empty { background: var(--white); border: 1px dashed var(--line); border-radius: var(--radius); padding: 30px; text-align: center; color: var(--muted); }

.hero { background: var(--blue2); color: var(--white); border-radius: 18px; padding: 18px 22px; display: flex; align-items: center; gap: 18px; }
.hero .t { flex: 1; min-width: 0; }
.hero small { color: #F0D49C; font-weight: 700; letter-spacing: .05em; font-size: 11px; }
.hero h2 { margin: 4px 0; font-size: 28px; overflow: hidden; text-overflow: ellipsis; }
.hero p { margin: 0; opacity: .92; }
.hero .badge { background: var(--white); color: var(--blue); border-radius: 13px; padding: 10px 18px; text-align: center; flex: none; }
.hero .badge b { display: block; font-size: 28px; line-height: 1.1; }
@media (max-width: 600px) { .hero h2 { font-size: 21px; } .hero .badge b { font-size: 22px; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .l { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .03em; }
.kpi .v { font-size: 23px; font-weight: 700; color: var(--blue2); margin: 6px 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .s { font-size: 12px; color: var(--muted); }

.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); }
.cards.projects { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: 15px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.card .head { display: flex; align-items: flex-start; gap: 10px; }
.card .head h3 { margin: 0; font-size: 15px; flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { color: var(--muted); font-size: 12px; }
.card .money { font-size: 19px; font-weight: 700; color: var(--blue); }
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 4px; flex-wrap: wrap; }
.card .foot .btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.card.current { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue) inset; }

.table-wrap { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; color: var(--muted); letter-spacing: .03em; font-weight: 700; background: #FAFCFE; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.paid { color: var(--ok); }
td .btns { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
tfoot td { font-weight: 700; background: #FAFCFE; }

.hist { display: flex; flex-direction: column; gap: 8px; }
.hist .it { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: flex; gap: 14px; justify-content: space-between; }
.hist .it .l { min-width: 0; flex: 1; }
.hist .it b { color: var(--blue2); display: block; }
.hist .it span, .hist .it .r { color: var(--muted); font-size: 12px; }
.hist .it .r { text-align: right; flex: none; max-width: 40%; }
.hist .it .l span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .admin-grid { grid-template-columns: 1fr; } }
.list { display: flex; flex-direction: column; gap: 8px; }
.list .it { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: flex; align-items: center; gap: 12px; }
.list .it .l { flex: 1; min-width: 0; }
.list .it .l b { display: block; }
.list .it .l span { color: var(--muted); font-size: 12px; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 15px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.panel h3 { margin: 0; color: var(--blue2); font-size: 15px; }
.panel p { margin: 0; color: var(--muted); font-size: 13px; }
.panel .btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- janelas (dialog) ---------- */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  box-shadow: 0 20px 60px rgba(18, 62, 105, .25); color: var(--ink);
}
dialog.wide { width: min(1000px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(18, 40, 64, .45); }
.dlg { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 18px; color: var(--blue2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-head .x { border: 0; background: transparent; font-size: 22px; color: var(--muted); cursor: pointer; width: 34px; height: 34px; border-radius: 8px; }
.dlg-head .x:hover { background: var(--blue3); }
.dlg-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.dlg-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.dlg-foot .left { margin-right: auto; }
.dlg .alert { margin: 0; }
.drop {
  border: 2px dashed #BFD3E4; border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); background: #FAFCFE; cursor: pointer;
}
.drop.over { border-color: var(--blue); background: var(--blue3); }

/* ---------- avisos ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: var(--blue2); color: var(--white); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; max-width: 420px; }
.toast.err { background: var(--danger); }

/* ajustes finos */
td.nowrap, td .btns { white-space: nowrap; }
td .btns { flex-wrap: nowrap; }
.panel.perms { margin-top: 12px; }
.row-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 600px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .v { font-size: 18px; }
  .hist .it { flex-direction: column; gap: 4px; }
  .hist .it .r { text-align: left; max-width: none; }
  .list .it { flex-wrap: wrap; }
}
@media (max-width: 640px) {
  .table-wrap.stack thead { display: none; }
  .table-wrap.stack tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .table-wrap.stack tr:last-child { border-bottom: 0; }
  .table-wrap.stack td { display: flex; gap: 10px; padding: 3px 0; border: 0; text-align: left; }
  .table-wrap.stack td[data-label]::before { content: attr(data-label); flex: 0 0 92px; color: var(--muted); font-size: 12px; font-weight: 600; }
  .table-wrap.stack td.num { justify-content: flex-start; }
  .table-wrap.stack td .btns { justify-content: flex-start; flex-wrap: wrap; padding-top: 6px; }
}
