/* Emphatiq Partnership Admin — manager-facing SPA, light theme.
   Mirrors services/perf_dashboard/spa/styles.css aesthetic for consistency. */

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

:root {
  --bg-page:    #fafafa;
  --bg-card:    #ffffff;
  --border:     #e5e7eb;
  --border-light: #f0f1f3;
  --text-primary:   #0a0a0a;
  --text-secondary: #525252;
  --text-muted:     #a3a3a3;
  --green:      #15803d;
  --green-bg:   #f0fdf4;
  --red:        #b91c1c;
  --red-bg:     #fef2f2;
  --blue:       #1d4ed8;
  --blue-light: #eff6ff;
  --amber:      #b45309;
  --amber-bg:   #fefce8;
  --radius:     10px;
  --radius-sm:  6px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 4px 12px rgba(0,0,0,0.08);
  --font-sans: -apple-system, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Consolas", monospace;
}

html, body { min-height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: calc(56px + env(safe-area-inset-top, 0px));
}

/* ── Top bar ────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 max(32px, env(safe-area-inset-right)) 0 max(32px, env(safe-area-inset-left));
  height: 56px;
  gap: 16px;
}

.topbar-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}
.topbar-logo {
  width: 28px; height: 28px;
  background: var(--text-primary);
  color: white;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.topbar-logo svg { width: 16px; height: 16px; fill: currentColor; }
.topbar-name {
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
}
.topbar-spacer { flex: 1; }

.mock-badge {
  background: #fefce8;
  color: #b45309;
  border: 1px solid #fde68a;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ns-switcher {
  display: flex;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.ns-pill {
  border: none;
  background: transparent;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
}
.ns-pill:hover { color: var(--text-primary); }
.ns-pill.active {
  background: white;
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.auth-controls {
  display: flex; align-items: center; gap: 12px;
}
.auth-user {
  font-size: 13px; color: var(--text-secondary);
  max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.auth-signout, .auth-signin {
  border: 1px solid var(--border);
  background: white;
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.auth-signout:hover { background: var(--bg-page); }
.auth-signin {
  background: var(--text-primary);
  color: white;
  border-color: var(--text-primary);
  padding: 10px 22px;
  font-size: 14px;
}
.auth-signin:hover { background: #1f1f1f; }

/* ── Auth gate ───────────────────────────────────────────────── */
.auth-gate {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #fafafa 0%, #f0f1f3 100%);
}
.auth-gate-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 44px 40px;
  max-width: 440px;
  width: 100%;
  text-align: center;
}
.auth-gate-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}
.auth-gate-sub {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 14px;
}
.auth-forbidden-body {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: left;
  margin: 16px 0 24px 0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Page layout ─────────────────────────────────────────────── */
.page-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px max(24px, env(safe-area-inset-right)) 64px max(24px, env(safe-area-inset-left));
}
.dashboard-header { margin-bottom: 24px; }
.dashboard-header-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.dashboard-title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.dashboard-asof {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.back-btn, .action-btn {
  border: 1px solid var(--border);
  background: white;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
}
.back-btn:hover, .action-btn:hover { color: var(--text-primary); background: var(--bg-page); }
.action-btn {
  margin-left: auto;
  font-weight: 500;
  border-color: var(--text-primary);
  color: var(--text-primary);
}
.action-btn:hover { background: var(--text-primary); color: white; }
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Recompute modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10,10,10,0.4);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 28px 32px;
  max-width: 480px;
  width: 100%;
}
.modal h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}
.modal label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 12px 0 4px 0;
}
.modal input, .modal select {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 20px;
}
.modal-output {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 300px;
  overflow: auto;
  margin-top: 16px;
}

/* ── Partners list table ─────────────────────────────────────── */
.dashboard-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.dashboard-table thead th {
  text-align: left;
  padding: 12px 18px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.dashboard-table tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}
.dashboard-table tbody tr:last-child td { border-bottom: none; }
.dashboard-table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}
.dashboard-table tbody tr:hover { background: var(--bg-page); }
.dashboard-table .num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 13px; }
.dashboard-table .muted { color: var(--text-muted); }
.dashboard-table .holder-name { font-weight: 500; }
.dashboard-table .holder-email { color: var(--text-muted); font-size: 12px; }

/* ── Cards (partner detail) ──────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  padding: 18px 22px 14px 22px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.card-body { padding: 18px 22px; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.info-cell {
  display: flex;
  flex-direction: column;
}
.info-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.info-value {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  color: var(--text-primary);
}
.info-value.text { font-family: var(--font-sans); font-weight: 500; }

/* ── Returns / detail tables ─────────────────────────────────── */
.returns-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.returns-table thead th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.returns-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.returns-table tbody tr:last-child td { border-bottom: none; }
.returns-table .text { font-family: var(--font-sans); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 18px;
  font-size: 14px;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.row-btn {
  border: 1px solid var(--border);
  background: white;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.row-btn:hover { color: var(--text-primary); background: var(--bg-page); }
.row-btn.primary {
  background: var(--text-primary);
  color: white;
  border-color: var(--text-primary);
}
.row-btn.primary:hover { background: #1f1f1f; }
.row-btn.danger { color: var(--red); border-color: var(--red); }
.row-btn.danger:hover { background: var(--red-bg); }
.row-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.preview-frame {
  width: 100%;
  height: 700px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
}

/* ── Status pills / colors ───────────────────────────────────── */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pill.draft     { background: var(--amber-bg);  color: var(--amber); }
.pill.approved  { background: var(--blue-light); color: var(--blue); }
.pill.invoiced  { background: var(--green-bg); color: var(--green); }
.pill.void      { background: var(--red-bg);   color: var(--red); }

.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral  { color: var(--text-secondary); }

/* ── Footer ──────────────────────────────────────────────────── */
.page-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}
.app-version {
  position: fixed;
  bottom: 8px; right: 12px;
  font-size: 10px;
  color: var(--text-muted);
  pointer-events: none;
  font-family: var(--font-mono);
}

/* Fade-in for view transitions */
.fade-in { animation: fade-in 0.25s ease; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
