:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f6f9fe;
  --ink: #111827;
  --text: #1f2937;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #d8dee8;
  --line-soft: #e8edf5;
  --blue: #0b57d0;
  --blue-2: #4285f4;
  --blue-soft: #eaf2ff;
  --green: #188038;
  --amber: #f29900;
  --red: #c5221f;
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(244, 248, 255, 0.8), transparent 380px),
    var(--bg);
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

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

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 5px;
  background: linear-gradient(180deg, #3b82f6, #0b57d0);
  color: #fff;
  font-size: 18px;
  font-weight: 820;
  box-shadow: 0 8px 18px rgba(11, 87, 208, 0.22);
}

.brand strong {
  display: block;
  color: #0f172a;
  font-size: 21px;
  font-weight: 820;
  line-height: 1;
}

.appbar-actions,
.toolbar,
.modal-actions,
.table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.review-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #27364a;
  font-size: 13px;
  font-weight: 520;
}

.review-status b {
  color: #e8710a;
  font-weight: 760;
}

.review-status i,
.state-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
}

.review-status i {
  background: #f29900;
}

.top-icon,
.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  color: #334155;
}

.top-icon {
  border: 1px solid transparent;
  font-size: 20px;
  font-weight: 760;
}

.top-icon:hover {
  border-color: var(--line);
  background: var(--surface-soft);
}

.avatar {
  background: #e8edf5;
  font-size: 13px;
  font-weight: 760;
}

.chevron {
  color: #475569;
  font-size: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: 102px 280px minmax(0, 1fr);
  min-height: calc(100vh - 66px);
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 24px 0 16px;
  border-right: 1px solid var(--line);
  background: #fbfdff;
}

.rail-spacer {
  flex: 1;
}

.rail-item {
  position: relative;
  display: grid;
  min-height: 70px;
  place-items: center;
  gap: 6px;
  padding: 9px 8px;
  border: 0;
  background: transparent;
  color: #46566c;
  font-size: 20px;
  font-weight: 760;
}

.rail-item span {
  line-height: 1;
}

.rail-item em {
  color: #334155;
  font-size: 12px;
  font-style: normal;
  font-weight: 560;
}

.rail-item.selected {
  color: var(--blue);
  background: #eaf2ff;
}

.rail-item.selected::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  content: "";
  background: var(--blue);
}

.account-sidebar {
  min-width: 0;
  padding: 32px 16px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
}

.sidebar-header,
.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.sidebar-header {
  margin-bottom: 14px;
}

.sidebar-header p,
.panel-title h2,
.page-heading h1,
.scope-card h2,
.metrics-title h2 {
  margin: 0;
}

.sidebar-header p {
  color: #334155;
  font-size: 12px;
  font-weight: 820;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-header span,
.panel-title p,
.metrics-title p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.account-search {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
}

.account-search span,
.account-search button {
  color: #526174;
  font-size: 18px;
}

.account-search button {
  display: grid;
  width: 34px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

input,
select {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 520;
  text-transform: none;
}

input:focus,
select:focus {
  border-color: var(--blue-2);
  outline: 2px solid rgba(66, 133, 244, 0.16);
}

.account-list {
  display: grid;
  gap: 7px;
}

.account-button {
  position: relative;
  display: grid;
  width: 100%;
  grid-template-columns: 34px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 10px;
  padding: 12px 9px 12px 11px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.account-button.selected,
.account-button:hover {
  border-color: #c8ddff;
  background: #eaf2ff;
}

.account-button.selected::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  content: "";
  border-radius: 5px 0 0 5px;
  background: var(--blue);
}

.account-button strong,
.account-button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-button strong {
  margin-bottom: 4px;
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
}

.account-button small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 520;
}

.ads-glyph {
  position: relative;
  display: block;
  width: 28px;
  height: 28px;
}

.ads-glyph i,
.ads-glyph b,
.ads-glyph em {
  position: absolute;
  display: block;
  width: 8px;
  height: 26px;
  border-radius: 999px;
  content: "";
}

.ads-glyph i {
  left: 5px;
  top: 1px;
  background: #34a853;
  transform: rotate(28deg);
}

.ads-glyph b {
  left: 13px;
  top: 1px;
  background: #4285f4;
  transform: rotate(-28deg);
}

.ads-glyph em {
  left: 3px;
  bottom: 0;
  width: 9px;
  height: 9px;
  background: #fbbc04;
}

.state-dot.pending {
  background: var(--amber);
}

.state-dot.sync_failed,
.state-dot.revoked {
  background: #8b929c;
}

.authorize-button {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 22px 0 12px;
  border: 1px solid #7da7f7;
  border-radius: 5px;
  background: #fff;
  color: var(--blue);
  font-size: 13px;
  font-weight: 760;
}

.authorize-button span {
  font-size: 20px;
  line-height: 1;
}

.status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-tabs button,
.period-row button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 680;
}

