:root {
  /* Cores definidas em Configurações (o JavaScript substitui estes valores) */
  --navy: #1b2433;
  --accent: #06AAE6;
  --c1: #DA3740;
  --c2: #A0C556;
  --c3: #06AAE6;
  --c4: #FDDB04;
  --on-navy: #ffffff;
  --on-accent: #0f1720;
  --top-bg: var(--navy);
  --top-fg: var(--on-navy);
  --stripe: linear-gradient(90deg, var(--c1) 0 25%, var(--c2) 25% 50%, var(--c3) 50% 75%, var(--c4) 75% 100%);
  --logo-h: 48px;
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --navy-2: color-mix(in srgb, var(--navy) 80%, white);
  --navy-soft: color-mix(in srgb, var(--navy) 8%, white);
  --accent-soft: color-mix(in srgb, var(--accent) 14%, white);
  --bg: #f3f5f8;
  --card: #fff;
  --text: #1c2430;
  --muted: #667285;
  --border: #dde3ea;
  --danger: #c62828;
  --radius: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); }
button, input, textarea, select { font-family: inherit; }
button { font: inherit; cursor: pointer; }
a { color: inherit; }

/* Marca */
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-height: 44px; }
.brand strong { display: block; line-height: 1.1; }
.brand small { display: block; font-size: 15px; font-weight: 600; letter-spacing: .02em; opacity: .95; }
.brand .logo { background: var(--accent); color: var(--on-accent); font-weight: 800; width: var(--logo-h); height: var(--logo-h); border-radius: 10px; display: grid; place-items: center; flex: none; }
.brand .logo-img { height: var(--logo-h); max-width: calc(var(--logo-h) * 6); object-fit: contain; display: block; }
.brand .sep { width: 1px; height: calc(var(--logo-h) * .6); background: currentColor; opacity: .3; }
.brand.big .logo { width: calc(var(--logo-h) * 1.4); height: calc(var(--logo-h) * 1.4); font-size: 22px; }
.brand.big .logo-img { height: calc(var(--logo-h) * 1.6); max-width: calc(var(--logo-h) * 7); }

