:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1b1f24;
  --muted: #657080;
  --line: #dfe4ea;
  --blue: #275dff;
  --blue-soft: #e9efff;
  --green: #127a45;
  --green-soft: #e7f5ee;
  --amber: #9a5a00;
  --amber-soft: #fff3d8;
  --red: #b42318;
  --red-soft: #ffe9e7;
  --shadow: 0 16px 40px rgba(31, 42, 55, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  width: 100%;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  min-height: 40px;
  max-width: 100%;
  padding: 0 14px;
  white-space: normal;
}

button:hover {
  border-color: #aeb8c5;
}

button:focus,
input:focus,
select:focus {
  outline: 3px solid rgba(39, 93, 255, 0.22);
  outline-offset: 1px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 24px 28px;
  background: #162033;
  color: #ffffff;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: #b8d2ff;
  font-size: 13px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

h2 {
  margin-bottom: 4px;
  font-size: 19px;
}

h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.header-meta {
  display: grid;
  gap: 2px;
  justify-items: end;
  color: #d5dce8;
  font-size: 13px;
}

.header-side {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.header-meta strong {
  color: #ffffff;
  font-size: 14px;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #d5dce8;
  font-size: 13px;
}

.auth-user button {
  min-height: 32px;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.login-panel {
  max-width: 480px;
  margin: 28px auto;
  padding: 0 18px;
}

.login-box {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.login-box label {
  display: grid;
  gap: 6px;
  color: #364152;
  font-weight: 700;
}

.app-shell {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 18px;
  min-width: 0;
}

.app-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 8px;
}

.tab-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 42px;
  border-color: transparent;
  background: transparent;
  color: #364152;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

.tab-button.is-active {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.tab-hidden {
  display: none !important;
}

.toolbar,
.results-panel,
.details-panel,
.dependents-panel {
  width: 100%;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 18px;
  padding: 16px;
}

.search-area label,
.filters label {
  display: grid;
  gap: 6px;
  color: #364152;
  font-weight: 700;
}

.search-controls {
  display: grid;
  grid-template-columns: 190px minmax(260px, 1fr);
  gap: 10px;
  align-items: end;
}

.search-field {
  display: grid;
  gap: 6px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
}

.hint,
#resultMeta,
.detail-muted {
  color: var(--muted);
}

.hint {
  margin: 8px 0 0;
  font-size: 13px;
}

.field-note {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.filters {
  display: grid;
  grid-template-columns: 190px 180px auto;
  gap: 10px;
  align-items: end;
}

#exportBtn {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
  font-weight: 700;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
}

.summary-card {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 13px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-card strong {
  display: block;
  margin-top: 4px;
  font-size: 23px;
}

.dependents-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
  overflow: hidden;
}

.dependents-head,
.section-title-row,
.document-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.dependents-head p {
  margin-bottom: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.eyebrow-dark {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.dependents-actions {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: end;
  min-width: 0;
}

.saved-picker {
  display: grid;
  gap: 6px;
  color: #364152;
  font-weight: 700;
  min-width: 0;
}

.dependents-actions input[type="file"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-action,
.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
  white-space: normal;
}

.file-action:hover,
.primary-action:hover {
  border-color: #1746c8;
  background: #1746c8;
}

.dependent-form-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 0.85fr);
  gap: 14px;
  min-width: 0;
}

.form-section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  overflow: hidden;
}

.store-details summary {
  color: #364152;
  cursor: pointer;
  font-weight: 700;
}

.company-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 12px;
  margin-top: 12px;
  min-width: 0;
}

.company-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.company-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #364152;
  font-weight: 700;
}

.company-toggle input {
  width: 18px;
  min-height: 18px;
}

.store-grid {
  margin-top: 12px;
}

.lookup-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
  min-width: 0;
}

.lookup-results {
  display: grid;
  gap: 8px;
  margin: -4px 0 12px;
}

.lookup-result {
  display: grid;
  gap: 3px;
  min-height: 48px;
  padding: 8px 10px;
  text-align: left;
}

.lookup-result strong,
.lookup-result span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.lookup-result span {
  color: var(--muted);
  font-size: 13px;
}

