* {
  box-sizing: border-box;
}

:root {
  --bg: #f4f6f8;
  --sidebar: #14213d;
  --sidebar-soft: #1d2d50;
  --text: #1f2937;
  --muted: #6b7280;
  --card: #ffffff;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 300px;
  background: var(--sidebar);
  color: #ffffff;
  padding: 24px;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 34px;
}

.brand-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: #ffffff;
  color: var(--sidebar);
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: -1px;
}

.brand h1 {
  font-size: 17px;
  margin: 0 0 4px;
  line-height: 1.2;
}

.brand p {
  margin: 0;
  font-size: 13px;
  color: #cbd5e1;
}

.menu {
  display: grid;
  gap: 10px;
}

.menu-item {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  color: #e5e7eb;
  background: transparent;
  text-align: left;
  font-size: 15px;
  cursor: pointer;
}

.menu-item:hover,
.menu-item.active {
  background: var(--sidebar-soft);
  color: #ffffff;
}

.server-box {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--sidebar-soft);
  padding: 14px;
  border-radius: 16px;
}

.server-box strong {
  display: block;
  font-size: 13px;
}

.server-box small {
  display: block;
  color: #cbd5e1;
  margin-top: 2px;
}

.server-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--warning);
  flex: 0 0 auto;
}

.server-dot.online {
  background: var(--success);
}

.server-dot.offline {
  background: var(--danger);
}

.content {
  flex: 1;
  margin-left: 300px;
  padding: 28px;
}

.topbar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}

.topbar h2 {
  margin: 0 0 6px;
  font-size: 26px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.primary-button,
.secondary-button,
.action-button {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  color: #ffffff;
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  color: var(--text);
  background: #eef2f7;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.card,
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.card {
  padding: 22px;
}

.card span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 10px;
}

.card strong {
  display: block;
  font-size: 34px;
}

.panel {
  padding: 24px;
  margin-bottom: 22px;
}

.panel h3 {
  margin: 0 0 10px;
  font-size: 20px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  margin-top: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  background: #ffffff;
}

input:focus,
select:focus {
  border-color: var(--primary);
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.checkbox-group {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
}

.checkbox-group legend {
  padding: 0 8px;
  font-weight: 800;
  font-size: 14px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.checkbox-item input {
  width: auto;
}

.security-note {
  margin: 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 14px;
  font-weight: 700;
}

.form-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.system-message {
  min-height: 20px;
  margin: 16px 0 0;
  font-weight: 700;
}

.system-message.success {
  color: var(--success);
}

.system-message.error {
  color: var(--danger);
}

.table-wrapper {
  overflow-x: auto;
  overflow-y: visible;
}

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

th,
td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: #f9fafb;
}

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

.action-button {
  background: #eef2f7;
  color: var(--text);
  padding: 9px 12px;
  border-radius: 12px;
}

.floating-action-menu {
  position: fixed;
  min-width: 150px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.2);
  padding: 8px;
  z-index: 9999;
}

.floating-action-menu button {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 11px 12px;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  font-weight: 800;
  color: var(--text);
}

.floating-action-menu button:hover {
  background: #f3f4f6;
}

.floating-action-menu .delete-action {
  color: var(--danger);
}

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: 100%;
  }

  .app {
    display: block;
  }

  .content {
    margin-left: 0;
    padding: 18px;
  }

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

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


.topbar.compact-topbar {
  justify-content: flex-end;
  padding: 0;
  min-height: 56px;
  background: transparent;
  border: 0;
  box-shadow: none;
  margin-bottom: 12px;
}

.topbar.compact-topbar > div:first-child {
  display: none;
}

.topbar.compact-topbar > .add-menu-wrapper {
  display: inline-flex;
}

.round-add-button {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 30px;
  line-height: 1;
}

.cert-status {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 800;
}

.cert-ok {
  color: var(--success);
}

.cert-alert {
  color: var(--warning);
}

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

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


.table-panel {
  padding: 0;
  overflow: visible;
}

.table-panel .table-wrapper {
  border-radius: 22px;
}

.inline-action-button {
  border: 0;
  border-radius: 12px;
  padding: 9px 12px;
  font-weight: 800;
  cursor: pointer;
  background: #eef2f7;
  color: var(--text);
  white-space: nowrap;
}

.inline-action-button:hover {
  background: #e2e8f0;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  z-index: 10000;
  padding: 18px;
}

