/**
 * sight-ui.css — the shared shell: top bar, buttons, fields, tables, cards,
 * toasts, the update banner.
 *
 * Tenant colours arrive as CSS variables set by sight-ui.js, so nothing here
 * names a client. Everything else is a neutral grey scale that reads the same
 * behind any brand colour.
 */

:root {
  /* Overwritten per tenant at boot. These are the fallbacks. */
  --sight-primary: #1f2937;
  --sight-primary-soft: #eef2f7;
  --sight-primary-dark: #111827;
  --sight-accent: #4f46e5;

  --s-ink: #111827;
  --s-text: #374151;
  --s-muted: #6b7280;
  --s-faint: #9ca3af;
  --s-line: #e5e7eb;
  --s-line-soft: #f1f3f5;
  --s-bg: #f7f8fa;
  --s-surface: #ffffff;
  --s-danger: #dc2626;
  --s-danger-soft: #fef2f2;
  --s-ok: #15803d;
  --s-ok-soft: #f0fdf4;
  --s-warn: #b45309;
  --s-warn-soft: #fffbeb;

  --s-radius: 10px;
  --s-radius-sm: 7px;
  --s-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --s-shadow-lg: 0 10px 28px rgba(16, 24, 40, .12);
  --s-bar-h: 60px;
  --s-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  margin: 0;
  font-family: var(--s-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--s-text);
  background: var(--s-bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */

/*
 * Stacking: the top bar is the suite's outermost chrome and has to sit above
 * whatever a product draws under it, because its menus open downwards over
 * that product's page. It sat at 40, which lost to PaySight's ported sidebar
 * (800) and page bar (700) — the menus opened behind them and their first
 * items were invisible.
 *
 * The bands, so the next product does not rediscover this:
 *
 *     0–899     a product's own page furniture: sidebars, sticky bars, popovers
 *     1000      this bar, and the menus that hang off it
 *     2000+     modals, confirmations and toasts, which cover everything
 *
 * A product needing to paint over the top bar wants a modal, not a z-index.
 */
.sight-topbar {
  position: sticky; top: 0; z-index: var(--s-z-topbar, 1000);
  display: flex; align-items: center; gap: 12px;
  height: var(--s-bar-h);
  padding: 0 18px;
  background: var(--s-surface);
  border-bottom: 1px solid var(--s-line);
}
.sight-topbar .s-spacer { flex: 1; }

.s-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; min-width: 0; }
.s-logo {
  display: grid; place-items: center;
  width: 36px; height: 36px; flex: none;
  border-radius: 9px; overflow: hidden;
  background: var(--sight-primary-soft);
}
.s-logo img { width: 100%; height: 100%; object-fit: contain; }
.s-logo-text { font-weight: 700; font-size: 13px; color: var(--sight-primary); letter-spacing: .02em; }
.s-brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.s-tenant { font-weight: 650; color: var(--s-ink); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-module { font-size: 11.5px; color: var(--s-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.s-iconbtn, .s-userbtn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 11px;
  background: transparent; border: 1px solid transparent; border-radius: var(--s-radius-sm);
  font: inherit; font-size: 13px; color: var(--s-text); cursor: pointer;
}
.s-iconbtn:hover, .s-userbtn:hover { background: var(--s-line-soft); }
/* The same control as an anchor: products get a Home button, not a back button. */
.s-homebtn { text-decoration: none; }
.s-iconbtn:focus-visible, .s-userbtn:focus-visible { outline: 2px solid var(--sight-primary); outline-offset: 1px; }

.s-user-meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.s-user-name { font-weight: 600; color: var(--s-ink); font-size: 13px; }
.s-user-role { font-size: 11px; color: var(--s-muted); }
.s-avatar {
  display: grid; place-items: center;
  width: 32px; height: 32px; flex: none;
  border-radius: 50%;
  background: var(--sight-primary); color: #fff;
  font-size: 12px; font-weight: 650; letter-spacing: .02em;
}

/* ── Dropdowns ───────────────────────────────────────────────────────────── */

.s-menu { position: relative; }
.s-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;
  display: none; min-width: 216px; padding: 6px;
  background: var(--s-surface);
  border: 1px solid var(--s-line); border-radius: var(--s-radius);
  box-shadow: var(--s-shadow-lg);
}
.s-dropdown-right { left: auto; right: 0; }
.s-menu.is-open .s-dropdown { display: block; }
.s-dropdown a, .s-dropdown button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px;
  background: none; border: 0; border-radius: var(--s-radius-sm);
  font: inherit; font-size: 13px; color: var(--s-text); text-align: left;
  text-decoration: none; cursor: pointer;
}
.s-dropdown a:hover, .s-dropdown button:hover { background: var(--s-line-soft); color: var(--s-ink); }
.s-dropdown a.is-current { background: var(--sight-primary-soft); color: var(--sight-primary); font-weight: 600; }
.s-dropdown-head { padding: 9px 10px 11px; border-bottom: 1px solid var(--s-line); margin-bottom: 5px; display: flex; flex-direction: column; gap: 2px; }
.s-dropdown-head strong { font-size: 13px; color: var(--s-ink); }
.s-dropdown-head span { font-size: 11.5px; color: var(--s-muted); word-break: break-all; }

/* ── Layout ──────────────────────────────────────────────────────────────── */

.s-page { max-width: 1240px; margin: 0 auto; padding: 24px 18px 56px; }
.s-page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.s-page-head h1 { margin: 0 0 3px; font-size: 22px; font-weight: 680; color: var(--s-ink); letter-spacing: -.01em; }
.s-page-head p { margin: 0; color: var(--s-muted); font-size: 13px; }
.s-page-head .s-spacer { flex: 1; }

.s-card {
  background: var(--s-surface);
  border: 1px solid var(--s-line); border-radius: var(--s-radius);
  box-shadow: var(--s-shadow);
}
.s-card-body { padding: 18px; }
.s-card-head { padding: 14px 18px; border-bottom: 1px solid var(--s-line); display: flex; align-items: center; gap: 12px; }
.s-card-head h2 { margin: 0; font-size: 14.5px; font-weight: 650; color: var(--s-ink); }
.s-grid { display: grid; gap: 16px; }
.s-grid-tiles { grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.s-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px;
  background: var(--sight-primary); color: #fff;
  border: 1px solid transparent; border-radius: var(--s-radius-sm);
  font: inherit; font-size: 13px; font-weight: 560; cursor: pointer;
  white-space: nowrap; text-decoration: none;
}
.s-btn:hover:not(:disabled) { background: var(--sight-primary-dark); }
.s-btn:focus-visible { outline: 2px solid var(--sight-primary); outline-offset: 2px; }
.s-btn:disabled { opacity: .55; cursor: not-allowed; }
.s-btn-secondary { background: var(--s-surface); color: var(--s-text); border-color: var(--s-line); }
.s-btn-secondary:hover:not(:disabled) { background: var(--s-line-soft); color: var(--s-ink); }
.s-btn-danger { background: var(--s-danger); }
.s-btn-danger:hover:not(:disabled) { background: #b91c1c; }
.s-btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.s-btn-block { width: 100%; }
.s-linkbtn { background: none; border: 0; padding: 4px 6px; font: inherit; color: var(--s-muted); cursor: pointer; border-radius: 6px; }
.s-linkbtn:hover { color: var(--s-ink); background: var(--s-line-soft); }

/* ── Fields ──────────────────────────────────────────────────────────────── */

.s-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.s-field label { font-size: 12.5px; font-weight: 570; color: var(--s-text); }
.s-input, .s-select, .s-textarea {
  width: 100%; min-height: 38px; padding: 8px 11px;
  background: var(--s-surface); color: var(--s-ink);
  border: 1px solid var(--s-line); border-radius: var(--s-radius-sm);
  font: inherit; font-size: 13.5px;
}
.s-input:focus, .s-select:focus, .s-textarea:focus {
  outline: none; border-color: var(--sight-primary);
  box-shadow: 0 0 0 3px var(--sight-primary-soft);
}
.s-input:disabled, .s-select:disabled, .s-textarea:disabled { background: var(--s-line-soft); color: var(--s-muted); }
.s-textarea { min-height: 82px; resize: vertical; }
.s-hint { font-size: 11.5px; color: var(--s-muted); }
.s-error { font-size: 12.5px; color: var(--s-danger); }
.s-field-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* ── Tables ──────────────────────────────────────────────────────────────── */

.s-table-wrap { overflow-x: auto; border-radius: var(--s-radius); }
.s-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--s-surface); }
.s-table th {
  position: sticky; top: 0;
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 640; text-transform: uppercase; letter-spacing: .04em;
  color: var(--s-muted); background: var(--s-line-soft);
  border-bottom: 1px solid var(--s-line); white-space: nowrap;
}
.s-table td { padding: 11px 14px; border-bottom: 1px solid var(--s-line-soft); color: var(--s-text); }
.s-table tbody tr:hover { background: var(--s-line-soft); }
.s-table .s-num { text-align: right; font-variant-numeric: tabular-nums; }
.s-empty { padding: 44px 20px; text-align: center; color: var(--s-muted); }
.s-empty strong { display: block; margin-bottom: 4px; color: var(--s-ink); font-size: 14px; }

