@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Instrument+Serif:ital@0;1&display=swap");

:root {
  --bg: #f4f7fb;
  --bg-mesh: radial-gradient(ellipse 90% 55% at 0% -5%, rgba(16, 185, 129, 0.12), transparent 50%),
    radial-gradient(ellipse 70% 45% at 100% 0%, rgba(14, 165, 233, 0.08), transparent 45%);
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --sidebar-bg: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #059669;
  --accent-soft: rgba(5, 150, 105, 0.12);
  --sky: #0284c7;
  --warn: #d97706;
  --danger: #dc2626;
  --hover: rgba(15, 23, 42, 0.04);
  --chart-grid: rgba(15, 23, 42, 0.06);
  --chart-tick: #64748b;
  --hero-grad: linear-gradient(145deg, rgba(5, 150, 105, 0.14) 0%, #ffffff 58%);
  --hero-border: rgba(5, 150, 105, 0.22);
  --hero-label: #475569;
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 272px;
  --font: "DM Sans", system-ui, sans-serif;
  --font-display: "Instrument Serif", Georgia, serif;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] {
  --bg: #071018;
  --bg-mesh: radial-gradient(ellipse 80% 50% at 10% -10%, rgba(16, 185, 129, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(56, 189, 248, 0.08), transparent 50%);
  --bg-elevated: #0d1624;
  --bg-card: rgba(18, 28, 45, 0.92);
  --sidebar-bg: linear-gradient(165deg, #0a1220 0%, #060c14 100%);
  --topbar-bg: rgba(7, 16, 24, 0.9);
  --border: rgba(255, 255, 255, 0.07);
  --text: #f1f5f9;
  --muted: #8b9cb3;
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.18);
  --sky: #38bdf8;
  --warn: #fbbf24;
  --danger: #f87171;
  --hover: rgba(255, 255, 255, 0.04);
  --chart-grid: rgba(255, 255, 255, 0.05);
  --chart-tick: #94a3b8;
  --hero-grad: linear-gradient(145deg, rgba(16, 185, 129, 0.22) 0%, rgba(18, 28, 45, 0.95) 55%);
  --hero-border: rgba(16, 185, 129, 0.25);
  --hero-label: rgba(255, 255, 255, 0.65);
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  background-image: var(--bg-mesh);
  color: var(--text);
  font-family: var(--font);
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 1.35rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0 0.25rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, #059669 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
  color: #022c22;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.35);
}

.brand strong {
  display: block;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.brand span {
  font-size: 0.78rem;
  color: var(--muted);
}

.tenant-pill {
  margin: 0;
  padding: 0.45rem 0.65rem;
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 999px;
  text-align: center;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, transform 0.12s;
}

.nav a .ico {
  width: 1.35rem;
  text-align: center;
  opacity: 0.85;
}

.nav a:hover {
  background: var(--hover);
  color: var(--text);
}

.nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.sync-pill {
  padding: 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.45;
}

.sync-pill.ok {
  border-color: rgba(16, 185, 129, 0.35);
}

.sync-pill.warn {
  border-color: rgba(251, 191, 36, 0.4);
}

.sync-pill.syncing {
  border-color: rgba(56, 189, 248, 0.45);
}

.content-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--hover);
}

.theme-toggle:focus-visible,
.chip:focus-visible,
.menu-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sidebar-theme {
  width: 100%;
  margin-top: 0.25rem;
}

@media (max-width: 960px) {
  .sidebar-theme {
    display: none;
  }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.menu-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-family: inherit;
  font-size: 0.85rem;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.live-dot.ok {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.live-dot.syncing {
  background: var(--sky);
  animation: pulse 1.4s ease infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.main {
  flex: 1;
  padding: 1.5rem 2rem 5rem;
}

.page-header {
  margin-bottom: 1.35rem;
}

.page-header h1 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3vw, 2.15rem);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.page-header p {
  margin: 0;
  color: var(--muted);
  max-width: 40rem;
  line-height: 1.55;
  font-size: 0.95rem;
}

.banner {
  padding: 1rem 1.15rem;
  border-radius: var(--radius-sm);
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.35);
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  line-height: 1.5;
}

.banner.info {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.35);
}

.banner.hidden {
  display: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--hover);
}

.chip.active {
  background: var(--accent-soft);
  border-color: rgba(16, 185, 129, 0.45);
  color: var(--accent);
}

.hero-kpi {
  display: grid;
  grid-template-columns: 1.2fr repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.35rem;
}

@media (max-width: 1100px) {
  .hero-kpi {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .hero-kpi {
    grid-template-columns: 1fr;
  }
}

.kpi-hero {
  background: var(--hero-grad);
  border: 1px solid var(--hero-border);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow);
}

.kpi-hero label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--hero-label);
}

.kpi-hero.danger {
  --hero-grad: linear-gradient(145deg, rgba(220, 38, 38, 0.12) 0%, var(--bg-card) 58%);
  --hero-border: rgba(220, 38, 38, 0.28);
}

.kpi-hero .value {
  font-size: clamp(1.85rem, 4vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0.25rem 0;
}

.kpi-hero .sub {
  font-size: 0.88rem;
  color: var(--muted);
}

.kpi-grid {
  display: contents;
}

.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  backdrop-filter: blur(6px);
}

.kpi label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.kpi .value {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.kpi .sub {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.kpi .sub.up {
  color: var(--accent);
}

.kpi .sub.down {
  color: var(--danger);
}

.termo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.35rem;
}

.termo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  position: relative;
  overflow: hidden;
}

.termo-card::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0.7;
}

.termo-card.warn::after {
  background: var(--warn);
}

.termo-card.danger::after {
  background: var(--danger);
}

.termo-card .n {
  font-size: 1.55rem;
  font-weight: 700;
}

.termo-card .t {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.25rem;
  line-height: 1.35;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.card h2,
.section-title {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.35rem;
}


.chart-wrap {
  position: relative;
  height: 300px;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.15rem;
  padding: 0 0.15rem;
}

.table-scroll .data {
  min-width: 280px;
}

.card.section-indicadores {
  border-color: rgba(5, 150, 105, 0.18);
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-card) 70%, var(--accent-soft) 160%);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

table.data th,
table.data td {
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

table.data th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

table.data tbody tr:nth-child(even) td {
  background: var(--hover);
}

table.data tr:hover td {
  background: var(--hover);
}

.bar-inline .track {
  flex: 1;
  height: 6px;
  background: var(--chart-grid);
  border-radius: 99px;
  overflow: hidden;
}

.bar-inline .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #34d399);
  border-radius: 99px;
}

.bar-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.motivo {
  max-width: 220px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.loading {
  color: var(--muted);
  padding: 2.5rem;
  text-align: center;
}

.skeleton {
  animation: shimmer 1.2s ease infinite;
  background: linear-gradient(90deg, var(--bg-card) 0%, rgba(255, 255, 255, 0.06) 50%, var(--bg-card) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius);
  min-height: 120px;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.bottom-nav {
  display: none;
}

@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .topbar {
    display: flex;
  }

  .main {
    padding: 1.1rem 1rem 5.5rem;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--topbar-bg);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(10px);
    padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom));
    z-index: 35;
    justify-content: space-around;
  }

  .bottom-nav a {
    flex: 1;
    text-align: center;
    font-size: 0.65rem;
    color: var(--muted);
    padding: 0.35rem 0.15rem;
  }

  .bottom-nav a .ico {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 0.15rem;
  }

  .bottom-nav a.active {
    color: var(--accent);
  }
}
