:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #68737d;
  --line: #d9dee5;
  --accent: #256f61;
  --accent-2: #a64d2a;
  --warn: #b7791f;
  --danger: #a93636;
  --shadow: 0 8px 24px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.processing-overlay {
  align-items: center;
  background: rgba(246, 247, 249, 0.72);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 20;
}

.processing-overlay[hidden] {
  display: none;
}

.processing-box {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  min-width: 220px;
  padding: 16px 18px;
}

.processing-spinner {
  animation: spin 0.8s linear infinite;
  border: 3px solid #d9dee5;
  border-top-color: var(--accent);
  border-radius: 999px;
  height: 24px;
  width: 24px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 38px;
  padding: 0 12px;
}

button:hover {
  border-color: var(--accent);
}

.app-shell {
  padding: 20px;
}

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

.topbar-actions {
  align-items: flex-end;
  display: grid;
  gap: 8px;
  justify-items: end;
}

.topbar h1 {
  font-size: 28px;
  letter-spacing: 0;
  line-height: 1.1;
  margin: 0 0 4px;
}

.topbar p {
  color: var(--muted);
  margin: 0;
}

.status-pill {
  background: #e8f1ee;
  border: 1px solid #b8d2cb;
  border-radius: 999px;
  color: var(--accent);
  font-weight: 700;
  padding: 8px 12px;
  white-space: nowrap;
}

.top-auth-actions,
.top-password-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.company-switcher {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
}

.company-switcher[hidden] {
  display: none;
}

.company-switcher select {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 36px;
  padding: 0 10px;
}

.top-auth-actions[hidden],
.top-password-form[hidden] {
  display: none;
}

.top-password-form input {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 38px;
  padding: 0 10px;
  width: 150px;
}

.workspace-grid {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.app-shell.company-admin-mode .workspace-grid {
  grid-template-columns: 1fr;
}

.app-shell.company-admin-mode .side-panel,
.app-shell.company-admin-mode .kpi-grid,
.app-shell.company-admin-mode .tabs,
.app-shell.company-admin-mode .tab-panel:not(.company-admin-page) {
  display: none;
}

.app-shell.company-admin-mode .company-admin-page {
  display: block;
}

.side-panel,
.main-panel,
.panel-block,
.kpi-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.side-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.panel-block {
  box-shadow: none;
  padding: 14px;
}

.panel-block.locked {
  opacity: 0.58;
}

.panel-block.locked::after {
  color: var(--muted);
  content: "Entre para alterar esta area.";
  display: block;
  font-size: 12px;
  margin-top: 10px;
}

.panel-block h2 {
  font-size: 15px;
  margin: 0 0 12px;
}

.auth-panel {
  background: #fbfcfd;
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.auth-session {
  color: var(--muted);
  font-size: 13px;
}

.auth-session span {
  color: var(--accent);
  font-weight: 700;
}

.file-picker {
  align-items: center;
  background: var(--accent);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: flex;
  font-weight: 700;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
  text-align: center;
}

.file-picker input {
  display: none;
}

.metric-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
}

.metric-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.metric-list dt {
  color: var(--muted);
}

.metric-list dd {
  font-weight: 700;
  margin: 0;
  text-align: right;
}

.import-actions {
  margin-top: 12px;
}

.sync-log-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 12px;
  padding: 10px;
  background: #f8fafb;
}

.sync-log-card h3 {
  font-size: 13px;
  margin: 0;
}

.metric-list.compact {
  gap: 6px;
  margin-top: 10px;
}

.metric-list.compact dt,
.metric-list.compact dd {
  font-size: 12px;
}

.small-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin: 10px 0 0;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

.field input {
  border: 1px solid var(--line);
  border-radius: 6px;
  height: 38px;
  padding: 0 10px;
  width: 100%;
}

.check-field {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.check-field input {
  height: 18px;
  width: 18px;
}

.simulation-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.simulation-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.company-admin-form {
  display: grid;
  gap: 14px;
  max-width: 980px;
}

.page-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
}

.page-header h2 {
  font-size: 22px;
  margin: 0 0 4px;
}

.page-header p {
  color: var(--muted);
  margin: 0;
}

.form-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.form-section h3 {
  font-size: 16px;
  margin: 0 0 12px;
}

.muted-section {
  background: #f8fafb;
}

.form-grid,
.weekday-grid {
  display: grid;
  gap: 12px;
}

.form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.weekday-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.option-row,
.form-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.compact-check {
  align-self: end;
  min-height: 38px;
}

.created-company-result {
  background: #eef4f2;
  border: 1px solid #b8d2cb;
  border-radius: 8px;
  color: var(--accent);
  font-weight: 700;
  padding: 12px;
}

.created-company-result[hidden] {
  display: none;
}

.simulation-summary {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.projection-input {
  border: 1px solid var(--line);
  border-radius: 6px;
  height: 34px;
  max-width: 150px;
  padding: 0 8px;
  text-align: right;
  width: 100%;
}

.projection-control {
  align-items: center;
  display: flex;
  gap: 8px;
}

.projection-reset {
  min-height: 34px;
  white-space: nowrap;
}

.projection-source {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.cost-actions {
  margin-bottom: 10px;
}

.cost-list {
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}

.cost-item {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 6px;
  grid-template-columns: 42px 1fr 92px;
  padding-bottom: 8px;
}

.cost-item input {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
  padding: 6px;
}

.main-panel {
  min-width: 0;
  padding: 16px;
}

.kpi-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 14px;
}

.kpi-grid article {
  box-shadow: none;
  min-height: 86px;
  padding: 14px;
}

.kpi-grid span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}

