/* Portal Pinguim Perspicaz — linguagem visual:
   executado = traço contínuo verde-mar; planeado = tracejado âmbar (bico do pinguim); dívida/atraso = vermelho krill. */
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/public-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/public-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/public-sans-latin-700-normal.woff2") format("woff2"); }
/* Fonte servida localmente: o portal funciona sem internet. */
:root {
  --ice: #eef3f4;
  --paper: #ffffff;
  --ink: #17262f;
  --slate: #56666f;
  --line: #ccd7db;
  --sea: #1f6e6a;
  --sea-soft: #dcebe9;
  --beak: #c98a12;
  --beak-soft: #fbf0d9;
  --krill: #b4432f;
  --krill-soft: #f6e1dc;
  --focus: #2a6fdb;
  --radius-s: 4px;
  --radius-m: 8px;
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--ice); color: var(--ink); font: 15px/1.5 var(--font); font-variant-numeric: tabular-nums; }
a { color: var(--sea); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 .25rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; font-weight: 650; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; font-weight: 650; }
p { margin: 0 0 .75rem; max-width: 72ch; }
.muted { color: var(--slate); }
.small { font-size: .85rem; }

/* ---------- estrutura ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #dfe8eb; padding: 1.25rem 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { padding: 0 1.25rem 1.25rem; display: flex; gap: .6rem; align-items: center; }
.brand svg { flex: none; }
.brand b { display: block; font-size: .95rem; line-height: 1.2; color: #fff; }
.brand span { font-size: .75rem; color: #9fb2b9; }
.nav a { display: block; padding: .45rem 1.25rem; color: #cfdade; text-decoration: none; border-left: 3px solid transparent; }
.nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav a[aria-current="page"] { border-left-color: var(--beak); color: #fff; background: rgba(255,255,255,.07); }
.nav .grp { margin: .9rem 1.25rem .25rem; font-size: .75rem; color: #8aa0a8; }
.side .who { margin-top: auto; padding: 1rem 1.25rem 0; font-size: .85rem; color: #9fb2b9; }
.side .who button { background: none; border: 0; color: #dfe8eb; padding: 0; text-decoration: underline; cursor: pointer; }
main { padding: 1.75rem 2.25rem 4rem; min-width: 0; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- controlos ---------- */
.btn { border: 1px solid var(--line); background: var(--paper); padding: .45rem .85rem; border-radius: var(--radius-s); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--slate); }
.btn.primary { background: var(--sea); border-color: var(--sea); color: #fff; }
.btn.primary:hover { background: #185a57; }
.btn.warn { color: var(--krill); border-color: #e0b3aa; }
.btn.plan { border: 1px dashed var(--beak); color: #7a5306; background: var(--beak-soft); }
.btn.link { border: 0; background: none; color: var(--sea); padding: .1rem .2rem; text-decoration: underline; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: .2rem .5rem; font-size: .85rem; }
label.f { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--slate); }
label.f > input, label.f > select, label.f > textarea { color: var(--ink); font-size: .95rem; }
input, select, textarea { border: 1px solid var(--line); border-radius: var(--radius-s); padding: .45rem .55rem; background: #fff; min-width: 0; }
input.money { text-align: right; }
textarea { min-height: 4rem; resize: vertical; }
.grid { display: grid; gap: .75rem 1rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.grid .wide { grid-column: 1 / -1; }
.check { display: flex; gap: .5rem; align-items: flex-start; font-size: .92rem; }
.check input { margin-top: .25rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-bottom: 1rem; }
.filters label.f { min-width: 140px; }

/* ---------- tabelas ---------- */
.tablewrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .5rem .65rem; text-align: left; border-bottom: 1px solid #e3eaec; vertical-align: top; }
th { font-weight: 600; color: var(--slate); background: #f6f9f9; position: sticky; top: 0; white-space: nowrap; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfb; }
tr.click { cursor: pointer; }
tfoot td { font-weight: 650; background: #f6f9f9; border-top: 1px solid var(--line); }
.neg { color: var(--krill); }
.pos { color: var(--sea); }
.empty { padding: 2rem; text-align: center; color: var(--slate); }

/* estados — a ideia central do portal */
.st { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; white-space: nowrap; border: 1px solid transparent; }
.st.exec { background: var(--sea-soft); color: var(--sea); border-color: #b5d5d1; }
.st.plan { background: var(--beak-soft); color: #7a5306; border: 1px dashed var(--beak); }
.st.open { background: #eef1f2; color: var(--slate); border-color: var(--line); }
.st.late { background: var(--krill-soft); color: var(--krill); border-color: #e6b8ae; }
tr.is-plan td:first-child { box-shadow: inset 3px 0 0 0 var(--beak); }
tr.is-exec td:first-child { box-shadow: inset 3px 0 0 0 var(--sea); }
tr.is-late td:first-child { box-shadow: inset 3px 0 0 0 var(--krill); }

/* ---------- painel ---------- */
.position { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1.5rem 1.75rem; margin-bottom: 1.5rem; }
.position .free { font-size: 2.6rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.position .free.neg { color: var(--krill); }
.ledger { position: relative; display: flex; height: 18px; border-radius: 3px; margin: 1rem 0 .6rem; background: #e7eef0; }
.ledger > i { display: block; height: 100%; }
.ledger > i:first-child { border-radius: 3px 0 0 3px; }
.ledger > i:nth-last-child(2) { border-radius: 0 3px 3px 0; }
.ledger .l-free { background: var(--sea); }
.ledger .l-tax { background: repeating-linear-gradient(135deg, var(--beak) 0 6px, #e6b34f 6px 12px); }
.ledger .l-debt { background: var(--krill); }
.ledger .l-mark { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1px; background: var(--ink, #17262f); border-radius: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; font-size: .88rem; color: var(--slate); }
.legend b { color: var(--ink); font-weight: 650; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1rem 1.25rem; min-width: 0; }
.panel h2 { margin-top: 0; }
.alert { padding: .5rem .75rem; border-radius: var(--radius-s); margin-bottom: .4rem; font-size: .9rem; border-left: 3px solid; background: #f4f7f8; }
.alert.erro { border-color: var(--krill); background: var(--krill-soft); }
.alert.aviso { border-color: var(--beak); background: var(--beak-soft); }
.alert.info { border-color: var(--sea); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; font-size: .92rem; }
.kv dt { color: var(--slate); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }
.bars svg { width: 100%; height: auto; display: block; }
.note { background: #f4f7f8; border-left: 3px solid var(--line); padding: .6rem .8rem; font-size: .88rem; color: var(--slate); margin: .75rem 0; max-width: 80ch; }

/* ---------- modal ---------- */
dialog { border: 0; border-radius: var(--radius-m); padding: 0; width: min(860px, 94vw); max-height: 92vh; box-shadow: 0 20px 60px rgba(10, 25, 35, .35); }
dialog::backdrop { background: rgba(15, 30, 40, .45); }
dialog .mh { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
dialog .mh h2 { margin: 0; }
dialog .mb { padding: 1.25rem; overflow-y: auto; }
dialog .mf { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.25rem; border-top: 1px solid var(--line); background: #f8fbfb; position: sticky; bottom: 0; }
.confirm-box { border: 1px dashed var(--beak); background: var(--beak-soft); padding: .75rem .9rem; border-radius: var(--radius-s); margin-top: 1rem; }
.confirm-box.done { border-style: solid; border-color: var(--sea); background: var(--sea-soft); }
.drop { border: 1px dashed var(--slate); border-radius: var(--radius-m); padding: 1rem; text-align: center; background: #fafcfc; cursor: pointer; }
.drop.over { background: var(--sea-soft); border-color: var(--sea); }
.sugg { font-size: .8rem; color: #7a5306; background: var(--beak-soft); border-radius: 3px; padding: 0 .3rem; margin-left: .3rem; }
.hist { font-size: .88rem; }
.hist td { font-size: .85rem; }
.hist .old { color: var(--krill); text-decoration: line-through; word-break: break-word; }
.hist .new { color: var(--sea); word-break: break-word; }
.toast { position: fixed; bottom: 1.25rem; right: 1.25rem; background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: var(--radius-s); z-index: 100; max-width: 420px; font-size: .92rem; }
.toast.err { background: var(--krill); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: .5rem .9rem; border-bottom: 2px solid transparent; cursor: pointer; color: var(--slate); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--sea); font-weight: 600; }

/* ---------- login ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.gate form { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-m); padding: 2rem; width: min(420px, 100%); display: grid; gap: 1rem; }
.gate.setup form { width: min(640px, 100%); }
.offline { position: fixed; top: 0; left: 0; right: 0; background: var(--beak); color: #fff; text-align: center; padding: .3rem; font-size: .85rem; z-index: 200; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .nav { display: flex; flex-wrap: wrap; }
  .nav .grp { display: none; }
  .nav a { border-left: 0; border-bottom: 3px solid transparent; padding: .4rem .7rem; }
  .nav a[aria-current="page"] { border-bottom-color: var(--beak); }
  main { padding: 1.25rem 1rem 3rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .side, .actions, .filters { display: none; } .shell { display: block; } }

/* O atributo hidden tem de ganhar a regras como .grid { display: grid } */
[hidden] { display: none !important; }