.modal-card {
  width: min(460px, 100%);
  background: #ffffff;
  border-radius: 22px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.25);
  padding: 24px;
}

.modal-card h3 {
  margin: 0 0 10px;
  font-size: 20px;
}

.modal-card p {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
}

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

.danger-primary-button {
  background: var(--danger);
}

.danger-primary-button:hover {
  background: #b91c1c;
}


.status-toggle-field {
  display: grid;
  gap: 8px;
  align-content: start;
}

.field-label {
  font-weight: 700;
  font-size: 14px;
}

.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  cursor: pointer;
  user-select: none;
}

.switch-control input {
  display: none;
}

.switch-slider {
  width: 58px;
  height: 32px;
  border-radius: 999px;
  background: #d1d5db;
  position: relative;
  transition: 0.2s ease;
}

.switch-slider::before {
  content: "";
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  position: absolute;
  left: 3px;
  top: 3px;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.22);
  transition: 0.2s ease;
}

.switch-control input:checked + .switch-slider {
  background: var(--success);
}

.switch-control input:checked + .switch-slider::before {
  transform: translateX(26px);
}

#statusToggleText {
  min-width: 52px;
  font-size: 14px;
}

.sort-header {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.sort-header:hover {
  color: var(--primary);
}

.sort-header.active-sort {
  color: var(--primary);
}

.sort-header.active-sort::after {
  content: attr(data-arrow);
  margin-left: 6px;
  font-size: 12px;
}


.add-menu-wrapper {
  position: relative;
  display: inline-flex;
  justify-content: flex-end;
}

.round-add-button {
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.round-add-button.menu-open {
  transform: rotate(45deg);
  box-shadow: 0 18px 40px rgba(37, 99, 235, 0.28);
}

.add-floating-menu {
  position: absolute;
  right: 0;
  top: 64px;
  min-width: 210px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.2);
  padding: 8px;
  z-index: 9000;
}

.add-floating-menu button {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 12px;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  font-weight: 800;
  color: var(--text);
}

.add-floating-menu button:hover {
  background: #f3f4f6;
}

.import-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.import-modal-card {
  max-width: 520px;
}

.import-review-card {
  width: min(1180px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.import-review-table-wrapper {
  overflow: auto;
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.import-review-table-wrapper table {
  min-width: 1450px;
}

.import-review-table-wrapper th,
.import-review-table-wrapper td {
  font-size: 13px;
  padding: 10px;
}

.import-issue-ok {
  color: var(--success);
  font-weight: 800;
}

.import-issue-error {
  color: var(--danger);
  font-weight: 800;
}

.import-issue-warning {
  color: #b45309;
  font-weight: 800;
}

.import-row-error {
  background: #fef2f2;
}


.obrigacoes-toolbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 12px;
}

#obrigacoes .round-add-button {
  flex: 0 0 auto;
}

.campo-obrigacao-condicional.hidden {
  display: none !important;
}


.parametros-toolbar,
.obrigacoes-toolbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 12px;
}

.campo-obrigacao-atividade.hidden {
  display: none !important;
}

.controle-fiscal-panel {
  padding: 0;
}

.controle-fiscal-container {
  overflow-x: auto;
  padding: 18px;
}

.regime-block {
  margin-bottom: 28px;
}

.regime-title {
  margin: 0;
  padding: 12px 14px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  font-size: 16px;
  font-weight: 900;
  color: var(--sidebar);
}

.controle-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

.controle-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  white-space: normal;
  min-width: 110px;
  max-width: 140px;
  color: #1d4ed8;
  background: #f8fafc;
  vertical-align: middle;
  text-align: center;
}

.controle-table th.col-empresa,
.controle-table td.col-empresa {
  position: sticky;
  left: 80px;
  z-index: 2;
  background: #ffffff;
  min-width: 240px;
  max-width: 320px;
  text-align: left;
}

.controle-table th.col-codigo,
.controle-table td.col-codigo {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #ffffff;
  min-width: 80px;
  max-width: 80px;
  text-align: center;
}

.controle-table thead th.col-codigo,
.controle-table thead th.col-empresa {
  z-index: 4;
  background: #f8fafc;
}

