:root {
  --bg: #07111f;
  --surface: #0d1b2d;
  --surface-2: #12243a;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f4f7fb;
  --muted: #9aabc2;
  --accent: #f3c500;
  --good: #2ecc71;
  --warn: #f5a623;
  --bad: #ff5d5d;
  --blue: #4aa3ff;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  background:
    radial-gradient(circle at top right, rgba(74, 163, 255, 0.08), transparent 25%),
    var(--bg);
}

button, select { font: inherit; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #081422;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 34px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #07111f;
  font-weight: 900;
  font-size: 24px;
  background: var(--accent);
}

.brand strong,
.brand span { display: block; }

.brand span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.menu {
  display: grid;
  gap: 8px;
}

.menu a,
.menu span {
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.menu a:hover,
.menu a.active {
  color: var(--text);
  background: var(--surface-2);
}

.menu a.active {
  border-left: 3px solid var(--accent);
}

.menu .disabled {
  opacity: 0.45;
  cursor: default;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.sidebar-footer small,
.sidebar-footer strong { display: block; }

.sidebar-footer small {
  color: var(--muted);
  margin-bottom: 5px;
}

.main-content {
  padding: 26px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.4px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 42px);
}

.topbar p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.select-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

select, button {
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 42px;
  padding: 0 14px;
}

select {
  min-width: 170px;
  color: var(--text);
  background: var(--surface);
}

button {
  color: #07111f;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

button:hover { filter: brightness(1.05); }

.alert {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 10px;
  color: #ffdede;
  border: 1px solid rgba(255, 93, 93, 0.35);
  background: rgba(255, 93, 93, 0.10);
}

.hidden { display: none; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card,
.panel {
  background: linear-gradient(180deg, rgba(18, 36, 58, 0.96), rgba(13, 27, 45, 0.96));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.kpi-card {
  min-height: 150px;
  padding: 18px;
  border-radius: 14px;
  border-top: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-label,
.kpi-card small,
.panel p {
  color: var(--muted);
}

.kpi-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.kpi-card strong {
  font-size: clamp(25px, 2.5vw, 38px);
  line-height: 1;
}

.kpi-card small {
  font-size: 11px;
  line-height: 1.35;
}

.content-grid,
.charts-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.content-grid {
  grid-template-columns: 1.2fr 0.8fr;
}

.charts-grid {
  grid-template-columns: 1.35fr 0.65fr;
}

.panel {
  padding: 20px;
  border-radius: 14px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0;
  font-size: 17px;
}

.panel p {
  margin: 6px 0 0;
  font-size: 12px;
}

.status-pill {
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.status-pill.good {
  color: #bdf8d2;
  background: rgba(46, 204, 113, 0.15);
}

.status-pill.warn {
  color: #ffe0a6;
  background: rgba(245, 166, 35, 0.16);
}

.status-pill.bad {
  color: #ffc5c5;
  background: rgba(255, 93, 93, 0.16);
}

.goal-values {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.goal-values strong { color: var(--text); }

.progress-track {
  height: 16px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s ease;
}

.goal-message,
.flow-message {
  min-height: 18px;
}

.flow-compare {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  text-align: center;
  gap: 14px;
  margin-top: 8px;
}

.flow-compare span {
  color: var(--muted);
  font-size: 12px;
}

.flow-compare strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.flow-arrow {
  color: var(--accent);
  font-size: 28px;
}

.bar-chart {
  min-height: 280px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding-top: 20px;
  overflow-x: auto;
}

.month-bar {
  min-width: 52px;
  flex: 1;
  display: grid;
  grid-template-rows: 210px auto;
  gap: 8px;
}

.month-bar-area {
  display: flex;
  gap: 5px;
  align-items: flex-end;
  justify-content: center;
  border-bottom: 1px solid var(--border);
}

.bar {
  width: 13px;
  min-height: 2px;
  border-radius: 5px 5px 0 0;
}

.bar.new { background: var(--blue); }
.bar.done { background: var(--accent); }

.month-label {
  text-align: center;
  color: var(--muted);
  font-size: 10px;
}

.year-chart {
  min-height: 280px;
  display: grid;
  align-content: center;
  gap: 18px;
}

.year-row {
  display: grid;
  grid-template-columns: 48px 1fr 72px;
  align-items: center;
  gap: 10px;
}

.year-row span {
  color: var(--muted);
  font-size: 12px;
}

.year-track {
  height: 20px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.07);
}

.year-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--blue), var(--accent));
}

.year-value {
  color: var(--text) !important;
  font-weight: 800;
  text-align: right;
}

.table-panel { margin-bottom: 16px; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th, td {
  padding: 12px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

th {
  color: var(--muted);
  font-weight: 700;
}

th:first-child,
td:first-child { text-align: left; }

tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 1300px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 950px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }
  .menu {
    display: flex;
    overflow-x: auto;
  }
  .sidebar-footer { display: none; }
  .content-grid,
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .main-content { padding: 16px; }
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }
  select, button { width: 100%; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  footer { flex-direction: column; }
}


/* =====================================================
   PERFORMANCE V2 - INDICADORES EXECUTIVOS
===================================================== */

.executive-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.executive-card {
  min-height: 132px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-left: 3px solid var(--blue);
}

.executive-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.executive-card strong {
  font-size: 28px;
  line-height: 1;
}

.executive-card small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.value-good { color: var(--good) !important; }
.value-warn { color: var(--warn) !important; }
.value-bad { color: var(--bad) !important; }

.ranking-panel {
  margin-bottom: 16px;
}

.ranking-list {
  display: grid;
  gap: 10px;
}

.ranking-item {
  display: grid;
  grid-template-columns: 36px 130px 1fr 90px;
  align-items: center;
  gap: 12px;
}

.ranking-position {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(243, 197, 0, 0.14);
  color: var(--accent);
  font-weight: 900;
  font-size: 12px;
}

.ranking-name {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.ranking-track {
  height: 13px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.07);
}

.ranking-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--accent));
}

