:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #202733;
  --muted: #667085;
  --line: #d8dee8;
  --soft-line: #edf1f6;
  --primary: #0f766e;
  --primary-hover: #115e59;
  --danger: #b42318;
  --success: #047857;
  --warning: #b54708;
  --sidebar: #18212f;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body.is-guest {
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.09), rgba(24, 33, 47, 0.04)),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

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

.is-guest .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

.is-guest .sidebar {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: var(--sidebar);
  color: #ffffff;
}

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

.brand-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
}

.brand p,
.brand h1 {
  margin: 0;
}

.brand p {
  color: #aab4c3;
  font-size: 13px;
}

.brand h1 {
  font-size: 23px;
  line-height: 1.1;
}

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

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

.nav-group-title {
  margin: 0 0 2px;
  padding: 0 12px;
  color: #8fa1b8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-button,
.ghost-button {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  color: inherit;
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.nav-button {
  padding: 0 12px;
  color: #c8d1df;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.session-box {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.session-box span {
  display: block;
  overflow-wrap: anywhere;
  color: #dbe3ef;
  font-size: 13px;
}

.ghost-button {
  margin-top: 10px;
  padding: 0;
  color: #ffffff;
}

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

.is-guest .main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-panel {
  width: min(100%, 440px);
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 18px 45px rgba(31, 41, 55, 0.08);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 28px;
}

.login-brand img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: contain;
}

.login-brand p,
.login-brand strong {
  margin: 0;
}

.login-brand p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-brand strong {
  display: block;
  color: var(--text);
  font-size: 23px;
  line-height: 1.1;
}

.section-heading,
.topbar {
  margin-bottom: 24px;
}

.section-heading p,
.topbar p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.section-heading h2,
.topbar h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

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

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  font-weight: 500;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 6px;
  font-weight: 800;
}

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

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

.secondary-button {
  border: 1px solid var(--line);
  padding: 0 14px;
  background: #ffffff;
  color: var(--text);
}

.ghost-light-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
}

.dashboard {
  display: grid;
  gap: 18px;
}

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

.message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

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

.request-debug {
  min-height: 18px;
  margin: -10px 0 0;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

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

.compact-metrics-grid .metric strong {
  font-size: 24px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  font-size: 30px;
  line-height: 1;
}

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

.panel {
  overflow: hidden;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: end;
  gap: 12px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filters label {
  min-width: 0;
}

.secret-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  background: #ecfdf3;
  border: 1px solid #abefc6;
  border-radius: 8px;
}

.secret-box div {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.secret-box span {
  color: #166534;
  font-size: 12px;
  font-weight: 800;
}

.secret-box code {
  max-width: none;
  white-space: normal;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--soft-line);
}

.panel-heading h3 {
  margin: 0;
  font-size: 16px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pagination-bar span {
  white-space: nowrap;
}

.inline-password-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  gap: 8px;
  min-width: 270px;
}

.inline-password-form input {
  height: 34px;
}

.compact-number-input,
.compact-select {
  max-width: 130px;
  height: 34px;
  padding: 0 10px;
}

.list {
  display: grid;
}

.list-row,
.empty {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid var(--soft-line);
}

.list-row:last-child,
.empty:last-child {
  border-bottom: 0;
}

.list-row span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #344054;
}