.empresa-cnpj {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.controle-cell-disabled {
  background: #d9d9d9;
}

.controle-input {
  width: 120px;
  min-width: 110px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px;
  font-size: 13px;
  text-align: center;
}

.controle-input[type="date"] {
  min-width: 140px;
}

.param-rule-action {
  font-weight: 900;
}

.param-rule-action.incluir {
  color: var(--success);
}

.param-rule-action.excluir {
  color: var(--danger);
}


.parametro-form {
  margin-top: 20px;
}

.param-rule-builder {
  display: grid;
  gap: 18px;
}

.rule-card,
.rule-preview-card {
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 18px;
  background: #ffffff;
}

.rule-card {
  display: grid;
  gap: 16px;
}

.rule-card-then {
  background: #f8fafc;
}

.rule-chip {
  width: fit-content;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--sidebar);
  color: #ffffff;
  font-weight: 900;
  letter-spacing: 0.5px;
  font-size: 12px;
}

.mini-help {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.checklist-grid label,
.checklist-inline label {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  background: #ffffff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.checklist-grid input,
.checklist-inline input {
  width: auto;
}

.checklist-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.compact-checklist {
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}

.segment-rule-row {
  display: grid;
  grid-template-columns: minmax(190px, 260px) 1fr;
  gap: 12px;
  align-items: start;
}

.no-margin {
  margin-top: 0;
}

.rule-preview-card {
  background: #eef6ff;
  color: var(--sidebar);
}

.rule-preview-card strong {
  display: block;
  margin-bottom: 6px;
}

.rule-preview-card p {
  margin: 0;
  line-height: 1.5;
  color: var(--text);
}

.param-condition-list {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .segment-rule-row {
    grid-template-columns: 1fr;
  }
}


/* Controle Fiscal - visual refinado */
.controle-fiscal-panel {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.controle-fiscal-container {
  display: grid;
  gap: 24px;
  padding: 0;
}

.regime-block {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.regime-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 18px 22px;
  background: linear-gradient(135deg, #f8fafc, #eef2ff);
  border: 0;
  color: var(--sidebar);
  font-size: 18px;
  font-weight: 900;
}

.regime-title::before {
  content: "";
  width: 10px;
  height: 28px;
  border-radius: 999px;
  background: var(--primary);
}

.controle-table {
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
}

.controle-table th {
  border-bottom: 1px solid #dbe3ef;
  font-size: 12px;
  line-height: 1.2;
  color: #1d4ed8;
  background: #f8fafc;
}

.controle-table td {
  border-bottom: 1px solid #eef2f7;
}

.controle-table tbody tr:hover td {
  background: #f8fafc;
}

.controle-table tbody tr:hover td.controle-cell-disabled {
  background: #e5e7eb;
}

.controle-table th.col-codigo,
.controle-table th.col-empresa {
  color: var(--sidebar);
}

.controle-table td.col-codigo {
  font-weight: 900;
  color: var(--primary);
}

.controle-table td.col-empresa strong {
  display: block;
  max-width: 320px;
  white-space: normal;
  line-height: 1.25;
}

.controle-cell-disabled {
  background: #edf0f3;
  background-image: repeating-linear-gradient(
    135deg,
    rgba(148, 163, 184, 0.14) 0,
    rgba(148, 163, 184, 0.14) 8px,
    transparent 8px,
    transparent 16px
  );
}

.controle-input {
  background: #ffffff;
  border-color: #cbd5e1;
  font-weight: 800;
}

.controle-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.controle-cell-forced-enabled {
  background: #ecfdf5;
}

.controle-cell-forced-disabled {
  background: #fff7ed;
}


/* Controle Fiscal v2 - visual limpo */
body .controle-fiscal-panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

body .controle-fiscal-container {
  display: grid;
  gap: 18px;
  padding: 0;
}

body .regime-block {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

body .regime-title {
  display: block;
  margin: 0;
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  color: #111827;
  font-size: 15px;
  font-weight: 800;
}

body .regime-title::before {
  content: none;
}

body .controle-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

body .controle-table th,
body .controle-table td {
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 12px;
  font-size: 13px;
}

body .controle-table th {
  background: #f9fafb;
  color: #374151;
  font-weight: 800;
  text-align: center;
  white-space: normal;
}

body .controle-table tbody tr:hover td {
  background: #fafafa;
}

body .controle-table tbody tr:hover td.controle-cell-disabled,
body .controle-table tbody tr:hover td.controle-cell-forced-disabled {
  background: #e5e7eb;
}

body .controle-table th.col-codigo,
body .controle-table th.col-empresa,
body .controle-table td.col-codigo,
body .controle-table td.col-empresa {
  background: #ffffff;
  color: #111827;
}

body .controle-table thead th.col-codigo,
body .controle-table thead th.col-empresa {
  background: #f9fafb;
}

body .controle-table td.col-codigo {
  font-weight: 800;
  text-align: center;
}

body .controle-table td.col-empresa strong {
  display: block;
  color: #111827;
  line-height: 1.25;
  font-weight: 800;
}

body .empresa-cnpj {
  display: block;
  margin-top: 3px;
  color: #6b7280;
  font-size: 12px;
  font-weight: 600;
}

body .controle-cell-disabled,
body .controle-cell-forced-disabled {
  background: #e5e7eb;
  background-image: none;
}

body .controle-cell-forced-enabled {
  background: #ffffff;
}

body .controle-input {
  width: 112px;
  min-width: 100px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 9px;
  background: #ffffff;
  color: #111827;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  outline: none;
  box-shadow: none;
}

body .controle-input:focus {
  border-color: #9ca3af;
  box-shadow: none;
}

body .controle-input[data-field-type="Data"] {
  min-width: 112px;
}

.col-header-wrap {
  display: grid;
  gap: 6px;
  place-items: center;
}

.col-header-title {
  line-height: 1.15;
}

.col-move-buttons {
  display: inline-flex;
  gap: 4px;
}

.col-move-button {
  width: 22px;
  height: 22px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  background: #ffffff;
  color: #374151;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
}

.col-move-button:hover {
  background: #f3f4f6;
}

.option-line {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  background: #ffffff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.option-line input {
  width: auto;
}


/* Controle Fiscal v3 - grade tipo Excel e arrastar colunas */
body .controle-fiscal-container {
  gap: 14px;
}

body .regime-block {
  border-radius: 0;
  box-shadow: none;
  border: 1px solid #cfd4dc;
  background: #ffffff;
}

body .regime-title {
  border-radius: 0;
  padding: 9px 12px;
  font-size: 14px;
  background: #ffffff;
  border-bottom: 1px solid #cfd4dc;
}

body .controle-table {
  border-collapse: collapse;
  border-spacing: 0;
}

body .controle-table th,
body .controle-table td {
  border: 1px solid #cfd4dc;
  padding: 0;
  font-size: 13px;
}

body .controle-table th {
  height: 54px;
  background: #f8f9fa;
  color: #111827;
  vertical-align: middle;
}

body .controle-table td {
  height: 34px;
  background: #ffffff;
}

body .controle-table td.col-codigo,
body .controle-table td.col-empresa {
  padding: 5px 8px;
}

body .controle-table th.col-codigo,
body .controle-table th.col-empresa {
  padding: 6px 8px;
}

body .controle-table tbody tr:hover td {
  background: #ffffff;
}

body .controle-table tbody tr:hover td.controle-cell-disabled,
body .controle-table tbody tr:hover td.controle-cell-forced-disabled {
  background: #e5e7eb;
}

body .controle-cell-disabled,
body .controle-cell-forced-disabled {
  background: #e5e7eb !important;
}

body .controle-cell-forced-enabled {
  background: #ffffff !important;
}

body .controle-input {
  display: block;
  width: 100%;
  min-width: 100px;
  height: 33px;
  border: 0;
  border-radius: 0;
  padding: 0 6px;
  background: #ffffff;
  color: #111827;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  box-shadow: none;
}

body .controle-input:focus {
  outline: 2px solid #9ca3af;
  outline-offset: -2px;
  border: 0;
  box-shadow: none;
}

body .controle-table th:not(.col-codigo):not(.col-empresa),
body .controle-table td:not(.col-codigo):not(.col-empresa) {
  min-width: 112px;
  max-width: 145px;
}

.col-header-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px;
  align-items: center;
  justify-items: center;
  padding: 5px 6px;
  min-height: 53px;
  cursor: grab;
  user-select: none;
}

.col-header-title {
  line-height: 1.1;
  text-align: center;
}

.drag-handle {
  color: #9ca3af;
  font-weight: 900;
  letter-spacing: -3px;
  cursor: grab;
}

.draggable-col-header.dragging-column {
  opacity: 0.45;
}

.draggable-col-header.drag-over-column {
  outline: 2px solid #6b7280;
  outline-offset: -2px;
}

.col-move-buttons,
.col-move-button {
  display: none !important;
}


/* Controle Fiscal v4 - sem pontos, com redimensionamento e menu recolhível */
.drag-handle {
  display: none !important;
}

.col-header-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px 5px 6px;
  min-height: 53px;
  cursor: grab;
  user-select: none;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
}

.col-resize-handle:hover {
  background: rgba(107, 114, 128, 0.18);
}

body.resizing-col,
body.resizing-col * {
  cursor: col-resize !important;
  user-select: none !important;
}

body .controle-fiscal-container {
  overflow-x: auto;
  overflow-y: visible;
  width: 100%;
  max-width: 100%;
  scrollbar-gutter: stable;
}

body .controle-table {
  table-layout: fixed;
}

body .controle-table th:not(.col-codigo):not(.col-empresa),
body .controle-table td:not(.col-codigo):not(.col-empresa) {
  min-width: unset;
  max-width: unset;
}

:root {
  --sidebar-expanded: 300px;
  --sidebar-collapsed: 74px;
}

.sidebar {
  transition: width 0.2s ease, padding 0.2s ease;
  overflow-x: hidden;
  z-index: 50;
}

.content {
  transition: margin-left 0.2s ease;
}

body:not(.sidebar-pinned) .sidebar {
  width: var(--sidebar-collapsed);
  padding: 18px 10px;
}

body:not(.sidebar-pinned) .content {
  margin-left: var(--sidebar-collapsed);
}

body:not(.sidebar-pinned) .sidebar:hover {
  width: var(--sidebar-expanded);
  padding: 24px;
  box-shadow: 14px 0 35px rgba(15, 23, 42, 0.16);
}

body.sidebar-pinned .sidebar {
  width: var(--sidebar-expanded);
}

body.sidebar-pinned .content {
  margin-left: var(--sidebar-expanded);
}

.sidebar .brand-text,
.sidebar .pin-text,
.sidebar .server-box div {
  transition: opacity 0.15s ease;
}

body:not(.sidebar-pinned) .sidebar:not(:hover) .brand-text,
body:not(.sidebar-pinned) .sidebar:not(:hover) .pin-text,
body:not(.sidebar-pinned) .sidebar:not(:hover) .server-box div {
  opacity: 0;
  pointer-events: none;
}

body:not(.sidebar-pinned) .sidebar:not(:hover) .brand {
  justify-content: center;
}

body:not(.sidebar-pinned) .sidebar:not(:hover) .menu-item {
  font-size: 0;
  padding: 14px 0;
  text-align: center;
}

body:not(.sidebar-pinned) .sidebar:not(:hover) .menu-item::before {
  content: "•";
  font-size: 22px;
  line-height: 1;
}

.sidebar-pin-button {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
  color: #e5e7eb;
  background: var(--sidebar-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.sidebar-pin-button:hover,
.sidebar-pin-button.active {
  background: #2b3d68;
  color: #ffffff;
}

.pin-icon {
  font-size: 18px;
  line-height: 1;
}

body:not(.sidebar-pinned) .sidebar:not(:hover) .sidebar-pin-button {
  justify-content: center;
  padding: 12px 0;
}

body:not(.sidebar-pinned) .sidebar:not(:hover) .server-box {
  justify-content: center;
  padding: 14px 0;
}


/* Controle Fiscal - correção refeita sobre a versão 4 */
html,
body {
  overflow-x: hidden;
}

.content {
  min-width: 0;
  box-sizing: border-box;
}

body:not(.sidebar-pinned) .content {
  width: calc(100vw - var(--sidebar-collapsed));
  max-width: calc(100vw - var(--sidebar-collapsed));
}

body.sidebar-pinned .content {
  width: calc(100vw - var(--sidebar-expanded));
  max-width: calc(100vw - var(--sidebar-expanded));
}

#controleFiscal,
#controleFiscal.active {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

body .controle-fiscal-panel,
body .controle-fiscal-container {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.controle-table-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto !important;
  overflow-y: visible;
  padding-bottom: 10px;
}

body .controle-table {
  width: max-content;
  min-width: max-content;
  table-layout: fixed;
  border-collapse: collapse;
}

body .controle-table th,
body .controle-table td {
  box-sizing: border-box;
}

body .controle-table th.col-codigo,
body .controle-table td.col-codigo,
body .controle-table th.col-empresa,
body .controle-table td.col-empresa {
  position: static !important;
  left: auto !important;
  min-width: unset !important;
  max-width: unset !important;
}

body .controle-table th:not(.col-codigo):not(.col-empresa),
body .controle-table td:not(.col-codigo):not(.col-empresa) {
  min-width: unset !important;
  max-width: unset !important;
}

body .controle-input {
  width: 100%;
  min-width: 0;
}

.col-header-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 53px;
  padding: 5px 12px 5px 6px;
  cursor: grab;
  user-select: none;
}

.col-header-wrap.no-drag {
  cursor: default;
}

.drag-handle {
  display: none !important;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 20;
}

.col-resize-handle:hover {
  background: rgba(107, 114, 128, 0.16);
}

body.resizing-col,
body.resizing-col * {
  cursor: col-resize !important;
  user-select: none !important;
}

.sidebar-switch-button {
  justify-content: flex-start;
  gap: 10px;
}

.sidebar-switch-track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #6b7280;
  position: relative;
  flex: 0 0 auto;
  transition: 0.2s ease;
}

.sidebar-switch-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.sidebar-switch-button.active .sidebar-switch-track {
  background: var(--success);
}

.sidebar-switch-button.active .sidebar-switch-thumb {
  transform: translateX(18px);
}

body:not(.sidebar-pinned) .sidebar:not(:hover) .sidebar-switch-button {
  justify-content: center;
}

body:not(.sidebar-pinned) .sidebar:not(:hover) .sidebar-switch-track {
  width: 28px;
}

body:not(.sidebar-pinned) .sidebar:not(:hover) .sidebar-switch-thumb {
  transform: none;
}

body:not(.sidebar-pinned) .sidebar:not(:hover) .pin-icon {
  display: none;
}


/* SRF v7 - CNPJ, mês/ano e observações do Controle Fiscal */
.observacoes-mes-card {
  margin-top: 18px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid #cfd4dc;
  border-radius: 0;
}

.observacoes-mes-card label {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
  color: #111827;
}

.observacoes-mes-textarea {
  width: 100%;
  min-width: 280px;
  min-height: 110px;
  resize: both;
  border: 1px solid #cfd4dc;
  border-radius: 8px;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  color: #111827;
  background: #ffffff;
  box-sizing: border-box;
}

.observacoes-mes-textarea:focus {
  outline: 2px solid #9ca3af;
  outline-offset: -2px;
}


/* Controle Fiscal por mês */
.controle-meses-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  margin-bottom: 14px;
}

.controle-meses-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px 10px;
  flex: 1;
  scrollbar-gutter: stable;
}

.controle-mes-tab,
.controle-mes-add {
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #ffffff;
  color: #374151;
  padding: 9px 14px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 5px 14px rgba(15, 23, 42, 0.05);
}

.controle-mes-tab.active {
  background: var(--sidebar);
  color: #ffffff;
  border-color: var(--sidebar);
}

.controle-mes-tab.travado {
  border-style: dashed;
}

.controle-mes-add {
  flex: 0 0 auto;
  background: #f8fafc;
}

.periodo-status-bar {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #f8fafc;
  font-weight: 800;
  color: #374151;
}

.periodo-status-bar.travado {
  background: #fff7ed;
  color: #9a3412;
}

.parametro-mes-especifico {
  display: grid;
  gap: 10px;
}

.month-specific-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 11px;
  font-weight: 900;
}


