:root {
  --navy: #073b61;
  --navy-deep: #042a46;
  --blue: #0b659d;
  --cyan: #21a5c8;
  --teal: #138a86;
  --surface: #ffffff;
  --surface-soft: #f4f8fb;
  --surface-blue: #edf5fa;
  --text: #173246;
  --muted: #5f7281;
  --line: #d8e3ea;
  --shadow: 0 10px 32px rgba(10, 55, 84, 0.11);
  --radius: 18px;
  --radius-sm: 11px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: #f7fafc; }
a { color: inherit; }
button, select, input { font: inherit; }
button, select { cursor: pointer; }
img { max-width: 100%; }
.hidden { display: none !important; }
.container { width: min(1460px, calc(100% - 40px)); margin: 0 auto; }

.site-header { position: sticky; top: 0; z-index: 40; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.header-inner { min-height: 76px; display: grid; grid-template-columns: 180px 1fr 180px; align-items: center; gap: 20px; }
.brand { display: inline-flex; align-items: center; }
.brand img { width: 142px; height: auto; display: block; }
.main-nav { justify-self: center; display: inline-flex; gap: 6px; background: var(--surface-soft); padding: 5px; border-radius: 999px; border: 1px solid var(--line); }
.nav-tab { border: 0; background: transparent; color: var(--muted); padding: 10px 22px; border-radius: 999px; font-weight: 700; }
.nav-tab.active { background: var(--navy); color: #fff; box-shadow: 0 4px 12px rgba(7,59,97,.18); }
#logoutButton { justify-self: end; }

.portal-panel { display: none; min-height: calc(100vh - 150px); }
.portal-panel.active { display: block; }
.hero { background: linear-gradient(115deg, var(--navy-deep), var(--navy) 52%, #0d668d); color: #fff; }
.compact-hero { padding: 44px 0 42px; }
.hero-content { display: flex; align-items: center; justify-content: space-between; gap: 30px; }
.hero h1 { font-size: clamp(2rem, 4vw, 3.35rem); line-height: 1.04; margin: 6px 0 12px; letter-spacing: -.035em; }
.hero p:not(.eyebrow) { max-width: 840px; margin: 0; color: rgba(255,255,255,.82); font-size: 1.08rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-weight: 800; font-size: .72rem; margin: 0 0 5px; color: #4b8bad; }
.hero .eyebrow { color: #87dbec; }
.live-badge { display: inline-flex; align-items: center; gap: 9px; padding: 10px 15px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); border-radius: 999px; white-space: nowrap; font-size: .9rem; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #7ce7bf; box-shadow: 0 0 0 5px rgba(124,231,191,.12); }

.button { border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; font-weight: 750; transition: .16s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--navy); border-color: var(--navy); }
.button.secondary { color: var(--navy); background: var(--surface-blue); border-color: #c8ddea; }
.button.ghost { color: var(--navy); background: #fff; border-color: var(--line); }
.button.small { padding: 8px 13px; font-size: .88rem; }
.button.full { width: 100%; }

.operational-section { padding: 36px 0 62px; }
.section-heading { margin-bottom: 22px; }
.inline-heading { display: flex; justify-content: space-between; gap: 20px; align-items: end; }
.section-heading h2, .results-header h2, .filter-panel h2 { margin: 4px 0 0; font-size: 1.72rem; letter-spacing: -.025em; }
.forecast-dashboard { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.forecast-product-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.forecast-card-header { min-height: 118px; display: flex; justify-content: space-between; align-items: start; gap: 20px; padding: 22px 22px 17px; border-bottom: 1px solid var(--line); }
.forecast-card-header h3 { margin: 7px 0 3px; font-size: 1.38rem; }
.cycle-label { margin: 0; color: var(--muted); font-size: .9rem; }
.product-tag { display: inline-flex; background: #e5f4fa; color: #0b658b; border-radius: 999px; padding: 5px 9px; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.product-tag.regional { background: #e5f5f1; color: #167466; }
.compact-control { display: grid; gap: 5px; min-width: 108px; }
.compact-control span, .filter-field span { color: var(--muted); font-size: .78rem; font-weight: 750; }
.compact-control select, .filter-field select { width: 100%; border: 1px solid #cfdde5; background: #fff; color: var(--text); border-radius: 9px; padding: 9px 34px 9px 10px; }
.filter-field select:disabled { appearance: none; -webkit-appearance: none; -moz-appearance: none; background-image: none; padding-right: 10px; cursor: default;}
.forecast-image-wrap { position: relative; background: #eef3f6; min-height: 330px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.forecast-image { width: 100%; height: 100%; min-height: 330px; max-height: 520px; object-fit: contain; display: block; background: #fff; cursor: zoom-in; }
.image-loading, .image-error { min-height: 330px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.spinner { width: 20px; height: 20px; border: 2px solid #c9d9e3; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.forecast-meta { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.forecast-meta > div { padding: 13px 20px; }
.forecast-meta > div + div { border-left: 1px solid var(--line); }
.forecast-meta span { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 3px; }
.forecast-meta strong { font-size: .95rem; }
.lead-strip { display: flex; gap: 7px; padding: 14px 18px; overflow-x: auto; scrollbar-width: thin; background: #fbfdfe; }
.lead-button { flex: 0 0 auto; border: 1px solid var(--line); background: #fff; color: var(--navy); border-radius: 8px; padding: 7px 10px; font-weight: 750; font-size: .78rem; }
.lead-button.active { color: #fff; background: var(--navy); border-color: var(--navy); }
.forecast-actions { display: flex; gap: 10px; padding: 17px 18px 20px; }

.evaluation-layout { display: grid; grid-template-columns: 315px minmax(0, 1fr); gap: 24px; padding: 34px 0 68px; align-items: start; }
.filter-panel { position: sticky; top: 100px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.filter-panel-heading { padding-bottom: 15px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.filter-kicker { color: var(--blue); text-transform: uppercase; letter-spacing: .12em; font-size: .7rem; font-weight: 800; }
.filter-grid { display: grid; gap: 12px; }
.filter-field { display: grid; gap: 5px; }
.filter-field.is-hidden { display: none; }
.filter-note { margin: 16px 0; padding: 11px 12px; border-radius: 9px; background: var(--surface-soft); border: 1px solid var(--line); color: var(--muted); font-size: .81rem; line-height: 1.45; }
.evaluation-results { min-width: 0; }
.results-header { display: flex; justify-content: space-between; align-items: end; gap: 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.results-header p:not(.eyebrow) { margin: 5px 0 0; color: var(--muted); }
.state-panel { background: #fff; border: 1px dashed #c8d8e2; border-radius: var(--radius); padding: 36px; text-align: center; color: var(--muted); display: flex; gap: 10px; align-items: center; justify-content: center; }
.state-panel.error { color: #9b3f3f; border-color: #efcaca; background: #fff9f9; }
.evaluation-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.evaluation-gallery.single { grid-template-columns: minmax(0, 1fr); }
.evaluation-card { background: #fff; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; box-shadow: 0 6px 20px rgba(10,55,84,.07); }
.evaluation-card-image { background: #f1f5f8; min-height: 250px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.evaluation-card-image img { width: 100%; max-height: 620px; object-fit: contain; display: block; cursor: zoom-in; background: #fff; }
.evaluation-card-footer { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.evaluation-card-footer strong { font-size: .86rem; overflow-wrap: anywhere; }
.evaluation-card-footer button { border: 0; background: transparent; color: var(--blue); font-weight: 750; padding: 3px; }

.data-section { padding: 42px 0 70px; }
.resource-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.resource-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 22px; text-decoration: none; display: grid; gap: 8px; box-shadow: 0 5px 18px rgba(10,55,84,.06); transition: .16s ease; }
.resource-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.resource-card > span:last-child { color: var(--muted); font-size: .84rem; }
.resource-code { color: var(--blue); font-weight: 850; font-size: .78rem; letter-spacing: .08em; }

.site-footer { background: var(--navy-deep); color: #fff; padding: 24px 0; }
.footer-inner { display: flex; align-items: center; gap: 18px; }
.footer-inner img { width: 115px; filter: brightness(0) invert(1); opacity: .92; }
.footer-inner p { margin: 3px 0 0; color: rgba(255,255,255,.68); font-size: .86rem; }

.login-overlay { position: fixed; inset: 0; z-index: 100; background: linear-gradient(135deg, rgba(3,31,51,.98), rgba(7,59,97,.97)); display: grid; place-items: center; padding: 24px; }
.login-overlay[aria-hidden="true"] { display: none; }
.login-card { width: min(430px, 100%); background: #fff; border-radius: 22px; padding: 32px; box-shadow: 0 28px 70px rgba(0,0,0,.28); }
.login-logo { width: 150px; margin-bottom: 18px; }
.login-card h1 { margin: 2px 0 8px; }
.login-copy { color: var(--muted); margin: 0 0 20px; }
.login-form { display: grid; gap: 9px; }
.login-form label { font-weight: 750; }
.password-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.password-row input { min-width: 0; border: 1px solid #cad9e2; border-radius: 10px; padding: 11px 12px; }
.login-error { min-height: 18px; margin: 0; color: #ad3939; font-size: .84rem; }
.security-note { margin: 17px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.45; }

.image-dialog {
  width: min(100vw, 1200px);
  max-width: 1200px;
  max-height: 100vh;
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 28px 80px rgba(0,0,0,.35);
}

.image-dialog::backdrop { background: rgba(3,26,43,.75); }
.dialog-header, .dialog-footer { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.dialog-footer { border-bottom: 0; border-top: 1px solid var(--line); justify-content: flex-end; }

.dialog-body {
  background: #edf2f5;
  overflow: auto;
  max-height: calc(100vh - 225px);
  text-align: center;
}

.dialog-body img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 225px);
  width: auto;
  height: auto;
  margin: 0 auto;
}


@media (max-width: 1100px) {
  .forecast-dashboard, .evaluation-gallery { grid-template-columns: 1fr; }
  .evaluation-layout { grid-template-columns: 1fr; }
  .filter-panel { position: static; }
  .filter-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .resource-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 760px) {
  .container { width: min(100% - 24px, 1460px); }
  .header-inner { grid-template-columns: 1fr auto; min-height: 68px; }
  .brand img { width: 116px; }
  .main-nav { grid-column: 1 / -1; grid-row: 2; width: 100%; justify-content: stretch; margin-bottom: 9px; }
  .nav-tab { flex: 1; padding: 8px 10px; }
  #logoutButton { grid-column: 2; grid-row: 1; }
  .hero-content, .inline-heading, .forecast-card-header, .results-header { align-items: flex-start; flex-direction: column; }
  .compact-hero { padding: 32px 0; }
  .live-badge { display: none; }
  .forecast-image-wrap, .forecast-image, .image-loading, .image-error { min-height: 245px; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .resource-grid { grid-template-columns: 1fr 1fr; }
  .forecast-actions { flex-direction: column; }
  .forecast-actions .button { width: 100%; }
}

@media (max-width: 500px) {
  .filter-grid, .resource-grid { grid-template-columns: 1fr; }
  .forecast-meta { grid-template-columns: 1fr; }
  .forecast-meta > div + div { border-left: 0; border-top: 1px solid var(--line); }
}

/* V2.1: seleção de rodada e destaque dos produtos MONAN */
.forecast-controls { display: flex; align-items: end; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.run-control { min-width: 205px; }
.featured-resource { border-color: #b7d8e8; background: linear-gradient(145deg, #ffffff, #f1f8fb); }
.featured-resource .resource-code { color: var(--navy); }

@media (max-width: 760px) {
  .forecast-controls { width: 100%; justify-content: stretch; }
  .forecast-controls .compact-control { flex: 1 1 130px; }
  .forecast-controls .run-control { flex-basis: 210px; }
}
