:root {
  color-scheme: light;
  --bg: #f4f1e8;
  --surface: #ffffff;
  --surface-2: #f7faf7;
  --ink: #17231e;
  --muted: #65736d;
  --line: #dce4de;
  --brand: #1f5b45;
  --brand-2: #2d8062;
  --accent: #b76e2b;
  --danger: #bd3b3b;
  --ok: #247a54;
  --shadow: 0 18px 50px rgba(35, 45, 39, 0.14);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(31, 91, 69, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(183, 110, 43, 0.12), transparent 34%),
    var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
}

.auth-visual {
  position: relative;
  overflow: hidden;
  padding: 44px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(rgba(17, 44, 34, 0.42), rgba(17, 44, 34, 0.58)),
    url("https://images.unsplash.com/photo-1500595046743-cd271d694d30?auto=format&fit=crop&w=1500&q=80")
      center/cover;
  color: #fff;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #fff;
  color: var(--brand);
  font-weight: 900;
  letter-spacing: 0;
}

.auth-visual h1 {
  margin: 0;
  max-width: 560px;
  font-size: clamp(2.1rem, 5vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.auth-visual p {
  margin: 18px 0 0;
  max-width: 520px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 1.05rem;
}

.auth-panel {
  display: grid;
  align-items: center;
  padding: 36px;
}

.auth-card {
  width: min(100%, 560px);
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 4vw, 42px);
}

.auth-card h2,
.page-title h1,
.panel h2,
.module-card h3 {
  margin: 0;
  letter-spacing: 0;
}

.auth-card h2 {
  font-size: clamp(1.65rem, 3vw, 2.35rem);
}

.auth-card > p,
.page-title p,
.panel > p,
.module-card p {
  color: var(--muted);
}

.auth-card form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: #36473f;
  font-size: 0.92rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.password-control {
  position: relative;
}

.password-control input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
}

.password-toggle:hover,
.password-toggle.active {
  color: var(--brand);
  background: #edf4ef;
}

.password-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.badge.warn {
  background: #fff4d6;
  color: #8a5b00;
}

.badge.danger {
  background: #fde7e7;
  color: var(--danger);
}

.badge.ok {
  background: #e5f4eb;
  color: var(--ok);
}

.danger-zone {
  border-color: rgba(189, 59, 59, 0.28);
}

.cleanup-form {
  display: grid;
  gap: 18px;
}

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

