:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --text: #1b2430;
  --muted: #647184;
  --line: #d7dee8;
  --accent: #176b87;
  --accent-dark: #0f4c61;
  --ok: #1f7a45;
  --warn: #9a5a00;
  --bad: #a43434;
}

* {
  box-sizing: border-box;
}

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

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

.shell {
  display: grid;
  gap: 1rem;
  margin: 0 auto;
  max-width: 1480px;
  padding: 1.25rem;
}

.topbar {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 1rem;
}

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

.topbar h1,
.panel h2,
.auth-card h2 {
  margin-bottom: .25rem;
}

.topbar p,
.muted,
.status {
  color: var(--muted);
}

.auth-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(20, 35, 50, .06);
  padding: 1rem;
}

.auth-card {
  margin: 8vh auto 0;
  max-width: 28rem;
  width: 100%;
}

.dashboard {
  align-items: start;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.4fr) minmax(20rem, .8fr);
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-heading,
.actions {
  align-items: center;
  display: flex;
  gap: .75rem;
  justify-content: space-between;
}

form,
.connect-form,
.target-grid {
  display: grid;
  gap: .75rem;
}

label {
  display: grid;
  gap: .3rem;
}

label span {
  color: #314258;
  font-size: .9rem;
  font-weight: 650;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-width: 0;
  padding: .58rem .68rem;
  width: 100%;
}

textarea {
  min-height: 12rem;
  resize: vertical;
}

.button {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 2.35rem;
  padding: .58rem .9rem;
  text-decoration: none;
}

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

.button-secondary {
  background: #fff;
  color: var(--accent);
}

.button-secondary:hover {
  background: #edf7fa;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin: .25rem 0 .75rem;
}

.main-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: .8rem 0;
}

.tab {
  background: #f4f7fa;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #314258;
  cursor: pointer;
  padding: .38rem .65rem;
}

.tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.main-tab {
  align-items: center;
  background: #f4f7fa;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #314258;
  cursor: pointer;
  display: inline-flex;
  gap: .55rem;
  min-height: 2.45rem;
  padding: .5rem .75rem;
}

.main-tab.is-active {
  background: #e6f3f7;
  border-color: var(--accent);
  color: var(--accent-dark);
}

.main-tab span {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  min-width: 1.55rem;
  padding: .08rem .42rem;
  text-align: center;
}

.group-form {
  align-items: end;
  display: grid;
  gap: .5rem;
  grid-template-columns: minmax(10rem, 18rem) auto;
}

.group-edit {
  align-items: end;
  display: grid;
  gap: .5rem;
  grid-template-columns: minmax(12rem, 22rem) auto auto minmax(8rem, 1fr);
}

.button-danger {
  background: #fff;
  border-color: rgba(164, 52, 52, .35);
  color: var(--bad);
}

.button-danger:hover {
  background: #faeaea;
}

.button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.connect-form {
  display: none;
}

.connect-form.is-active {
  display: grid;
}

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

.account-option,
.account-row,
.provider-card,
.activity-row,
.result-row,
.publish-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: .25rem;
  padding: .75rem;
}

.account-option {
  align-items: center;
  cursor: pointer;
  grid-template-columns: auto minmax(0, 1fr);
}

.inline-select {
  align-items: center;
  display: grid;
  gap: .45rem;
  grid-template-columns: auto minmax(8rem, 1fr);
  margin-top: .35rem;
}

.account-option strong,
.account-row strong,
.provider-card strong,
.result-row strong {
  overflow-wrap: anywhere;
}

.target-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: .7rem;
}

.search-form {
  align-items: end;
  grid-template-columns: minmax(12rem, 20rem) minmax(0, 1fr) auto;
}

.provider-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.provider-card small,
.activity-row small,
.account-row small,
.result-row small,
.publish-row small {
  color: var(--muted);
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: .78rem;
  font-weight: 800;
  justify-self: start;
  padding: .18rem .45rem;
}

.badge.available,
.badge.available_limited {
  background: #e8f6ed;
  color: var(--ok);
}

.badge.needs_app_keys,
.badge.limited_app_review,
.badge.app_review_required,
.badge.business_app_review,
.badge.page_app_review,
.badge.unofficial_cookie,
.badge.unofficial_login {
  background: #fff4df;
  color: var(--warn);
}

.badge.paid_api {
  background: #faeaea;
  color: var(--bad);
}

.status {
  min-height: 1.4rem;
}

.publish-results,
.result-list,
.activity-list,
.account-list {
  display: grid;
  gap: .6rem;
  margin-top: .75rem;
}

.publish-row.ok {
  border-color: rgba(31, 122, 69, .35);
}

.publish-row.error {
  border-color: rgba(164, 52, 52, .35);
}

code {
  background: #f4f7fa;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .1rem .25rem;
}

@media (max-width: 1023px) {
  .dashboard,
  .group-edit,
  .search-form,
  .provider-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 767px) {
  .shell {
    padding: .75rem;
  }

  .topbar,
  .panel-heading,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .account-grid,
  .group-form,
  .target-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
