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

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #eef3f9;
}

[hidden] {
  display: none !important;
}

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

.login-screen {
  align-items: center;
  background: #eef3f9;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  padding: 24px;
}

.login-panel {
  background: #ffffff;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
  display: grid;
  gap: 16px;
  max-width: 420px;
  padding: 24px;
  width: 100%;
}

.login-panel strong {
  display: block;
  font-size: 22px;
}

.login-panel > div > span {
  color: #64748b;
  display: block;
  margin-top: 4px;
}

.login-error {
  background: #fdecea;
  border: 1px solid #f2b8b5;
  border-radius: 8px;
  color: #b3261e;
  margin: 0;
  padding: 10px 12px;
}

.shell {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  min-height: 100vh;
  background: #eef3f9;
}

.sidebar {
  background: #1b2433;
  border-right: 1px solid #d7dee9;
  box-shadow: 8px 0 30px rgba(15, 23, 42, 0.08);
  color: #f8fafc;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0;
  transition: width 0.3s ease;
  width: 78px;
  z-index: 10;
}

.sidebar:hover,
.sidebar:focus-within {
  width: 304px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 80px;
  overflow: hidden;
  padding: 20px 16px;
  background: #e24b38;
}

.brand-button {
  align-items: center;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  height: 42px;
  justify-content: center;
  padding: 4px;
  width: 42px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #d84b35;
  color: #ffffff;
  font-weight: 800;
}

.brand-copy {
  display: none;
  min-width: 180px;
}

.sidebar:hover .brand-copy,
.sidebar:focus-within .brand-copy {
  display: block;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 24px;
  padding: 16px 12px;
}

.nav-group {
  display: grid;
  gap: 6px;
}

.nav-group-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 16px;
  color: #cbd5e1;
  cursor: pointer;
  display: flex;
  justify-content: center;
  min-height: 40px;
  padding: 6px;
  text-align: left;
  text-transform: uppercase;
  width: 100%;
}

.nav-group-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
}

.nav-group-initial {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #f1f5f9;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  height: 32px;
  justify-content: center;
  letter-spacing: 0;
  width: 32px;
}

.nav-group-title,
.nav-group-symbol {
  display: none;
}

.sidebar:hover .nav-group-toggle,
.sidebar:focus-within .nav-group-toggle {
  justify-content: space-between;
  padding: 8px 12px;
}

.sidebar:hover .nav-group-initial,
.sidebar:focus-within .nav-group-initial {
  display: none;
}

.sidebar:hover .nav-group-title,
.sidebar:hover .nav-group-symbol,
.sidebar:focus-within .nav-group-title,
.sidebar:focus-within .nav-group-symbol {
  display: inline;
}

.nav-group-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.nav-items {
  display: none;
  gap: 6px;
}

.nav-group.open .nav-items {
  display: grid;
}

.nav-item {
  align-items: center;
  border: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
  cursor: pointer;
  display: flex;
  justify-content: center;
  min-height: 42px;
  overflow: hidden;
  padding: 6px;
  text-align: left;
  width: 100%;
}

.sidebar:hover .nav-item,
.sidebar:focus-within .nav-item {
  justify-content: flex-start;
  padding: 9px 12px;
}

.nav-initial {
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #f8fafc;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  height: 32px;
  justify-content: center;
  letter-spacing: 0;
  min-width: 32px;
  padding: 0 4px;
}