.cleanup-card {
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.cleanup-card input {
  width: 18px;
  height: 18px;
}

.cleanup-card span {
  display: grid;
  gap: 4px;
}

.cleanup-card small {
  color: var(--muted);
  font-weight: 700;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(45, 128, 98, 0.15);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.check {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  color: #384940;
  font-size: 0.94rem;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.link-button {
  background: transparent;
  color: var(--brand);
  font-weight: 800;
  padding: 0;
}

.primary,
.secondary,
.ghost,
.danger {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
}

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

.secondary {
  background: #e8f2ed;
  color: var(--brand);
}

.ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--line);
}

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

.message {
  min-height: 22px;
  color: var(--danger);
  font-weight: 700;
}

.message.ok {
  color: var(--ok);
}

.sidebar {
  min-height: 100vh;
  background: #17382d;
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px;
}

.sidebar-head strong {
  display: block;
  font-size: 1.2rem;
}

.sidebar-head span {
  display: block;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.82rem;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 12px;
  color: rgba(255, 255, 255, 0.8);
  background: transparent;
  text-align: left;
  font-weight: 750;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.user-mini {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 18px;
  display: grid;
  gap: 12px;
}

.user-name-only strong {
  display: block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #f2d6ad;
  color: #17382d;
  display: inline-grid;
  place-items: center;
  font-weight: 900;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.content {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.sync-status {
  min-height: 38px;
  border: 1px solid rgba(36, 122, 84, 0.24);
  border-radius: 999px;
  padding: 8px 13px;
  display: inline-flex;
  align-items: center;
  color: var(--ok);
  background: #eef8f2;
  font-size: 0.9rem;
  font-weight: 850;
  white-space: nowrap;
}

.page-title h1 {
  font-size: clamp(1.75rem, 3vw, 2.7rem);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat,
.panel,
.module-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(220, 228, 222, 0.9);
  border-radius: 8px;
  box-shadow: 0 10px 32px rgba(35, 45, 39, 0.08);
}

.stat {
  padding: 18px;
}

.stat span {
  color: var(--muted);
  font-weight: 700;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  overflow-wrap: anywhere;
}

.subscription-card {
  width: min(100%, 780px);
}

.subscription-stats {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.subscription-stats .stat {
  min-height: 118px;
  display: grid;
  align-content: center;
}

.subscription-stats .stat strong {
  font-size: clamp(1.05rem, 1.4vw, 1.35rem);
  line-height: 1.2;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.pix-box {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid rgba(36, 122, 84, 0.24);
  border-radius: 8px;
  background: #eef8f2;
}

.pix-qr {
  display: grid;
  place-items: center;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
}

.pix-qr img {
  width: 160px;
  height: 160px;
}

.pix-copy {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.pix-copy strong {
  color: var(--brand);
}

.pix-copy code {
  display: block;
  padding: 12px;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  overflow-wrap: anywhere;
}

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

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

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.chart-card {
  min-height: 250px;
  position: relative;
  overflow: hidden;
  transform-style: preserve-3d;
  perspective: 900px;
}

.chart-card::after {
  content: "";
  position: absolute;
  inset: auto 16px 12px;
  height: 18px;
  border-radius: 50%;
  background: rgba(23, 35, 30, 0.12);
  filter: blur(12px);
  pointer-events: none;
}

.chart-bars {
  display: grid;
  gap: 13px;
  margin-top: 18px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(88px, 0.8fr) minmax(120px, 1.5fr) minmax(
      70px,
      auto
    );
  align-items: center;
  gap: 10px;
}

.chart-row span {
  color: #34463e;
  font-size: 0.9rem;
  font-weight: 800;
}

.chart-row strong {
  color: var(--ink);
  font-size: 0.9rem;
  text-align: right;
  white-space: nowrap;
}

.chart-track {
  height: 18px;
  border-radius: 6px;
  background: linear-gradient(180deg, #f6faf7, #dce8e0);
  overflow: hidden;
  transform: rotateX(14deg) skewX(-8deg);
  transform-origin: left center;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.9), inset 0 -3px 5px rgba(23, 35, 30, 0.16), 0 9px 14px rgba(23, 35, 30, 0.12);
}

.chart-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  box-shadow: inset 0 3px 4px rgba(255, 255, 255, 0.3), inset 0 -6px 9px rgba(23, 35, 30, 0.2), 8px 8px 0 rgba(23, 35, 30, 0.08);
}

.column-chart {
  min-height: 204px;
  display: grid;
  grid-template-columns: repeat(6, minmax(48px, 1fr));
  align-items: end;
  gap: 12px;
  margin-top: 20px;
}

.column-item {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 140px auto;
  gap: 8px;
  align-items: end;
  text-align: center;
}

.column-item strong {
  color: var(--ink);
  font-size: 0.7rem;
  overflow-wrap: anywhere;
}

.column-item span {
  color: #34463e;
  font-size: 0.6rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.column-track {
  height: 140px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #f8fbf9, #e0eae4);
  display: flex;
  align-items: end;
  overflow: hidden;
  transform: rotateX(10deg) rotateY(-5deg);
  transform-origin: bottom center;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.9), 10px 12px 16px rgba(23, 35, 30, 0.14);
}

.column-track i {
  width: 100%;
  min-height: 8px;
  border-radius: 8px 8px 0 0;
  box-shadow: inset -10px 0 0 rgba(23, 35, 30, 0.12), inset 0 8px 0 rgba(255, 255, 255, 0.18);
}

.line-chart {
  margin-top: 16px;
}

.line-chart svg {
  width: 100%;
  min-height: 170px;
  display: block;
  transform: rotateX(10deg);
  transform-origin: center bottom;
  filter: drop-shadow(12px 14px 10px rgba(23, 35, 30, 0.18));
}

.line-area {
  fill: rgba(56, 103, 214, 0.12);
}

.line-stroke {
  fill: none;
  stroke: url("#lineGradient");
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 8px 2px rgba(56, 103, 214, 0.18));
}

.line-labels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.line-labels span {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-2);
  font-size: 0.78rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.line-labels strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 0.82rem;
}

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

.module-card {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.module-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.integration-card {
  align-content: start;
}

.integration-form {
  display: grid;
  gap: 12px;
}

.integration-form .message {
  min-height: 18px;
  font-size: 0.86rem;
}

.badge {
  align-self: start;
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef4ef;
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 900;
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: #43564d;
  font-size: 0.84rem;
}

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

.auth-actions {
  margin-top: 18px;
}

.wide-form {
  align-items: end;
}

.field.full {
  grid-column: 1 / -1;
}

textarea {
  resize: vertical;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.64;
}

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

.mini-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin: 16px 0;
}

.bars {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.bars div {
  position: relative;
  min-height: 46px;
  padding: 8px 10px;
  background: #edf4ef;
  border-radius: 8px;
  overflow: hidden;
}

.bars span,
.bars strong {
  position: relative;
  z-index: 1;
}

.bars span {
  display: block;
  color: #354840;
  font-weight: 800;
}

.bars strong {
  color: #17382d;
}

.bars i {
  position: absolute;
  inset: auto auto 0 0;
  height: 100%;
  min-width: 6px;
  background: rgba(45, 128, 98, 0.22);
}

.alert-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.alert-list p {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.report-area .panel {
  box-shadow: none;
  border: 0;
  padding: 0;
}

.report-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.report-heading h2 {
  margin: 0;
}

.report-heading strong {
  color: var(--brand);
  font-size: 0.98rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 20px;
}

.photo-box {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.photo-box .avatar {
  width: 118px;
  height: 118px;
  font-size: 2rem;
}

.hidden {
  display: none !important;
}

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

  .sidebar {
    min-height: auto;
  }

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

  .stats,
  .modules,
  .record-grid,
  .dashboard-grid,
  .chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .auth-page {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    min-height: 340px;
  }

  .form-grid,
  .profile-grid,
  .stats,
  .modules,
  .record-grid,
  .dashboard-grid,
  .chart-grid,
  .mini-form {
    grid-template-columns: 1fr;
  }

  .chart-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .chart-row strong {
    text-align: left;
  }

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

  .line-labels {
    grid-template-columns: 1fr;
  }

  .content,
  .auth-panel,
  .auth-visual {
    padding: 22px;
  }

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

  .sync-status {
    white-space: normal;
  }

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

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar .actions,
  .actions-col,
  form,
  button {
    display: none !important;
  }

  .shell {
    display: block;
  }

  .content {
    padding: 0;
  }

  .panel,
  .stat,
  .module-card {
    box-shadow: none;
    border-color: #bbb;
  }
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
}

.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.edit-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 35, 30, 0.52);
}

.edit-box {
  width: min(920px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.edit-box header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.edit-box h2 {
  margin: 0;
}