.kpi-grid strong {
  font-size: 22px;
  letter-spacing: 0;
}

.tabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.tab {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-color: transparent;
}

.tab.active {
  background: #eef4f2;
  border-color: var(--line);
  color: var(--accent);
  font-weight: 700;
}

.product-subtabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.product-subtab {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-color: transparent;
}

.product-subtab.active {
  background: #eef4f2;
  border-color: var(--line);
  color: var(--accent);
  font-weight: 700;
}

.product-subpanel {
  display: none;
}

.product-subpanel.active {
  display: block;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.table-export-bar {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 8px;
}

.excel-export-btn {
  background: #eef4f2;
  border-color: var(--line);
  color: var(--accent);
  min-height: 32px;
  padding: 6px 10px;
}

.excel-export-btn:hover {
  background: #dfece8;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 66vh;
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2),
th:nth-child(3),
td:nth-child(3) {
  text-align: left;
}

th {
  background: #f1f4f6;
  color: #34404a;
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.sort-header {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: inherit;
  font-weight: 700;
  min-height: 0;
  padding: 0;
  text-align: right;
  width: 100%;
}

.sort-header:hover,
.sort-header.active {
  color: var(--accent);
}

.negative {
  color: var(--danger);
  font-weight: 700;
}

.positive {
  color: #0f766e;
  font-weight: 700;
}

.price-up {
  color: var(--danger);
  font-weight: 700;
}

.price-down {
  color: #0f766e;
  font-weight: 700;
}

.uncertain {
  color: var(--warn);
  font-weight: 700;
}

.report-heading {
  align-items: baseline;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.report-heading h3 {
  margin: 0;
}

.report-heading .small-note {
  margin-top: 4px;
}

.report-heading span {
  color: var(--muted);
  font-size: 13px;
}

.report-heading-meta {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: right;
}

.report-heading-meta strong {
  font-size: 13px;
}

.weekly-chart-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  overflow: hidden;
}

.weekly-chart-kpis {
  background: #f7faf9;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.weekly-chart-kpis article {
  background: #fff;
  border-radius: 0;
  box-shadow: none;
  min-height: 82px;
  padding: 14px;
}

.weekly-chart-kpis span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}

.weekly-chart-kpis strong {
  font-size: 22px;
}

.weekly-series-controls {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 10px 14px;
}

.check-field.compact {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin: 0;
}

.date-field.compact {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
  margin: 0;
}

.date-field.compact input {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  height: 32px;
  padding: 0 8px;
}

.check-field.compact input {
  height: 16px;
  width: 16px;
}

.weekly-chart {
  background: #fff;
  min-height: 330px;
  overflow-x: auto;
  padding: 10px;
}

.weekly-chart svg {
  display: block;
  min-width: 820px;
  width: 100%;
}

.chart-grid {
  stroke: #e4e9ed;
  stroke-width: 1;
}

.chart-axis-label,
.chart-x-labels text,
.chart-legend text {
  fill: #68737d;
  font-size: 12px;
}

.chart-area {
  fill: rgba(37, 111, 97, 0.08);
}

.chart-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chart-line-observed {
  stroke: var(--accent);
}

.chart-line-average {
  stroke: #265f8f;
}

.chart-line-trend {
  stroke: var(--accent-2);
  stroke-dasharray: 8 7;
}

.chart-point {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 3;
}

.chart-hotspot {
  cursor: help;
  fill: transparent;
  pointer-events: all;
  stroke: transparent;
}

.chart-tooltip {
  background: #172026;
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: #fff;
  display: grid;
  font-size: 12px;
  gap: 4px;
  line-height: 1.35;
  max-width: 280px;
  padding: 10px 12px;
  pointer-events: none;
  position: fixed;
  z-index: 40;
}

.chart-tooltip[hidden] {
  display: none;
}

.chart-tooltip strong {
  font-size: 13px;
}

.chart-tooltip span {
  color: #d8e3e0;
}

.chart-projection-boundary {
  stroke: #b8c2cb;
  stroke-dasharray: 4 6;
}

.chart-observation line {
  stroke: #d3b46d;
  stroke-dasharray: 3 7;
  stroke-width: 1;
}

.chart-observation text {
  fill: #8a6322;
  font-size: 11px;
  font-weight: 700;
}

.weekly-observations {
  align-items: center;
  background: #fffdf6;
  border-top: 1px solid var(--line);
  color: #6f5a2b;
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 8px;
  padding: 10px 14px;
}

.weekly-observations span {
  background: #fff7dd;
  border: 1px solid #ecdba7;
  border-radius: 999px;
  padding: 5px 9px;
}

.weekly-observations strong {
  color: #3d3420;
}

.projection-row td {
  color: var(--muted);
}

.weekly-table-wrap {
  max-height: 42vh;
}

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

.monthly-reports {
  display: grid;
  gap: 12px;
}

.month-tabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 0;
}

.month-tab {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-color: transparent;
  flex: 0 0 auto;
  text-transform: capitalize;
}

.month-tab.active {
  background: #eef4f2;
  border-color: var(--line);
  color: var(--accent);
  font-weight: 700;
}

.month-page {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: none;
  overflow: hidden;
}

.month-page.active {
  display: block;
}

.month-page header {
  align-items: center;
  background: #eef4f2;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px;
}

.month-page h3 {
  font-size: 16px;
  margin: 0;
}

.month-total {
  color: var(--accent);
  font-weight: 800;
}

.rule-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 220px 1fr;
  padding: 12px;
}

.rule-row strong {
  color: var(--accent);
}

.rule-row span {
  color: var(--muted);
}

@media (max-width: 1180px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

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