/* Controle Fiscal v9 - ordenação e filtro tipo Excel */
.controle-sortable-header {
  position: relative;
}

.controle-sort-title {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  padding: 0;
  line-height: 1.1;
  width: 100%;
}

.controle-sort-title:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.controle-filter-button {
  position: absolute;
  right: 8px;
  bottom: 4px;
  width: 18px;
  height: 18px;
  border: 1px solid #cfd4dc;
  border-radius: 4px;
  background: #ffffff;
  color: #374151;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.controle-sortable-header:hover .controle-filter-button,
.controle-filter-button.active {
  opacity: 1;
  pointer-events: auto;
}

.controle-filter-button.active {
  background: #eef2ff;
  border-color: #9ca3af;
}

.controle-filter-menu {
  position: fixed;
  z-index: 20000;
  width: 240px;
  max-height: 340px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22);
  padding: 10px;
  font-size: 13px;
}

.controle-filter-menu-title {
  font-weight: 900;
  margin-bottom: 8px;
  color: #111827;
}

.controle-filter-values {
  display: grid;
  gap: 4px;
  max-height: 210px;
  overflow: auto;
  border-top: 1px solid #eef2f7;
  border-bottom: 1px solid #eef2f7;
  padding: 8px 0;
  margin: 8px 0;
}

