:root {
  --navy: #0f2747;
  --navy-2: #163a66;
  --blue: #2563c9;
  --blue-soft: #e8f0fc;
  --green: #18794e;
  --green-soft: #e6f4ec;
  --amber: #b45f06;
  --amber-soft: #fdf1e2;
  --red: #c42b2b;
  --red-soft: #fdeaea;
  --ink: #142033;
  --muted: #5d6b80;
  --line: #dfe4ec;
  --bg: #f4f6fa;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 39, 71, .06), 0 4px 16px rgba(15, 39, 71, .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 20% -10%, #24508a 0%, transparent 60%),
              linear-gradient(160deg, var(--navy) 0%, #0a1c35 100%);
}
.login-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 18px; padding: 32px 28px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.login-card .logo { display: block; width: 84px; height: 84px; margin: 0 auto 10px; border-radius: 16px; object-fit: contain; }
.login-card h1 { text-align: center; margin: 0; font-size: 26px; letter-spacing: .02em; color: var(--navy); }
.login-card .sub { text-align: center; color: var(--muted); margin: 2px 0 22px; font-size: 14px; }
.login-card label.title { display: block; font-weight: 600; font-size: 14px; margin: 0 0 8px; }
.profiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.profile {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 8px; background: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 600; min-height: 76px;
  transition: border-color .15s, background .15s;
}
.profile svg { width: 24px; height: 24px; color: var(--muted); }
.profile[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); color: var(--navy); }
.profile[aria-pressed="true"] svg { color: var(--blue); }
.pw { position: relative; }
.pw input { padding-right: 48px; }
.pw .eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none;
  width: 40px; height: 40px; border-radius: 8px; cursor: pointer; color: var(--muted); display: grid; place-items: center;
}
.pw .eye svg { width: 20px; height: 20px; }
.login-card .err { color: var(--red); font-size: 14px; min-height: 20px; margin: 8px 0 4px; }
.login-card .foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 14px; }
.linkbtn { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 6px; font-size: 14px; }
.linkbtn:hover { text-decoration: underline; }
.center { text-align: center; }

