:root {
  --bg: #eef2f6;
  --ink: #18212f;
  --muted: #607086;
  --line: #c9d2df;
  --paper: #ffffff;
  --panel: #ffffff;
  --primary: #155e75;
  --accent: #2563eb;
  --soft: #f6f8fb;
  --danger: #a23a3a;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body.auth-locked .app-header,
body.auth-locked .app-shell {
  display: none;
}

body.auth-ready .auth-screen,
.auth-screen.hide {
  display: none;
}

button,
input {
  font: inherit;
}

.auth-screen {
  align-items: center;
  background: radial-gradient(circle at top, #12305a 0, #071225 48%, #020617 100%);
  display: flex;
  min-height: 100vh;
  padding: 24px;
  justify-content: center;
}

.login-card {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(2, 6, 23, 0.38);
  display: grid;
  gap: 12px;
  max-width: 390px;
  padding: 30px;
  width: 100%;
}

.login-card.hide {
  display: none;
}

.login-logo {
  height: 58px;
  width: 58px;
}

.login-logo-wide {
  background: #071225;
  border-radius: 8px;
  height: auto;
  max-height: 135px;
  object-fit: contain;
  padding: 10px;
  width: 100%;
}

.login-card h1 {
  font-size: 32px;
  line-height: 1;
  margin: 0;
}

.login-copy {
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 6px;
}

.login-card label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-card input {
  border: 1px solid #b9c5d6;
  border-radius: 6px;
  color: #0f172a;
  font-size: 14px;
  font-weight: 600;
  min-height: 42px;
  padding: 9px 11px;
}

.login-card input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: 0;
}

.login-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  min-height: 18px;
  margin: 0;
}

.login-status.error {
  color: var(--danger);
}

.auth-modal {
  align-items: center;
  background: rgba(2, 6, 23, 0.58);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 22px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 20;
}

.auth-modal.hide {
  display: none;
}

.auth-modal-card {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(2, 6, 23, 0.34);
  max-width: 440px;
  padding: 24px;
  width: 100%;
}

.auth-modal-card h2 {
  font-size: 22px;
  margin: 0 0 10px;
}

.auth-modal-card p {
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
}

.auth-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.app-header {
  align-items: center;
  background: #0f172a;
  color: #fff;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 18px 28px;
}

.app-header h1 {
  font-size: 26px;
  line-height: 1;
  margin: 0;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.brand-with-logo {
  background: #071225;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  min-width: 300px;
  padding: 8px 14px;
}

.brand-logo {
  display: block;
  height: 62px;
  object-fit: contain;
  width: 272px;
}

.brand-icon {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  height: 44px;
  width: 44px;
}

.eyebrow {
  color: #9ec8d6;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.header-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.button {
  align-items: center;
  background: var(--primary);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

.button.secondary {
  background: #334155;
}

.button.accent {
  background: var(--accent);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.top-pdf-button {
  display: none;
}

.user-menu {
  align-items: center;
  background: rgba(15, 23, 42, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  display: inline-flex;
  gap: 6px;
  min-height: 40px;
  padding: 4px;
}

.user-avatar {
  align-items: center;
  background: #e0f2fe;
  border-radius: 999px;
  color: #075985;
  display: inline-flex;
  font-size: 13px;
  font-weight: 900;
  height: 30px;
  justify-content: center;
  text-transform: uppercase;
  width: 30px;
}

.user-email {
  color: #e2e8f0;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-settings-button {
  align-items: center;
  background: #334155;
  border: 0;
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-size: 17px;
  font-weight: 900;
  height: 30px;
  justify-content: center;
  line-height: 1;
  width: 30px;
}

.user-settings-button:hover {
  background: #475569;
}

.logout-button {
  border-radius: 999px;
  min-height: 30px;
  padding: 0 10px;
}

.icon-button {
  align-items: center;
  background: #334155;
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-size: 22px;
  font-weight: 900;
  height: 40px;
  justify-content: center;
  line-height: 1;
  width: 42px;
}

.icon-button:hover {
  background: #475569;
}

.link-button {
  background: none;
  border: 0;
  color: var(--primary);
  cursor: pointer;
  font-weight: 700;
  padding: 0;
}

.app-shell {
  display: grid;
  gap: 34px;
  grid-template-columns: minmax(260px, 320px) 1fr;
  padding: 22px;
}

body.home-mode .app-shell {
  grid-template-columns: 1fr;
}

body.home-mode .sidebar {
  display: none;
}

body.settings-mode .app-shell {
  grid-template-columns: 1fr;
}

body.settings-mode .sidebar {
  display: none;
}

.sidebar {
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
}

.home-page {
  display: grid;
  gap: 20px;
  margin: 0 auto;
  max-width: 1120px;
  width: 100%;
}

.home-hero {
  align-items: center;
  background: #071225;
  border-radius: 8px;
  color: #fff;
  display: grid;
  justify-content: space-between;
  min-height: 190px;
  overflow: hidden;
  padding: 22px;
}

.home-hero.hide {
  display: none;
}

.frontier-start-page,
.user-admin-page {
  display: grid;
  gap: 16px;
  margin: 0 auto;
  max-width: 980px;
  width: 100%;
}

.frontier-start-header,
.user-admin-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 12px;
}

.frontier-start-header h2,
.user-admin-header h2 {
  font-size: 28px;
  margin: 0;
}

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

.frontier-start-card,
.user-admin-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 20px;
}

.frontier-start-card strong {
  font-size: 19px;
}

.frontier-start-card p,
.user-admin-card p {
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
}

.frontier-sefaz-imported {
  color: #15803d !important;
  font-weight: 600;
}

.user-admin-card-title {
  display: grid;
  gap: 4px;
}

.user-admin-card-title.with-action {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.user-admin-card-title h3 {
  font-size: 18px;
  margin: 0;
}

.frontier-start-actions,
.user-admin-form {
  display: grid;
  gap: 10px;
}

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

.user-admin-form label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.user-admin-form input,
.user-admin-form select {
  border: 1px solid #b9c5d6;
  border-radius: 6px;
  min-height: 40px;
  padding: 8px 10px;
}

.user-admin-form .full-row {
  grid-column: 1 / -1;
}

.user-admin-check {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex !important;
  flex-direction: row;
  min-height: 42px;
  padding: 8px 10px;
  text-transform: none !important;
}

.user-admin-check input {
  min-height: auto;
  padding: 0;
  width: auto;
}

.user-admin-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-groups-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.admin-group-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  padding: 10px;
}

.admin-group-card.blocked {
  border-color: #fca5a5;
  background: #fff1f2;
}

.admin-group-card strong {
  font-size: 13px;
}

.admin-group-card span,
.admin-group-card small {
  color: var(--muted);
  font-size: 11px;
}

.admin-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}

.admin-users-table {
  border-collapse: collapse;
  font-size: 12px;
  min-width: 760px;
  width: 100%;
}

.admin-users-table th,
.admin-users-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
}

