/* Payslice Partner Portal — design tokens and components, translated from
   the accepted dashboard blueprint (codex/partner-dashboard-prototype). */

:root {
  --surface-0: #fafafa;
  --surface-1: #f5f5f5;
  --surface-2: #ededed;
  --ink-0: #171717;
  --ink-1: #262626;
  --ink-2: #525252;
  --ink-3: #737373;
  --line-soft: rgba(23, 23, 23, 0.1);
  --line-strong: rgba(23, 23, 23, 0.18);
  --brand: #0c4a6e;
  --brand-deep: #0a3d5c;
  --brand-light: #dbeafe;
  --success: #065f46;
  --danger: #b91c1c;
  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--surface-0);
  color: var(--ink-0);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Shell ---- */

.shell {
  min-height: 100vh;
}

.sidebar {
  display: none;
}

.content {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

@media (min-width: 1024px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    width: 240px;
    flex-direction: column;
    border-right: 1px solid var(--line-soft);
    background: #fff;
  }

  .content {
    margin-left: 240px;
  }

  .topbar-brand {
    display: none;
  }

  .nav-horizontal {
    display: none;
  }
}

.sidebar-section {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line-soft);
}

.sidebar-brand {
  padding: 1.25rem 1.5rem;
}

.brand-name {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--brand);
}

.brand-tag {
  margin-top: 0.125rem;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}

.eyebrow {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
}

.sidebar-org {
  margin-top: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-1);
}

.nav-vertical {
  flex: 1;
  padding: 1rem 0.75rem;
  border-bottom: none;
}

.nav-vertical ul {
  list-style: none;
  display: grid;
  gap: 2px;
}

.nav-vertical a {
  display: block;
  border-left: 2px solid transparent;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--ink-2);
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.nav-vertical a:hover {
  background: var(--surface-1);
  color: var(--ink-0);
}

.nav-vertical a.active {
  border-left-color: var(--brand);
  background: var(--surface-1);
  font-weight: 500;
  color: var(--brand);
}

.sidebar-foot {
  border-top: 1px solid var(--line-soft);
  border-bottom: none;
  font-size: 0.75rem;
  color: var(--ink-3);
}

/* ---- Top bar and horizontal nav (narrow screens) ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line-soft);
  background: #fff;
  padding: 0.75rem 1rem;
}

@media (min-width: 1024px) {
  .topbar {
    justify-content: flex-end;
    padding: 0.75rem 2rem;
  }
}

.topbar-brand {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--brand);
}

.topbar-sub {
  margin-left: 0.5rem;
  vertical-align: middle;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}

.nav-horizontal {
  border-bottom: 1px solid var(--line-soft);
  background: #fff;
}

.nav-horizontal ul {
  list-style: none;
  display: flex;
  overflow-x: auto;
  padding: 0 1rem;
}

.nav-horizontal a {
  display: block;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  color: var(--ink-2);
  text-decoration: none;
}

.nav-horizontal a:hover {
  color: var(--ink-0);
}

.nav-horizontal a.active {
  border-bottom-color: var(--brand);
  font-weight: 500;
  color: var(--brand);
}

/* ---- Demo bar (guarded preview controls) ---- */

.demo-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.demo-eyebrow {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
}

.demo-bar select {
  border: 1px solid var(--line-soft);
  background: #fff;
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 0.75rem;
  color: var(--ink-1);
}

/* ---- Page scaffolding ---- */

main {
  flex: 1;
  padding: 1.5rem 1rem;
}

@media (min-width: 1024px) {
  main {
    padding: 2rem;
  }
}

.page {
  margin: 0 auto;
  width: 100%;
  max-width: 64rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-0);
}

.page-header p {
  margin-top: 0.375rem;
  max-width: 42rem;
  font-size: 0.875rem;
  color: var(--ink-2);
}

.section {
  margin-top: 2.5rem;
}

.section-head {
  margin-bottom: 0.75rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.section-head h2,
.section-title,
.card-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-1);
}

.section-title {
  margin-bottom: 0.75rem;
}

.section-actions {
  margin-top: 1rem;
}

.card {
  border: 1px solid var(--line-soft);
  background: #fff;
  padding: 1.25rem;
}

.card-title {
  margin-bottom: 1rem;
}

.campaign-card {
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
}

.campaign-label {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--brand);
}

.campaign-terms {
  margin-top: 0.25rem;
  max-width: 36rem;
  font-size: 0.875rem;
  color: var(--ink-2);
}