/* ---------- campos e botões ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 13.5px; font-weight: 600; }
.field small { color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=month], input[type=search], select, textarea {
  width: 100%; min-height: 44px; border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px;
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 201, .15); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 8px 16px;
  border-radius: 10px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; font-weight: 600;
  white-space: nowrap; text-decoration: none; color: var(--ink);
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { border-color: #c5cedb; background: #fafbfd; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #1f55ae; }
.btn.danger { color: var(--red); border-color: #f1c4c4; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: 13.5px; }
.btn.block { width: 100%; min-height: 50px; font-size: 16px; }
.btn[disabled] { opacity: .6; cursor: progress; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--navy); color: #dbe5f3; display: flex; flex-direction: column; padding: 18px 12px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 22px; }
.brand img { width: 44px; height: 44px; border-radius: 10px; object-fit: contain; background: #0b1d36; }
.brand b { display: block; color: #fff; font-size: 17px; letter-spacing: .02em; }
.brand small { color: #9fb2cc; font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #dbe5f3;
  text-decoration: none; font-weight: 500;
}
.nav a svg { width: 19px; height: 19px; flex: none; }
.nav a:hover { background: rgba(255, 255, 255, .07); }
.nav a.on { background: var(--blue); color: #fff; }
.side .spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; padding: 12px 8px; border-top: 1px solid rgba(255, 255, 255, .1); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--navy-2); display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }
.who b { color: #fff; display: block; font-size: 14px; }
.who small { color: #9fb2cc; font-size: 12px; }
.side .logout { color: #dbe5f3; background: none; border: 0; display: flex; gap: 10px; align-items: center; padding: 10px 8px; cursor: pointer; }
.side .logout svg { width: 18px; height: 18px; }

.main { padding: 24px 28px 48px; min-width: 0; }
.crumb { font-size: 12px; letter-spacing: .1em; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 4px 0 18px; }
.head h1 { margin: 0; font-size: 28px; color: var(--navy); }
.head p { margin: 2px 0 0; color: var(--muted); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar .period { display: flex; align-items: center; gap: 8px; }
.toolbar .period select { width: auto; min-width: 190px; }
.toolbar .grow { flex: 1; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.stat { border-top: 3px solid var(--blue); }
.stat .label { font-size: 12px; letter-spacing: .08em; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.stat .value { font-size: 28px; font-weight: 700; margin: 6px 0 2px; color: var(--blue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .hint { font-size: 13px; color: var(--muted); }
.stat.navy { border-top-color: var(--navy); } .stat.navy .value { color: var(--navy); }
.stat.green { border-top-color: var(--green); } .stat.green .value { color: var(--green); }
.stat.amber { border-top-color: var(--amber); } .stat.amber .value { color: var(--amber); }
.big-total { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; border: 1.5px solid var(--amber); background: var(--amber-soft); margin-bottom: 16px; }
.big-total .value { font-size: 30px; font-weight: 800; color: var(--amber); }
.big-total .label { font-weight: 700; color: var(--ink); }
.big-total small { color: var(--muted); }

.goal { margin-bottom: 16px; }
.goal .row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; flex-wrap: wrap; }
.bar { height: 10px; background: #e9edf3; border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), #4f8be6); border-radius: 99px; }

h2 { font-size: 18px; margin: 0 0 4px; color: var(--navy); }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head p { margin: 0; color: var(--muted); font-size: 14px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th { text-align: left; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid #edf0f5; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: #f7f9fc; }
.sub-line { color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.gray { background: #eef1f5; color: var(--muted); }
.pill.red { background: var(--red-soft); color: var(--red); }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stack > * + * { margin-top: 16px; }
.note { font-size: 13.5px; color: var(--muted); display: flex; gap: 8px; align-items: flex-start; margin: 4px 0 16px; }
.note svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--green); }

/* ---------- modal ---------- */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(10, 22, 40, .55); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 22px 6px; }
.modal-head h3 { margin: 0; font-size: 20px; color: var(--navy); }
.modal-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.modal-body { padding: 10px 22px; overflow-y: auto; max-height: calc(100dvh - 190px); }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 22px 20px; border-top: 1px solid var(--line); }
.x { border: 0; background: none; width: 38px; height: 38px; border-radius: 8px; cursor: pointer; font-size: 22px; color: var(--muted); }
.x:hover { background: #f1f3f7; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1.3fr 1.3fr .8fr; gap: 12px; }
.item-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 2px; margin-bottom: 12px; background: #fbfcfe; }
.item-box .item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 700; font-size: 14px; }
.total-box { display: flex; justify-content: space-between; align-items: center; background: var(--blue-soft); border-radius: 12px; padding: 12px 16px; margin: 4px 0 14px; }
.total-box b { font-size: 22px; color: var(--navy); }
.exo { border: 1.5px dashed #b9c6d8; border-radius: 12px; padding: 12px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: #fafcff; }
.exo small { color: var(--muted); flex: 1; min-width: 180px; }
.err-box { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; transition: .2s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); z-index: 50; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--red); }