.admin-users-table th {
  background: #e8eef6;
  color: var(--ink);
  font-size: 11px;
  text-transform: uppercase;
}

.admin-users-table tr:last-child td {
  border-bottom: 0;
}

.admin-users-table td.admin-table-actions {
  white-space: nowrap;
}

.admin-table-actions,
.admin-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-card-actions {
  margin-top: 8px;
}

.admin-mini-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 9px;
}

.frontier-history-actions {
  display: flex;
  gap: 6px;
}

.frontier-history-actions .admin-mini-button {
  font-size: 14px;
  line-height: 1;
  padding: 5px 8px;
}

.admin-mini-button:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.admin-mini-button.danger {
  background: #fff1f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.admin-status-tag {
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 999px;
  color: #166534;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  text-transform: uppercase;
}

.admin-status-tag.blocked {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.admin-only.hide {
  display: none;
}

.home-hero img {
  display: block;
  height: auto;
  margin: 0 auto;
  max-height: 160px;
  max-width: min(740px, 100%);
  object-fit: contain;
  width: 100%;
}

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

.home-card {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 14px;
  justify-items: center;
  min-height: 220px;
  padding: 24px 18px;
  text-align: center;
}

.home-card:hover {
  border-color: var(--primary);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}

.home-card-icon {
  align-items: center;
  background: linear-gradient(135deg, #e0f2fe, #dbeafe);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #075985;
  display: inline-flex;
  font-size: 32px;
  font-weight: 900;
  height: 76px;
  justify-content: center;
  line-height: 1;
  width: 76px;
}

.home-card strong {
  font-size: 20px;
  line-height: 1.2;
  text-transform: uppercase;
}

.home-card small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.panel h2 {
  font-size: 17px;
  margin: 0 0 14px;
}

.panel-title-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.upload-box {
  background: var(--soft);
  border: 1px dashed #93a3b8;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 7px;
  padding: 18px;
}

.folder-box {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  font-weight: 800;
  justify-content: center;
  margin-top: 10px;
  min-height: 38px;
  padding: 8px 10px;
}

.upload-box span {
  color: var(--primary);
  font-weight: 800;
}

.upload-box small,
.status {
  color: var(--muted);
  line-height: 1.45;
}

#xmlInput,
#folderInput,
#accountingPdfInput,
#sefazStatementInput {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.status {
  font-size: 13px;
  margin: 12px 0 0;
  overflow-wrap: anywhere;
}

.status.error {
  color: var(--danger);
  font-weight: 700;
}

.search-input {
  border: 1px solid #aebace;
  border-radius: 6px;
  margin-bottom: 12px;
  min-height: 36px;
  padding: 6px 9px;
  width: 100%;
}

.batch-actions {
  display: grid;
  gap: 7px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 12px;
}

.small-button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  min-height: 32px;
  padding: 5px 7px;
}

.small-button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  grid-column: 1 / -1;
}

.small-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.notes-list {
  display: grid;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  max-height: 360px;
  overflow: auto;
  padding-bottom: 8px;
  padding-right: 2px;
}