.stacked-row {
  min-height: 58px;
  align-items: flex-start;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.doc-block {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
}

.doc-block p {
  margin: 0;
  color: #344054;
  font-size: 13px;
  line-height: 1.5;
}

.doc-block pre {
  max-width: 100%;
  margin: 0;
  overflow: auto;
  padding: 14px;
  border-radius: 8px;
  background: #0f172a;
  color: #e5e7eb;
  font-size: 12px;
  line-height: 1.55;
}

.empty,
.empty-cell {
  color: var(--muted);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td {
  color: #344054;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: #f8fafc;
}

code {
  max-width: 220px;
  display: inline-block;
  overflow: hidden;
  color: #344054;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: #eef4ff;
  color: #3538cd;
  font-size: 12px;
  font-weight: 800;
}

.pill.attribution.click_id {
  background: #dcfce7;
  color: #166534;
}

.pill.attribution.user_identifier {
  background: #fef3c7;
  color: #92400e;
}

.pill.attribution.missing {
  background: #fee2e2;
  color: #991b1b;
}

.status-pill.sent {
  background: #dcfce7;
  color: #166534;
}

.status-pill.failed {
  background: #fee2e2;
  color: #991b1b;
}

.status-pill.warning {
  background: #fef3c7;
  color: #92400e;
}

.status-pill.skipped {
  background: #fef3c7;
  color: #92400e;
}

.status-pill.pending {
  background: #eef4ff;
  color: #3538cd;
}

.status-pill.duplicate {
  background: #e5e7eb;
  color: #374151;
}

.enriched-pill {
  margin-left: 4px;
  background: #ecfdf3;
  color: #067647;
}

.status {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--muted);
}

.status.sent {
  background: var(--success);
}

.status.failed {
  background: var(--danger);
}

.status.skipped {
  background: var(--warning);
}

.drawer[hidden] {
  display: none;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(680px, 92vw);
}

.drawer-backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.drawer-panel {
  min-width: 0;
  height: 100vh;
  overflow: auto;
  background: #ffffff;
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 50px rgba(15, 23, 42, 0.18);
}

.drawer-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.drawer-header p,
.drawer-header h2 {
  margin: 0;
}

.drawer-header p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.drawer-header h2 {
  font-size: 22px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.drawer-content {
  display: grid;
  gap: 16px;
  padding: 20px;
}

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

.detail-grid div,
.detail-block {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.detail-grid div {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.detail-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-grid strong,
.detail-block p {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.detail-block h3 {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--soft-line);
  font-size: 14px;
}

.detail-block p {
  padding: 14px;
}

.url-base {
  overflow-x: auto;
  padding: 14px;
  border-bottom: 1px solid var(--soft-line);
}

.url-base code {
  max-width: 100%;
  white-space: nowrap;
}

.url-params {
  display: grid;
  margin: 0;
}

.url-params div {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 1fr);
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--soft-line);
}

.url-params div:last-child {
  border-bottom: 0;
}

.url-params dt,
.url-params dd {
  min-width: 0;
  margin: 0;
  font-size: 13px;
}

.url-params dd {
  overflow-x: auto;
  white-space: nowrap;
}

.url-params dt {
  color: var(--muted);
  font-weight: 800;
}

.detail-block pre {
  max-height: 360px;
  margin: 0;
  overflow: auto;
  padding: 14px;
  background: #0f172a;
  color: #e5e7eb;
  font-size: 12px;
  line-height: 1.55;
}

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

  .sidebar {
    position: static;
  }

  .metrics-grid,
  .content-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

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

  .secret-box,
  .panel-heading,
  .pagination-bar,
  .inline-password-form {
    align-items: flex-start;
    flex-direction: column;
  }

  .inline-password-form {
    display: flex;
    min-width: 0;
  }

  .main {
    padding: 18px;
  }

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

  .drawer-backdrop {
    display: none;
  }
}

.content-grid .pageviews-panel {
  grid-column: 1 / -1;
}

.pageview-summary {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.pageview-site {
  display: grid;
  gap: 10px;
}

.pageview-site h4 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
}

.pageview-list {
  display: grid;
  border-top: 1px solid var(--soft-line);
}

.pageview-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 36px;
  border-bottom: 1px solid var(--soft-line);
  font-size: 13px;
}

.pageview-row span {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pageview-row strong {
  font-variant-numeric: tabular-nums;
}

.compact-filters {
  max-width: 420px;
}

.changelog-list {
  display: grid;
  gap: 0;
}

.changelog-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  border-bottom: 1px solid var(--soft-line);
}

.changelog-card:last-child {
  border-bottom: 0;
}

.changelog-meta {
  display: grid;
  align-content: start;
  gap: 10px;
}

.changelog-meta time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.type-pill {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.type-api {
  background: #ecfdf3;
  color: #047857;
}

.type-painel {
  background: #eff6ff;
  color: #1d4ed8;
}

.type-plugin {
  background: #fff7ed;
  color: #c2410c;
}

.changelog-body {
  min-width: 0;
}

.changelog-body h3,
.changelog-body p {
  margin: 0;
}

.changelog-body h3 {
  font-size: 16px;
}

.changelog-body p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.changelog-body ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.6;
}

@media (max-width: 900px) {
  .changelog-card {
    grid-template-columns: 1fr;
  }
}

.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.inline-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
}