.controle-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  cursor: pointer;
  color: #111827;
}

.controle-filter-option:hover {
  background: #f9fafb;
}

.controle-filter-option input {
  width: auto;
}

.controle-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.controle-filter-actions button {
  border: 1px solid #d1d5db;
  background: #ffffff;
  border-radius: 8px;
  padding: 7px 10px;
  font-weight: 800;
  cursor: pointer;
}

.controle-filter-actions button[data-filter-apply] {
  background: #111827;
  border-color: #111827;
  color: #ffffff;
}


/* Relatório NFS-e */
.nfse-page {
  display: grid;
  gap: 22px;
}

.nfse-hero {
  border-radius: 26px;
  padding: 26px;
  background: linear-gradient(135deg, #ffffff, #eef6ff);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.nfse-eyebrow {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 6px 11px;
  background: rgba(37, 99, 235, 0.10);
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 10px;
}

.nfse-hero h2 {
  margin: 0;
  font-size: 28px;
  color: var(--text);
}

.nfse-hero p {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 600;
}

.nfse-type-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

.nfse-type-button {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px 20px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
  cursor: pointer;
  text-align: left;
  transition: 0.18s ease;
}

.nfse-type-button strong,
.nfse-type-button span {
  display: block;
}

.nfse-type-button strong {
  color: var(--text);
  font-size: 16px;
}

.nfse-type-button span {
  color: var(--muted);
  margin-top: 4px;
  font-weight: 700;
}

.nfse-type-button.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10), var(--shadow);
  transform: translateY(-1px);
}

