/* DELTA VB · Sistema de obras — identidade: marinho #122642, azul aço #2F5D8C, Montserrat + DM Sans */
:root {
  --font-display: "Montserrat", "Segoe UI", Arial, sans-serif;
  --font-body: "DM Sans", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --radius: 12px;
  --bg: #EDF2F8; --surface: #FFFFFF; --surface-2: #F5F8FC; --surface-3: #E7EEF7;
  --ink: #122642; --ink-2: #4A5B70; --ink-3: #6E7F95;
  --line: #DCE4EE; --line-2: #C6D3E2;
  --accent: #2F5D8C; --accent-hover: #264D75; --accent-ink: #FFFFFF; --accent-soft: #E1EAF5;
  --nav: #0D2139; --nav-2: #17324F; --nav-ink: #F1F6FC; --nav-ink-2: #9DB6D3;
  --good: #3C7C74; --good-soft: #DCEDEA; --warn: #86691C; --warn-soft: #F4EAD0; --bad: #9C3D2A; --bad-soft: #F5E0DA;
  --neutral-soft: #EAEEF3; --editable: #FFF6D6;
  --in: #2E7D6B; --out: #9C3D2A;
  --shadow: 0 10px 30px rgba(13, 33, 57, .18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A1627; --surface: #0F1F35; --surface-2: #13263F; --surface-3: #1A304D;
    --ink: #E6EEF8; --ink-2: #AFC0D4; --ink-3: #8499B2; --line: #1F3551; --line-2: #2A4466;
    --accent: #86ACD9; --accent-hover: #A2C1E7; --accent-ink: #0A1627; --accent-soft: #1B3354;
    --nav: #060F1B; --nav-2: #132A45; --nav-ink: #E6EEF8; --nav-ink-2: #8EA6C4;
    --good: #63B7AB; --good-soft: #12302F; --warn: #D6B660; --warn-soft: #352C12; --bad: #E48C76; --bad-soft: #3A1D16;
    --neutral-soft: #1A2B41; --editable: #33301A; --in: #63B7AB; --out: #E48C76;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A1627; --surface: #0F1F35; --surface-2: #13263F; --surface-3: #1A304D;
  --ink: #E6EEF8; --ink-2: #AFC0D4; --ink-3: #8499B2; --line: #1F3551; --line-2: #2A4466;
  --accent: #86ACD9; --accent-hover: #A2C1E7; --accent-ink: #0A1627; --accent-soft: #1B3354;
  --nav: #060F1B; --nav-2: #132A45; --nav-ink: #E6EEF8; --nav-ink-2: #8EA6C4;
  --good: #63B7AB; --good-soft: #12302F; --warn: #D6B660; --warn-soft: #352C12; --bad: #E48C76; --bad-soft: #3A1D16;
  --neutral-soft: #1A2B41; --editable: #33301A; --in: #63B7AB; --out: #E48C76;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -.005em; text-wrap: balance; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.dica { text-decoration: underline dotted var(--ink-3); text-underline-offset: 3px; cursor: help; }
.in { color: var(--in); }
.out { color: var(--out); }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- estrutura */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--nav); color: var(--nav-ink); padding: 22px 12px 18px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; }
.side-logo { width: 150px; height: auto; margin: 0 10px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: var(--nav-ink); text-decoration: none; font-size: 14px; opacity: .82; }
.nav a:hover { background: var(--nav-2); opacity: 1; }
.nav a[aria-current="page"] { background: var(--nav-2); opacity: 1; font-weight: 600; }
.side-foot { margin-top: auto; font-size: 12px; color: var(--nav-ink-2); padding: 0 10px; display: flex; flex-direction: column; gap: 6px; }
.side-foot button { align-self: flex-start; border: 1px solid var(--nav-2); background: transparent; color: var(--nav-ink); border-radius: 7px; padding: 5px 10px; font-size: 12.5px; cursor: pointer; }
.side-foot button:hover { background: var(--nav-2); }
.main { min-width: 0; padding: 24px 28px 96px; }
.page { max-width: 1240px; margin: 0 auto; }
.topbar { display: none; }
.tabbar { display: none; }

.phead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 18px; }
.phead h1 { font-size: 24px; font-weight: 700; }
.phead .sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumbs { font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; }
.crumbs a { font-weight: 600; text-decoration: none; }

