/* Emissor NF 4.4 — interface corporativa de alta densidade. */

:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f8;
  --canvas: #f4f6f8;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --surface-raised: #ffffff;
  --border: #dce2ea;
  --border-strong: #bcc6d3;
  --line: #dce2ea;
  --line-light: #edf0f4;
  --ink: #1f2937;
  --ink-strong: #101828;
  --ink-muted: #596579;
  --muted: #596579;
  --muted-light: #748197;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-soft: #eff6ff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --info: #2563eb;
  --info-soft: #eff6ff;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --warning: #a16207;
  --warning-soft: #fffbeb;
  --danger: #b42318;
  --danger-soft: #fff1f2;
  --shadow: 0 12px 30px rgba(15, 23, 42, .08);
  --shadow-soft: 0 1px 3px rgba(15, 23, 42, .07);
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, .16);
  --scrollbar-track: #eef1f5;
  --scrollbar-thumb: #b8c1ce;
  --radius: 8px;
  --font-heading: "Segoe UI Variable Display", "Aptos Display", "Segoe UI", Arial, sans-serif;
  --font-body: "Segoe UI Variable Text", "Aptos", "Segoe UI", Arial, sans-serif;
  --font-display: var(--font-heading);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --canvas: #0b1220;
  --surface: #111b2e;
  --surface-subtle: #162238;
  --surface-raised: #1b2941;
  --border: #293950;
  --border-strong: #3e5069;
  --line: #293950;
  --line-light: #223148;
  --ink: #dce5f1;
  --ink-strong: #f8fafc;
  --ink-muted: #a4b0c2;
  --muted: #a4b0c2;
  --muted-light: #8492a8;
  --brand: #3b82f6;
  --brand-strong: #60a5fa;
  --brand-soft: #172f55;
  --primary: #3b82f6;
  --primary-dark: #60a5fa;
  --primary-soft: #172f55;
  --accent: #60a5fa;
  --accent-soft: #172f55;
  --info: #60a5fa;
  --info-soft: #172f55;
  --success: #4ade80;
  --success-soft: #102a20;
  --warning: #facc15;
  --warning-soft: #302710;
  --danger: #fb7185;
  --danger-soft: #351823;
  --shadow: 0 14px 34px rgba(0, 0, 0, .24);
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, .24);
  --focus-ring: 0 0 0 3px rgba(59, 130, 246, .22);
  --scrollbar-track: #0c1525;
  --scrollbar-thumb: #40516a;
}

html,
body {
  background: var(--bg);
  background-image: none;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  font-variant-numeric: tabular-nums lining-nums;
}

button,
input,
select,
textarea,
table {
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums lining-nums;
}

.app-shell { background: var(--bg); }

.topbar {
  height: 64px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  backdrop-filter: none;
}

.brand { gap: 10px; }
.brand-mark {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 7px;
  background: var(--brand);
  color: #ffffff;
  box-shadow: none;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -.02em;
}
.brand strong { font-family: var(--font-heading); font-size: 14px; font-weight: 720; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 10px; }

.company-context {
  width: min(390px, 32vw);
  min-width: 230px;
  gap: 6px;
  border: 0;
  background: transparent;
}
.company-context-label { color: var(--muted-light); font-size: 9px; letter-spacing: .09em; }
.company-context select {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--ink-strong);
  font-size: 12px;
  font-weight: 650;
}
.company-role {
  border: 1px solid #bfdbfe;
  border-radius: 99px;
  padding: 3px 7px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 8px;
  white-space: nowrap;
}
:root[data-theme="dark"] .company-role { border-color: #274a78; }

.topbar-actions { gap: 6px; }
.utility-button,
.user-menu-button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-muted);
  box-shadow: none;
}
.utility-button:hover,
.user-menu-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-subtle);
  color: var(--ink-strong);
  transform: none;
}
.utility-icon,
.theme-toggle-icon { color: var(--ink-muted); }
.user-avatar { background: var(--brand-soft); color: var(--brand-strong); }

