:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-strong: #eef3f1;
  --text: #17201c;
  --muted: #65726c;
  --line: #dce4e0;
  --accent: #16745f;
  --accent-dark: #0f5446;
  --warn: #a06000;
  --good: #12714e;
  --bad: #b44343;
  --shadow: 0 12px 30px rgba(25, 39, 33, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 14px;
  padding: 20px;
  background: var(--bg);
  overflow-y: auto;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.login-card p,
.login-error {
  color: var(--muted);
}

.login-card input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.login-error {
  min-height: 18px;
  font-size: 13px;
}

.token-output {
  min-height: 42px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17201c;
  color: #edf6f2;
}

button,
input,
select {
  font: inherit;
}

button,
.file-button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

.button-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  font-weight: 700;
  text-decoration: none;
}

.ghost-link {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.privacy-toggle {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 12px;
  font-weight: 800;
  cursor: pointer;
}

button.ghost {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.file-button {
  display: inline-flex;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  background: #17201c;
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #d8f05f;
  color: #17201c;
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.sidebar-footer span {
  color: #aab7b1;
  font-size: 13px;
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  color: #dce4e0;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
}

nav a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.sidebar-footer strong {
  display: block;
  margin-top: 4px;
}

main {
  margin-left: 250px;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.topbar h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
}

.actions,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

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

.kpi,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi {
  padding: 18px;
}

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

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.kpi small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.8fr);
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  padding: 18px;
  margin-bottom: 14px;
}

.panel.wide {
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel h2,
.panel h3 {
  margin: 0;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.positive {
  border-color: #b8dfce;
  background: #ddf3e8;
  color: var(--good);
}

.traffic-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.7fr);
  gap: 18px;
}

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

.mini-metric,
.utm-row,
.task,
.conversation,
.post,
.activity {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.mini-metric {
  padding: 14px;
}

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

.mini-metric strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.utm-box {
  background: var(--surface-strong);
  border-radius: 8px;
  padding: 14px;
}

.utm-box h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.utm-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px;
  margin-bottom: 8px;
  background: #fff;
}

.utm-row code {
  overflow-wrap: anywhere;
}

.compact-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.compact-form input,
.compact-form select,
.filters select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  color: var(--text);
}

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

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td a {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.status.positive {
  background: #ddf3e8;
  color: var(--good);
}

.status.warning {
  background: #fff1d6;
  color: var(--warn);
}

.status.negative {
  background: #fbe4e4;
  color: var(--bad);
}

.task-list,
.conversation-list,
.post-grid,
.activity-feed {
  display: grid;
  gap: 10px;
}

.skills-page .panel {
  max-width: 1040px;
}

.skill-copy {
  color: var(--text);
}

.skill-copy p {
  max-width: 780px;
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.6;
}

.skill-copy ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.7;
}

.skill-copy pre {
  overflow-x: auto;
  margin: 10px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17201c;
  color: #edf6f2;
}

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

.endpoint {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.endpoint strong,
.endpoint span {
  display: block;
}

.endpoint span {
  margin-top: 5px;
  color: var(--muted);
}

.task,
.conversation,
.post,
.activity {
  padding: 12px;
}

.task strong,
.conversation strong,
.post strong,
.activity strong {
  display: block;
  margin-bottom: 4px;
}

.task span,
.conversation span,
.post span,
.activity span {
  color: var(--muted);
  font-size: 13px;
}

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

.integration-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 12px;
}

.integration-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.integration-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.integration-title h3 {
  font-size: 16px;
}

.integration-card input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.instruction-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 140px auto;
  gap: 10px;
  margin-bottom: 14px;
}

.instruction-form input,
.instruction-form select,
.instruction-form textarea {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}

.instruction-form textarea {
  grid-column: 1 / -1;
  min-height: 70px;
  resize: vertical;
}

.instruction-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.instruction-column {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px;
}

.instruction-column h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.instruction-card {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.instruction-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.instruction-card select {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
}

.post p {
  margin: 8px 0;
  color: var(--muted);
}

@media (max-width: 1050px) {
  .kpi-grid,
  .panel-grid,
  .traffic-layout,
  .post-grid,
  .integration-grid {
    grid-template-columns: 1fr 1fr;
  }

  .compact-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
  }

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

  main {
    margin-left: 0;
    padding: 18px;
  }

  .topbar,
  .panel-header {
    display: grid;
  }

  .actions,
  .filters {
    justify-content: start;
  }

  .kpi-grid,
  .panel-grid,
  .traffic-layout,
  .metric-stack,
  .post-grid,
  .integration-grid,
  .endpoint-grid,
  .instruction-board,
  .compact-form {
    grid-template-columns: 1fr;
  }

  .instruction-form {
    grid-template-columns: 1fr;
  }
}
