:root {
  --bg: #f4efe6;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #fffaf3;
  --line: #d8cfbf;
  --ink: #1c2a22;
  --muted: #6b756d;
  --accent: #285943;
  --accent-soft: #d8eadf;
  --accent-strong: #1c4735;
  --warning: #a63f32;
  --shadow: 0 20px 45px rgba(32, 41, 35, 0.08);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Aptos", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(77, 125, 101, 0.24), transparent 28%),
    linear-gradient(180deg, #f9f4ec 0%, #f1ebdf 100%);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  padding: 28px 22px;
  background: rgba(28, 42, 34, 0.95);
  color: white;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand h1,
.page-header h2,
.hero h3,
.panel-heading h4 {
  font-family: Georgia, "Times New Roman", serif;
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  opacity: 0.75;
}

.muted {
  color: var(--muted);
}

.sidebar .muted {
  color: rgba(255, 255, 255, 0.72);
}

.small {
  font-size: 0.88rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-link,
button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: 0.2s ease;
}

.nav-link {
  text-align: left;
  background: rgba(255, 255, 255, 0.06);
  color: white;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(216, 234, 223, 0.18);
}

.sidebar-card {
  margin-top: auto;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 8px;
  opacity: 0.7;
}

.main {
  padding: 26px;
}

.page-header,
.hero,
.panel-heading.inline,
.form-actions,
.backup-grid,
.header-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #58b368;
  box-shadow: 0 0 0 6px rgba(88, 179, 104, 0.12);
}

.hero,
.panel {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.hero {
  padding: 22px 24px;
  margin-bottom: 18px;
}

.panel {
  padding: 20px;
  margin-bottom: 18px;
}

.kpi-grid,
.dashboard-grid,
.form-grid,
.catalog-grid {
  display: grid;
  gap: 16px;
}

.kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.dashboard-grid {
  grid-template-columns: 1.2fr 0.8fr;
}

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

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

.cols-span-3 {
  grid-column: span 3;
}

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

.kpi-card {
  background: linear-gradient(160deg, rgba(255, 250, 243, 0.96), rgba(216, 234, 223, 0.92));
  border-radius: 18px;
  padding: 18px;
  border: 1px solid rgba(40, 89, 67, 0.08);
}

.kpi-card strong {
  display: block;
  font-size: 1.6rem;
  margin-top: 10px;
  color: var(--accent-strong);
}

.kpi-card-sales {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kpi-subcards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.kpi-subcard {
  background: rgba(255, 250, 243, 0.9);
  border: 1px solid rgba(40, 89, 67, 0.1);
  border-radius: 14px;
  padding: 12px;
}

.kpi-subcard b {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
  color: var(--accent-strong);
}

.kpi-card-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stock-bars {
  display: flex;
  align-items: end;
  gap: 14px;
  min-height: 160px;
  height: 160px;
  margin-top: auto;
}

.stock-bar-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.stock-bar-wrap {
  width: 100%;
  height: 122px;
  display: flex;
  align-items: end;
  justify-content: center;
  padding-top: 22px;
}

.stock-bar {
  width: 100%;
  max-width: 52px;
  min-height: 14px;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, #3f7a60 0%, #285943 100%);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  text-align: center;
  position: relative;
}

.stock-bar-label {
  font-size: 0.84rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.15;
}

.stock-bar-value {
  color: #f9f4ec;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.1;
}

.stock-bar-compact {
  background: linear-gradient(180deg, #5d8f79 0%, #3a6c56 100%);
}

.stock-bar-value-outside {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  color: var(--accent-strong);
  background: rgba(255, 250, 243, 0.95);
  border: 1px solid rgba(216, 207, 191, 0.9);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(28, 42, 34, 0.08);
}

.availability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.availability-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 250, 243, 0.85);
  border: 1px solid rgba(40, 89, 67, 0.1);
}

.availability-pie {
  --availability-angle: 0deg;
  width: 92px;
  height: 92px;
  border-radius: 999px;
  background: conic-gradient(var(--accent) 0deg var(--availability-angle), rgba(216, 207, 191, 0.55) var(--availability-angle) 360deg);
  display: grid;
  place-items: center;
  position: relative;
  flex: 0 0 auto;
}

.availability-pie::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 999px;
  background: #fffaf3;
}

.availability-pie span {
  position: relative;
  z-index: 1;
  font-weight: 700;
  color: var(--accent-strong);
}

.city-map {
  min-height: 360px;
}

.city-map-shell {
  position: relative;
}

.city-map-frame {
  position: relative;
  min-height: 360px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(40, 89, 67, 0.1);
  background:
    url("./assets/brazil_states.svg") center 58% / min(78%, 900px) no-repeat,
    radial-gradient(circle at 20% 20%, rgba(216, 234, 223, 0.95), rgba(216, 234, 223, 0.15) 30%, transparent 40%),
    radial-gradient(circle at 60% 65%, rgba(40, 89, 67, 0.18), transparent 35%),
    linear-gradient(180deg, #f8f4ee 0%, #eef5f0 100%);
}

.city-map-frame--mapbox {
  min-height: 420px;
  background: linear-gradient(180deg, rgba(232, 240, 235, 0.95), rgba(245, 239, 230, 0.95));
}

.city-map-brazil {
  position: absolute;
  inset: 18px auto auto 18px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(28, 42, 34, 0.45);
}

.city-map-setup {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.city-map-setup code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(40, 89, 67, 0.08);
  color: var(--accent-strong);
}

.city-mapbox-marker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  box-shadow: none;
}

.city-mapbox-marker:hover {
  transform: translateY(-1px);
}

.city-mapbox-marker-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #c4513d;
  box-shadow: 0 0 0 5px rgba(196, 81, 61, 0.18);
  border: 2px solid rgba(255, 250, 243, 0.96);
  flex: 0 0 auto;
}

