/* 180 Licitações: identidade derivada do Portal 180graus
   Base navy + dourado (marca), o sol do logo vira a escala de status. */
:root {
  --navy: #0A1F44;
  --navy-2: #13305F;
  --navy-3: #1D4180;
  --gold: #C9A227;
  --gold-soft: #F3E7BF;
  --sol-1: #E10918;  /* vermelho do sol */
  --sol-2: #F4A300;  /* laranja */
  --sol-3: #FFD200;  /* amarelo */
  --ok: #1F8A5B;
  --ok-soft: #DDF1E7;
  --warn: #B86E00;
  --warn-soft: #FDEBC8;
  --bad: #C40716;
  --bad-soft: #FBDDE0;
  --paper: #F4F2EC;
  --card: #FFFFFF;
  --ink: #0B1424;
  --ink-2: #4A5468;
  --line: #E2DED3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(10, 31, 68, .06), 0 6px 24px -12px rgba(10, 31, 68, .18);
  --display: "Archivo", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #071531; --card: #0E2147; --ink: #EEF1F7; --ink-2: #A9B3C7; --line: #20365F;
    --gold-soft: #3A3215; --ok-soft: #12352A; --warn-soft: #3B2A0A; --bad-soft: #3E1218;
    --ok: #4CC38A; --warn: #F4A300; --bad: #FF5A66;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px -14px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

/* Instituto Galaxy: navy #1B2B6B + laranja #E8650A (marca oficial). Mesmo layout, outra identidade. */
:root[data-ctx="galaxy"] {
  --navy: #1B2B6B; --navy-2: #24398A; --navy-3: #2F49A8;
  --gold: #E8650A; --gold-soft: #FDE4D2;
  --sol-1: #C2410C; --sol-2: #E8650A; --sol-3: #F9A15A;
  --paper: #F3F4F8;
}
@media (prefers-color-scheme: dark) {
  :root[data-ctx="galaxy"] { --paper: #0B1433; --card: #142158; --line: #25347A; --gold-soft: #3F2410; }
}
:root[data-ctx="galaxy"] .btn.gold { color: #fff; }
:root[data-ctx="galaxy"] .btn.gold:hover { background: #F07A24; }
:root[data-ctx="galaxy"] .tag.B { color: #9A3F04; }
:root[data-ctx="galaxy"] .badge-ia { color: #9A3F04; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font: 15px/1.5 var(--body); font-feature-settings: "tnum" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100dvh; }
.side {
  background: var(--navy); color: #fff; position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; padding: 22px 16px; gap: 28px;
}
.side::after { /* faixa do sol */
  content: ""; position: absolute; top: 0; right: 0; width: 4px; height: 100%;
  background: linear-gradient(var(--sol-1), var(--sol-2) 50%, var(--sol-3));
}
.troca { position: relative; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; width: 100%; background: none; border: 0; color: inherit; cursor: pointer; padding: 6px; margin: -6px; border-radius: 12px; text-align: left; }
.brand:hover { background: var(--navy-2); }
.brand .seta { width: 18px; margin-left: auto; color: var(--gold); flex: none; }
:root[data-ctx="galaxy"] .brand { flex-wrap: wrap; row-gap: 8px; }
:root[data-ctx="galaxy"] .brand img { width: 110px; }
:root[data-ctx="galaxy"] .brand span { order: 3; flex-basis: 100%; }
:root[data-ctx="galaxy"] .brand .seta { order: 2; }
.brand span { min-width: 0; }
.brand b { font-size: 17px; }
.menu-ctx { position: absolute; top: calc(100% + 10px); left: -6px; right: -6px; background: var(--card); color: var(--ink); border-radius: 14px; box-shadow: 0 20px 50px -10px rgba(0,0,0,.45); padding: 6px; z-index: 30; display: grid; gap: 4px; }
.menu-ctx button { display: flex; gap: 10px; align-items: center; background: none; border: 0; border-radius: 10px; padding: 10px; cursor: pointer; text-align: left; color: inherit; }
.menu-ctx button:hover, .menu-ctx button[aria-pressed="true"] { background: var(--paper); }
.menu-ctx button[aria-pressed="true"] { box-shadow: inset 3px 0 0 var(--gold); }
.menu-ctx img { width: 54px; height: 32px; object-fit: contain; }
.menu-ctx b { display: block; font: 700 14px/1.2 var(--display); }
.menu-ctx small { color: var(--ink-2); font-size: 12px; }
.menu-ctx[hidden] { display: none; }
.topo { display: none; }
.brand img { width: 46px; height: auto; }
.brand b { display: block; font: 800 19px/1 var(--display); font-stretch: 112%; letter-spacing: -.01em; }
.brand small { display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin-top: 4px; }
.nav { display: grid; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  text-decoration: none; color: #C9D3E8; font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.nav a svg { width: 19px; height: 19px; flex: none; }
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a[aria-current="page"] { background: var(--navy-2); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.side-foot { margin-top: auto; font-size: 12px; color: #8D9BBA; line-height: 1.45; }
.side-foot strong { color: #fff; font-weight: 600; display: block; }

main { padding: 28px clamp(16px, 3vw, 40px) 64px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin: 0 0 6px; }
h1 { font: 800 clamp(26px, 3.2vw, 36px)/1.05 var(--display); font-stretch: 110%; letter-spacing: -.02em; margin: 0; }
h2 { font: 700 18px/1.2 var(--display); font-stretch: 105%; margin: 0 0 12px; }
.sub { color: var(--ink-2); margin: 6px 0 0; max-width: 62ch; }

/* ---------- Controles ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer;
  padding: 10px 16px; border-radius: 10px; font-weight: 600; text-decoration: none;
  background: var(--navy); color: #fff; transition: transform .12s ease, background .15s ease;
}
.btn:hover { background: var(--navy-3); }
.btn:active { transform: scale(.97); }
.btn.gold { background: var(--gold); color: var(--navy); }
.btn.gold:hover { background: #D9B43A; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.ghost:hover { background: var(--card); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn svg { width: 16px; height: 16px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.seg { display: inline-flex; background: var(--card); border-radius: 10px; padding: 3px; box-shadow: inset 0 0 0 1px var(--line); }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; }
@media (prefers-color-scheme: dark) { .seg button[aria-pressed="true"] { background: var(--gold); color: var(--navy); } }
.search {
  flex: 1 1 220px; min-width: 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card);
}
input, select, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus, .search:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }

/* ---------- Cartões ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 14px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.op { display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden; }
.op::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--line); }
.op[data-faixa="A"]::before { background: linear-gradient(var(--sol-1), var(--sol-2)); }
.op[data-faixa="B"]::before { background: var(--gold); }
.op-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.op-org { font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.op-obj { margin: 0; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.op-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-2); }
.op-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: auto; padding-top: 6px; border-top: 1px dashed var(--line); }
.valor { font: 700 20px/1 var(--display); font-stretch: 105%; }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.tag.A { background: #FFE9D6; color: #A43A00; }
.tag.B { background: var(--gold-soft); color: #7A5E00; }
.tag.C { background: var(--paper); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.tag.teto { background: var(--ok-soft); color: var(--ok); }
.tag.plat { background: var(--paper); color: var(--ink-2); }
@media (prefers-color-scheme: dark) { .tag.A { background: #3D2210; color: #FFB27A; } .tag.B { color: var(--gold); } }

/* contagem regressiva */
.prazo { font-weight: 600; }
.prazo.urgente { color: var(--bad); }
.prazo.perto { color: var(--warn); }

/* ---------- Gauge 180° ---------- */
.gauge { position: relative; width: 168px; aspect-ratio: 2 / 1.12; }
.gauge svg { width: 100%; height: 100%; overflow: visible; }
.gauge .trilho { stroke: var(--line); }
.gauge .arco { transition: stroke-dashoffset .8s cubic-bezier(.2, .8, .2, 1); }
.gauge .num { position: absolute; inset: auto 0 0; text-align: center; font: 800 30px/1 var(--display); font-stretch: 110%; }
.gauge .num small { display: block; font: 600 11px/1.4 var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.gauge.mini { width: 74px; }
.gauge.mini .num { font-size: 15px; }
.gauge.mini .num small { display: none; }

/* ---------- Licitação ---------- */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; }
.hero .kpis { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 14px; }
.kpi b { display: block; font: 800 22px/1 var(--display); font-stretch: 108%; }
.kpi span { font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .08em; }
.sec { margin-top: 18px; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.sec-head small { color: var(--ink-2); }

.lista { list-style: none; margin: 0; padding: 0; }
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .ref { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.item .doc { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.item .acoes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.item.ia-pendente { background: linear-gradient(90deg, var(--gold-soft), transparent 60%); margin: 0 -18px; padding-left: 18px; padding-right: 18px; }

.dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.dot svg { width: 15px; height: 15px; }
.dot.ok { background: var(--ok-soft); color: var(--ok); }
.dot.vence_antes, .dot.pendente, .dot.revisar { background: var(--warn-soft); color: var(--warn); }
.dot.falta, .dot.vencido { background: var(--bad-soft); color: var(--bad); }

.badge-ia { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: #7A5E00; background: var(--gold-soft); padding: 2px 6px; border-radius: 5px; margin-left: 6px; vertical-align: 1px; }
@media (prefers-color-scheme: dark) { .badge-ia { color: var(--gold); } }

/* linha do tempo de prazos */
.tempo { position: relative; padding-left: 22px; }
.tempo::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--sol-3), var(--sol-2), var(--sol-1)); border-radius: 2px; }
.tempo .marco { position: relative; padding: 6px 0 12px; }
.tempo .marco::before { content: ""; position: absolute; left: -21px; top: 12px; width: 12px; height: 12px; border-radius: 50%; background: var(--card); border: 3px solid var(--sol-2); }
.tempo .marco.feito::before { border-color: var(--ok); background: var(--ok); }
.tempo .marco.vencido::before { border-color: var(--bad); }
.tempo .data { font: 700 14px/1.2 var(--display); }

/* ---------- Cofre ---------- */
.tabela { width: 100%; border-collapse: collapse; }
.tabela th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tabela td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabela tr:last-child td { border-bottom: 0; }
.validade { display: grid; gap: 5px; min-width: 140px; }
.barra { height: 6px; border-radius: 6px; background: var(--paper); overflow: hidden; }
.barra i { display: block; height: 100%; border-radius: 6px; }
.cat { font: 700 13px/1 var(--display); text-transform: uppercase; letter-spacing: .1em; color: var(--gold); padding: 18px 10px 6px !important; border-bottom: 0 !important; }

.vazio { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.vazio svg { width: 120px; margin: 0 auto 12px; display: block; }
.carregando { display: flex; gap: 10px; align-items: center; color: var(--ink-2); padding: 30px 0; }
.sol-spin { width: 28px; height: 14px; border-radius: 28px 28px 0 0; background: conic-gradient(from 270deg at 50% 100%, var(--sol-1), var(--sol-2), var(--sol-3), var(--sol-1)); animation: pulso 1.1s ease-in-out infinite; }
@keyframes pulso { 50% { opacity: .45; transform: scaleX(.85); } }

dialog { border: 0; border-radius: var(--radius); padding: 0; box-shadow: 0 30px 80px -20px rgba(0,0,0,.45); width: min(520px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(7, 21, 49, .55); backdrop-filter: blur(2px); }
dialog form { padding: 22px; display: grid; gap: 14px; }
.dlg-acoes { display: flex; justify-content: flex-end; gap: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 500; z-index: 50; max-width: calc(100vw - 32px); }
.toast.erro { background: var(--bad); }

/* ---------- Login, triagem, avisos, calculadora ---------- */
.sem-sessao .side { display: none; }
.sem-sessao .shell { grid-template-columns: 1fr; }
.login { max-width: 380px; margin: 12vh auto; text-align: center; display: grid; gap: 12px; justify-items: center; }
.login form { display: grid; gap: 12px; width: 100%; text-align: left; }
.ia-nota { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--ink-2); background: var(--paper); border-radius: 10px; padding: 7px 10px; }
.ia-nota b { font: 800 18px/1 var(--display); color: var(--ink); min-width: 28px; }
.voto { border: 1px solid var(--line); background: var(--card); border-radius: 8px; width: 30px; height: 30px; cursor: pointer; color: var(--ink-2); font-size: 11px; }
.voto.on { background: var(--ok); color: #fff; border-color: var(--ok); }
.voto.on.nao { background: var(--bad); border-color: var(--bad); }
.sino { margin-left: auto; background: var(--sol-1); color: #fff; font: 700 11px/1 var(--body); border-radius: 999px; padding: 3px 7px; }
.item.aviso.novo { background: linear-gradient(90deg, var(--gold-soft), transparent 70%); margin: 0 -18px; padding-left: 18px; padding-right: 18px; }
.calc { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 8px; }
details.mais { margin-top: 14px; }
details.mais summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
.sair { margin-top: 10px; background: none; border: 1px solid #2B4A80; color: #C9D3E8; border-radius: 8px; padding: 5px 12px; cursor: pointer; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 20; gap: 0; }
  .side::after { width: 100%; height: 3px; top: 0; background: linear-gradient(90deg, var(--sol-1), var(--sol-2), var(--sol-3)); }
  .brand, .side-foot { display: none; }
  .nav { grid-auto-flow: column; grid-auto-columns: minmax(64px, 1fr); width: 100%; overflow-x: auto; scrollbar-width: none; }
  .sino { position: absolute; margin: -4px 0 0 18px; }
  .nav a { position: relative; }
  .nav a { flex-direction: column; gap: 3px; font-size: 11px; padding: 7px 4px; justify-content: center; }
  .nav a[aria-current="page"] { box-shadow: inset 0 3px 0 var(--gold); }
  main { padding: 0 16px 96px; }
  .topo { display: flex; position: sticky; top: 0; z-index: 15; margin: 0 -16px 16px; padding: 10px 16px; background: var(--navy); color: #fff; }
  .topo-troca { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: inherit; font: 700 15px var(--display); cursor: pointer; }
  .topo-troca img { height: 26px; width: auto; }
  .hero { grid-template-columns: 1fr; }
  .hero .gauge { order: -1; margin: 0 auto; }
  .hero .kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .item { grid-template-columns: auto 1fr; }
  .item .acoes { grid-column: 2; justify-content: flex-start; }
  .grid.cards { grid-template-columns: 1fr; }
  .tabela thead { display: none; }
  .tabela tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .tabela td { border: 0; padding: 0 10px; }
  .row2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before { transition: none !important; animation: none !important; } }
