:root {
  --brand: #5fa888;
  --brand-dark: #3d7a64;
  --brand-soft: #e6f3ed;
  --brand-mid: #8fc4ad;
  --ink: #24302c;
  --ink-muted: #6b7873;
  --line: #e2ebe6;
  --bg: #eef3f0;
  --surface: #ffffff;
  --sidebar: #1c2b26;
  --sidebar-text: #c5d4ce;
  --sidebar-active: #2a4038;
  --danger: #c24b4b;
  --danger-soft: #fceeee;
  --ok: #2f8f6a;
  --ok-soft: #e7f5ef;
  --warn: #b8860b;
  --warn-soft: #fff8e8;
  --shadow: 0 8px 30px rgba(28, 43, 38, 0.08);
  --radius: 14px;
  --sidebar-w: 260px;
  --sidebar-w-collapsed: 76px;
  --font: "Manrope", "IBM Plex Sans", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app {
  min-height: 100%;
  min-height: 100dvh;
}

button,
input,
select {
  font: inherit;
  max-width: 100%;
}

img {
  max-width: 100%;
  height: auto;
}

.label-short {
  display: none;
}

a {
  color: var(--brand-dark);
}

.hidden {
  display: none !important;
}

/* —— Login —— */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: var(--bg);
}

.login-visual {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(160deg, #1c2b26 0%, #2d4a3e 48%, #5fa888 120%);
  color: #fff;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-visual::before {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  top: -80px;
  right: -100px;
  pointer-events: none;
}

.login-visual::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: rgba(143, 196, 173, 0.18);
  bottom: -60px;
  left: -40px;
  pointer-events: none;
}

.login-visual-inner {
  position: relative;
  z-index: 1;
}

.login-visual .mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
  padding: 8px;
  margin-bottom: 36px;
}

.login-visual h2 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  max-width: 14ch;
}

.login-visual p {
  margin: 0;
  max-width: 36ch;
  color: rgba(255, 255, 255, 0.78);
  font-size: 1.02rem;
  line-height: 1.55;
}

.login-visual-foot {
  position: relative;
  z-index: 1;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.55);
}

.login-panel {
  display: grid;
  place-items: center;
  padding: 32px 24px;
}

.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 36px 32px 28px;
  animation: rise 0.45s var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.login-card .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  margin-bottom: 28px;
}

.login-card .brand img {
  height: 40px;
  width: auto;
  display: block;
  margin: 0 auto;
}

.login-card h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-card .lede {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fbfcfb;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(95, 168, 136, 0.22);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.12s, box-shadow 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-dark);
}

.btn-block {
  width: 100%;
  margin-top: 8px;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.btn-soft {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.btn-soft:hover:not(:disabled) {
  background: #d4ebe0;
}

.btn-outline {
  background: #fff;
  color: var(--brand-dark);
  border: 1px solid var(--line);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #a84848;
}

.btn-icon {
  width: auto;
  margin-top: 0;
  white-space: nowrap;
}

.alert {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
}

/* —— App shell (sidebar) —— */
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  transition: grid-template-columns 0.25s var(--ease);
}

.shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--sidebar-w);
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  z-index: 30;
  overflow: hidden;
  transition: width 0.25s var(--ease), padding 0.25s var(--ease);
}

.shell.sidebar-collapsed .sidebar {
  width: var(--sidebar-w-collapsed);
  padding: 16px 10px 12px;
  align-items: center;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 14px;
  width: 100%;
}

.shell.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 4px 0 14px;
}

.sidebar-brand img.mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.shell.sidebar-collapsed .sidebar-brand-text,
.shell.sidebar-collapsed .nav-item span,
.shell.sidebar-collapsed .sidebar-status .label,
.shell.sidebar-collapsed .sidebar-status #status-text,
.shell.sidebar-collapsed .user-meta,
.shell.sidebar-collapsed #logout-btn span {
  display: none;
}

.sidebar-collapse {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--sidebar-text);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.sidebar-collapse:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar-collapse svg {
  width: 16px;
  height: 16px;
  transition: transform 0.25s var(--ease);
}

.shell.sidebar-collapsed .sidebar-collapse {
  margin: 0 auto 12px;
}

.shell.sidebar-collapsed .sidebar-collapse svg {
  transform: rotate(180deg);
}