.history-item { padding: 10px 0; border-bottom: 1px solid #edf0f5; font-size: 14px; }
.history-item:last-child { border-bottom: 0; }

/* ---------- impressão ---------- */
.print-only { display: none; }
.rec-link { font-weight: 600; color: var(--blue); text-decoration: none; white-space: nowrap; }
.rec-link:hover { text-decoration: underline; }
.print-head { display: none; align-items: center; gap: 14px; border-bottom: 2px solid var(--navy); padding-bottom: 10px; margin-bottom: 14px; }
.print-head img { width: 60px; height: 60px; border-radius: 8px; }
.print-head h1 { margin: 0; font-size: 20px; color: var(--navy); }
.print-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.signatures { display: none; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 48px; text-align: center; font-size: 12px; }
.signatures span { display: block; border-top: 1px solid #333; margin-bottom: 4px; }
.print-foot { font-size: 11px; color: var(--muted); margin-top: 14px; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .crumb, .head { display: none !important; }
  .print-head { display: flex !important; }
  .signatures { display: grid !important; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  .stat .value { font-size: 20px; }
  .card { padding: 10px 12px; margin-bottom: 10px !important; border-color: #ccc; }
  table.responsive thead { display: table-header-group !important; }
  table.responsive tr { display: table-row !important; }
  table.responsive td { display: table-cell !important; }
  table.responsive td::before { content: none !important; }
  .side, .toolbar, .no-print, #toast, .mobile-nav, .fab, .mobile-top, dialog { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .card { box-shadow: none; }
  .stat, .big-total { break-inside: avoid; }
  .print-only { display: block; }
  .cards { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- celular ---------- */
.mobile-top, .mobile-nav, .fab { display: none; }
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .main { padding: 12px 16px 96px; }
  .mobile-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; }
  .mobile-top .brand { padding: 0; }
  .mobile-top .brand img { width: 34px; height: 34px; }
  .mobile-top button { background: none; border: 0; color: #dbe5f3; display: flex; align-items: center; gap: 6px; padding: 8px; cursor: pointer; }
  .mobile-top button svg { width: 20px; height: 20px; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; padding: 4px 0; }
  .mobile-nav a svg { width: 22px; height: 22px; }
  .mobile-nav a.on { color: var(--blue); font-weight: 700; }
  .fab {
    display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 21;
    width: 58px; height: 58px; border-radius: 50%; background: var(--blue); color: #fff; border: 0; box-shadow: 0 8px 24px rgba(37, 99, 201, .45); cursor: pointer;
  }
  .fab svg { width: 26px; height: 26px; }
  .head h1 { font-size: 24px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .toolbar .period { width: 100%; }
  .toolbar .period select { flex: 1; min-width: 0; }
  .hide-m { display: none !important; }
  .section-head .toolbar { width: 100%; }
  .section-head .toolbar input, .section-head .toolbar select { width: 100% !important; flex: 1 1 100%; }
  .head .toolbar #newWork { display: none; }
  .stat .value { font-size: 22px; }
  .stat { padding: 12px 14px; }
}
@media (max-width: 520px) {
  .row2, .row3 { grid-template-columns: minmax(0, 1fr); }
  .modal-body { padding: 8px 16px; }
  .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .modal-foot { display: grid; grid-template-columns: 1fr 1fr; }
  .modal-foot .btn { width: 100%; }
  .modal-foot .btn.primary { grid-column: 1 / -1; order: -1; min-height: 50px; }
  .modal-foot #delWork, .modal-foot #delPay { grid-column: 1 / -1; order: 10; margin: 0 !important; }
  dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .modal-body { max-height: calc(100dvh - 240px); }
  table.responsive thead { display: none; }
  table.responsive tr { display: block; padding: 10px 0; border-bottom: 1px solid #edf0f5; }
  table.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 3px 4px; }
  table.responsive td::before { content: attr(data-l); color: var(--muted); font-size: 13px; font-weight: 600; }
  table.responsive td.first { display: block; font-weight: 700; }
  table.responsive td.first::before { content: none; }
  table.responsive td.r { text-align: right; }
}

/* ---------- importação Exocad em lote ---------- */
dialog.wide { width: min(980px, calc(100vw - 24px)); }
.exo-row { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; background: #fff; }
.exo-row.done { opacity: .6; background: var(--green-soft); }
.exo-row-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.exo-row-head .chk { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.exo-row-head input[type=checkbox] { width: 20px; height: 20px; }
.exo-grid { display: grid; grid-template-columns: 2fr 1fr 1.5fr 1.1fr; gap: 10px; margin-top: 8px; }
.exo-grid .field { margin-bottom: 8px; }
.exo-item { display: grid; grid-template-columns: 1.2fr 1.3fr .6fr 1.2fr; gap: 8px; margin-bottom: 8px; }
.exo-item input, .exo-item select { min-height: 40px; padding: 6px 10px; }
@media (max-width: 720px) {
  .exo-grid { grid-template-columns: 1fr 1fr; }
  .exo-item { grid-template-columns: 1fr 1fr; }
}