/* ---------------------------------------------------------------- peças */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.card + .card { margin-top: 16px; }
.card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; flex-wrap: wrap; }
.card-h h2 { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-top: 16px; }
.cols > .stack { display: flex; flex-direction: column; gap: 16px; }
.cols .card + .card { margin-top: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kpi-l { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.kpi-v { font: 600 22px/1.2 var(--font-display); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-f { font-size: 12px; color: var(--ink-2); line-height: 1.4; }
.kpi.warn .kpi-v { color: var(--warn); }
button.kpi { text-align: left; cursor: pointer; font: inherit; color: inherit; }
button.kpi:hover { border-color: var(--line-2); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); padding: 8px 13px; border-radius: 8px; font-weight: 600; font-size: 13px; line-height: 1.2; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: none; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; line-height: 1; padding: 5px 8px; border-radius: 999px; background: var(--neutral-soft); color: var(--ink-2); white-space: nowrap; }
.chip-good { background: var(--good-soft); color: var(--good); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button, .seg a { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; text-decoration: none; }
.seg button:hover, .seg a:hover { color: var(--ink); }
.seg [aria-pressed="true"], .seg [aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(13, 33, 57, .18); }

.filters { display: flex; gap: 8px 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
input[type=date], input[type=search], input[type=text], input[type=email], input[type=number], select, textarea {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px; padding: 7px 10px; font-size: 13.5px; min-width: 0;
}
textarea { width: 100%; min-height: 70px; resize: vertical; }
select { padding-right: 28px; }
.sumrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.sumbox { background: var(--surface); padding: 10px 14px; min-width: 0; }
.sumbox .l { font-size: 12px; color: var(--ink-2); }
.sumbox .v { font: 600 16px/1.3 var(--font-display); }
.sumbox .n { font-size: 11.5px; color: var(--ink-3); }

.empty { color: var(--ink-2); font-size: 13px; padding: 14px 0; }
.hint { font-size: 12.5px; color: var(--ink-2); margin-top: 10px; }
.notice { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center; background: var(--editable); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }

/* ---------------------------------------------------------------- agenda */
.ag-sec { margin-top: 4px; }
.ag-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font: 600 11px/1 var(--font-display); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 16px 0 4px; }
.ag-h:first-child { margin-top: 0; }
.ag-h.late { color: var(--bad); }
.ag-h .tot { font: 600 12px/1 var(--font-body); letter-spacing: 0; text-transform: none; color: var(--ink-2); }
.item { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 10px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item-d { font: 600 12.5px/1.25 var(--font-display); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.item-d small { display: block; font: 500 11px/1.3 var(--font-body); color: var(--ink-3); }
.item-t { font-weight: 600; font-size: 13.5px; }
.item-s { font-size: 12.5px; color: var(--ink-2); display: flex; gap: 4px 8px; flex-wrap: wrap; align-items: center; }
.item-r { display: flex; align-items: center; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.item-v { font: 600 14px/1.2 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* agenda estreita: valor e botões descem para baixo do texto */
.card.agenda { container-type: inline-size; }
@container (max-width: 560px) {
  .item { grid-template-columns: 46px minmax(0, 1fr); }
  .item-r { grid-column: 2; justify-content: flex-start; }
}
@media (max-width: 1100px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------------------------------------------- tabelas */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card .tbl-wrap { border-radius: 8px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { font: 600 11px/1.25 var(--font-display); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); text-align: left; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line-2); border-bottom: 0; }
.tbl tr.grp td { background: var(--surface-3); font-weight: 600; }
.tbl .obs { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.tbl tr.clic { cursor: pointer; }
.tbl tr.clic:hover td { background: var(--surface-2); }
.tbl tr.virtual td { color: var(--ink-2); }
/* pouco espaço (celular ou janela estreita): a tabela vira lista — data à esquerda, descrição e valor em cima, situação e botões embaixo */
.tbl-wrap { container-type: inline-size; }
@container (max-width: 760px) {
  .tbl.resp thead { display: none; }
  .tbl.resp tr { display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; grid-template-areas: "d m v" "d s a"; gap: 6px 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .tbl.resp.nod tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "m v" "s a"; }
  .tbl.resp td { border: 0; padding: 0; }
  .tbl.resp td[data-c=d] { grid-area: d; align-self: start; font: 600 12.5px/1.3 var(--font-display); color: var(--ink-2); }
  .tbl.resp td[data-c=d] .d-sep { display: none; }
  .tbl.resp td[data-c=d] .d-ano { display: block; font: 500 11px/1.3 var(--font-body); color: var(--ink-3); }
  .tbl.resp td[data-c=m] { grid-area: m; font-weight: 600; }
  .tbl.resp td[data-c=v] { grid-area: v; text-align: right; font-weight: 600; }
  .tbl.resp td[data-c=s] { grid-area: s; }
  .tbl.resp td[data-c=a] { grid-area: a; text-align: right; }
  .tbl.resp td.hm { display: none; }
  .tbl.resp tbody tr:last-child { border-bottom: 0; }
  .tbl.resp .obs { font-weight: 400; }
}

/* ---------------------------------------------------------------- obras */
.obras { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.obra { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.obra:hover { border-color: var(--line-2); box-shadow: 0 2px 10px rgba(13, 33, 57, .06); }
.obra h2 { font-size: 16px; font-weight: 700; }
.obra .cli { font-size: 12.5px; color: var(--ink-2); }
.obra .vals { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 12.5px; }
.obra .vals b { display: block; font: 600 14px/1.3 var(--font-display); font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* ---------------------------------------------------------------- contas */
.contas { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.conta-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.conta-row:last-child { border-bottom: 0; }
.conta-row .v { font: 600 15px/1.3 var(--font-display); font-variant-numeric: tabular-nums; }
.conta-row .d { grid-column: 1 / -1; font-size: 12px; color: var(--ink-2); }

/* ---------------------------------------------------------------- gráfico (semanas) */
.wk-chart { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; }
.wk { min-width: 0; border-radius: 6px; }
.wk:hover { background: var(--surface-2); }
.wk-bars { height: 120px; display: flex; align-items: flex-end; justify-content: center; gap: 2px; border-bottom: 1px solid var(--line-2); }
.wk-bars i { display: block; width: min(12px, 38%); border-radius: 4px 4px 0 0; }
.b-in { background: var(--in); }
.b-out { background: var(--out); }
.wk span { display: block; text-align: center; font-size: 11px; color: var(--ink-3); margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.wk-tab { margin-top: 8px; font-size: 12.5px; }
.wk-tab summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.wk-tab table { margin-top: 6px; }
.legend { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.lk { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---------------------------------------------------------------- formulários e janela */
dialog.modal { border: 0; padding: 0; border-radius: 14px; width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(10, 22, 39, .55); }
.mbody { padding: 20px 22px 18px; overflow: auto; max-height: calc(100vh - 32px); }
.mbody h2 { font-size: 18px; margin-bottom: 4px; }
.mbody .lead { font-size: 13px; color: var(--ink-2); margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); min-width: 0; }
.field input, .field select, .field textarea { font-weight: 400; color: var(--ink); width: 100%; font-size: 14px; }
.field .help { font-weight: 400; font-size: 12px; color: var(--ink-3); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.form-actions .sp { flex: 1; }
.form-err { color: var(--bad); font-size: 13px; font-weight: 600; margin-top: 12px; }
.rat { display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.rat-row { display: grid; grid-template-columns: minmax(0, 1fr) 86px; gap: 8px; align-items: center; font-size: 13.5px; }
.rat-row input { text-align: right; }
.rat-tot { font-size: 12.5px; font-weight: 600; }

/* ---------------------------------------------------------------- login e avisos */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--nav); }
.login-box { width: min(400px, 100%); background: var(--surface); border-radius: 16px; padding: 28px 26px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.login-box img { width: 170px; height: auto; }
.login-box h1 { font-size: 20px; }
.login-box input { width: 100%; font-size: 15px; padding: 10px 12px; }
.login-box .btn { width: 100%; padding: 11px; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); z-index: 50; max-width: calc(100vw - 32px); }
.toast.err { background: var(--bad); color: #fff; }
.loading { padding: 60px 0; text-align: center; color: var(--ink-2); }
.demo-tag { display: inline-block; font: 700 10.5px/1 var(--font-display); letter-spacing: .1em; text-transform: uppercase; color: var(--warn); background: var(--warn-soft); padding: 6px 8px; border-radius: 5px; margin: 0 10px; }

/* ---------------------------------------------------------------- celular */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--nav); color: var(--nav-ink); padding: 10px 16px; position: sticky; top: 0; z-index: 20; }
  .topbar img { width: 118px; height: auto; }
  .topbar button { border: 1px solid var(--nav-2); background: transparent; color: var(--nav-ink); border-radius: 7px; padding: 5px 10px; font-size: 12.5px; }
  .tabbar { display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: var(--nav); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 9px; color: var(--nav-ink-2); text-decoration: none; font-size: 11.5px; font-weight: 600; }
  .tabbar a[aria-current="page"] { color: var(--nav-ink); }
  .main { padding: 16px 16px 92px; }
  .phead h1 { font-size: 20px; }
  .cols { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-v { font-size: 18px; }
  .item { grid-template-columns: 46px minmax(0, 1fr); }
  .item-r { grid-column: 2; justify-content: flex-start; }
  .filters > * { flex: 1 1 140px; }
  dialog.modal { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100dvh; margin: 0; border-radius: 0; }
  .mbody { max-height: 100dvh; }
}