.sidebar-brand-text strong {
  color: #fff;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.sidebar-brand-text span {
  font-size: 0.72rem;
  color: rgba(197, 212, 206, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  width: 100%;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  padding: 11px 12px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.shell.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 12px;
  gap: 0;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  opacity: 0.75;
  flex-shrink: 0;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-item:hover svg {
  opacity: 1;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--brand-mid);
}

.shell.sidebar-collapsed .nav-item.active {
  box-shadow: inset 0 -3px 0 var(--brand-mid);
}

.nav-item.active svg {
  opacity: 1;
  color: var(--brand-mid);
}

.sidebar-status {
  margin: 12px 4px 16px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: calc(100% - 8px);
}

.shell.sidebar-collapsed .sidebar-status {
  width: auto;
  margin: 8px 0 12px;
  padding: 10px;
  display: grid;
  place-items: center;
}

.sidebar-status .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(197, 212, 206, 0.55);
  margin-bottom: 6px;
}

.sidebar-status .value {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
}

.shell.sidebar-collapsed .sidebar-status .value {
  gap: 0;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-mid);
  flex-shrink: 0;
}

.dot.busy {
  background: #f0b429;
  box-shadow: 0 0 0 4px rgba(240, 180, 41, 0.2);
  animation: pulse 1.4s ease infinite;
}

.dot.idle {
  background: var(--brand-mid);
}

@keyframes pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(240, 180, 41, 0.35);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(240, 180, 41, 0);
  }
}

.sidebar-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.shell.sidebar-collapsed .sidebar-foot {
  align-items: center;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
}

.shell.sidebar-collapsed .user-chip {
  justify-content: center;
  padding: 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-meta {
  min-width: 0;
  flex: 1;
}

.user-meta strong {
  display: block;
  color: #fff;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-meta span {
  font-size: 0.72rem;
  color: rgba(197, 212, 206, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-foot .btn-ghost {
  width: 100%;
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-text);
}

.shell.sidebar-collapsed .sidebar-foot .btn-ghost {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
}

.content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(238, 243, 240, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  place-items: center;
}

.menu-toggle svg {
  width: 20px;
  height: 20px;
}

.topbar-title h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.topbar-title p {
  margin: 2px 0 0;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.main {
  padding: 18px 22px 28px;
  width: 100%;
  max-width: none;
}

.page-head {
  display: none;
}

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

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: rise 0.4s var(--ease) both;
}

.stat:nth-child(2) {
  animation-delay: 0.05s;
}

.stat:nth-child(3) {
  animation-delay: 0.1s;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-dark);
  flex-shrink: 0;
}

.stat-icon svg {
  width: 20px;
  height: 20px;
}

.stat.ok .stat-icon {
  background: var(--ok-soft);
  color: var(--ok);
}

.stat.err .stat-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.stat .label {
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.stat .value {
  font-size: 1.55rem;
  font-weight: 700;
  margin-top: 2px;
  letter-spacing: -0.02em;
}

.stat.ok .value {
  color: var(--ok);
}

.stat.err .value {
  color: var(--danger);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  align-items: center;
}

.toolbar select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  background: #fff;
  min-width: 200px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.log-list {
  max-height: min(72vh, 780px);
  overflow: auto;
  font-size: 0.86rem;
  line-height: 1.45;
}

.log-row {
  display: grid;
  grid-template-columns: 78px 68px 48px 1fr;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid #eef2f0;
  align-items: start;
}

.log-row:nth-child(odd) {
  background: #fafcfb;
}

.log-row:hover {
  background: var(--brand-soft);
}

.log-row .ts {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
}

.log-row .lvl {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  padding: 3px 0;
}

.log-row .lvl.success {
  color: var(--ok);
}

.log-row .lvl.error {
  color: var(--danger);
}

.log-row .lvl.warn {
  color: var(--warn);
}

.log-row .lvl.info {
  color: var(--brand-dark);
}

.log-row .filial {
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.log-row .msg {
  white-space: pre-wrap;
  word-break: break-word;
}

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

.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  display: grid;
  place-items: center;
}

.empty-icon svg {
  width: 24px;
  height: 24px;
}

.stat .value-sm {
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.25;
  margin-top: 6px;
}

.billing-toolbar {
  align-items: stretch;
}

.search-input {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  background: #fff;
  outline: none;
}

.search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(95, 168, 136, 0.18);
}

.table-wrap {
  overflow: auto;
  max-height: min(72vh, 780px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  background: #f7faf8;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #eef2f0;
  vertical-align: top;
}

.data-table tr:hover td {
  background: var(--brand-soft);
}

.cell-title {
  font-weight: 600;
}

.cell-sub {
  color: var(--ink-muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.mono {
  font-variant-numeric: tabular-nums;
  font-family: "IBM Plex Sans", ui-monospace, monospace;
  font-size: 0.82rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-badge.st-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.status-badge.st-warn {
  background: #fff4d6;
  color: #8a6a12;
}

.status-badge.st-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-badge.st-mute {
  background: #eef1f0;
  color: var(--ink-muted);
}

.status-badge.st-info {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.link-icon {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  text-decoration: none;
}

.link-icon svg {
  width: 16px;
  height: 16px;
}

.link-icon:hover {
  background: #d4ebe0;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.pager-info {
  color: var(--ink-muted);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  flex: 1;
  min-width: 140px;
}

.pager .btn {
  min-width: 130px;
}

/* —— Sync / filiais —— */
.sync-hero {
  display: grid;
  grid-template-columns: 1.6fr 0.9fr;
  gap: 14px;
  margin-bottom: 16px;
}

.hero-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--brand), var(--brand-dark));
}

.hero-card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.hero-card p {
  margin: 0 0 16px;
  color: var(--ink-muted);
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: 48ch;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 0.75rem;
  font-weight: 600;
}

.chip svg {
  width: 14px;
  height: 14px;
}

.hero-action {
  background:
    linear-gradient(145deg, #1c2b26 0%, #2d4a3e 100%);
  color: #fff;
  border: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100%;
}

.hero-action h3 {
  color: #fff;
}

.hero-action p {
  color: rgba(255, 255, 255, 0.7);
}

.hero-action .btn {
  align-self: flex-start;
}

.sync-busy-hint {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--warn-soft);
  border: 1px solid #f0d9a0;
  color: #7a5a10;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-busy-hint svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

.section-label h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.section-label span {
  color: var(--ink-muted);
  font-size: 0.82rem;
}

.filial-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.filial-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s, transform 0.2s var(--ease);
}

.filial-card:hover {
  border-color: var(--brand-mid);
  transform: translateY(-1px);
}

.filial-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.filial-card-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filial-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.filial-icon svg {
  width: 16px;
  height: 16px;
}

.filial-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--brand-dark);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--brand-soft);
  padding: 3px 8px;
  border-radius: 7px;
  width: fit-content;
}

