:root {
  --bg-body: #f3f6f8;
  --bg-surface: #ffffff;
  --bg-surface-soft: #f8fbfc;

  --text-main: #14263d;
  --text-muted: #64748b;
  --text-soft: #8aa0b2;

  --border-color: #dbe5ec;
  --border-strong: #c8d6df;

  --brand-primary: #005670;
  --brand-primary-strong: #00455a;
  --brand-dark: #073b4c;
  --brand-sidebar: #083f51;
  --brand-light: #e8f4f7;
  --brand-light-strong: #d7edf3;

  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --neutral: #94a3b8;
  --neutral-bg: #f1f5f9;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.14);

  --sidebar-width: 288px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, #f8fcfd 0%, #f3f6f8 35%, #edf2f6 100%);
  color: var(--text-main);
  display: flex;
  overflow: hidden;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */

.sidebar {
  width: var(--sidebar-width);
  background:
    linear-gradient(180deg, #08465a 0%, #073f52 45%, #06384a 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04);
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 28px 22px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #0f6f8c 0%, #0aa1b7 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.03em;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.16);
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.brand-text p {
  font-size: 12px;
  color: rgba(226, 232, 240, 0.78);
  line-height: 1.4;
}

.nav-menu {
  flex: 1;
  padding: 18px 14px 20px;
  overflow-y: auto;
}

.nav-menu::-webkit-scrollbar {
  width: 8px;
}

.nav-menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

.nav-btn {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: #d6e2ea;
  text-align: left;
  padding: 13px 14px;
  margin-bottom: 6px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.22s ease;
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.06);
  transform: translateX(2px);
}

.nav-btn.active {
  background: linear-gradient(135deg, #0a6c87 0%, #0a5d76 100%);
  color: #ffffff;
  font-weight: 600;
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow:
    0 10px 20px rgba(0, 0, 0, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.95;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.nav-label {
  flex: 1;
  line-height: 1.2;
}

/* ==========================================================================
   MAIN LAYOUT
   ========================================================================== */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
}

.header-bar {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  height: 78px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 5;
}

.header-context {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.context-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 700;
}

.header-context strong {
  font-size: 16px;
  color: var(--text-main);
}

.user-profile {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.tab-content {
  padding: 28px;
  display: none;
  animation: fadeIn 0.28s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   SECTIONS / CARDS / GRID
   ========================================================================== */

.section-header {
  margin-bottom: 26px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
}

.section-header h2 {
  font-size: 20px;
  color: var(--text-main);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.section-header p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.card {
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(207, 220, 229, 0.9);
  margin-bottom: 20px;
}

.card h3 {
  font-size: 16px;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 18px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* ==========================================================================
   BUTTONS / INPUTS
   ========================================================================== */

.btn {
  background: linear-gradient(135deg, var(--brand-primary) 0%, #0b6d87 100%);
  color: #fff;
  border: none;
  padding: 11px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 8px 18px rgba(0, 86, 112, 0.16);
}

.btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, var(--brand-primary-strong) 0%, #095d74 100%);
}

.btn.secondary {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  box-shadow: none;
}

.btn.secondary:hover {
  background: var(--neutral-bg);
  transform: translateY(-1px);
}

.btn.danger {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
  color: white;
  box-shadow: 0 8px 18px rgba(239, 68, 68, 0.16);
}

.btn.danger:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.btn.icon {
  padding: 8px 10px;
  font-size: 15px;
  min-width: 40px;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  outline: none;
  background: #fff;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 86, 112, 0.45);
  box-shadow: 0 0 0 4px rgba(0, 86, 112, 0.08);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 7px;
  color: var(--text-muted);
}

/* ==========================================================================
   TABLES
   ========================================================================== */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 13px 12px;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
}

td {
  padding: 13px 12px;
  border-bottom: 1px solid #e8eef3;
  vertical-align: middle;
}

tbody tr:hover {
  background-color: #f7fbfd;
}

/* ==========================================================================
   BADGES
   ========================================================================== */

.badge {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  display: inline-block;
  white-space: nowrap;
}

.badge.conforme,
.badge.ok {
  background: var(--success-bg);
  color: var(--success);
}

.badge.parcial,
.badge.warn {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge.nao-conforme,
.badge.bad {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.na,
.badge.neutral {
  background: var(--neutral-bg);
  color: var(--neutral);
}

/* ==========================================================================
   MAPA / DRAWER
   ========================================================================== */

.map-container {
  height: 520px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.36), rgba(255,255,255,0.2)),
    #e3ebf1 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" opacity="0.08"><path d="M0 0h100v100H0z" fill="none" stroke="%23000" stroke-width="1"/><circle cx="50" cy="50" r="2" fill="%23000"/></svg>');
  border-radius: var(--radius-lg);
  position: relative;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.map-pin {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.map-pin:hover {
  transform: translate(-50%, -50%) scale(1.22);
  z-index: 10;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.22);
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 23, 37, 0.34);
  z-index: 40;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.drawer {
  position: fixed;
  top: 0;
  right: -450px;
  width: 410px;
  max-width: 100%;
  height: 100vh;
  background: #fff;
  z-index: 50;
  box-shadow: var(--shadow-lg);
  transition: right 0.28s ease;
  display: flex;
  flex-direction: column;
}

.drawer-header {
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.drawer.open {
  right: 0;
}

.drawer-overlay.open {
  display: block;
  opacity: 1;
}

/* ==========================================================================
   VISTORIAS
   ========================================================================== */

.vistoria-layout {
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 24px;
  align-items: start;
}

.accordion {
  border: 1px solid var(--border-color);
  border-radius: 16px;
  margin-bottom: 12px;
  background: #fff;
  overflow: hidden;
}

.accordion-header {
  padding: 16px;
  background: #f7fafc;
  cursor: pointer;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.accordion-header:hover {
  background: #eef5f8;
}

.accordion-content {
  padding: 0 16px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease, padding 0.28s ease;
}

.accordion.open .accordion-content {
  padding: 16px;
  max-height: 2000px;
  border-top: 1px solid var(--border-color);
}

.accordion.open .accordion-header::after {
  content: "▲";
  font-size: 11px;
}

.accordion-header::after {
  content: "▼";
  font-size: 11px;
}

.check-item {
  display: grid;
  grid-template-columns: 2fr 1.3fr 2fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border-color);
}

.check-item:last-child {
  border-bottom: none;
}

.check-item-title {
  font-size: 14px;
  font-weight: 500;
}

.status-select {
  font-weight: 600;
}

.status-select[data-val="Conforme"] {
  color: var(--success);
  background: var(--success-bg);
  border-color: var(--success);
}

.status-select[data-val="Parcial"] {
  color: var(--warning);
  background: var(--warning-bg);
  border-color: var(--warning);
}

.status-select[data-val="Não conforme"] {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger);
}

.status-select[data-val="N/A"] {
  color: var(--neutral);
  background: var(--neutral-bg);
}

.vistoria-summary {
  position: sticky;
  top: 96px;
  background: linear-gradient(180deg, #083f51 0%, #06384a 100%);
  color: white;
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow-md);
}

.summary-metric {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,0.11);
  font-size: 14px;
}

.summary-metric:last-of-type {
  border-bottom: none;
}

.summary-metric strong {
  font-size: 16px;
}

.summary-result {
  margin-top: 16px;
  padding: 18px 16px;
  background: rgba(255,255,255,0.08);
  border-radius: 16px;
  text-align: center;
}

.summary-result h3 {
  font-size: 28px;
  margin-bottom: 6px;
}

/* ==========================================================================
   UTILIDADES EXTRAS
   ========================================================================== */

hr {
  border: none;
  border-top: 1px solid var(--border-color);
}

small {
  color: var(--text-muted);
}

/* ==========================================================================
   RESPONSIVO
   ========================================================================== */

@media (max-width: 1180px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .vistoria-layout {
    grid-template-columns: 1fr;
  }

  .vistoria-summary {
    position: relative;
    top: 0;
  }

  .check-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
    overflow: auto;
  }

  .sidebar {
    width: 100%;
    height: auto;
  }

  .brand-header {
    padding: 18px 16px;
  }

  .nav-menu {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    padding: 10px 12px 14px;
    gap: 8px;
  }

  .nav-btn {
    width: auto;
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .header-bar {
    height: auto;
    min-height: 68px;
    padding: 14px 16px;
    justify-content: space-between;
  }

  .tab-content {
    padding: 18px 16px;
  }

  .grid-4 {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .drawer {
    width: 100%;
  }
}