.app-layout { min-height: calc(100vh - 64px); }
.sidebar {
  top: 64px;
  width: 228px;
  height: calc(100vh - 64px);
  flex-basis: 228px;
  padding: 20px 12px 16px;
  border-right: 1px solid #27364a;
  background: #111a2a;
  color: #e5eaf1;
  box-shadow: none;
}
.sidebar-label {
  padding: 0 10px 8px;
  color: #8290a5;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .11em;
}
.sidebar-label-inline { margin-top: 14px; }
.main-nav { gap: 2px; }
.nav-item {
  min-height: 38px;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  color: #b5c0cf;
  font-size: 12px;
  font-weight: 600;
}
.nav-item:hover { background: #17243a; color: #f8fafc; }
.nav-item.active,
:root[data-theme="dark"] .nav-item.active {
  border: 0;
  background: #1b3154;
  color: #bfdbfe;
  box-shadow: inset 3px 0 0 #3b82f6;
}
.nav-item.module-maintenance { opacity: .48; cursor: not-allowed; }
.nav-icon,
.nav-item.active .nav-icon { width: 16px; height: 16px; color: currentColor; }
.sidebar-footer { border-color: #29384d; }
.sidebar-footer strong { color: #f8fafc; }
.sidebar-footer small { color: #8d9aaf; }
.status-dot { background: #22c55e; box-shadow: none; }

.main-content {
  max-width: 1660px;
  padding: 28px clamp(22px, 3vw, 48px) 72px;
}
.view { animation: corporate-view-in .12s ease-out; }
@keyframes corporate-view-in { from { opacity: .45; } }

.page-heading { margin-bottom: 22px; }
.page-heading h1 {
  color: var(--ink-strong);
  font-family: var(--font-heading);
  font-size: clamp(25px, 2.4vw, 33px);
  font-weight: 730;
  letter-spacing: -.03em;
  line-height: 1.1;
}
.section-heading h2,
.form-card h2,
.readiness-heading h2,
.app-modal h2,
.workspace-modal h2,
.auth-form h2,
.auth-intro h1,
.document-modal-title h1,
.note-item-modal-header h2 {
  color: var(--ink-strong);
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -.02em;
}
.eyebrow { color: var(--brand-strong); font-size: 9px; letter-spacing: .12em; }
.muted { color: var(--muted); }

.button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 680;
  box-shadow: none;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.button:not(:disabled):active { transform: none; }
.button-primary { border-color: var(--brand); background: var(--brand); color: #ffffff; box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.button-primary:hover { border-color: #1d4ed8; background: #1d4ed8; box-shadow: none; transform: none; }
:root[data-theme="dark"] .button-primary { color: #071225; }
:root[data-theme="dark"] .button-primary:hover { border-color: #93c5fd; background: #93c5fd; }
.button-secondary { border-color: var(--border); background: var(--surface); color: var(--ink); }
.button-secondary:hover { border-color: var(--border-strong); background: var(--surface-subtle); color: var(--ink-strong); }
.button-danger { background: var(--danger); color: #ffffff; }
.text-button { color: var(--brand-strong); font-weight: 650; }

.form-card,
.readiness-card,
.metric-card,
.table-card,
.search-box,
.totals-card,
.registry-command-bar {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.form-stack { gap: 16px; }
.form-card,
.form-stack > .form-card:nth-child(even) { padding: 22px; background: var(--surface); }
.card-title-row { margin-bottom: 18px; }
.section-heading h2,
.form-card h2,
.readiness-heading h2 { font-size: 18px; }
.section-badge,
.role-tag {
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface-subtle);
  color: var(--ink-muted);
  font-family: var(--font-body);
}

.field-grid { gap: 14px; }
.field { gap: 5px; color: var(--ink); font-size: 11px; font-weight: 650; }
.field input,
.field select,
.field textarea,
.item-input,
select.inline-picker,
.inline-picker select {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  box-shadow: none;
}
.field input:hover,
.field select:hover,
.field textarea:hover,
select.inline-picker:hover { border-color: var(--border-strong); }
.field input:focus,
.field select:focus,
.field textarea:focus,
.item-input:focus,
select.inline-picker:focus {
  border-color: var(--brand);
  outline: 0;
  box-shadow: var(--focus-ring);
}
select.inline-picker { width: min(220px, 100%); min-height: 32px; padding: 4px 28px 4px 8px; }

.notice,
.operations-alert,
.validation-box {
  border-radius: 7px;
  box-shadow: none;
}
.notice-info { border-color: #bfdbfe; background: var(--info-soft); color: var(--info); }
.notice-warning { border-color: #fde68a; background: var(--warning-soft); color: var(--warning); }
.operations-alert { border: 1px solid #fde68a; background: var(--warning-soft); color: var(--ink); }
.operations-alert.operations-alert-critical { border-color: #fecaca; background: var(--danger-soft); }
.operations-alert.operations-alert-critical .operations-alert-icon { color: var(--danger); }

.section-badge.certificate-valid { border-color: #bbf7d0; background: var(--success-soft); color: var(--success); }
.section-badge.certificate-warning { border-color: #fde68a; background: var(--warning-soft); color: var(--warning); }
.section-badge.certificate-critical { border-color: #fecaca; background: var(--danger-soft); color: var(--danger); }
:root[data-theme="dark"] .section-badge.certificate-valid { border-color: #265b47; }
:root[data-theme="dark"] .section-badge.certificate-warning { border-color: #665128; }
:root[data-theme="dark"] .section-badge.certificate-critical { border-color: #6d3540; }

.metric-grid { gap: 10px; margin-bottom: 26px; }
.metric-card,
.metric-card:nth-child(2),
.metric-card:nth-child(3),
.metric-accent {
  min-height: 106px;
  padding: 17px 18px;
  border-color: var(--border);
  background: var(--surface);
}
.metric-card::before { display: none; }
.metric-label,
.metric-caption { color: var(--muted); }
.metric-value {
  margin: 4px 0 2px;
  color: var(--ink-strong);
  font-family: var(--font-heading);
  font-size: 25px;
  font-weight: 730;
  letter-spacing: -.025em;
}

.document-tabs {
  gap: 2px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.document-tab {
  border-radius: 5px 5px 0 0;
  color: var(--muted);
}
.document-tab.active { border-color: var(--border); border-bottom-color: var(--surface); background: var(--surface); color: var(--brand-strong); }

.registry-command-bar,
.operations-command-bar {
  min-height: 58px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-color: var(--border);
  background: var(--surface);
}
.registry-command-bar h2,
.operations-command-bar h2 { font-size: 13px; font-weight: 700; }
.search-box { min-height: 36px; border-radius: 6px; box-shadow: none; }
.search-box input { background: transparent; color: var(--ink); font-size: 12px; }
.compact-select select,
.compact-select input {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 11px;
}

.table-card { overflow: hidden; border-radius: 8px; box-shadow: none; }
.table-scroll { scrollbar-gutter: stable; }
.data-table {
  font-size: 12px;
  font-variant-numeric: tabular-nums lining-nums;
}
.data-table th {
  height: 38px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 760;
  letter-spacing: .065em;
}
.data-table td {
  height: 44px;
  padding: 8px 12px;
  border-color: var(--line-light);
  color: var(--ink);
  font-size: 12px;
}
.data-table tbody tr { transition: background-color .1s ease; }
.data-table tbody tr:hover { background: var(--surface-subtle); box-shadow: none; }
.data-table tbody tr.selected { background: var(--brand-soft); }
.row-title { color: var(--ink-strong); font-weight: 650; }
.row-subtitle { margin-top: 2px; color: var(--muted); font-size: 10px; }
.row-link { color: var(--brand-strong); font-weight: 700; }
.row-actions { gap: 3px; flex-wrap: nowrap; }
.row-actions .text-button {
  min-height: 26px;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--brand-strong);
  font-size: 10px;
  white-space: nowrap;
}
.row-actions .text-button:hover { border-color: #bfdbfe; background: var(--brand-soft); }
.row-actions .danger-text { color: var(--danger); }
.row-actions .danger-text:hover { border-color: #fecdd3; background: var(--danger-soft); }

.status-pill,
.xml-state {
  border: 1px solid transparent;
  border-radius: 99px;
  padding: 3px 7px;
  font-size: 9px;
  font-weight: 720;
  letter-spacing: .015em;
  white-space: nowrap;
}
.status-draft { border-color: var(--border); background: var(--surface-subtle); color: var(--muted); }
.status-pending { border-color: #fde68a; background: var(--warning-soft); color: #854d0e; }
.status-authorized { border-color: #bbf7d0; background: var(--success-soft); color: #166534; }
.status-imported { border-color: #bfdbfe; background: var(--info-soft); color: #1d4ed8; }
.status-rejected,
.status-error { border-color: #fecdd3; background: var(--danger-soft); color: #be123c; }
.status-cancelled { border-color: var(--border); background: var(--surface-subtle); color: var(--muted); }
:root[data-theme="dark"] .status-pending { border-color: #665318; color: #fde68a; }
:root[data-theme="dark"] .status-authorized { border-color: #1e5f3a; color: #86efac; }
:root[data-theme="dark"] .status-imported { border-color: #274a78; color: #93c5fd; }
:root[data-theme="dark"] .status-rejected,
:root[data-theme="dark"] .status-error { border-color: #743044; color: #fda4af; }

.skeleton-row { pointer-events: none; }
.skeleton-row:hover { background: transparent !important; }
.skeleton-line {
  display: block;
  width: 62%;
  height: 10px;
  border-radius: 3px;
  background: var(--border);
  opacity: .55;
  animation: skeleton-pulse 1.15s ease-in-out infinite alternate;
  animation-delay: var(--skeleton-delay, 0ms);
}
.skeleton-line-wide { width: 86%; }
@keyframes skeleton-pulse { to { opacity: .22; } }
@media (prefers-reduced-motion: reduce) { .skeleton-line { animation: none; } }

.readiness-card { padding: 20px; }
.readiness-card.ok,
.readiness-card.warn,
.readiness-card.fail { box-shadow: none; }
.readiness-check { border-radius: 6px; box-shadow: none; }
.totals-card { border-left: 3px solid var(--brand); box-shadow: var(--shadow-soft); }
.totals-card::before { display: none; }

.app-modal::backdrop,
.workspace-modal::backdrop,
.document-modal::backdrop {
  background: rgba(8, 15, 28, .66);
  backdrop-filter: none;
}
.modal-card,
.workspace-modal-shell,
.workspace-modal-form,
.document-modal {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(8, 15, 28, .25);
}
.modal-accent { height: 3px; background: var(--brand); }
.modal-danger .modal-accent { background: var(--danger); }
.modal-actions,
.modal-form-actions { border-color: var(--border); background: var(--surface-subtle); backdrop-filter: none; }
.workspace-modal-close { border-color: var(--border); border-radius: 6px; background: var(--surface-subtle); color: var(--muted); }

.toast {
  border: 1px solid #334155;
  border-radius: 7px;
  background: #0f172a;
  color: #f8fafc;
  box-shadow: 0 12px 28px rgba(8, 15, 28, .2);
}
.toast.success { border-color: #166534; background: #166534; }
.toast.error { border-color: #991b1b; background: #991b1b; }

.auth-shell { background: var(--bg); }
.auth-brand-panel { border-color: var(--border); background: #111a2a; color: #e5eaf1; }
.auth-brand-lockup strong,
.auth-intro h1 { color: #f8fafc; }
.auth-brand-lockup small,
.auth-intro > p:last-child,
.auth-feature-list { color: #aab5c5; }
.auth-form-panel { background: var(--bg); }
.auth-card { border-color: var(--border); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow); }

@media (max-width: 1180px) {
  .topbar { padding-inline: 14px; }
  .main-content { padding-inline: 24px; }
  .company-context { width: min(310px, 30vw); }
}

@media (max-width: 900px) {
  .topbar { min-height: 64px; height: auto; }
  .app-layout { min-height: 0; }
  .sidebar {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    height: 62px;
    padding: 6px 8px;
    border: 0;
    border-top: 1px solid #29384d;
    background: #111a2a;
  }
  .main-nav { gap: 2px; }
  .nav-item { min-width: 76px; min-height: 48px; padding: 4px 8px; }
  .nav-item.active { box-shadow: inset 0 3px 0 #3b82f6; }
  .main-content { padding: 24px 20px 86px; }
}

@media (max-width: 700px) {
  .main-content { padding-inline: 14px; }
  .page-heading { gap: 14px; margin-bottom: 18px; }
  .page-heading h1 { font-size: 25px; }
  .form-card { padding: 17px; }
  .metric-grid { gap: 8px; }
  .metric-card { min-height: 92px; }
  .registry-command-bar,
  .operations-command-bar { align-items: stretch; }
  .row-actions { flex-wrap: wrap; }
}