.nfse-type-button.muted {
  opacity: 0.48;
}

.nfse-html-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.nfse-html-card,
.nfse-add-card {
  min-height: 300px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.nfse-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.nfse-remove-page {
  border: 0;
  border-radius: 999px;
  padding: 7px 10px;
  background: #fee2e2;
  color: #991b1b;
  font-weight: 800;
  cursor: pointer;
}

.nfse-html-card textarea {
  width: 100%;
  min-height: 255px;
  height: 255px;
  border: 0;
  resize: vertical;
  outline: none;
  padding: 16px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
  box-sizing: border-box;
}

.nfse-add-card {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--primary);
  cursor: pointer;
  border-style: dashed;
}

.nfse-add-card span {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.10);
  font-size: 42px;
  font-weight: 900;
}

.nfse-add-card strong {
  color: var(--text);
}

.nfse-add-card.disabled {
  opacity: 0.38;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

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

@media (max-width: 760px) {
  .nfse-type-toggle {
    grid-template-columns: 1fr;
  }

  .nfse-html-grid {
    grid-template-columns: 1fr;
  }
}


/* Relatório NFS-e - complemento opcional por XML */
.nfse-xml-panel {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
  padding: 18px;
  display: grid;
  gap: 12px;
}

.nfse-xml-switch {
  width: fit-content;
}

.nfse-xml-area {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.nfse-xml-area p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.4;
}

.nfse-xml-area input[type="file"] {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 16px;
  background: #f8fafc;
}

.nfse-xml-area small {
  color: var(--muted);
  font-weight: 800;
}


/* SRF Online - Login e usuários */
body.auth-pending .app {
  display: none;
}

body.authenticated .auth-screen {
  display: none;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 35%),
    linear-gradient(135deg, #0f172a, #1e293b 55%, #eef2ff);
}

.auth-card {
  width: min(520px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 28px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.35);
  padding: 28px;
}

.auth-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.auth-pill {
  display: inline-flex;
  width: fit-content;
  padding: 7px 11px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 12px;
}

.auth-card h1,
.auth-card h2,
.auth-card p {
  margin: 0;
}

.auth-card h1 {
  font-size: 34px;
  color: var(--sidebar);
}

.auth-card-header p {
  color: var(--muted);
  font-weight: 700;
  margin-top: 4px;
}

.auth-link-button {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: #eef2ff;
  color: var(--primary);
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form h2 {
  color: var(--text);
  font-size: 22px;
}

.auth-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.logout-button {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  margin-top: 12px;
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 800;
  cursor: pointer;
  text-align: left;
}

.logout-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

body:not(.sidebar-pinned) .sidebar:not(:hover) .logout-button {
  font-size: 0;
  text-align: center;
  padding: 12px 0;
}

body:not(.sidebar-pinned) .sidebar:not(:hover) .logout-button::before {
  content: "↩";
  font-size: 18px;
}

.users-panel {
  margin-bottom: 22px;
}

.users-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(420px, 1.4fr);
  gap: 18px;
  align-items: start;
}

.users-grid.two-columns {
  grid-template-columns: 1fr 1fr;
}

.user-form-card,
.user-list-card {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #ffffff;
  padding: 18px;
}

.user-form-card h4,
.user-list-card h4 {
  margin: 0 0 14px;
  font-size: 17px;
}

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

.small-table-wrapper {
  margin-top: 18px;
}

.menu-item.hidden,
.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .users-grid,
  .users-grid.two-columns {
    grid-template-columns: 1fr;
  }
}


