/* Variaveis do tema do sistema web (dark por padrao). */
:root {
  --app-bg: #121214;
  --sidebar-bg: #18181b;
  --surface: #1b1b1e;
  --surface-elevated: #222226;
  --border: #2a2a2e;
  --border-subtle: #232327;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: rgba(59, 130, 246, 0.14);
  --primary-link-hover: #60a5fa;
  --orange: #f97316;
  --orange-soft: rgba(249, 115, 22, 0.14);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.12);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.12);
  --input-bg: #16161a;
  --input-placeholder: #52525b;
  --nav-hover-bg: rgba(255, 255, 255, 0.04);
  --btn-outline-hover-border: #3f3f46;
  --btn-outline-hover-bg: rgba(255, 255, 255, 0.03);
  --info-banner-bg: rgba(59, 130, 246, 0.1);
  --info-banner-border: rgba(59, 130, 246, 0.25);
  --theme-switch-bg: #2f2f35;
  --theme-icon-active: #f4f4f5;
  --theme-icon-idle: #71717a;
  --sidebar-width: 248px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --panel-content-inset: 16px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --app-bg: #f1f3f8;
  --sidebar-bg: #ffffff;
  --surface: #ffffff;
  --surface-elevated: #f8fafc;
  --border: #e2e8f0;
  --border-subtle: #edf2f7;
  --text: #111827;
  --text-muted: #4b5563;
  --text-dim: #6b7280;
  --primary-soft: rgba(59, 130, 246, 0.12);
  --primary-link-hover: #1d4ed8;
  --orange-soft: rgba(249, 115, 22, 0.12);
  --green-soft: rgba(34, 197, 94, 0.12);
  --red-soft: rgba(239, 68, 68, 0.1);
  --input-bg: #ffffff;
  --input-placeholder: #9ca3af;
  --nav-hover-bg: rgba(15, 23, 42, 0.05);
  --btn-outline-hover-border: #cbd5e1;
  --btn-outline-hover-bg: rgba(15, 23, 42, 0.04);
  --info-banner-bg: rgba(59, 130, 246, 0.08);
  --info-banner-border: rgba(59, 130, 246, 0.2);
  --theme-switch-bg: #e5e7eb;
  --theme-icon-active: #f59e0b;
  --theme-icon-idle: #9ca3af;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

:root[data-theme="light"] .badge--plan {
  color: #1d4ed8;
}

:root[data-theme="light"] .badge--sync {
  color: #15803d;
}

:root[data-theme="light"] .badge--master {
  color: #c2410c;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 17px;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: var(--app-bg);
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
}

button,
a {
  font: inherit;
}

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

.web-dev-banner {
  position: sticky;
  top: 0;
  z-index: 40;
  margin: 0;
  padding: 10px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--red) 45%, transparent);
  background: color-mix(in srgb, var(--red) 18%, var(--surface));
  color: #fecaca;
  font-size: 0.92rem;
  line-height: 1.45;
  text-align: center;
}

.web-dev-banner strong {
  color: #fee2e2;
  font-weight: 700;
}

:root[data-theme="light"] .web-dev-banner {
  background: rgba(239, 68, 68, 0.12);
  border-bottom-color: rgba(239, 68, 68, 0.35);
  color: #991b1b;
}

:root[data-theme="light"] .web-dev-banner strong {
  color: #7f1d1d;
}

/* ---- Sidebar ---- */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 8px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-brand__logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-bottom: 10px;
}

.sidebar-brand__title {
  margin: 0;
  font-size: 15.2px;
  font-weight: 700;
  color: var(--text);
}

.sidebar-brand__version {
  margin: 4px 0 0;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.sidebar-badges {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 4px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
}

.badge--master {
  color: #fb923c;
  background: rgba(249, 115, 22, 0.18);
  border: 1px solid rgba(249, 115, 22, 0.45);
}

.badge--plan {
  color: #93c5fd;
  background: var(--primary-soft);
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.badge--sync {
  color: #86efac;
  background: var(--green-soft);
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.badge svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item__icon {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-mode: alpha;
  mask-mode: alpha;
  opacity: 0.9;
}

.nav-item:hover {
  color: var(--text);
  background: var(--nav-hover-bg);
}

.nav-item.is-active {
  color: #ffffff;
  background: var(--primary);
}

.nav-item.is-active .nav-item__icon {
  opacity: 1;
}

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--red);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}

.sidebar-logout svg {
  width: 18px;
  height: 18px;
}

.sidebar-logout:hover {
  background: var(--red-soft);
}

/* ---- Main area ---- */

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 22px 24px;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Recuo interno do conteúdo dentro do card principal */
.products-page > :not(.page-header):not(.page-header--settings) {
  margin-left: var(--panel-content-inset);
  margin-right: var(--panel-content-inset);
}

.products-page > :last-child {
  margin-bottom: var(--panel-content-inset);
}

.registrations-page .reg-tabs,
.financial-page .fin-tabs {
  margin-left: var(--panel-content-inset);
  margin-right: var(--panel-content-inset);
}

.registrations-page [data-reg-tab-panels],
.financial-page [data-fin-tab-panels] {
  padding: 0 var(--panel-content-inset) var(--panel-content-inset);
}

.financial-page > .fin-empty-state {
  margin-left: var(--panel-content-inset);
  margin-right: var(--panel-content-inset);
  margin-bottom: var(--panel-content-inset);
}

.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
}

