/* Layout geral */
:root {
  --bg-main: #F0F5A4;
  --bg-header: #F5E214;
  --bg-nav: #B1F52D;
  --bg-mainpage: #F1F573;
  --text-main: #6E704B;
  --text-header: #6B6309;
  --text-nav: #537315;
  --text-mainpage: #6C6E33;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
}

#container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* HEADER */
.app-header {
  background: var(--bg-header);
  color: var(--text-header);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: contain;
}

.header-title-group {
  display: flex;
  flex-direction: column;
}

.header-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.header-subtitle {
  font-size: 0.8rem;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.header-clock-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.header-meta {
  font-size: 0.75rem;
}

/* NAV */
.app-nav {
  background: var(--bg-nav);
  color: var(--text-nav);
  padding: 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.menu-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.menu-row input[type="text"] {
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  border: 1px solid #aaa;
  font-size: 0.85rem;
}

/* BOTÕES */
.btn {
  border: none;
  border-radius: 4px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
  background: #4c7c11;
  color: #fff;
}

.btn.primary {
  background: #336699;
}

.btn.secondary {
  background: #888;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* MAIN LAYOUT */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-mainpage);
  color: var(--text-mainpage);
}

.panel {
  background: rgba(255,255,255,0.75);
  border-radius: var(--radius);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.panel-left {
  flex-basis: 32%;
  min-width: 260px;
}

.panel-right {
  flex-basis: 63%;
  flex-grow: 1;
}

h3, h4 {
  margin-top: 0;
}

/* INFO GRID */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.25rem 0.75rem;
  font-size: 0.85rem;
}

.small-info {
  font-size: 0.8rem;
  opacity: 0.9;
}

/* TABELA TOP20 */
.table-wrapper {
  flex: 1;
  overflow: auto;
  border-radius: var(--radius);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid #ddd;
  text-align: right;
}

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

th {
  background: #e0ec9c;
  position: sticky;
  top: 0;
  z-index: 1;
}

tr:hover {
  background: #f5f9d5;
  cursor: pointer;
}

/* GRÁFICOS */
#charts-panel {
  margin-top: 0.5rem;
  background: rgba(255,255,255,0.7);
  border-radius: var(--radius);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.charts-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chart-container {
  width: 100%;
  height: 220px;
}

/* FOOTER */
.app-footer {
  background: #ddd;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
}

.modal {
  background: #fff;
  padding: 1rem;
  border-radius: var(--radius);
  min-width: 280px;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal input[type="text"] {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #aaa;
  font-size: 0.85rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* RESPONSIVO */
@media (max-width: 900px) {
  .app-main {
    flex-direction: column;
  }
  .panel-left,
  .panel-right {
    width: 100%;
  }
  .chart-container {
    height: 200px;
  }
}