/* ── Badges ──────────────────────────────────────────────────────────────── */

.s-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
  background: var(--s-line-soft); color: var(--s-muted);
}
.s-badge-ok { background: var(--s-ok-soft); color: var(--s-ok); }
.s-badge-warn { background: var(--s-warn-soft); color: var(--s-warn); }
.s-badge-danger { background: var(--s-danger-soft); color: var(--s-danger); }
.s-badge-brand { background: var(--sight-primary-soft); color: var(--sight-primary); }

/* ── Toasts and the update banner ────────────────────────────────────────── */

.sight-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.s-toast {
  min-width: 232px; max-width: 380px; padding: 11px 14px;
  background: var(--s-ink); color: #fff;
  border-radius: var(--s-radius); box-shadow: var(--s-shadow-lg);
  font-size: 13px; opacity: 1; transform: translateY(0);
  transition: opacity .22s ease, transform .22s ease;
}
.s-toast.is-going { opacity: 0; transform: translateY(6px); }
.s-toast-error { background: var(--s-danger); }
.s-toast-ok { background: var(--s-ok); }

.sight-update {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 95;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 16px;
  background: var(--s-ink); color: #fff;
  border-radius: 999px; box-shadow: var(--s-shadow-lg);
  font-size: 13px;
}
.sight-update .s-btn { background: #fff; color: var(--s-ink); }
.sight-update .s-btn:hover { background: #e9ecef; }
.sight-update .s-linkbtn { color: rgba(255, 255, 255, .7); font-size: 17px; line-height: 1; }
.sight-update .s-linkbtn:hover { color: #fff; background: rgba(255, 255, 255, .12); }

/* ── Utilities ───────────────────────────────────────────────────────────── */

.s-hidden { display: none !important; }
.s-muted { color: var(--s-muted); }
.s-nowrap { white-space: nowrap; }
.s-stack { display: flex; flex-direction: column; gap: 12px; }
.s-row { display: flex; align-items: center; gap: 10px; }
.s-spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: s-spin .6s linear infinite; display: inline-block;
}
@keyframes s-spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .s-hide-sm { display: none !important; }
  .sight-topbar { padding: 0 12px; gap: 8px; }
  .s-page { padding: 18px 12px 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
