/* Visual alinhado ao Power BI Bases (2)
   Extraído do PBIX: tableEx fontSize 11, cards 26pt, slicer 10pt,
   página 1280x900, tema CY18SU07 (Segoe UI), cantos retos.
*/

:root {
  --teal: #5bb0b3;
  --teal-deep: #4a9e9e;
  --charcoal: #333333;
  --grey-head: #666666;
  --grey-chip: #9e9e9e;
  --grey-header: #b0b0b0;
  --nf: #e7b145;
  --cte: #f18982;
  --sub: #4fb7b3;
  --purple: #a663d1;
  --border: #c8c8c8;
  --row-alt: #f5f5f5;
  --bg: #ffffff;
  --text: #252423;
  --muted: #605e5c;
  --font: "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  border-radius: 0 !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

/* ---- Overlay de carregamento ---- */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.loading-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px 28px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #d0d0d0;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e0e0e0;
  border-top-color: var(--teal);
  animation: spin 0.75s linear infinite;
}

.loading-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--charcoal);
  letter-spacing: 0.3px;
  text-transform: lowercase;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


button,
input,
select,
textarea {
  font-family: inherit;
  border-radius: 0 !important;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 8px 8px;
  max-width: 1280px;
  margin: 0 auto;
  min-height: calc(100vh - 44px);
}

/* ---- Filtros (slicers) ---- */
.top-filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.month-bar {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  flex: 1 1 auto;
  overflow-x: auto;
}

.chip {
  border: none;
  background: var(--teal);
  color: #fff;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}

.chip:hover { filter: brightness(0.97); }

.chip.is-active,
.chip.year.is-active {
  background: var(--charcoal);
}

.chip.year {
  background: var(--grey-chip);
  min-width: 42px;
  padding: 4px 6px;
}

.chip.apply {
  background: var(--charcoal);
  margin-left: 4px;
  padding: 4px 10px;
}

.chip.clear {
  background: #8a8a8a;
  margin-left: 2px;
  padding: 4px 10px;
}

.chip.clear:hover {
  filter: brightness(0.95);
}

.year-day {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex: 0 0 auto;
}

.year-label,
.day-label {
  font-size: 9px;
  color: var(--muted);
  margin-bottom: 2px;
  font-weight: 600;
}

.year-list {
  display: flex;
  gap: 2px;
}

.day-range {
  display: flex;
  align-items: center;
  gap: 4px;
}

.day-range input[type="number"] {
  width: 36px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  font-size: 10px;
  text-align: center;
}

.day-range input[type="range"] {
  width: 72px;
  height: 3px;
  accent-color: var(--teal);
}

.error-banner {
  background: #fde7e9;
  color: #a4262c;
  border: 1px solid #f3b3b8;
  padding: 6px 8px;
  font-size: 11px;
}

/* ---- Meio ---- */
.mid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 8px;
  align-items: start;
}

.kpi-hero .kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.05;
  color: #000;
}

.kpi-hero .kpi-caption {
  color: var(--muted);
  margin-top: 1px;
  font-size: 11px;
  font-weight: 400;
}

.search-box {
  display: block;
  margin-top: 10px;
  max-width: 220px;
}

.search-box > span {
  display: block;
  font-size: 9px;
  color: var(--muted);
  margin-bottom: 2px;
  font-weight: 600;
}

.search-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  overflow: hidden;
  height: 24px;
}

.search-row input {
  flex: 1;
  border: none;
  padding: 2px 6px;
  outline: none;
  font-size: 11px;
  min-width: 0;
}

.search-row input::placeholder {
  color: #a19f9d;
}

.search-btn {
  border: none;
  border-left: 1px solid var(--border);
  background: #f3f2f1;
  padding: 0 7px;
  cursor: pointer;
  font-size: 11px;
  color: #605e5c;
  line-height: 1;
}

.mid-right {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 0;
}

.mini-title {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 0;
  color: var(--text);
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
  position: relative;
}

.col-head {
  background: var(--grey-head);
  color: #fff;
  text-align: center;
  font-weight: 700;
  padding: 5px 28px 5px 4px;
  font-size: 12px;
  letter-spacing: 0.2px;
  position: relative;
}

.more-menu {
  position: relative;
  flex: 0 0 auto;
}

.col-head .more-menu {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
}

.more-btn {
  border: none;
  background: transparent;
  color: #605e5c;
  cursor: pointer;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.more-btn:hover,
.more-menu.is-open .more-btn {
  background: rgba(0, 0, 0, 0.08);
}

.more-menu.on-dark .more-btn {
  color: #fff;
}

.more-menu.on-dark .more-btn:hover,
.more-menu.on-dark.is-open .more-btn {
  background: rgba(255, 255, 255, 0.18);
}

.more-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  right: 0;
  min-width: 140px;
  background: #fff;
  border: 1px solid #c8c8c8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  z-index: 30;
}

.more-dropdown a {
  display: block;
  padding: 8px 12px;
  color: #252423;
  text-decoration: none;
  font-size: 11px;
  white-space: nowrap;
}

.more-dropdown a:hover {
  background: #f3f2f1;
}


.table-scroll {
  border: 1px solid var(--border);
  overflow: auto;
  background: #fff;
}

.table-scroll.mini { max-height: 168px; }
.table-scroll.main {
  max-height: 340px;
  flex: 1;
  border-left: none;
  border-right: none;
  border-bottom: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  table-layout: auto;
}

th, td {
  padding: 2px 6px;
  border-bottom: 1px solid #ededed;
  text-align: left;
  font-size: 11px;
  font-weight: 400;
  height: 18px;
  line-height: 1.25;
}

thead th {
  position: sticky;
  top: 0;
  background: #f3f2f1;
  z-index: 1;
  font-weight: 600;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
  padding: 3px 6px;
}

.mini-panel thead th {
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.th-nf th { background: var(--nf); color: #252423; font-weight: 700; }
.th-cte th { background: var(--cte); color: #fff; font-weight: 700; }
.th-sub th { background: var(--sub); color: #fff; font-weight: 700; }

.th-purple {
  background: var(--purple) !important;
  color: #fff !important;
  font-weight: 700 !important;
}

.mini-panel:nth-child(2) thead th:first-child {
  background: var(--grey-header);
  color: #fff;
}

tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: #eef6f6; }

tfoot td {
  position: sticky;
  bottom: 0;
  background: #faf9f8;
  font-weight: 700;
  border-top: 1px solid var(--border);
  padding: 2px 6px;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 10px;
}

/* ---- Colunas inferiores ---- */
.columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  flex: 1;
  min-height: 0;
}

.col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
  border: none;
}

.col-kpi {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  padding: 6px 4px 4px;
  line-height: 1.1;
  color: #000;
}

/* scrollbars finos estilo desktop */
.table-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.table-scroll::-webkit-scrollbar-thumb { background: #c8c6c4; }
.table-scroll::-webkit-scrollbar-track { background: #f3f2f1; }

@media (max-width: 1100px) {
  .page { max-width: none; }
  .top-filters { flex-wrap: wrap; }
  .mid { grid-template-columns: 1fr; }
  .mid-right { grid-template-columns: 1fr; }
  .columns { grid-template-columns: 1fr; }
}