.status-tabs button.selected,
.period-row button.selected {
  border-color: rgba(11, 87, 208, 0.28);
  color: var(--blue);
  background: var(--blue-soft);
}

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

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 272px;
  gap: 30px;
  max-width: 1180px;
}

.review-main {
  min-width: 0;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 30px;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  color: #475569;
  font-size: 13px;
}

.crumbs a {
  color: var(--blue);
  font-weight: 650;
}

.crumbs b {
  font-weight: 520;
}

.page-heading h1 {
  margin-bottom: 9px;
  color: #0f172a;
  font-size: 29px;
  font-weight: 560;
  line-height: 1.12;
}

.page-heading p {
  margin: 0;
  color: #607089;
  font-size: 14px;
  line-height: 1.5;
}

.toolbar {
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
  padding-top: 28px;
}

.date-button,
.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: #1f2937;
  font-size: 13px;
  font-weight: 620;
}

.button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.button.secondary:hover,
.date-button:hover,
.authorize-button:hover {
  border-color: #a9c5f8;
  background: #f8fbff;
}

.compare-note {
  color: #8090a5;
  font-size: 12px;
}

.primary-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 28px;
}

.primary-kpis article,
.table-panel,
.scope-card,
.filter-panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.primary-kpis article {
  min-height: 170px;
  padding: 22px 20px;
}

.primary-kpis small {
  display: block;
  margin-bottom: 18px;
  color: #0f172a;
  font-size: 13px;
  font-weight: 750;
}

.primary-kpis small span {
  color: #9aa7b8;
  font-weight: 500;
}

.primary-kpis strong {
  display: block;
  margin-bottom: 12px;
  color: #0f172a;
  font-size: 21px;
  font-weight: 620;
  line-height: 1.15;
}

.primary-kpis b {
  display: block;
  margin-bottom: 11px;
  color: var(--green);
  font-size: 14px;
  font-weight: 650;
}

.primary-kpis b.up {
  color: var(--green);
}

.primary-kpis em {
  color: #526174;
  font-size: 12px;
  font-style: normal;
}

.filter-panel {
  margin-bottom: 18px;
  padding: 14px;
  box-shadow: none;
}

.period-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.filter-grid label,
.search-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 820;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.table-panel {
  overflow: hidden;
  margin-bottom: 18px;
}

.panel-title {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-title h2 {
  margin-bottom: 6px;
  color: #0f172a;
  font-size: 18px;
  font-weight: 650;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #334155;
  background: #f8fafc;
  font-size: 11px;
  font-weight: 720;
}

td {
  color: #243247;
}

td:nth-child(3),
td:nth-child(4) {
  color: #1f2d3d;
  font-weight: 650;
}

td:nth-child(n+7) {
  white-space: nowrap;
}

.table-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  color: #526174;
  font-size: 12px;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(112px, 1fr));
  gap: 9px;
  margin-bottom: 18px;
}

.metrics-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-top: 2px;
}

.metrics-title h2 {
  color: #0f172a;
  font-size: 17px;
  font-weight: 650;
}

.metric-card {
  min-height: 88px;
  padding: 13px;
}

.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin: 8px 0 4px;
  color: #0f172a;
  font-size: 18px;
  font-weight: 620;
  line-height: 1.1;
}

.metric-card span {
  color: var(--faint);
  font-size: 12px;
  line-height: 1.35;
}

.review-aside {
  display: grid;
  align-content: start;
  gap: 20px;
}

.scope-card {
  padding: 16px 14px;
}

.scope-card h2 {
  margin-bottom: 16px;
  color: #111827;
  font-size: 16px;
  font-weight: 650;
}