/* Formulários */
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
input, textarea, select { font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
input[type="color"] { padding: 2px; height: 42px; cursor: pointer; }
input[type="file"] { padding: 8px; }
input[type="range"] { padding: 0; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea { min-height: 90px; resize: vertical; }
.error { color: var(--danger); font-size: 14px; min-height: 18px; margin: 0; }
.muted { color: var(--muted); font-size: 14px; }

.btn { border: 1px solid var(--border); background: #fff; color: var(--text); padding: 9px 16px; border-radius: 8px; font-weight: 600; text-decoration: none; display: inline-block; }
.btn:hover { background: #eef1f5; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(.93); background: var(--accent); }
.btn.danger { color: var(--danger); border-color: #efc2c2; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--top-fg); border-color: color-mix(in srgb, var(--top-fg) 40%, transparent); }
.btn.ghost:hover { background: color-mix(in srgb, var(--top-fg) 14%, transparent); }
.link { background: none; border: none; color: var(--top-fg); padding: 8px 12px; border-radius: 8px; opacity: .9; }
.link:hover { background: color-mix(in srgb, var(--top-fg) 14%, transparent); opacity: 1; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-side { background: linear-gradient(140deg, var(--navy), var(--navy-2)); color: var(--on-navy); display: flex; align-items: center; padding: 48px; position: relative; overflow: hidden; }
.login-side::before { content: ""; position: absolute; inset: 0; background-image: var(--hero-img, none); background-size: cover; background-position: center; opacity: .28; }
.login-side::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 10px; background: var(--stripe); }
.login-side-inner { position: relative; z-index: 1; max-width: 520px; }
.login-side h1 { font-size: 34px; line-height: 1.15; margin: 28px 0 12px; }
.login-side p { font-size: 17px; line-height: 1.55; opacity: .9; margin: 0; }
.login-panel { display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card { background: #fff; width: 100%; max-width: 390px; padding: 30px; border-radius: var(--radius); box-shadow: 0 8px 30px rgba(15,30,50,.12); display: flex; flex-direction: column; gap: 14px; border-top: 5px solid transparent; border-image: var(--stripe) 1; }
.login-card h2 { margin: 0 0 4px; }

/* Topo */
.topbar { background: var(--top-bg); color: var(--top-fg); display: flex; justify-content: space-between; align-items: center; padding: 8px 24px 13px; position: sticky; top: 0; z-index: 5; flex-wrap: nowrap; gap: 16px; box-shadow: 0 1px 8px rgba(15,30,50,.08); }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--stripe); }
.topbar nav { display: flex; align-items: center; gap: 2px; min-width: 0; margin-left: auto; }
.topbar .brand { flex: none; }
.who { font-size: 13px; opacity: .8; margin: 0 10px; }

main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 12px; width: 100%; min-height: calc(100vh - 190px); }

/* Banner */
.hero { display: grid; grid-template-columns: 1.15fr 1fr; background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: var(--on-navy); border-radius: 20px; overflow: hidden; margin-bottom: 30px; position: relative; }
.hero.no-img { grid-template-columns: 1fr; }
.hero-text { padding: 44px; position: relative; z-index: 1; }
.hero-text::before { content: ""; display: block; width: 96px; height: 8px; border-radius: 4px; background: var(--stripe); margin-bottom: 20px; }
.hero h1 { font-size: 34px; line-height: 1.15; margin: 0 0 12px; }
.hero p { font-size: 17px; line-height: 1.55; opacity: .92; margin: 0; max-width: 560px; }
.hero-img { width: 100%; height: 100%; min-height: 240px; object-fit: cover; display: block; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 26px 0 14px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 22px; }
.section-head h2::after { content: ""; display: block; width: 56px; height: 5px; background: var(--stripe); border-radius: 3px; margin-top: 8px; }

/* Avisos */
.notices { display: grid; gap: 10px; }
.notice { background: var(--accent-soft); border-left: 5px solid var(--accent); border-radius: 10px; padding: 14px 18px; }
.notice strong { display: block; margin-bottom: 4px; }
.notice p { margin: 0; white-space: pre-wrap; line-height: 1.5; }
.notice small { color: var(--muted); }

/* Cartões de módulos */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { --tone: var(--accent); display: flex; flex-direction: column; gap: 8px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-decoration: none; transition: transform .15s, box-shadow .15s, border-color .15s; border-top: 6px solid var(--tone); }
.cards-palette .card:nth-child(4n+1) { --tone: var(--c1); }
.cards-palette .card:nth-child(4n+2) { --tone: var(--c2); }
.cards-palette .card:nth-child(4n+3) { --tone: var(--c3); }
.cards-palette .card:nth-child(4n+4) { --tone: var(--c4); }
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(15,30,50,.12); border-color: var(--tone); }
.card h3 { margin: 0; font-size: 18px; color: var(--navy); }
.card p { margin: 0; color: var(--muted); line-height: 1.45; flex: 1; font-size: 14px; }
.card .count { font-size: 13px; font-weight: 600; color: var(--navy); background: color-mix(in srgb, var(--tone) 22%, white); padding: 4px 10px; border-radius: 20px; align-self: flex-start; }
.empty { color: var(--muted); padding: 28px 10px; text-align: center; }

/* Página do módulo */
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--navy); font-weight: 600; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.mod-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--border); border-left: 8px solid var(--accent); border-radius: var(--radius); padding: 22px 24px; }
.mod-head h2 { margin: 0 0 4px; color: var(--navy); }
.mod-head p { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.post { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.post-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.post h3 { margin: 0 0 4px; color: var(--navy); }
.meta { color: var(--muted); font-size: 13px; }
.desc { white-space: pre-wrap; margin: 12px 0; line-height: 1.55; }
.files { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.files li { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; background: #fafbfc; flex-wrap: wrap; }
.files .name { flex: 1; min-width: 160px; word-break: break-all; font-weight: 600; }
.files .size { color: var(--muted); font-size: 12px; }
.viewer { margin-top: 12px; }
.viewer iframe, .viewer video { width: 100%; height: 520px; border: 1px solid var(--border); border-radius: 10px; background: #000; }
.viewer img { max-width: 100%; border-radius: 10px; }

/* Rodapé */
.footer { background: var(--navy); color: var(--on-navy); margin-top: 40px; padding: 24px 24px 22px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; position: relative; }
.footer::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--stripe); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(10,20,35,.55); display: grid; place-items: center; z-index: 20; padding: 16px; overflow: auto; }
.modal-box { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; }
.modal-box.wide { max-width: 800px; }
.modal-box h3 { margin-top: 0; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form .row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cols4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.fieldset > strong { font-size: 15px; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row output { min-width: 48px; font-weight: 700; }
.swatches { display: flex; gap: 6px; }
.swatches i { width: 28px; height: 28px; border-radius: 6px; display: block; }
.img-field { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.img-field .preview { width: 120px; height: 64px; border: 1px dashed var(--border); border-radius: 8px; display: grid; place-items: center; overflow: hidden; background: #f6f8fa; font-size: 12px; color: var(--muted); }
.img-field .preview img { width: 100%; height: 100%; object-fit: contain; }
.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mini-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.dropzone { border: 2px dashed var(--border); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.picked { font-size: 13px; margin: 6px 0 0; padding-left: 18px; }
.progress { height: 8px; background: #e6eaf0; border-radius: 6px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .15s; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--navy-soft); }
.tag.admin { background: var(--accent-soft); }
.tag.off { background: #fde7e7; color: var(--danger); }

@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { padding: 32px 24px; }
  .login-side h1 { font-size: 26px; }
  .hero, .hero.no-img { grid-template-columns: 1fr; }
  .hero-text { padding: 28px 22px; }
  .hero h1 { font-size: 26px; }
  .hero-img { min-height: 160px; max-height: 220px; }
  main { padding: 18px 16px 8px; }
  .topbar { padding: 8px 14px 12px; }
  .cols, .cols4 { grid-template-columns: 1fr 1fr; }
  .viewer iframe, .viewer video { height: 320px; }
}

/* Aplicativos incorporados */
.app-frame { width: 100%; height: 78vh; min-height: 420px; border: 1px solid var(--border); border-radius: 12px; background: #fff; display: block; margin-bottom: 8px; }

/* Controle de PO */
.panel { background: var(--card); border: 1px solid var(--border); border-left: 8px solid var(--accent); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 8px; }
.panel h3 { margin: 0 0 14px; color: var(--navy); }
.po-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.po-grid .span2 { grid-column: span 2; }
.po-grid .hint { grid-column: 1 / -1; margin-top: -6px; }
.hint { font-size: 13px; min-height: 18px; color: var(--muted); }
.hint.ok { color: #2e7d32; }
.hint.info { color: #0b6e99; }
.hint.warn { color: #b26a00; }
.hint.err { color: var(--danger); font-weight: 600; }
.sheet-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.sheet-bar input[type="search"] { max-width: 340px; }
.sheet-bar .muted { flex: 1; }
.sheet { overflow: auto; max-height: 70vh; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.po-table { font-size: 13px; min-width: 1100px; }
.po-table th { position: sticky; top: 0; background: var(--navy); color: var(--on-navy); z-index: 1; white-space: nowrap; padding: 10px 8px; }
.po-table td { padding: 8px; white-space: nowrap; }
.po-table tbody tr:nth-child(even) { background: #f8fafc; }
.po-table tbody tr:hover { background: var(--accent-soft); }
.po-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.po-table td.notes { white-space: normal; min-width: 220px; max-width: 360px; }
.po-table td.reg { color: var(--muted); font-size: 12px; }
.po-table td.acts { white-space: nowrap; }
@media (max-width: 860px) { .po-grid { grid-template-columns: 1fr; } .po-grid .span2 { grid-column: auto; } }
.hint:empty { display: none; }

/* Invoice pendente de Siscoserv: linha em vermelho */
.po-table tbody tr.inv-pending { background: #fbd5d5; color: #7f1d1d; }
.po-table tbody tr.inv-pending:hover { background: #f8bcbc; }
.po-table tbody tr.inv-pending td:first-child { box-shadow: inset 5px 0 0 #c62828; }
.po-table tbody tr.inv-pending td.reg { color: #9b2c2c; }
.po-table td.sis { white-space: nowrap; }
.chk { flex-direction: row; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.chk input { width: auto; accent-color: var(--accent); }
.po-flags { grid-column: 1 / -1; display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.sheet-sum { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.pend-count { color: #b71c1c; font-weight: 700; }
.pend-count:empty { display: none; }

/* Menu enxuto: links compactos + menu do usuário */
.topbar nav > .link { font-size: 14px; font-weight: 600; padding: 8px 12px; white-space: nowrap; position: relative; }
.topbar nav > .link.active { background: color-mix(in srgb, var(--top-fg) 16%, transparent); opacity: 1; }
.usermenu { position: relative; margin-left: 10px; padding-left: 10px; border-left: 1px solid color-mix(in srgb, var(--top-fg) 25%, transparent); }
.userbtn { display: flex; align-items: center; gap: 8px; background: none; border: none; color: var(--top-fg); padding: 4px 8px 4px 4px; border-radius: 999px; cursor: pointer; font: inherit; }
.userbtn:hover { background: color-mix(in srgb, var(--top-fg) 14%, transparent); }
.userbtn .who { margin: 0; font-size: 14px; font-weight: 600; opacity: .95; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbtn .caret { font-size: 11px; opacity: .8; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.userdrop { position: absolute; right: 0; top: calc(100% + 10px); min-width: 170px; background: var(--top-bg); color: var(--top-fg); border-radius: 12px; padding: 6px; box-shadow: 0 10px 30px rgba(15,30,50,.28); display: flex; flex-direction: column; z-index: 10; }
.userdrop[hidden] { display: none; }
.userdrop .link { text-align: left; width: 100%; }
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 6px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .topbar nav::-webkit-scrollbar { display: none; }
  .usermenu { order: 2; margin-left: auto; border-left: 0; padding-left: 0; }
  .topbar nav { margin-left: 0; }
  .userbtn .who { display: none; }
}