.disabled-checklist {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(0.2);
}


/* Painel - calendário fiscal */
#painel {
  min-height: calc(100vh - 40px);
}

.painel-calendario-page {
  min-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.painel-calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  border: 1px solid #e5e7eb;
  border-radius: 22px;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

.painel-calendar-header h2 {
  margin: 0;
  font-size: 24px;
  color: #0f172a;
}

.painel-calendar-header p {
  margin: 6px 0 0;
  color: #64748b;
  font-weight: 600;
}

.painel-month-selector {
  display: grid;
  gap: 6px;
  min-width: 190px;
  color: #475569;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.painel-month-selector select {
  height: 42px;
  border: 1px solid #d8dee9;
  border-radius: 14px;
  padding: 0 12px;
  background: #ffffff;
  color: #0f172a;
  font-weight: 900;
  outline: none;
}

.painel-calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 0 6px;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

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

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot.done {
  background: #16a34a;
}

.legend-dot.pending {
  background: #f97316;
}

.legend-dot.late {
  background: #dc2626;
}

.painel-calendar-shell {
  flex: 1;
  min-height: 0;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  background: #ffffff;
  overflow: visible;
  box-shadow: 0 12px 35px rgba(15, 23, 42, 0.06);
}

.painel-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
  border-radius: 24px 24px 0 0;
}

