:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f5f7;
  color: #17202a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f3f5f7;
}

button,
input,
select {
  font: inherit;
}

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

.menu-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 32px 24px;
}

.menu-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 24px;
}

.module-menu {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.module-link {
  display: grid;
  gap: 10px;
  min-height: 150px;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  padding: 18px;
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.module-link:hover,
.module-link:focus-visible {
  border-color: #2563eb;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  outline: none;
  transform: translateY(-2px);
}

.module-link-active {
  border-color: #2563eb;
}

.module-code {
  color: #17202a;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
}

.module-name {
  align-self: end;
  color: #64748b;
  font-size: 0.95rem;
  font-weight: 700;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 10px 12px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0 8px;
}

.eyebrow {
  margin: 0 0 2px;
  color: #2563eb;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 1.45rem;
  line-height: 1.1;
}

h2 {
  font-size: 1rem;
}

.status-pill {
  min-width: 92px;
  border: 1px solid #d4dae3;
  border-radius: 999px;
  padding: 4px 10px;
  color: #334155;
  text-align: center;
  font-size: 0.76rem;
  font-weight: 800;
  background: #ffffff;
}

.status-pill[data-mode="ready"] {
  border-color: #86efac;
  color: #166534;
  background: #f0fdf4;
}

.status-pill[data-mode="error"] {
  border-color: #fecaca;
  color: #991b1b;
  background: #fef2f2;
}

.field-filters,
.table-section,
.filters-actions-card {
  border: 1px solid #d9dee7;
  border-radius: 8px;
  background: #ffffff;
}

.field-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
}

.filters-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
  align-items: stretch;
}

.filters-row .field-filters {
  margin-top: 0;
}

.filters-sidebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
  gap: 8px;
  align-items: stretch;
}