/* ---- Stats ---- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background: #fff;
}

@media (min-width: 640px) {
  .stat-row {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat {
  padding: 1rem 1.25rem;
  border-left: 1px solid var(--line-soft);
}

.stat:first-child {
  border-left: none;
}

.stat dt {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
}

.stat dd {
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-1);
}

.freshness {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--ink-3);
}

/* ---- Tables ---- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

th {
  white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
  padding: 0.625rem 1rem;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
}

td {
  border-bottom: 1px solid var(--line-soft);
  padding: 0.625rem 1rem;
  color: var(--ink-1);
}

tbody tr:last-child td {
  border-bottom: none;
}

.mono {
  font-family: var(--font-mono);
}

.num {
  font-variant-numeric: tabular-nums;
}

.small {
  font-size: 0.75rem;
}

.muted {
  color: var(--ink-2);
}

.nowrap {
  white-space: nowrap;
}

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

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

.badge {
  display: inline-block;
  border: 1px solid var(--line-strong);
  padding: 0.125rem 0.375rem;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
}

.badge-reported {
  border-color: rgba(6, 95, 70, 0.3);
  color: var(--success);
}

.badge-failed {
  border-color: rgba(185, 28, 28, 0.3);
  color: var(--danger);
}

.tag {
  display: inline-block;
  margin-left: 0.375rem;
  border: 1px solid var(--line-strong);
  padding: 0.125rem 0.375rem;
  font-size: 11px;
  color: var(--ink-3);
}

.footnote {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--ink-3);
}

.text-link {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--brand);
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.button {
  display: inline-block;
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-1);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.button:hover {
  border-color: var(--brand);
  color: var(--brand);
}

/* ---- Chart ---- */

.chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-legend {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--ink-3);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.swatch {
  display: inline-block;
  width: 0.625rem;
  height: 0.625rem;
}

.swatch-light {
  background: var(--brand-light);
}

.swatch-brand {
  background: var(--brand);
}

/* ---- Empty / unavailable / loading states ---- */

.empty-state {
  border: 1px dashed var(--line-strong);
  background: #fff;
  padding: 3rem 2rem;
  text-align: center;
}

.empty-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-1);
}

.empty-body,
.unavailable-body {
  margin: 0.5rem auto 0;
  max-width: 28rem;
  font-size: 0.875rem;
  color: var(--ink-3);
}

.unavailable {
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 3rem 2rem;
  text-align: center;
}

.unavailable-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--danger);
}

.skeleton {
  display: grid;
  gap: 1rem;
}

.skeleton-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  border: 1px solid var(--line-soft);
  background: var(--line-soft);
}

@media (min-width: 640px) {
  .skeleton-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.skeleton-stat {
  background: #fff;
  padding: 1rem 1.25rem;
}

.shimmer {
  height: 1rem;
  background: var(--surface-2);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.shimmer-label {
  height: 0.75rem;
  width: 6rem;
}

.shimmer-value {
  margin-top: 0.75rem;
  height: 1.75rem;
  width: 4rem;
}

.skeleton-lines {
  display: grid;
  gap: 0.75rem;
}

@keyframes pulse {
  50% {
    opacity: 0.5;
  }
}

/* ---- Error page ---- */

.error-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.5rem;
}

.error-card {
  width: 100%;
  max-width: 28rem;
  border: 1px solid var(--line-soft);
  background: #fff;
  padding: 3rem 2rem;
  text-align: center;
}

.error-title {
  margin-top: 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-1);
}

.error-body {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--ink-3);
}

/* ---- Entrance animation ---- */

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.rise > * {
  animation: rise-in 0.35s ease-out both;
}

.rise > *:nth-child(2) {
  animation-delay: 60ms;
}

.rise > *:nth-child(3) {
  animation-delay: 120ms;
}

.rise > *:nth-child(4) {
  animation-delay: 180ms;
}

@media (prefers-reduced-motion: reduce) {
  .rise > *,
  .shimmer {
    animation: none;
  }
}

/* ---- Sign-in ---- */

.login-form {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.75rem;
}

.login-form input[type="email"] {
  border: 1px solid var(--line-strong);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--ink-1);
}

.login-form input[type="email"]:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.login-error {
  color: #b91c1c;
}

.signout-form {
  margin-top: 0.75rem;
}

/* ---- Skip link ---- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  background: var(--brand);
  color: #fff;
  padding: 0.5rem 0.875rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* ---- Keyboard focus ---- */

a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

/* ---- Co-branding monogram ---- */

.monogram {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-right: 0.375rem;
  background: var(--brand);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: -0.35rem;
}

/* ---- Range controls ---- */

.range-bar {
  border: 1px solid var(--line-soft);
  background: #fff;
  padding: 0.75rem 1rem;
}

.range-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.chip {
  display: inline-block;
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.chip:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.chip-active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.chip-active:hover {
  color: #fff;
}

.range-custom {
  margin-top: 0.625rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.5rem;
}

.range-custom.custom-active {
  border-left: 2px solid var(--brand);
  padding-left: 0.625rem;
}

.range-label {
  font-size: 0.75rem;
  color: var(--ink-2);
}

.range-custom input[type="date"] {
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--ink-1);
}

.range-error {
  margin-top: 0.625rem;
  font-size: 0.75rem;
  color: var(--danger);
}

.scope-line {
  margin-top: 0.625rem;
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  color: var(--ink-3);
}

/* ---- Stat annotations ---- */

.stat-note {
  margin-top: 0.25rem;
  font-size: 0.6875rem;
  color: var(--ink-3);
}

/* ---- Pagination ---- */

.pager {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.pager-summary {
  font-size: 0.75rem;
  color: var(--ink-3);
}

.pager-links {
  display: flex;
  gap: 0.5rem;
}