.scope-box {
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: linear-gradient(180deg, #fff, #fbfdff);
}

.scope-box label,
.details-list dt {
  display: block;
  margin-bottom: 6px;
  color: #0f172a;
  font-size: 12px;
  font-weight: 760;
}

.scope-box p {
  margin: 0 0 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
  color: #172033;
  font-size: 14px;
  line-height: 1.45;
}

.scope-box p:last-of-type {
  margin-bottom: 10px;
}

.scope-box a,
.api-details {
  color: var(--blue);
  font-size: 13px;
  font-weight: 650;
}

.api-details {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 12px;
  border: 1px solid #7da7f7;
  border-radius: 5px;
}

.evidence-mini {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  padding: 13px;
  border: 1px solid rgba(24, 128, 56, 0.2);
  border-radius: 5px;
  background: #f0f8f2;
}

.evidence-mini strong {
  color: #155c2f;
  font-size: 13px;
}

.evidence-mini span {
  color: #526174;
  font-size: 12px;
  line-height: 1.4;
}

.button.full {
  width: 100%;
}

.details-list {
  display: grid;
  gap: 7px;
  margin: 0;
}

.details-list dd {
  margin: 0 0 14px;
  color: #172033;
  font-size: 13px;
}

.view-summary,
.account-grid,
.settings-grid,
.help-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

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

.view-summary article,
.account-grid article,
.settings-grid article,
.help-panel article,
.timeline-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.view-summary article {
  padding: 16px;
}

.view-summary small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
  text-transform: uppercase;
}

.view-summary strong {
  display: block;
  margin: 8px 0 4px;
  color: #0f172a;
  font-size: 24px;
  font-weight: 620;
}

.view-summary span,
.settings-grid span {
  color: var(--muted);
  font-size: 12px;
}

.compact-table {
  min-width: 940px;
}

.status-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #475569;
  font-size: 12px;
  font-weight: 650;
}

.status-pill.enabled,
.status-pill.connected {
  background: #e6f4ea;
  color: var(--green);
}

.status-pill.paused,
.status-pill.pending {
  background: #fff4df;
  color: #b06000;
}

.status-pill.sync_failed,
.status-pill.revoked {
  background: #eef2f7;
  color: #64748b;
}

.timeline-panel {
  display: grid;
  overflow: hidden;
}

.timeline-panel article {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 18px;
  padding: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.timeline-panel article:last-child {
  border-bottom: 0;
}

.timeline-panel time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.timeline-panel h2,
.account-grid h2,
.settings-grid h2,
.help-panel h2 {
  margin: 0 0 6px;
  color: #0f172a;
  font-size: 15px;
  font-weight: 700;
}

.timeline-panel p,
.settings-grid p,
.help-panel p {
  margin: 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.5;
}

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

.account-grid article,
.settings-grid article,
.help-panel article {
  padding: 16px;
}

.account-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.account-grid dl {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

.account-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.account-grid dd {
  margin: 0;
  color: #1f2937;
  font-size: 12px;
}

.authorize-button.wide {
  width: min(260px, 100%);
}

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

.settings-grid p {
  margin-bottom: 7px;
  color: #172033;
  font-weight: 650;
}

.help-panel {
  grid-template-columns: 1fr;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.38);
}

.modal {
  width: min(680px, 100%);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(18, 24, 38, 0.22);
}

.icon-close {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-size: 20px;
}

.oauth-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.oauth-steps div {
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: var(--surface-soft);
}

.oauth-steps span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  margin-bottom: 8px;
  border-radius: 5px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 850;
}

.oauth-steps p,
.oauth-link {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

.oauth-link {
  display: grid;
  gap: 7px;
  padding: 0 16px 16px;
  font-weight: 760;
}

.modal-actions {
  justify-content: flex-end;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

.policy-page {
  width: min(860px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.policy-card {
  margin-top: 28px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.policy-card h1 {
  margin-bottom: 8px;
  font-size: 32px;
}

.policy-card h2 {
  margin: 24px 0 8px;
  font-size: 17px;
}

.policy-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: 86px 260px minmax(0, 1fr);
  }

  .review-layout {
    grid-template-columns: minmax(0, 1fr);
  }

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

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .account-sidebar {
    display: none;
  }

  .primary-kpis,
  .review-aside {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 720px) {
  .appbar,
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .appbar-actions,
  .toolbar,
  .table-actions {
    width: 100%;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .workspace {
    display: block;
  }

  .rail {
    display: none;
  }

  .content {
    padding: 18px 14px;
  }

  .primary-kpis,
  .review-aside,
  .filter-grid,
  .metrics-row,
  .view-summary,
  .account-grid,
  .settings-grid,
  .oauth-steps {
    grid-template-columns: 1fr;
  }

  .timeline-panel article {
    grid-template-columns: 1fr;
  }

  .panel-title,
  .table-footer {
    flex-direction: column;
  }
}