.compact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.compact-grid label,
.lookup-row label {
  display: grid;
  gap: 6px;
  color: #364152;
  font-weight: 700;
  min-width: 0;
}

.span-2 {
  grid-column: span 2;
}

.dependents-list-section,
.document-actions-section,
.documents-section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  overflow: hidden;
}

.section-title-row h3,
.document-actions-section h3 {
  margin-bottom: 0;
}

#dependentsCount,
.status-line {
  color: var(--muted);
  font-size: 13px;
}

.dependents-table-wrap {
  max-height: 280px;
  margin-top: 12px;
}

.dependents-table {
  min-width: 760px;
}

.document-actions-section {
  display: grid;
  gap: 12px;
}

.documents-section {
  display: grid;
  gap: 10px;
}

.document-upload-row {
  display: grid;
  grid-template-columns: auto auto minmax(180px, 1fr);
  gap: 8px;
  align-items: center;
}

.documents-section input[type="file"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.selected-file-name {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.documents-list {
  display: grid;
  gap: 8px;
}

.document-item {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}

.document-item small {
  display: block;
  color: var(--muted);
}

.status-line {
  min-height: 18px;
  margin-bottom: 0;
}

.results-panel {
  overflow: hidden;
}

.results-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.results-top p {
  margin-bottom: 0;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.legend span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.dot-high {
  background: var(--green);
}

.dot-medium {
  background: var(--blue);
}

.dot-review {
  background: var(--amber);
}

.table-wrap {
  position: relative;
  overflow: auto;
  max-width: 100%;
  min-width: 0;
  max-height: 62vh;
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0f3f7;
  color: #364152;
  font-size: 12px;
  font-weight: 700;
}

td {
  background: #ffffff;
}

tr:hover td {
  background: #f8fbff;
}

.code-cell {
  font-weight: 700;
  white-space: nowrap;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.chip-doc {
  background: var(--green-soft);
  color: var(--green);
}

.chip-name {
  background: var(--blue-soft);
  color: #1746c8;
}

.chip-none,
.chip-criar_only {
  background: var(--red-soft);
  color: var(--red);
}

.chip-multi {
  background: var(--amber-soft);
  color: var(--amber);
}

.link-button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--blue);
  font-weight: 700;
}

.empty-state {
  padding: 36px 16px;
  color: var(--muted);
  text-align: center;
}

.details-panel {
  padding: 16px;
}

.details-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.details-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.detail-section dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 12px;
  margin: 0;
}

.detail-section dt {
  color: var(--muted);
}

.detail-section dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.criar-list {
  display: grid;
  gap: 12px;
}

.source-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

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

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

  .summary-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .dependent-form-grid {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 720px) {
  .app-header {
    gap: 16px;
    padding: 20px 16px;
  }

  h1 {
    font-size: 23px;
    line-height: 1.15;
  }

  .app-header,
  .results-top,
  .details-head,
  .dependents-head,
  .section-title-row,
  .document-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .header-meta {
    justify-items: start;
  }

  .app-shell {
    gap: 12px;
    padding: 10px;
  }

  .app-tabs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 6px;
  }

  .tab-button {
    width: 100%;
    min-height: 46px;
    padding: 8px 10px;
    white-space: normal;
  }

  .dependents-panel {
    padding: 12px;
  }

  .dependents-actions > *,
  .document-actions > *,
  .document-upload-row > *,
  .lookup-row > * {
    min-width: 0;
  }

  .search-controls,
  .search-row,
  .lookup-row,
  .compact-grid,
  .dependents-actions,
  .filters,
  .summary-grid,
  .detail-grid,
  .document-upload-row,
  .document-item,
  .detail-section dl {
    grid-template-columns: 1fr;
  }

  button,
  .file-action,
  .primary-action {
    width: 100%;
    justify-content: center;
    min-height: 42px;
    padding: 8px 10px;
    text-align: center;
  }

  input,
  select {
    font-size: 16px;
  }

  .selected-file-name {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .summary-card {
    min-height: auto;
  }

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

  .span-2 {
    grid-column: span 1;
  }
}