.filters-actions-card {
  display: grid;
  gap: 6px;
  padding: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.legend-card {
  margin-top: 0;
}

.filters-actions-title {
  margin: 0;
  color: #475569;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.button-small {
  min-height: 28px;
  padding: 0 8px;
  font-size: 0.76rem;
}

.legend-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.legend-label {
  color: #475569;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.legend-chip {
  min-height: 26px;
  border: 1px solid #cbd5e1;
  border-left: 4px solid var(--legend-color, #64748b);
  border-radius: 999px;
  padding: 0 8px;
  background: #ffffff;
  color: #334155;
  font-size: 0.74rem;
  font-weight: 800;
}

.legend-chip[data-active="true"] {
  background: #f8fafc;
  border-color: var(--legend-color, #64748b);
  color: #111827;
}

.legend-chip:hover {
  background: #f8fafc;
}

.filter-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.filter-field span {
  overflow: hidden;
  color: #536173;
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-field input,
.filter-field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 10px;
  color: #17202a;
  background: #ffffff;
  outline: none;
}

.filter-field input:focus,
.filter-field select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

button {
  min-height: 34px;
  border-radius: 6px;
  padding: 0 10px;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.button-primary {
  border: 1px solid #1d4ed8;
  color: #ffffff;
  background: #2563eb;
}

.button-primary:hover {
  background: #1d4ed8;
}

.button-secondary {
  border: 1px solid #cbd5e1;
  color: #263445;
  background: #f8fafc;
}

.button-secondary:hover {
  border-color: #94a3b8;
  background: #eef2f7;
}

.table-section {
  margin-top: 8px;
  overflow: hidden;
}

.table-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e2e8f0;
  padding: 8px;
}

.table-heading p {
  margin: 2px 0 0;
  color: #64748b;
  font-size: 0.82rem;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination span {
  min-width: 64px;
  color: #475569;
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  border-radius: 0 0 8px 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  min-width: 120px;
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  border-bottom: 1px solid #e7ebf0;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #334155;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  background: #f8fafc;
  border-top: 1px solid #e7ebf0;
}

td {
  color: #1f2937;
  font-size: 0.9rem;
}

th.col-detalhe-ambiente,
td.col-detalhe-ambiente {
  min-width: 84px;
  width: 96px;
  max-width: 120px;
}

td.col-detalhe-ambiente {
  overflow: hidden;
  text-overflow: ellipsis;
}

tbody tr:hover {
  background: #f8fbff;
  transition: background-color 0.15s ease-in-out;
}

tbody tr.warranty-row {
  transition: background-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

tbody tr.warranty-row td:first-child {
  box-shadow: inset 4px 0 0 var(--warranty-accent, transparent);
}

tbody tr.warranty-row--roteiro-pendente {
  --warranty-accent: #ca8a04;
}

tbody tr.warranty-row--roteiro-baixado {
  --warranty-accent: #2563eb;
}

tbody tr.warranty-row--montagem-andamento {
  --warranty-accent: #0284c7;
}

tbody tr.warranty-row--montagem-finalizada {
  --warranty-accent: #64748b;
}

tbody tr.warranty-row--garantia-vigente {
  --warranty-accent: #16a34a;
}

tbody tr.warranty-row--garantia-expirada {
  --warranty-accent: #dc2626;
}

tbody tr.warranty-row--garantia-estendida {
  --warranty-accent: #2563eb;
}

.empty-state {
  padding: 42px 16px;
  color: #64748b;
  text-align: center;
}

.field-filters {
  display: block;
  margin-top: 6px;
  padding: 0;
  border: 1px solid #d9dee7;
  border-radius: 6px;
  background: #ffffff;
  overflow-x: auto;
}

.filters-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 1fr) minmax(180px, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
}

.filter-row:last-child {
  border-bottom: none;
}

.filter-select,
.filter-row input {
  min-height: 30px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 8px;
  color: #17202a;
  background: #ffffff;
  outline: none;
  font-size: 0.8rem;
}

.filter-select:focus,
.filter-row input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.filter-row input:disabled {
  background: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
}

.filter-buttons {
  display: flex;
  gap: 2px;
}

.filter-btn-icon {
  min-width: 26px;
  min-height: 26px;
  padding: 0 4px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #f8fafc;
  color: #334155;
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.filter-btn-icon:hover {
  background: #eef2f7;
  border-color: #94a3b8;
}

.filter-btn-icon:active {
  background: #e2e8f0;
}

.pcp-shell {
  padding-top: 18px;
}

.pcp-filters-sidebar {
  grid-template-columns: 1fr;
}

.pcp-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.pcp-toolbar p {
  margin: 0;
  color: #475569;
  font-size: 0.92rem;
  font-weight: 700;
}

.pcp-main-table th,
.pcp-main-table td {
  min-width: 110px;
}

.pcp-expand-col {
  width: 64px;
  min-width: 64px;
  text-align: center;
}

.pcp-expand-button {
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0;
  color: #334155;
  background: #f8fafc;
  font-size: 1.05rem;
  line-height: 1;
}

.pcp-expand-button:hover {
  border-color: #94a3b8;
  background: #eef2f7;
}

.pcp-order-row td {
  background: #ffffff;
}

.pcp-detail-row td {
  padding: 10px 12px 14px;
  background: #f8fafc;
}

.pcp-subgrid-wrap {
  overflow-x: auto;
  border: 1px solid #d7dee8;
  border-radius: 8px;
}

.pcp-subgrid-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

.pcp-subgrid-table th,
.pcp-subgrid-table td {
  min-width: 100px;
  padding: 10px 12px;
  border-bottom: 1px solid #e7ebf0;
  white-space: nowrap;
}

.pcp-subgrid-table th {
  position: static;
  background: #f1f5f9;
  color: #334155;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.pcp-empty-items {
  margin: 4px 0;
  color: #64748b;
  font-size: 0.9rem;
}

.pcp-tree-button {
  min-height: 28px;
  padding: 0 8px;
  white-space: nowrap;
}

.pcp-tree-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
}

.pcp-tree-modal-backdrop[hidden] {
  display: none;
}

.pcp-tree-modal {
  width: min(1100px, 100%);
  max-height: min(80vh, 820px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #d9dee7;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.pcp-tree-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #e2e8f0;
}

.pcp-tree-modal-header p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 0.86rem;
}

.pcp-tree-modal-body {
  min-height: 180px;
  padding: 14px 18px 18px;
  overflow: auto;
  background: #f8fafc;
}

.pcp-tree-close {
  width: auto;
}

.pcp-tree-indent-cell {
  min-width: 180px;
}

.pcp-tree-indent-content {
  position: relative;
}

@media (max-width: 820px) {
  .menu-shell {
    padding: 20px 16px;
  }

  .menu-header {
    flex-direction: column;
    align-items: stretch;
  }

  .module-menu {
    grid-template-columns: 1fr;
  }

  .module-link {
    min-height: 112px;
  }

  .app-shell {
    padding: 16px;
  }

  .topbar,
  .table-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .legend-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .legend-items {
    justify-content: flex-start;
  }

  .filters-row {
    grid-template-columns: 1fr;
  }

  .filters-sidebar {
    grid-template-columns: 1fr;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .pcp-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .pcp-expand-col {
    min-width: 54px;
    width: 54px;
  }

  .pcp-tree-modal-backdrop {
    padding: 12px;
  }

  .pcp-tree-modal-header {
    flex-direction: column;
    align-items: stretch;
  }

  button {
    width: 100%;
  }

  .button-small {
    width: 100%;
  }
}