.painel-weekdays span {
  padding: 12px 10px;
  text-align: center;
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.painel-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  grid-auto-rows: minmax(112px, 1fr);
  min-height: calc(100vh - 250px);
  overflow: visible;
}

.painel-calendar-day {
  position: relative;
  border-right: 1px solid #edf2f7;
  border-bottom: 1px solid #edf2f7;
  padding: 10px;
  background: #ffffff;
  overflow: visible;
}

.painel-calendar-day:nth-child(7n) {
  border-right: 0;
}

.painel-calendar-day.empty-day {
  background: #f8fafc;
}

.painel-calendar-day.today {
  box-shadow: inset 0 0 0 2px #1d4ed8;
}

.painel-calendar-day.has-events {
  cursor: default;
}

.day-number {
  color: #0f172a;
  font-size: 14px;
  font-weight: 900;
}

.day-markers {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 9px;
  align-items: flex-start;
}

.day-pill {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.day-pill.done {
  color: #166534;
  background: #dcfce7;
}

.day-pill.pending {
  color: #9a3412;
  background: #ffedd5;
}

.day-pill.late {
  color: #991b1b;
  background: #fee2e2;
}

.painel-day-popover {
  position: absolute;
  left: 12px;
  top: 46px;
  z-index: 30;
  display: none;
  width: min(360px, 80vw);
  max-height: 360px;
  overflow: auto;
  padding: 10px;
  border: 1px solid #d8dee9;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
}

.painel-calendar-day:nth-child(7n) .painel-day-popover,
.painel-calendar-day:nth-child(7n - 1) .painel-day-popover {
  left: auto;
  right: 12px;
}

.painel-calendar-day:hover .painel-day-popover {
  display: grid;
  gap: 8px;
}

.painel-popover-item {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border-left: 4px solid #94a3b8;
  border-radius: 12px;
  background: #f8fafc;
}

.painel-popover-item.done {
  border-left-color: #16a34a;
}

.painel-popover-item.pending {
  border-left-color: #f97316;
}

.painel-popover-item.late {
  border-left-color: #dc2626;
}

.painel-popover-item strong {
  color: #0f172a;
  font-size: 13px;
}

.painel-popover-item span,
.painel-popover-item small {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .painel-calendar-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .painel-calendar-shell {
    overflow-x: auto;
  }

  .painel-weekdays,
  .painel-calendar-grid {
    min-width: 920px;
  }
}