.filial-card h3 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.filial-card .cnpj {
  color: var(--ink-muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filial-card .cnpj svg {
  width: 13px;
  height: 13px;
  opacity: 0.7;
  flex-shrink: 0;
}

.filial-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: auto;
}

.filial-actions .btn {
  width: 100%;
  font-size: 0.8rem;
  padding: 10px 12px;
  line-height: 1.25;
  text-align: left;
  justify-content: flex-start;
}

.filial-actions .btn span {
  white-space: normal;
}

.filial-grid.sync-locked .filial-card {
  opacity: 0.6;
  pointer-events: none;
  transform: none;
}

/* —— Overlay —— */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 43, 38, 0.45);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.overlay-card {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(28, 43, 38, 0.2);
  padding: 28px;
  text-align: center;
  animation: rise 0.35s var(--ease) both;
}

.overlay-card h2 {
  margin: 12px 0 4px;
  font-size: 1.2rem;
}

.overlay-card p {
  margin: 0 0 14px;
  color: var(--ink-muted);
}

.progress-status {
  margin: 8px 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 600;
  font-size: 0.95rem;
  text-align: left;
}

.progress-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: left;
  max-height: 200px;
  overflow: auto;
}

.progress-steps li {
  padding: 8px 10px;
  border-bottom: 1px solid #eef2f0;
  font-size: 0.88rem;
  color: var(--ink);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.progress-steps li::before {
  content: "•";
  color: var(--brand);
  font-weight: 700;
  line-height: 1.3;
}

.progress-steps li.ok {
  color: var(--ok);
}

.progress-steps li.err {
  color: var(--danger);
}

.overlay-hint {
  margin: 14px 0 0 !important;
  font-size: 0.8rem !important;
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid var(--brand-soft);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.sidebar-backdrop {
  display: none;
}

.label-short {
  display: none;
}

/* —— Responsivo —— */
@media (max-width: 1200px) {
  .sync-hero {
    grid-template-columns: 1.2fr 1fr;
  }

  .filial-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media (max-width: 960px) {
  .shell,
  .shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .shell.sidebar-collapsed .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(300px, 88vw);
    height: 100dvh;
    align-items: stretch;
    padding: 18px 12px max(14px, env(safe-area-inset-bottom));
    transform: translateX(-105%);
    transition: transform 0.28s var(--ease);
    box-shadow: 16px 0 40px rgba(0, 0, 0, 0.25);
  }

  .shell.sidebar-open .sidebar {
    transform: none;
  }

  .shell.sidebar-collapsed .sidebar-brand-text,
  .shell.sidebar-collapsed .nav-item span,
  .shell.sidebar-collapsed .sidebar-status .label,
  .shell.sidebar-collapsed .sidebar-status #status-text,
  .shell.sidebar-collapsed .user-meta,
  .shell.sidebar-collapsed #logout-btn span {
    display: revert;
  }

  .shell.sidebar-collapsed .nav-item {
    justify-content: flex-start;
    padding: 11px 12px;
    gap: 12px;
  }

  .shell.sidebar-collapsed .sidebar-collapse,
  .sidebar-collapse {
    display: none;
  }

  .shell.sidebar-collapsed .sidebar-foot .btn-ghost {
    width: 100%;
    height: auto;
    padding: 11px 16px;
  }

  .shell.sidebar-collapsed .sidebar-status {
    width: calc(100% - 8px);
    margin: 12px 4px 16px;
    padding: 12px;
    display: block;
  }

  .shell.sidebar-collapsed .sidebar-status .value {
    gap: 8px;
  }

  .shell.sidebar-collapsed .sidebar-brand {
    justify-content: flex-start;
    padding: 4px 8px 16px;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(28, 43, 38, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    z-index: 25;
  }

  .shell.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .menu-toggle {
    display: grid;
  }

  .sync-hero {
    grid-template-columns: 1fr;
  }

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

  .stat .value {
    font-size: 1.25rem;
  }

  .stat .value-sm {
    font-size: 0.88rem;
  }

  .topbar {
    padding: 12px max(14px, env(safe-area-inset-right)) 12px max(14px, env(safe-area-inset-left));
    gap: 10px;
    flex-wrap: wrap;
  }

  .topbar-title {
    min-width: 0;
  }

  .topbar-title h2 {
    font-size: 1.1rem;
  }

  .topbar-title p {
    font-size: 0.8rem;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .sync-control,
  .topbar-actions .btn {
    width: 100%;
  }

  .main {
    padding: 14px max(14px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .billing-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .billing-toolbar select,
  .billing-toolbar .search-input,
  .billing-toolbar .btn {
    width: 100%;
    min-width: 0;
  }

  .billing-toolbar .search-input {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .login-shell {
    grid-template-columns: 1fr;
    min-height: 100dvh;
  }

  .login-visual {
    min-height: auto;
    padding: 28px 22px 24px;
  }

  .login-visual h2 {
    max-width: none;
    font-size: clamp(1.4rem, 6vw, 1.75rem);
  }

  .login-visual p {
    max-width: none;
    font-size: 0.95rem;
  }

  .login-visual-foot {
    margin-top: 20px;
  }

  .login-panel {
    padding: 20px 16px max(24px, env(safe-area-inset-bottom));
    align-items: start;
  }

  .login-card {
    width: 100%;
    padding: 24px 18px 20px;
    border-radius: 18px;
  }

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

  .log-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 12px 14px;
  }

  .log-list {
    max-height: none;
  }

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

  .filial-actions {
    grid-template-columns: 1fr;
  }

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

  .toolbar select,
  .toolbar .btn {
    width: 100%;
  }

  .label-full {
    display: none;
  }

  .label-short {
    display: inline;
  }

  .overlay {
    padding: 12px;
    align-items: end;
  }

  .overlay-card {
    width: 100%;
    border-radius: 18px 18px 12px 12px;
    padding: 22px 16px;
    max-height: min(88dvh, 640px);
    overflow: auto;
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table thead {
    display: none;
  }

  .data-table tr {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
  }

  .data-table tr:nth-child(odd) {
    background: #fafcfb;
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 6px 0;
    border-bottom: none;
  }

  .data-table td::before {
    content: attr(data-label);
    color: var(--ink-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex: 0 0 38%;
    padding-top: 2px;
  }

  .data-table td:last-child {
    justify-content: flex-end;
  }

  .data-table td:last-child::before {
    content: none;
  }

  .cell-title,
  .cell-sub,
  .mono {
    text-align: right;
  }
}

@media (max-width: 480px) {
  .topbar-title p {
    display: none;
  }

  .hero-card {
    padding: 16px;
  }

  .hero-meta {
    gap: 6px;
  }

  .chip {
    font-size: 0.7rem;
  }

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

  .section-label {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .btn-icon {
    white-space: normal;
  }
}

@media (min-width: 1400px) {
  .main {
    padding: 22px 28px 36px;
  }

  .filial-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (min-width: 961px) and (max-width: 1100px) {
  .shell:not(.sidebar-collapsed) {
    grid-template-columns: 220px 1fr;
  }

  .shell:not(.sidebar-collapsed) .sidebar {
    width: 220px;
  }
}