.frontier-result {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.frontier-summary {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.frontier-summary strong {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  padding: 8px;
  text-align: center;
}

.frontier-list {
  display: grid;
  gap: 7px;
  max-height: 260px;
  overflow: auto;
}

.frontier-item {
  background: var(--soft);
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 7px;
  display: grid;
  gap: 3px;
  padding: 9px;
}

.frontier-item.ok {
  border-left-color: #16803a;
}

.frontier-item.missing {
  border-left-color: var(--danger);
}

.frontier-item strong {
  font-size: 13px;
}

.frontier-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.frontier-page {
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
  color: var(--ink);
  margin: 0 auto 30px;
  max-width: 1120px;
  padding: 18px;
}

.frontier-header {
  align-items: center;
  border-bottom: 2px solid #0f172a;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
}

.frontier-header h2 {
  font-size: 22px;
  margin: 0;
}

.frontier-header strong {
  background: #0f172a;
  border-radius: 6px;
  color: #fff;
  font-size: 15px;
  padding: 8px 11px;
}

.frontier-page .frontier-summary {
  margin-bottom: 12px;
}

.frontier-import-panel {
  align-items: stretch;
  display: grid;
  gap: 10px;
  grid-template-columns: 1.2fr .9fr .8fr .8fr .8fr;
  margin-bottom: 10px;
}

.frontier-import-card {
  align-items: center;
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  min-height: 86px;
  padding: 10px 12px;
}

.frontier-import-card-wide {
  grid-template-columns: 1fr auto;
}

.frontier-import-card > div {
  display: grid;
  gap: 3px;
}

.frontier-import-card strong {
  font-size: 13px;
}

.frontier-import-card span {
  color: var(--muted);
  font-size: 12px;
}

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

.frontier-import-actions .small-button {
  min-width: 170px;
}

.frontier-import-card > .small-button {
  justify-self: stretch;
  min-height: 32px;
}

.frontier-page .frontier-list {
  max-height: none;
  overflow: visible;
}

.frontier-tools {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 110px 80px;
  margin-bottom: 12px;
}

.frontier-tools .search-input {
  margin: 0;
}

.frontier-tools .small-button.primary {
  grid-column: auto;
}

@media (max-width: 900px) {
  .frontier-import-panel {
    grid-template-columns: 1fr;
  }

  .frontier-import-card-wide {
    grid-template-columns: 1fr;
  }

  .frontier-import-actions {
    justify-content: stretch;
  }

  .frontier-import-actions .small-button {
    flex: 1 1 180px;
  }
}

.frontier-tax-controls {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.frontier-tax-controls span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.frontier-regime-button {
  background: #fff;
  border: 1px solid #aebace;
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  min-height: 32px;
  padding: 5px 12px;
}

.frontier-regime-button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.frontier-layout {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, 230px) 1fr;
}

.frontier-note-list {
  display: grid;
  gap: 7px;
  border-bottom: 1px solid var(--line);
  max-height: 720px;
  overflow: auto;
  padding-bottom: 8px;
  padding-right: 2px;
}

.frontier-note {
  background: var(--soft);
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: 7px;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 3px;
  padding: 9px;
  text-align: left;
  width: 100%;
}

.frontier-note.active,
.frontier-note:hover {
  border-left-color: var(--primary);
}

.frontier-note strong {
  font-size: 13px;
}

.frontier-note span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.frontier-detail {
  min-width: 0;
}

.frontier-detail-header {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-bottom: 10px;
  padding: 10px;
}

.frontier-detail-title-row {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 4px;
}

.frontier-detail-header h3 {
  font-size: 16px;
  margin: 0;
}

.frontier-status-actions {
  align-items: stretch;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, 128px);
  justify-content: end;
}

.frontier-contest-reason {
  background: #fff7ed;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  display: block;
  margin-top: 10px;
  padding: 10px;
}

.frontier-contest-reason span {
  color: #92400e;
  display: block;
  font-size: 10px;
  font-weight: 800;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.frontier-contest-reason textarea {
  border: 1px solid #d7e0ec;
  border-radius: 4px;
  color: #0f172a;
  font: inherit;
  font-size: 13px;
  min-height: 58px;
  padding: 8px;
  resize: vertical;
  width: 100%;
}

.frontier-contest-reason-cell {
  max-width: 170px;
  text-align: left;
  white-space: normal;
}

.frontier-canceled-flag,
.frontier-checked-flag,
.frontier-contested-flag,
.frontier-consumption-flag {
  align-items: center;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  font-size: 11px;
  font-weight: 900;
  gap: 5px;
  justify-content: center;
  height: 34px;
  min-width: 0;
  padding: 5px 8px;
  text-transform: uppercase;
  width: 128px;
}

.frontier-canceled-flag {
  background: #fee2e2;
  border: 1px solid #ef4444;
  color: #991b1b;
}

.frontier-checked-flag {
  background: #dcfce7;
  border: 1px solid #22c55e;
  color: #14532d;
}

.frontier-contested-flag {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #78350f;
}

.frontier-consumption-flag {
  background: #e0f2fe;
  border: 1px solid #0ea5e9;
  color: #075985;
}

.frontier-canceled-flag input {
  accent-color: #dc2626;
}

.frontier-checked-flag input {
  accent-color: #16a34a;
}

.frontier-contested-flag input {
  accent-color: #d97706;
}

.frontier-consumption-flag input {
  accent-color: #0284c7;
}

.frontier-canceled-notice {
  background: #fee2e2;
  border: 1px solid #ef4444;
  border-radius: 7px;
  color: #7f1d1d;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 10px;
  padding: 8px 10px;
  text-transform: uppercase;
}

.frontier-canceled-status {
  color: #991b1b;
}

.frontier-checked-status {
  color: #166534;
}

.frontier-contested-status {
  color: #5b21b6;
}

.frontier-pending-status {
  color: #92400e;
}

.frontier-period-warning {
  color: #b45309;
  font-weight: 600;
  background: #fff7ed;
}

.frontier-note-status {
  align-self: start;
  border-radius: 999px;
  display: inline-flex;
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
  padding: 2px 7px;
  text-transform: uppercase;
}

.frontier-note-status.checked {
  background: #dcfce7;
  color: #166534;
}

.frontier-note-status.pending {
  background: #fef3c7;
  color: #92400e;
}

.frontier-note-status.canceled {
  background: #fee2e2;
  color: #991b1b;
}

.frontier-note-status.contested {
  background: #ede9fe;
  color: #5b21b6;
}

.frontier-detail-header p {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.frontier-note-info {
  background: #fffbea;
  border: 1px solid #e2c94f;
  border-radius: 7px;
  margin-bottom: 10px;
  padding: 8px 10px;
}

.frontier-note-info strong {
  display: block;
  font-size: 11px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.frontier-note-info p {
  color: var(--ink);
  font-size: 11px;
  line-height: 1.35;
  margin: 0;
}

.frontier-prompt-backdrop {
  align-items: center;
  background: rgba(15, 23, 42, 0.42);
  display: flex;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 20;
}

.frontier-prompt {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  max-width: 460px;
  padding: 20px;
  width: min(460px, calc(100vw - 32px));
}

.frontier-prompt h3 {
  font-size: 20px;
  margin: 4px 0 8px;
}

.frontier-prompt p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
}

.frontier-prompt-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
}

.frontier-prompt-actions .small-button {
  min-height: 38px;
}

.frontier-table {
  font-size: 7.6px;
}

.frontier-table th,
.frontier-table td {
  padding: 3px;
}

.frontier-ncm-table {
  table-layout: fixed;
}

.frontier-ncm-table th:nth-child(1),
.frontier-ncm-table td:nth-child(1) {
  width: 3%;
}

.frontier-ncm-table th:nth-child(4),
.frontier-ncm-table td:nth-child(4) {
  width: 7%;
}

.frontier-ncm-table th:nth-child(5),
.frontier-ncm-table td:nth-child(5) {
  width: 7%;
}

.frontier-ncm-table th:nth-child(6),
.frontier-ncm-table td:nth-child(6) {
  width: 8%;
}

.frontier-row-mva,
.frontier-row-reduction,
.frontier-row-credit {
  border: 1px solid #aebace;
  border-radius: 4px;
  min-height: 20px;
  padding: 2px;
  width: 100%;
}

.frontier-row-mva,
.frontier-row-reduction {
  font-size: 10px;
  font-weight: 900;
}

.frontier-row-credit {
  font-size: 8px;
}

.frontier-row-mva,
.frontier-row-reduction,
.frontier-row-credit {
  text-align: right;
}

.frontier-type-toggle {
  border: 1px solid #aebace;
  border-radius: 999px;
  cursor: pointer;
  font-size: 7.5px;
  font-weight: 900;
  min-height: 20px;
  line-height: 1;
  max-width: 100%;
  min-width: 46px;
  padding: 2px 4px;
  white-space: nowrap;
  width: auto;
}

.frontier-type-toggle.normal {
  background: #e2f5df;
  color: #14532d;
}

.frontier-type-toggle.st {
  background: #fde2e2;
  color: #991b1b;
}

.frontier-ncm-marker {
  cursor: pointer;
}

.frontier-edit-mva-cell {
  text-align: center;
  width: 22px;
}

.frontier-edit-mva {
  align-items: center;
  background: #eef2f7;
  border: 1px solid #b7c2d4;
  border-radius: 4px;
  color: var(--primary);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 9px;
  font-weight: 900;
  height: 17px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 17px;
}

.frontier-edit-mva:hover {
  background: #dce8f3;
}

.frontier-ncm-row:hover td {
  background: #f1f5f9;
}

.frontier-ncm-row.selected td {
  background: #dff3f8;
  font-weight: 800;
}

.frontier-product-selected-st td {
  background: #ffd6d6;
  color: #7f1d1d;
  font-weight: 800;
}

.frontier-product-selected-normal td {
  background: #dff4dc;
  color: #14532d;
  font-weight: 800;
}

.frontier-tax-line {
  background: #fff7a8;
  font-weight: 900;
}

.frontier-selected-summary {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 10px;
}

.frontier-selected-title {
  align-items: center;
  display: flex;
  gap: 10px;
}

.frontier-selected-title strong {
  color: var(--ink);
  font-size: 13px;
}

.frontier-selected-title span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.frontier-selected-cards {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.frontier-selected-cards div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 2px;
  padding: 6px 7px;
}

.frontier-selected-cards span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.frontier-selected-cards strong {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.15;
}

.frontier-selected-cards .frontier-split-card {
  grid-template-columns: 1fr 1fr;
  padding: 0;
}

.frontier-split-card span {
  display: grid;
  gap: 2px;
  padding: 6px 7px;
}

.frontier-split-card span + span {
  border-left: 1px solid var(--line);
}

.frontier-split-card small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.frontier-selected-summary.has-selection {
  border-color: var(--primary);
  box-shadow: inset 4px 0 0 var(--primary);
}

.frontier-calculation {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 10px;
}

.frontier-calculation-block {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
}

.frontier-calculation-st {
  background: #fde2e2;
  border-color: #ef9a9a;
}

.frontier-calculation-normal {
  background: #e2f5df;
  border-color: #9ccc9c;
}

.frontier-calculation-block h3 {
  font-size: 12px;
  margin: 0 0 7px;
  text-transform: uppercase;
}

.frontier-calculation-block .frontier-selected-cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.frontier-tax-total {
  align-items: center;
  background: #fff36d;
  border: 1px solid #d6b600;
  border-radius: 7px;
  display: flex;
  gap: 12px;
  grid-column: 1 / -1;
  justify-content: flex-end;
  padding: 8px 10px;
}

.frontier-tax-total span {
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.frontier-tax-total strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}

.frontier-file-button {
  align-items: center;
  display: inline-flex;
  justify-content: center;
}

.frontier-sefaz-comparison {
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  display: grid;
  gap: 8px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 8px;
}

.frontier-sefaz-comparison div,
.frontier-sefaz-card,
.frontier-sefaz-comparison.missing {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 7px;
}

.frontier-sefaz-card {
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
  width: 100%;
}

.frontier-sefaz-card small {
  color: var(--muted);
  display: block;
  font-size: 10px;
  font-weight: 800;
  margin-top: 2px;
}

.frontier-sefaz-comparison span {
  color: var(--muted);
  display: block;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.frontier-sefaz-comparison strong {
  display: block;
  font-size: 15px;
}

.frontier-sefaz-comparison.ok {
  background: #ecfdf3;
  border-color: #22c55e;
}

.frontier-sefaz-comparison.warn,
.frontier-sefaz-comparison.missing {
  background: #fff7ed;
  border-color: #f59e0b;
}

.frontier-sefaz-comparison .frontier-sefaz-detail {
  background: #fff;
  border: 1px solid #f59e0b;
  border-radius: 5px;
  display: grid;
  gap: 4px;
  grid-column: 1 / -1;
  padding: 8px;
}

.frontier-sefaz-detail p {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin: 0;
}

.frontier-sefaz-detail p + p {
  border-top: 1px solid #fde68a;
  padding-top: 4px;
}

.frontier-sefaz-detail span {
  color: var(--ink);
  font-size: 11px;
}

.frontier-sefaz-detail strong {
  font-size: 12px;
  white-space: nowrap;
}

.frontier-final-summary {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.frontier-final-report .frontier-header strong {
  background: #fff36d;
  border: 1px solid #d6b600;
  color: #111827;
}

.frontier-final-header-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.frontier-final-header-actions .small-button.primary {
  grid-column: auto;
}

.frontier-final-table {
  font-size: 7.6px;
}

.frontier-final-table th,
.frontier-final-table td {
  padding: 3px;
}

.frontier-final-table tfoot td {
  background: #fff36d;
  border-top: 2px solid #111827;
  font-weight: 900;
}

.frontier-final-total {
  background: #fff7a8;
  font-weight: 900;
}

.frontier-final-percent {
  background: #e8f7ff;
  font-weight: 900;
}

.settings-page {
  background: var(--paper);
  margin: 0 auto;
  max-width: 1120px;
  min-height: 70vh;
  padding: 22px;
}

.settings-header {
  align-items: center;
  border-bottom: 2px solid var(--ink);
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
}

.settings-header h2 {
  font-size: 24px;
  margin: 0;
}

.settings-form {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 8px;
  grid-template-columns: 1.2fr repeat(5, minmax(80px, 1fr)) auto;
  margin-bottom: 16px;
  padding: 12px;
}

.settings-tools {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 12px;
}

.settings-tools small {
  color: var(--muted);
  font-size: 12px;
  width: 100%;
}

.settings-form label {
  display: grid;
  gap: 4px;
}

.settings-form span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.settings-form input,
.settings-rule-input {
  border: 1px solid #aebace;
  border-radius: 5px;
  min-height: 34px;
  padding: 6px 8px;
  width: 100%;
}

.settings-table {
  font-size: 12px;
}

.settings-table th,
.settings-table td {
  padding: 6px;
}

.settings-note-layout {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(170px, 220px) 1fr;
}

.settings-note-list {
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 6px;
  max-height: 280px;
  overflow: auto;
  padding: 8px;
}

.settings-note-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  display: grid;
  gap: 4px;
  padding: 8px;
  text-align: left;
}

.settings-note-card.selected {
  border-color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}

.settings-note-card small,
.settings-note-title {
  color: var(--muted);
}

.settings-note-title {
  font-weight: 800;
  margin: 0 0 8px;
}

.frontier-selected-cards .frontier-tax-result {
  background: #fff36d;
  border-color: #d6b600;
}

.frontier-selected-cards .frontier-tax-result span,
.frontier-selected-cards .frontier-tax-result strong {
  color: #111827;
}

.note-card {
  align-items: start;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  gap: 9px;
  padding: 10px;
  text-align: left;
  width: 100%;
}

.note-card input {
  accent-color: var(--primary);
  flex: 0 0 auto;
  height: 18px;
  margin-top: 1px;
  width: 18px;
}

.note-card-content {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.note-card:hover,
.note-card.active {
  border-color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}

.note-card strong {
  font-size: 14px;
}

.note-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.field-options {
  display: grid;
  gap: 10px;
}

.margin-control {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 7px;
  margin: 0 0 14px;
  padding: 12px;
}

.margin-control span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.margin-control input {
  border: 1px solid #aebace;
  border-radius: 6px;
  min-height: 36px;
  padding: 6px 9px;
  width: 100%;
}

.margin-control small {
  color: var(--muted);
}

.field-option {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.field-option label {
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}

.field-option input {
  accent-color: var(--primary);
  height: 18px;
  width: 18px;
}

.preview-area {
  min-width: 0;
  overflow-x: auto;
  padding-left: 32px;
}

.frontier-mode .app-shell {
  grid-template-columns: 1fr;
}

.frontier-mode .sidebar {
  display: none;
}

.frontier-mode .preview-area {
  padding-left: 0;
}

.empty-state {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  justify-items: center;
  min-height: 420px;
  padding: 40px;
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
}

.empty-state p {
  color: var(--muted);
  margin: 0;
  max-width: 520px;
}

.danfe-page {
  background: var(--paper);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
  color: #111827;
  font-family: Arial, Helvetica, sans-serif;
  margin: 0 auto 30px;
  min-height: 297mm;
  padding: 8mm;
  width: 210mm;
}

.danfe-page + .danfe-page {
  page-break-before: always;
}

.report-page {
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
  color: var(--ink);
  margin: 0 auto 30px;
  max-width: 1120px;
  padding: 14px;
}

.report-header {
  align-items: center;
  border-bottom: 2px solid #0f172a;
  display: flex;
  justify-content: space-between;
  margin-bottom: 9px;
  padding-bottom: 8px;
}

.report-header h2 {
  font-size: 21px;
  margin: 0 0 4px;
}

.report-header span {
  color: var(--muted);
  font-size: 12px;
}

.report-header strong {
  background: #0f172a;
  border-radius: 6px;
  color: #fff;
  font-size: 15px;
  padding: 8px 11px;
}

.report-kpis {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 9px;
}

.report-kpis div {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  padding: 6px 8px;
}

.report-kpis span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.report-kpis strong {
  font-size: 14px;
}

.due-summary {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
}

.due-summary div {
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 5px 6px;
}

.due-summary span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.due-summary strong {
  font-size: 11px;
  white-space: nowrap;
}

.due-alert {
  background: #fff7ed;
  border: 1px solid #f59e0b;
  border-radius: 7px;
  color: #7c2d12;
  margin-top: 8px;
  padding: 8px;
}

.due-alert strong {
  display: block;
  font-size: 11px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.due-alert-table {
  margin-top: 0;
}

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

.report-section {
  margin-bottom: 9px;
}

.report-section h3 {
  font-size: 13px;
  margin: 0 0 6px;
}

.bar-chart {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 7px;
}

.bar-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(105px, 1.2fr) 2fr minmax(78px, auto);
}

.bar-label {
  color: var(--ink);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  background: #e5edf5;
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.bar-track span {
  background: var(--primary);
  display: block;
  height: 100%;
}

.bar-row strong {
  font-size: 10px;
  text-align: right;
}

.report-table {
  border-collapse: collapse;
  font-size: 9px;
  width: 100%;
}

.report-table th,
.report-table td {
  border: 1px solid var(--line);
  padding: 3px 4px;
  vertical-align: top;
}

.report-table th {
  background: #e7edf5;
  text-align: left;
}

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

.danfe-grid {
  border-left: 1px solid #111;
  border-top: 1px solid #111;
  display: grid;
}

.danfe-cell {
  border-bottom: 1px solid #111;
  border-right: 1px solid #111;
  min-width: 0;
  padding: 4px 5px;
}

.danfe-label {
  display: block;
  font-size: 7px;
  font-weight: 700;
  line-height: 1.1;
  text-transform: uppercase;
}

.danfe-value {
  display: block;
  font-size: 10px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.highlight-cell {
  background: #111;
  color: #fff;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.highlight-cell .danfe-label {
  color: #fff;
  font-size: 7.5px;
}

.highlight-cell .danfe-value {
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.15;
}

.inline-highlight-cell {
  align-items: center;
  display: flex;
  gap: 6px;
}

.inline-highlight-cell .danfe-label,
.inline-highlight-cell .danfe-value {
  display: inline;
}

.inline-highlight-cell .danfe-value {
  font-size: 12px;
}

.value-only-highlight-cell {
  align-items: center;
  display: flex;
  justify-content: center;
}

.value-only-highlight-cell .danfe-value {
  font-size: 14px;
  text-align: center;
}

.danfe-header {
  grid-template-columns: 1.3fr 0.9fr 1.8fr;
}

.danfe-title {
  align-items: center;
  display: grid;
  gap: 2px;
  justify-items: center;
  text-align: center;
}

.danfe-title strong {
  font-size: 26px;
  line-height: 1;
}

.danfe-title span {
  font-size: 9px;
  font-weight: 700;
  max-width: 170px;
}

.issuer-name {
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 3px;
}

.issuer-name-highlight {
  background: #111;
  color: #fff;
  margin: -4px -5px 4px;
  padding: 3px 5px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.access-key-box {
  display: grid;
  gap: 4px;
}

.barcode {
  display: block;
  height: 52px;
  width: 100%;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.barcode rect,
.product-barcode rect {
  fill: #000;
}

.product-description-text,
.product-ean {
  display: block;
}

.product-ean {
  font-size: 5.8px;
  font-weight: 700;
  margin-top: 2px;
}

.product-barcode {
  display: block;
  height: 18px;
  margin-top: 1px;
  max-width: 100%;
  width: 100%;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.access-key {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-align: center;
}

.section-title {
  background: #e7edf5;
  border: 1px solid #111;
  border-bottom: 0;
  font-size: 9px;
  font-weight: 800;
  margin-top: 7px;
  padding: 3px 5px;
  text-transform: uppercase;
}

.section-title,
.danfe-grid,
.payment-table,
.volumes-table,
.additional-info {
  break-inside: avoid;
  page-break-inside: avoid;
}

.note-grid {
  grid-template-columns: 1.4fr 0.7fr 0.55fr 0.85fr;
}

.person-grid {
  grid-template-columns: 2.25fr 0.75fr 0.7fr 0.55fr;
}

.totals-grid {
  grid-template-columns: repeat(8, 1fr);
}

.transport-grid {
  grid-template-columns: 0.62fr 0.9fr 1.35fr 0.55fr 1.75fr;
}

.payment-grid {
  grid-template-columns: 1.5fr 0.45fr 0.55fr 0.4fr;
}

.payment-table {
  border-collapse: collapse;
  font-size: 8px;
  line-height: 1.2;
  table-layout: fixed;
  width: 100%;
}

.volumes-table {
  border-collapse: collapse;
  font-size: 8px;
  line-height: 1.2;
  margin-bottom: 5px;
  table-layout: fixed;
  width: 100%;
}

.payment-table th,
.payment-table td,
.volumes-table th,
.volumes-table td {
  border: 1px solid #111;
  padding: 3px;
  vertical-align: top;
}

.payment-table th,
.volumes-table th {
  background: #e7edf5;
  font-size: 7px;
  text-transform: uppercase;
}

.compact-payment-table th,
.compact-payment-table td {
  padding: 2px 3px;
}

.compact-payment-table th:nth-child(1),
.compact-payment-table th:nth-child(3),
.compact-payment-table th:nth-child(5),
.compact-payment-table th:nth-child(7),
.compact-payment-table td:nth-child(1),
.compact-payment-table td:nth-child(3),
.compact-payment-table td:nth-child(5),
.compact-payment-table td:nth-child(7) {
  width: 17%;
}

.compact-payment-table th:nth-child(2),
.compact-payment-table th:nth-child(4),
.compact-payment-table th:nth-child(6),
.compact-payment-table th:nth-child(8),
.compact-payment-table td:nth-child(2),
.compact-payment-table td:nth-child(4),
.compact-payment-table td:nth-child(6),
.compact-payment-table td:nth-child(8) {
  width: 8%;
}

.no-installments {
  border-left: 1px solid #111;
}

.products-table {
  border-collapse: collapse;
  font-size: 6.4px;
  line-height: 1.2;
  table-layout: fixed;
  width: 100%;
}

.products-table th,
.products-table td {
  border: 1px solid #111;
  padding: 2px 3px;
  vertical-align: top;
  word-break: break-word;
}

.products-table th {
  background: #e7edf5;
  font-size: 5.8px;
  line-height: 1.05;
  text-transform: uppercase;
}

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

.suggested-price {
  font-weight: 800;
}

.additional-info {
  border: 1px solid #111;
  min-height: 8mm;
  padding: 4px 5px;
}

.additional-info p {
  font-size: 7.4px;
  line-height: 1.18;
  margin: 0;
  white-space: pre-wrap;
}

.hide {
  display: none !important;
}

@media (max-width: 980px) {
  .app-header,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-with-logo {
    min-width: 0;
    width: 100%;
  }

  .brand-logo {
    max-width: 260px;
    width: 100%;
  }

  .header-actions {
    justify-content: flex-start;
    width: 100%;
  }

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

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

  .home-hero {
    min-height: 150px;
  }

  .report-grid,
  .report-kpis,
  .frontier-start-grid,
  .user-admin-form {
    grid-template-columns: 1fr;
  }
}

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

  .home-hero {
    padding: 24px;
  }

  .home-hero h2 {
    font-size: 28px;
  }

  .user-menu {
    width: 100%;
  }

  .user-email {
    max-width: none;
    min-width: 0;
  }
}

@page {
  margin: 6mm;
  size: A4;
}

@page frontier-final-report {
  margin: 6mm;
  size: A4 landscape;
}

@media print {
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    background: #fff;
  }

  .app-header,
  .sidebar,
  .empty-state {
    display: none !important;
  }

  .app-shell,
  .preview-area {
    display: block;
    padding: 0;
  }

  .danfe-page {
    box-shadow: none;
    margin: 0;
    min-height: auto;
    padding: 0;
    width: 100%;
  }

  .report-page {
    box-shadow: none;
    margin: 0;
    max-width: none;
    padding: 0;
  }

  .frontier-page {
    box-shadow: none;
    margin: 0;
    max-width: none;
    padding: 0;
  }

  .frontier-final-report {
    page: frontier-final-report;
    width: 100%;
  }

  .frontier-final-report .frontier-header,
  .frontier-final-report .frontier-summary {
    display: flex;
  }

  .frontier-final-report .frontier-summary {
    display: grid;
    gap: 3px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin-bottom: 6px;
  }

  .frontier-final-report .frontier-summary strong {
    font-size: 7px;
    padding: 3px;
  }

  .frontier-final-table {
    font-size: 5.8px;
    line-height: 1.05;
    table-layout: fixed;
    width: 100%;
  }

  .frontier-final-table th,
  .frontier-final-table td {
    overflow-wrap: anywhere;
    padding: 2px;
  }

  .frontier-final-table th:nth-child(1),
  .frontier-final-table td:nth-child(1) {
    width: 6%;
  }

  .frontier-final-table th:nth-child(2),
  .frontier-final-table td:nth-child(2) {
    width: 5.5%;
  }

  .frontier-final-table th:nth-child(3),
  .frontier-final-table td:nth-child(3) {
    width: 7%;
  }

  .frontier-final-table th:nth-child(4),
  .frontier-final-table td:nth-child(4) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 13%;
  }

  .frontier-final-table th:nth-child(5),
  .frontier-final-table td:nth-child(5) {
    text-align: center;
    width: 2.5%;
  }

  .frontier-final-table th:nth-child(6),
  .frontier-final-table td:nth-child(6),
  .frontier-final-table th:nth-child(7),
  .frontier-final-table td:nth-child(7),
  .frontier-final-table th:nth-child(8),
  .frontier-final-table td:nth-child(8),
  .frontier-final-table th:nth-child(11),
  .frontier-final-table td:nth-child(11),
  .frontier-final-table th:nth-child(12),
  .frontier-final-table td:nth-child(12),
  .frontier-final-table th:nth-child(13),
  .frontier-final-table td:nth-child(13),
  .frontier-final-table th:nth-child(14),
  .frontier-final-table td:nth-child(14),
  .frontier-final-table th:nth-child(15),
  .frontier-final-table td:nth-child(15) {
    width: 6%;
  }

  .frontier-final-table th:nth-child(9),
  .frontier-final-table td:nth-child(9),
  .frontier-final-table th:nth-child(10),
  .frontier-final-table td:nth-child(10) {
    text-align: center;
    width: 4%;
  }

  .frontier-final-table th:nth-child(16),
  .frontier-final-table td:nth-child(16) {
    width: 5.5%;
  }

  .frontier-page > .frontier-header,
  .frontier-page > .frontier-summary,
  .frontier-page > .frontier-import-panel,
  .frontier-page > .frontier-tools,
  .frontier-page > .frontier-tax-controls,
  .frontier-note-list {
    display: none !important;
  }

  .frontier-final-report > .frontier-header {
    display: flex !important;
  }

  .frontier-final-report > .frontier-summary {
    display: grid !important;
  }

  .frontier-layout {
    display: block;
  }

  .frontier-detail {
    display: block;
    width: 100%;
  }

  .frontier-detail-header,
  .frontier-note-info,
  .frontier-selected-summary,
  .frontier-calculation,
  .report-section {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .frontier-detail-header {
    margin-bottom: 4px;
    padding: 6px 8px;
  }

  .frontier-detail-header h3 {
    font-size: 14px;
    line-height: 1.1;
  }

  .frontier-canceled-flag,
  .frontier-checked-flag,
  .frontier-contested-flag,
  .frontier-consumption-flag {
    border-radius: 4px;
    font-size: 7px;
    height: 26px;
    padding: 3px 5px;
    width: 96px;
  }

  .frontier-status-actions {
    grid-template-columns: repeat(2, 96px);
  }

  .frontier-final-header-actions .small-button {
    display: none !important;
  }

  .frontier-print-note {
    break-after: page;
    page-break-after: always;
  }

  .frontier-print-note:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .frontier-canceled-notice {
    border-radius: 4px;
    font-size: 8px;
    margin-bottom: 4px;
    padding: 4px 6px;
  }

  .frontier-detail-header p,
  .frontier-note-info p {
    font-size: 8px;
    line-height: 1.15;
  }

  .frontier-selected-summary {
    gap: 4px;
    margin-bottom: 5px;
    padding: 5px 7px;
  }

  .frontier-selected-title strong {
    font-size: 10px;
  }

  .frontier-selected-title span {
    font-size: 8px;
  }

  .frontier-selected-cards {
    gap: 3px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .frontier-selected-cards div {
    gap: 1px;
    padding: 3px 4px;
  }

  .frontier-selected-cards .frontier-split-card {
    padding: 0;
  }

  .frontier-split-card span {
    padding: 3px 4px;
  }

  .frontier-split-card small {
    font-size: 6px;
  }

  .frontier-selected-cards span {
    font-size: 6px;
    line-height: 1;
  }

  .frontier-selected-cards strong {
    font-size: 8px;
    line-height: 1.05;
  }

  .frontier-calculation {
    gap: 4px;
    margin-bottom: 5px;
  }

  .frontier-calculation-block {
    border-radius: 4px;
    padding: 5px;
  }

  .frontier-calculation-block h3 {
    font-size: 8.5px;
    margin-bottom: 4px;
  }

  .frontier-tax-total {
    border-radius: 4px;
    padding: 5px 7px;
  }

  .frontier-tax-total span {
    font-size: 8px;
  }

  .frontier-tax-total strong {
    font-size: 13px;
  }

  .frontier-table {
    font-size: 5.6px;
    line-height: 1.05;
    table-layout: fixed;
    width: 100%;
  }

  .frontier-table th,
  .frontier-table td {
    overflow-wrap: anywhere;
    padding: 2px;
    vertical-align: top;
  }

  .frontier-table .text-right {
    font-size: 5.4px;
    line-height: 1.05;
    white-space: normal;
  }

  .frontier-table input,
  .frontier-table button {
    max-width: 100%;
  }

  .frontier-ncm-table th:nth-child(1),
  .frontier-ncm-table td:nth-child(1),
  .frontier-ncm-table th:nth-child(6),
  .frontier-ncm-table td:nth-child(6),
  .frontier-ncm-table th:nth-child(7),
  .frontier-ncm-table td:nth-child(7) {
    display: none;
  }

  .frontier-ncm-table th:nth-child(2),
  .frontier-ncm-table td:nth-child(2) {
    width: 9%;
  }

  .frontier-ncm-table th:nth-child(3),
  .frontier-ncm-table td:nth-child(3),
  .frontier-ncm-table th:nth-child(4),
  .frontier-ncm-table td:nth-child(4),
  .frontier-ncm-table th:nth-child(8),
  .frontier-ncm-table td:nth-child(8),
  .frontier-ncm-table th:nth-child(9),
  .frontier-ncm-table td:nth-child(9) {
    width: 6%;
  }

  .frontier-row-mva,
  .frontier-row-reduction,
  .frontier-row-credit,
  .frontier-type-toggle {
    background: transparent !important;
    border: 0;
    border-radius: 0;
    color: inherit !important;
    min-height: 0;
    padding: 0;
  }

  .frontier-row-mva,
  .frontier-row-reduction {
    font-size: 6.2px;
  }

  .frontier-type-toggle {
    font-size: 6px;
  }

  .frontier-edit-mva {
    display: none !important;
  }

  .frontier-product-selected-st td,
  .frontier-product-selected-normal td {
    color: #111827 !important;
  }

  .report-section h3 {
    font-size: 10px;
    margin: 5px 0 3px;
  }

  .report-kpis {
    grid-template-columns: repeat(5, 1fr);
  }

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

  .due-summary {
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
  }

  .due-summary div {
    border-radius: 4px;
    overflow: hidden;
    padding: 2px;
  }

  .due-summary span {
    font-size: 6.5px;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .due-summary strong {
    font-size: 6.8px;
    line-height: 1.05;
  }

  .highlight-cell {
    background: #000 !important;
    color: #fff !important;
  }

  .issuer-name-highlight {
    background: #000 !important;
    color: #fff !important;
  }

  .highlight-cell .danfe-label,
  .highlight-cell .danfe-value {
    color: #fff !important;
  }

  .barcode {
    border-color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .barcode rect,
  .product-barcode rect {
    fill: #000 !important;
  }
}