.nav-label {
  display: none;
  margin-left: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar:hover .nav-label,
.sidebar:focus-within .nav-label {
  display: inline;
}

.nav-item.active {
  background: #e24b38;
  box-shadow: 0 12px 24px rgba(226, 75, 56, 0.22);
  color: #ffffff;
}

.nav-item.active .nav-initial {
  background: rgba(255, 255, 255, 0.18);
}

.nav-item:disabled {
  background: rgba(255, 255, 255, 0.03);
  color: #64748b;
  cursor: default;
}

.nav-item:disabled .nav-initial {
  background: rgba(255, 255, 255, 0.04);
  color: #64748b;
}

.batch-progress {
  border-top: 1px solid #e2e8f0;
  display: grid;
  gap: 8px;
  padding: 12px 14px;
}

.batch-progress[hidden] {
  display: none;
}

.batch-progress-row {
  align-items: center;
  color: #34435a;
  display: flex;
  font-size: 13px;
  justify-content: space-between;
}

.batch-progress-track {
  background: #e6edf7;
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.batch-progress-fill {
  background: #188038;
  height: 100%;
  transition: width 0.2s ease;
  width: 0;
}

.batch-progress-current {
  color: #5f6f89;
  font-size: 12px;
  min-height: 18px;
}

.nav-soon {
  display: none;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  margin-left: auto;
  text-transform: uppercase;
}

.sidebar:hover .nav-soon,
.sidebar:focus-within .nav-soon {
  display: inline;
}

.main {
  min-width: 0;
  padding: 16px 20px;
}

.topbar {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px;
}

h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.topbar p {
  color: #64748b;
  margin: 4px 0 0;
}

.user-chip {
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #ffffff;
  min-width: 190px;
  padding: 10px 12px;
}

.user-chip span,
.user-chip small {
  display: block;
}

.user-chip span {
  font-weight: 700;
}

.user-chip small {
  color: #64748b;
  margin-top: 2px;
}

.logout-button {
  background: transparent;
  border: 0;
  color: #b3261e;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  margin-top: 6px;
  padding: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.feedback {
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #172033;
  margin-bottom: 16px;
  padding: 10px 12px;
}

.feedback.success {
  background: #e9f8ef;
  border-color: #b7e1c2;
  color: #137333;
}

.feedback.warning {
  background: #fff7e6;
  border-color: #f6d28b;
  color: #996900;
}

.feedback.error {
  background: #fdecea;
  border-color: #f2b8b5;
  color: #b3261e;
}

.summary-card {
  border: 1px solid #d8dee8;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.summary-card span {
  color: #64748b;
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
  margin-bottom: 16px;
}

.importacoes-toolbar {
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(320px, 2fr) minmax(180px, 0.8fr);
}

.importacoes-view {
  display: grid;
  gap: 16px;
}

.importacoes-view[hidden] {
  display: none;
}

.field,
.status-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span,
.status-block > span {
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: #172033;
  height: 36px;
  min-width: 0;
  padding: 0 10px;
  width: 100%;
}

.field textarea {
  height: auto;
  min-height: 96px;
  padding: 10px;
  resize: vertical;
}

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

.field-full {
  grid-column: 1 / -1;
}

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

.segmented button,
.cadastro-tabs button,
.primary {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
  background: #ffffff;
  color: #172033;
}

.segmented button.active {
  background: #e24b38;
  border-color: #e24b38;
  color: #ffffff;
}

.cadastro-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.cadastro-tabs button.active {
  background: #e24b38;
  border-color: #e24b38;
  color: #ffffff;
}

.cadastros-view[hidden],
.monitor-view[hidden],
.nfse-recebidas-view[hidden],
.usuarios-view[hidden] {
  display: none;
}

.cadastro-toolbar {
  grid-template-columns: minmax(160px, 1fr) minmax(260px, 2fr) 160px;
}

.nfse-recebidas-toolbar {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.tabbar {
  border-bottom: 1px solid #d8dee8;
  margin-bottom: 0;
  padding: 0 0 12px;
}

.primary {
  align-self: end;
  background: #e24b38;
  border-color: #e24b38;
  color: #ffffff;
  font-weight: 700;
}

.export-actions {
  align-self: end;
  display: flex;
  gap: 6px;
}

.export-actions button {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  min-height: 36px;
  padding: 0 10px;
  background: #ffffff;
  color: #172033;
  cursor: pointer;
  font-weight: 700;
}

.table-section,
.detail-panel {
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #ffffff;
}

.table-section {
  margin-bottom: 16px;
  padding: 16px;
}

.section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  font-size: 18px;
  margin: 0;
}

.section-heading span {
  background: #f1f5f9;
  border-radius: 999px;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
}

.list-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.table-wrap {
  border: 1px solid #d8dee8;
  border-radius: 8px;
  overflow: auto;
}

.bulkbar {
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid #d8dee8;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-width: 980px;
  padding: 10px 12px;
}

.bulkbar span {
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

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

th,
td {
  border-bottom: 1px solid #e5e9f0;
  padding: 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

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

.row-action {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  min-height: 32px;
  padding: 0 10px;
  cursor: pointer;
}

.sort-header {
  align-items: center;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  min-height: 24px;
  padding: 0;
  text-transform: inherit;
}

.row-action.danger {
  border-color: #d84b35;
  color: #b3261e;
}

.row-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.create-button,
.save-button,
.neutral-button {
  border-radius: 6px;
  min-height: 36px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.create-button {
  border: 1px solid #e24b38;
  background: #e24b38;
  color: #ffffff;
}

.save-button {
  border: 1px solid #198754;
  background: #198754;
  color: #ffffff;
}

.neutral-button {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
}

.form-panel {
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #ffffff;
  margin-top: 16px;
  padding: 16px;
}

.form-panel[hidden] {
  display: none;
}

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

.form-actions {
  border-top: 1px solid #e5e9f0;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 14px;
}

.related-section {
  border-top: 1px solid #e5e9f0;
  margin-top: 18px;
  padding-top: 16px;
}

.related-section[hidden] {
  display: none;
}

.related-form {
  margin-top: 14px;
}

.compact-table table {
  min-width: 720px;
}

.text-right {
  text-align: right;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
  min-width: 150px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  min-height: 26px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.badge.N {
  background: #e9f8ef;
  color: #137333;
}

.badge.E {
  background: #fdecea;
  color: #b3261e;
}

.badge.P,
.badge.X {
  background: #fff7e6;
  color: #996900;
}

.detail-panel {
  min-height: 180px;
  padding: 16px;
}

.detail-empty,
.empty {
  color: #64748b;
  text-align: center;
}

.detail-panel h2 {
  font-size: 18px;
  margin: 0;
}

.detail-heading {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
}

.detail-line {
  border-bottom: 1px solid #e5e9f0;
  padding-bottom: 10px;
}

.detail-line span {
  color: #64748b;
  display: block;
  font-size: 12px;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.detail-line strong {
  overflow-wrap: anywhere;
}

.artifact-grid {
  border-top: 1px solid #e5e9f0;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  margin-top: 14px;
  padding-top: 14px;
}

.artifact-grid span,
.event-line span {
  color: #64748b;
  display: block;
  font-size: 12px;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.artifact-grid strong {
  overflow-wrap: anywhere;
}

.artifact-viewer-panel {
  border-top: 1px solid #e5e9f0;
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
}

.artifact-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.artifact-tab {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #172033;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  min-height: 34px;
  padding: 0 10px;
}

.artifact-tab.active {
  background: #e24b38;
  border-color: #e24b38;
  color: #ffffff;
}

.artifact-tab:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.artifact-viewer-heading {
  display: grid;
  gap: 3px;
}

.artifact-viewer-heading h3 {
  border-top: 0;
  margin: 0;
  padding-top: 0;
}

.artifact-viewer-heading span {
  color: #64748b;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.artifact-viewer {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  color: #e2e8f0;
  font-family: "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
  max-height: 520px;
  min-height: 220px;
  overflow: auto;
  padding: 12px;
  white-space: pre;
}

.artifact-viewer.error {
  background: #fdecea;
  border-color: #f2b8b5;
  color: #b3261e;
}

.detail-panel h3 {
  border-top: 1px solid #e5e9f0;
  font-size: 16px;
  margin: 16px 0 10px;
  padding-top: 14px;
}

.artifact-viewer-heading h3 {
  border-top: 0;
  margin: 0;
  padding-top: 0;
}

.events {
  display: grid;
  gap: 8px;
}

.event-line {
  border: 1px solid #e5e9f0;
  border-radius: 8px;
  padding: 10px;
}

.event-line p {
  margin: 5px 0 0;
}

.error {
  color: #b3261e;
}

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

  .sidebar {
    display: flex;
    align-items: center;
    gap: 16px;
    overflow-x: auto;
    padding: 14px;
  }

  .nav {
    display: flex;
    margin-top: 0;
  }

  .toolbar {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .detail-list {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

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

  .form-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 720px) {
  .main {
    padding: 14px;
  }

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

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

  .field-wide {
    grid-column: span 1;
  }

  .detail-list {
    grid-template-columns: 1fr;
  }

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

  .form-actions {
    flex-direction: column-reverse;
  }
}