.top-header__welcome {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.top-header__meta {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.top-header__profile {
  color: var(--orange);
  font-weight: 600;
}

.top-header__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  overflow: hidden;
}

.top-header__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transform: scale(1.12);
}

.content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 0;
}

.page-header__title {
  margin: 0;
  font-size: 26.4px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-header__subtitle {
  margin: 6px 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 52ch;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.btn-outline svg {
  width: 16px;
  height: 16px;
}

.btn-outline:hover {
  color: var(--text);
  border-color: var(--btn-outline-hover-border);
  background: var(--btn-outline-hover-bg);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 18px 22px 22px;
}

.info-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 148px;
}

.info-card__icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-card__icon svg {
  width: 20px;
  height: 20px;
}

.info-card__icon--blue {
  background: var(--primary-soft);
  color: var(--primary);
}

.info-card__icon--orange {
  background: var(--orange-soft);
  color: var(--orange);
}

.info-card__title {
  margin: 0;
  font-size: 15.68px;
  font-weight: 700;
}

.info-card__text {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.info-card__link {
  margin-top: auto;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.info-card__link:hover {
  color: var(--primary-link-hover);
}

.next-modules {
  padding: 20px 22px 22px;
}

.next-modules__title {
  margin: 0;
  font-size: 15.68px;
  font-weight: 700;
}

.next-modules__text {
  margin: 8px 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ---- Mobile shell ---- */

.mobile-topbar,
.sidebar-backdrop {
  display: none;
}

.main-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mobile-topbar {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.mobile-topbar__menu-btn,
.mobile-topbar__action {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.mobile-topbar__menu-btn svg,
.mobile-topbar__action svg {
  width: 18px;
  height: 18px;
}

.mobile-topbar__title {
  margin: 0;
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand__title--user {
  display: none;
}

@media (max-width: 768px) {
  :root {
    --panel-content-inset: 12px;
  }

  .mobile-topbar {
    display: flex;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.58);
    z-index: 180;
    border: 0;
    padding: 0;
    margin: 0;
    cursor: pointer;
  }

  .sidebar-backdrop[hidden] {
    display: none !important;
  }

  .main-column {
    width: 100%;
    gap: 12px;
    padding: 12px 14px 20px;
  }

  .main-area {
    width: 100%;
    padding: 0;
    gap: 12px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(88vw, 320px);
    z-index: 190;
    transform: translateX(-100%);
    transition: transform 0.24s ease;
    border-right: 1px solid var(--border-subtle);
    border-bottom: 0;
    overflow-y: auto;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.35);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .nav-item {
    font-size: 1.02rem;
    padding: 12px 14px;
  }

  .nav-item__icon {
    width: 22px;
    height: 22px;
  }

  .sidebar-brand__title--app {
    display: none;
  }

  .sidebar-brand__title--user {
    display: block;
  }

  .sidebar-brand__logo {
    width: 64px;
    height: 64px;
  }

  .nav-item.is-active {
    color: #93c5fd;
    background: var(--primary-soft);
    border: 1px solid rgba(59, 130, 246, 0.45);
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.08);
  }

  :root[data-theme="light"] .nav-item.is-active {
    color: var(--primary);
  }

  .top-header {
    display: none;
  }

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

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

  .page-header__subtitle {
    max-width: none;
  }

  html {
    font-size: 18px;
  }
}

@media (min-width: 769px) and (max-width: 960px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
  }
}

.product-panel__title,
.product-details-panel__title,
.dialog-card h3,
.fin-receivable-card__title {
  font-size: 16px;
}

.settings-card__title,
.form-section__title,
.info-banner__title,
.module-access-card__title,
.cnpj-report__title,
.settings-scope-banner__title {
  font-size: 15.68px;
}

.fin-form-section__title {
  font-size: 14.08px;
}

.fin-details-section__title {
  font-size: 14.4px;
}
