:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-2: #eef3f5;
  --ink: #172026;
  --muted: #61717b;
  --line: #d9e1e5;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #15803d;
  --shadow: 0 14px 34px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px;
  background: #152126;
  color: #f8fbfc;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #37b4a3;
  color: #08211f;
  font-weight: 800;
}

.brand-title {
  font-size: 17px;
  font-weight: 750;
}

.brand-subtitle,
.muted-line,
.panel p,
.kpi-card small {
  color: var(--muted);
}

.sidebar .brand-subtitle {
  color: #a7b7bd;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-list a {
  color: #dce7eb;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 7px;
}

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

.tenant-box {
  margin-top: auto;
  display: grid;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.tenant-box label {
  font-size: 12px;
  color: #b5c5ca;
}

.tenant-box input {
  border-color: rgba(255, 255, 255, 0.16);
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sidebar-note {
  min-width: 0;
  color: #b5c5ca;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.inline-control {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 8px;
}

input,
select {
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
}

.workspace {
  min-width: 0;
  padding: 24px;
  overflow-x: hidden;
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.15;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 13px;
  margin-bottom: 10px;
  color: var(--muted);
}

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

.primary-button,
.secondary-button,
.icon-button,
.action-button {
  min-height: 36px;
  border-radius: 7px;
  padding: 0 12px;
  font-weight: 650;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.icon-button {
  background: #26363c;
  color: #f8fbfc;
}

.action-button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
}

.action-button.danger {
  color: var(--danger);
}

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

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

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

.kpi-card {
  display: grid;
  gap: 6px;
  padding: 15px;
}

.kpi-card span {
  font-size: 12px;
  color: var(--muted);
}

.kpi-card strong {
  font-size: 24px;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.wide-panel {
  grid-column: span 2;
}

.tall-panel {
  grid-row: span 2;
}

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

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.panel p {
  margin-top: 3px;
  font-size: 12px;
}

.provider-list,
.compact-list,
.recommendation-list {
  display: grid;
  gap: 8px;
}

.provider-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 12px;
}

.provider-pill,
.list-item,
.recommendation-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.provider-pill {
  padding: 10px;
}

.provider-pill strong,
.list-item strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.provider-pill span,
.list-item span {
  font-size: 12px;
  color: var(--muted);
}

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

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

th,
td {
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

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

.creative-thumb {
  display: block;
  width: 72px;
  height: 60px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  object-fit: cover;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
}

.status.open,
.status.approved,
.status.pending,
.status.paused,
.status.no_funds_paused {
  color: var(--warn);
  background: #fff7ed;
}

.status.applied,
.status.connected,
.status.succeeded {
  color: var(--ok);
  background: #ecfdf3;
}

.status.failed,
.status.rejected {
  color: var(--danger);
  background: #fef3f2;
}

.recommendation-item {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.recommendation-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.recommendation-item p {
  line-height: 1.4;
}

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

.list-item {
  padding: 10px;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #152126;
  color: #f8fbfc;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tall-panel,
  .wide-panel {
    grid-column: span 2;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    width: 100%;
    min-width: 0;
    max-width: 100vw;
    padding: 20px 16px;
  }

  .tenant-box {
    width: 100%;
    max-width: 100%;
    align-self: stretch;
  }

  .tenant-box > *,
  .inline-control,
  .inline-control input {
    min-width: 0;
  }

  .topbar,
  .panel-header {
    flex-direction: column;
  }

  .workspace {
    width: 100%;
    max-width: 100vw;
    padding: 24px 16px;
  }

  .topbar {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .kpi-grid,
  .content-grid,
  .activity-grid {
    grid-template-columns: 1fr;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .kpi-card,
  .panel {
    min-width: 0;
    max-width: 100%;
  }

  .tall-panel,
  .wide-panel {
    grid-column: span 1;
  }

  .provider-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .tenant-box,
  .topbar,
  .kpi-grid,
  .content-grid,
  .activity-grid {
    width: min(100%, 358px);
    max-width: 358px;
  }
}