.ranking-value {
  text-align: right;
  color: var(--text);
  font-weight: 900;
  font-size: 12px;
}

@media (max-width: 1100px) {
  .executive-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  .executive-grid { grid-template-columns: 1fr; }
  .ranking-item {
    grid-template-columns: 32px 100px 1fr 72px;
    gap: 8px;
  }
}


/* =====================================================
   PERFORMANCE V3 - EXPORTAÇÃO E RESUMO EXECUTIVO
===================================================== */

.topbar-actions {
  flex-wrap: wrap;
}

.secondary-action {
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  background: rgba(255, 255, 255, 0.07) !important;
  color: var(--text) !important;
}

.secondary-action:hover {
  border-color: var(--blue) !important;
  background: rgba(33, 150, 243, 0.14) !important;
}

.executive-summary {
  margin-bottom: 16px;
  padding: 18px 20px;
  border-left: 4px solid var(--blue);
}

.executive-summary-text {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
}

@media print {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  body {
    background: #ffffff !important;
    color: #111111 !important;
  }

  .sidebar,
  .topbar-actions,
  footer {
    display: none !important;
  }

  .app-shell {
    display: block !important;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  .topbar {
    margin-bottom: 10px !important;
  }

  .panel,
  .kpi-card {
    break-inside: avoid;
    box-shadow: none !important;
    background: #ffffff !important;
    border: 1px solid #cccccc !important;
    color: #111111 !important;
  }

  .panel *,
  .kpi-card *,
  .topbar * {
    color: #111111 !important;
  }

  .ranking-fill,
  .year-fill,
  .bar,
  .progress-bar {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .table-wrap {
    overflow: visible !important;
  }

  table {
    min-width: 0 !important;
  }
}


/* =====================================================
   PERFORMANCE - SOLICITAÇÕES DA GERÊNCIA / V30
===================================================== */

:root {
  --accent: #00a6d6;
  --blue: #00a6d6;
  --yellow: #ffd100;
}

body.embed-mode .app-shell {
  display: block !important;
  width: 100% !important;
}

body.embed-mode .sidebar {
  display: none !important;
}

body.embed-mode .main-content {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 18px !important;
}

body.embed-mode {
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(0, 166, 214, 0.10), transparent 34%),
    linear-gradient(90deg, #06111b 0%, #071521 50%, #0a1e2e 100%);
}

.menu a strong,
.menu a small {
  display: block;
}

.menu a small {
  margin-top: 4px;
  color: #7f96aa;
  font-size: 10px;
}

.kpi-grid-four {
  grid-template-columns: repeat(4, minmax(180px, 1fr)) !important;
}

.executive-summary {
  width: 100%;
}

.comparison-panel {
  min-height: 420px;
}

.comparison-header {
  align-items: center;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 18px;
  height: 7px;
  border-radius: 99px;
}

.legend-current { background: #00a6d6; }
.legend-previous { background: #7c8cff; }
.legend-target { background: #ffd100; }
.legend-new { background: #7c8cff; }
.legend-done { background: #00a6d6; }

.comparison-chart,
.volume-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(60px, 1fr));
  gap: 10px;
  min-width: 900px;
  min-height: 300px;
  padding-top: 12px;
}

.comparison-panel,
.chart-panel {
  overflow-x: auto;
}

.comparison-month,
.volume-month {
  min-height: 285px;
  display: grid;
  grid-template-rows: 42px 220px 22px;
  align-items: end;
}

.comparison-values,
.volume-values {
  display: flex;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.comparison-values span,
.volume-values span {
  width: 42px;
  text-align: center;
}

.comparison-bars,
.volume-bars {
  position: relative;
  height: 220px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  background:
    linear-gradient(to top, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 100% 25%;
}

.comparison-bar,
.volume-bar {
  width: 30%;
  max-width: 34px;
  min-height: 0;
  border-radius: 6px 6px 2px 2px;
  transition: height .25s ease;
}

.comparison-bar.current {
  background: linear-gradient(180deg, #13b9eb, #008dbb);
}

.comparison-bar.previous {
  background: linear-gradient(180deg, #929cff, #646fd8);
}

.volume-bar.new {
  background: linear-gradient(180deg, #929cff, #646fd8);
}

.volume-bar.done {
  background: linear-gradient(180deg, #13b9eb, #008dbb);
}

.monthly-target {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 3;
  height: 2px;
  border-top: 2px dashed #ffd100;
  pointer-events: none;
}

.month-label {
  text-align: center;
  color: var(--text);
  font-size: 10px;
  font-weight: 900;
}

.table-panel {
  width: 100%;
}

.status-pill.warn {
  color: #ffd978;
}

@media (max-width: 1100px) {
  .kpi-grid-four {
    grid-template-columns: repeat(2, minmax(180px, 1fr)) !important;
  }
}

@media (max-width: 700px) {
  .kpi-grid-four {
    grid-template-columns: 1fr !important;
  }

  .topbar {
    align-items: flex-start;
  }
}

@media print {
  .topbar-actions,
  .sidebar {
    display: none !important;
  }

  .app-shell {
    display: block !important;
  }

  .main-content {
    width: 100% !important;
    padding: 0 !important;
  }

  .comparison-chart,
  .volume-chart {
    min-width: 0;
    gap: 4px;
  }

  .comparison-values,
  .volume-values {
    font-size: 7px;
  }
}