.city-mapbox-marker-label {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.96);
  border: 1px solid rgba(40, 89, 67, 0.12);
  color: var(--accent-strong);
  font-size: 0.82rem;
  white-space: nowrap;
  box-shadow: 0 10px 18px rgba(28, 42, 34, 0.08);
}

.city-popup {
  color: var(--ink);
}

.city-popup strong {
  display: block;
  margin-bottom: 6px;
}

.city-popup p {
  margin: 0;
}

.mapboxgl-popup-content {
  border-radius: 14px;
  padding: 12px 14px;
  font-family: "Aptos", "Segoe UI", sans-serif;
}

.mapboxgl-ctrl-group {
  border-radius: 12px;
  overflow: hidden;
}

label,
.stack,
.stack-xl {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stack-xl {
  gap: 18px;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

button {
  background: var(--accent);
  color: white;
  font-weight: 600;
}

button:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

button.secondary {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.button-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 16px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 600;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.icon-button {
  padding: 9px 12px;
  font-size: 0.9rem;
}

button.danger {
  background: rgba(166, 63, 50, 0.12);
  color: var(--warning);
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(216, 207, 191, 0.7);
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid rgba(216, 207, 191, 0.7);
  vertical-align: top;
}

td.wrap-cell {
  white-space: normal;
  min-width: 260px;
}

td.status-cell {
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-badge.ok {
  background: #d8eadf;
  color: #1c4735;
}

.status-badge.warning {
  background: #fde7b0;
  color: #8a5b00;
}

.status-badge.danger {
  background: #f7d4cf;
  color: #8f2f24;
}

.maintenance-hero {
  margin-bottom: 18px;
}

.report-hero {
  margin-bottom: 18px;
}

.report-actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

.director-report {
  background: #fffefb;
  border: 1px solid rgba(216, 207, 191, 0.7);
  border-radius: 22px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.director-report-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(216, 207, 191, 0.7);
}

.director-report-title h3,
.director-report-title h4 {
  margin: 0;
}

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

.report-card {
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(246, 250, 246, 1), rgba(234, 242, 236, 1));
  border: 1px solid rgba(40, 89, 67, 0.08);
}

.report-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.28rem;
  color: var(--accent-strong);
}

.report-section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.report-section {
  padding: 16px;
  border-radius: 18px;
  background: #faf6ef;
  border: 1px solid rgba(216, 207, 191, 0.7);
}

.report-section h5 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.inline-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.metric-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #eef4ef;
  color: var(--accent-strong);
  font-size: 0.9rem;
}

.empty-report {
  padding: 20px;
  border-radius: 18px;
  background: #faf6ef;
  border: 1px dashed rgba(216, 207, 191, 0.9);
}

th {
  background: #eef4ef;
  color: var(--accent-strong);
  font-size: 0.92rem;
}

tr:last-child td {
  border-bottom: 0;
}

.month-filter {
  min-width: 220px;
}

.hero-fields {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.backup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inline-field {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
}

.field-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.detail-card {
  padding: 14px;
  background: #f8f4ee;
  border-radius: 14px;
  border: 1px solid rgba(216, 207, 191, 0.65);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.labor-diff-cell {
  white-space: nowrap;
  color: var(--accent-strong);
  font-weight: 600;
}

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

  .sidebar {
    gap: 18px;
  }

  .kpi-grid,
  .dashboard-grid,
  .maintenance-grid,
  .director-report-grid,
  .report-section-grid,
  .form-grid.cols-4,
  .catalog-grid,
  .backup-grid {
    grid-template-columns: 1fr;
  }

  .cols-span-3 {
    grid-column: auto;
  }

  .hero-fields {
    justify-content: stretch;
  }

  .kpi-subcards {
    grid-template-columns: 1fr;
  }
}
