:root {
  --bg: #f7f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --border: #e5e7eb;
  --accent: #eef2ff;
}
* { box-sizing: border-box }
html, body { height: 100% }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(8px);
}
.brand {
  font-weight: 600;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  height: 100%;
}
.brand-logo {
  height: 60%;
  width: 40%;
  margin-right: 8px;
  vertical-align: middle;
  display: inline-block;
}
.hamburger {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
}
.menu-panel {
  position: absolute;
  right: 16px;
  top: 56px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  padding: 12px;
  width: 280px;
  max-height: 70vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.menu-panel.hidden { display: none }
.menu-group { margin-bottom: 8px }
.menu-title { font-size: 12px; color: var(--muted); margin-bottom: 6px }
.menu-item {
  display: block;
  text-decoration: none;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
}
.menu-item:hover { background: var(--accent); color: var(--primary) }
.checkbox-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
}
.checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--primary);
  font-size: 12px;
  margin: 2px 6px 2px 0;
}
main#app {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
}
.view.hidden { display: none }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.03);
}
h2, h3 { margin: 0 0 12px 0 }
.icon-link { margin-left: 8px; color: var(--muted); text-decoration: none; vertical-align: middle }
.icon-link:hover { color: var(--primary) }
.icon-link svg { display: inline-block }
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 6px }
.field.full { grid-column: 1 / -1 }
label { font-size: 12px; color: var(--muted) }
input, select {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}
.divider {
  grid-column: 1 / -1;
  height: 1px;
  background: var(--border);
  margin: 6px 0 2px 0;
}
.radio-group { display: flex; gap: 12px; flex-wrap: wrap }
.radio-group label { display: inline-flex; align-items: center; gap: 8px }
.input-with-actions { display: flex; gap: 8px; align-items: center }
.input-with-actions input { flex: 1 }
.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.preset-actions { justify-content: flex-start; flex-wrap: wrap }
.form-actions { justify-content: flex-end; flex-wrap: wrap }
.btn {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 0 14px;
  color: var(--text);
  cursor: pointer;
}
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px }
.btn-group { display: flex; flex-wrap: wrap; gap: 6px }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn[disabled] { opacity: .5; cursor: not-allowed }
.table-wrap {
  overflow: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead tr { background: #fafafa }
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
td .btn {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}
.summary {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
}
.total {
  font-weight: 600;
}
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.filters select { width: 180px }
.filters input { width: 220px }
#view-home .filters { margin-bottom: 12px }
.muted { color: var(--muted) }
.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.kpi {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}
.kpi-label {
  font-size: 12px;
  color: var(--muted);
}
.kpi-value {
  margin-top: 4px;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}
.table-total-row { background: var(--accent) }
.table-total-row td { font-weight: 600; border-top: 2px solid var(--primary) }
.modal.hidden { display: none }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal .modal-content {
  max-width: 700px;
  width: 100%;
}
.loading-overlay.hidden { display: none }
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.5);
  z-index: 999;
}
.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg) }
}

/* Responsividade */
@media (max-width: 900px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 600px) {
  .kpis {
    grid-template-columns: 1fr;
  }
  .list-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .filters select,
  .filters input {
    width: 100%;
  }
  .summary {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
