/* Syndeavors Onboarding Portal — palette + typography mirror syndeavors.com.
   Primary navy #0f2c70 (logo, h1, header BG), action blue #116dff (CTAs/links),
   light tint #e5f0f7, font Questrial (Google Fonts) for headings + UI. */

@import url('https://fonts.googleapis.com/css2?family=Questrial&family=Inter:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-tint: #f5f8fb;
  --bg-tint-2: #eef3f8;
  --card: #ffffff;
  --ink: #0a0a0a;
  --ink-2: #2c2c2c;
  --muted: #6b7280;
  --line: #e5e9ef;
  --line-strong: #c9d1dd;

  --navy: #0f2c70;        /* primary brand */
  --navy-2: #0a1f56;
  --navy-soft: #e5f0f7;
  --action: #116dff;      /* action blue */
  --action-2: #0a58cc;
  --accent: #2e7ec3;
  --accent-soft: #d8e7f4;

  --ok: #1f8a4c;
  --ok-soft: #e8f5ee;
  --pending: #c97a00;
  --pending-soft: #fff3df;
  --overdue: #c1272d;
  --overdue-soft: #fde8ea;
  --locked: #9aa0a6;
  --locked-soft: #f1f3f5;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .07), 0 2px 4px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 36px rgba(15, 44, 112, .12), 0 4px 14px rgba(15, 44, 112, .06);

  --ff-display: Questrial, "Helvetica Neue", Arial, sans-serif;
  --ff-body: Inter, "Helvetica Neue", Arial, sans-serif;
}

/* Dark mode — recolor only the design tokens. Component rules below all read
   from these vars, so the layout stays identical and we don't have to fork
   per-component dark styles. Pills get explicit colour-scheme: light to keep
   their filled backgrounds reading correctly on either OS appearance. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0d121b;
    --bg-tint:   #161c28;
    --bg-tint-2: #1c2433;
    --card:      #131925;
    --ink:       #e9edf5;
    --ink-2:     #c8cfdb;
    --muted:     #98a1b3;
    --line:      #2a3344;
    --line-strong: #3a4458;

    --navy:      #5a85e6;          /* lifted so it reads on dark surfaces */
    --navy-2:    #4a74d4;
    --navy-soft: #1d2a4a;
    --action:    #5e9bff;
    --action-2:  #7cb0ff;
    --accent:    #4a78c4;
    --accent-soft: #1f2c45;

    --ok:        #4cc380;
    --ok-soft:   #15301f;
    --pending:   #e8b86a;          /* warmer, less saturated orange */
    --pending-soft: #2b2210;
    --overdue:   #e57078;
    --overdue-soft: #34161a;
    --locked:    #8a93a3;
    --locked-soft: #1a1f2a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .25);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .25);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55), 0 6px 18px rgba(0, 0, 0, .3);
  }
  body {
    background:
      radial-gradient(at 12% -5%, rgba(94, 155, 255, .07), transparent 45%),
      radial-gradient(at 92% 105%, rgba(74, 120, 196, .08), transparent 45%),
      var(--bg);
  }
  /* Header gradient stays navy but a touch lighter so the logo tile blends. */
  .header { background: linear-gradient(135deg, #1b2a5e 0%, #142250 70%, #0a1438 100%); }
  /* Form fields hardcode #fff bg — override for dark. */
  .field { background: var(--bg-tint); color: var(--ink); border-color: var(--line); }
  .field::placeholder { color: #6b7385; }
  /* Inline-edit pill-edit + url-edit-row keep light internals so the controls
     read like the pill colours. Override their hardcoded #fff background. */
  .pill-edit, .url-edit-row { background: var(--bg-tint); border-color: var(--accent); }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--ff-body);
  background:
    radial-gradient(at 12% -5%, rgba(15, 44, 112, .06), transparent 45%),
    radial-gradient(at 92% 105%, rgba(46, 126, 195, .07), transparent 45%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  padding: 28px;
}

a { color: var(--action); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 920px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.container.wide { max-width: 1240px; }

.header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 70%, #061439 100%);
  color: #fff;
  padding: 26px 32px;
  position: relative;
  display: flex; align-items: center; gap: 18px;
}
.header::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 100% 0%, rgba(46, 126, 195, .25), transparent 45%);
  pointer-events: none;
}
.header > * { position: relative; z-index: 1; }
.header .logo {
  width: 56px; height: 56px; border-radius: 10px; flex-shrink: 0;
  background: #fff; padding: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  display: flex; align-items: center; justify-content: center;
}
.header .logo img { width: 100%; height: 100%; object-fit: contain; }
.header .header-text { flex: 1; min-width: 0; }
.header h1 {
  font-family: var(--ff-display);
  font-size: 1.85rem; font-weight: 400; letter-spacing: .2px;
  margin-bottom: 4px; color: #fff;
}
.header p { opacity: .82; font-size: .92rem; max-width: 720px; }
.header .brand-tag {
  font-size: .68rem; text-transform: uppercase; letter-spacing: 1.4px; opacity: .7; margin-bottom: 6px;
  display: inline-flex; align-items: center; gap: 8px; font-family: var(--ff-display);
}

.content { padding: 24px 28px 28px; }

h2, h3 { font-family: var(--ff-display); font-weight: 400; color: var(--navy); }

.section { margin-bottom: 20px; }
.section h2 { font-size: 1.15rem; margin-bottom: 8px; }
.section .hint { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }

.field {
  width: 100%;
  padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-size: .95rem; background: #fff; color: var(--ink);
  font-family: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.field:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px rgba(17, 109, 255, .18); }
.field::placeholder { color: #adb5bd; }
/* Read-only / disabled fields (admin "view responses" mode). Without this,
   WebKit/Blink dim the text and force a near-white background that fights
   our dark-mode tokens, leaving values illegible. */
.field:disabled,
.field[readonly] {
  background: var(--bg-tint-2);
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
  border-color: var(--line);
  opacity: 1;
  cursor: default;
  -webkit-appearance: none;
  appearance: none;
}

label.row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: .85rem; color: var(--muted); }
label.row .label-text { font-weight: 600; color: var(--ink); font-family: var(--ff-body); }
label.row .help { font-size: .78rem; color: var(--muted); }

/* Unified button system — all pill-shaped, same vertical rhythm.
   Default: 36px tall toolbar / form button. Use .btn.lg for primary CTAs
   that should stand out (slightly taller, heavier shadow). */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px;
  background: var(--action);
  color: #fff; border: 1px solid transparent; border-radius: 999px;
  font-size: .85rem; font-weight: 600; cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(17, 109, 255, .22);
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease, transform .08s ease;
}
.btn:hover { background: var(--action-2); text-decoration: none; box-shadow: 0 4px 14px rgba(17, 109, 255, .25); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; background: var(--locked); box-shadow: none; }
.btn.ghost { background: #fff; color: var(--navy); border-color: var(--line-strong); box-shadow: none; }
.btn.ghost:hover { background: var(--bg-tint); border-color: var(--accent); }
.btn.danger { background: var(--overdue); box-shadow: 0 1px 2px rgba(193, 39, 45, .22); }
.btn.danger:hover { background: #a01f24; }
.btn .icon { width: 14px; height: 14px; flex-shrink: 0; }
.btn .icon-leading { margin-left: -2px; }
.btn .icon-trailing { margin-right: -2px; }
.btn.sm { height: 28px; padding: 0 12px; font-size: .78rem; }
.btn.sm .icon { width: 12px; height: 12px; }

/* Stepper */
.stepper { display: flex; flex-direction: column; gap: 12px; }
.step {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 14px; align-items: center;
  padding: 16px 18px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform .08s ease, box-shadow .12s ease, border-color .12s ease;
}
.step:hover { box-shadow: var(--shadow-md); }
.step.active { border-color: rgba(201, 122, 0, .35); }
.step.done   { border-color: rgba(31, 138, 76, .25); }
.step .step-icon {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem;
  background: var(--locked-soft); color: var(--locked);
  border: 2px solid var(--locked);
}
.step.done .step-icon    { background: var(--ok-soft);      color: var(--ok);      border-color: var(--ok); }
.step.active .step-icon  { background: var(--pending-soft); color: var(--pending); border-color: var(--pending); }
.step.locked .step-icon  { background: var(--locked-soft);  color: var(--locked);  border-color: var(--locked); }
.step .step-body .step-title { font-family: var(--ff-display); font-weight: 400; color: var(--navy); font-size: 1.05rem; margin-bottom: 2px; }
.step .step-body .step-desc { font-size: .85rem; color: var(--muted); line-height: 1.45; }
.step.locked .step-body .step-title { color: var(--locked); }
.step .step-action { display: flex; gap: 8px; }

/* Pills (chips) — clickable in admin table to open the inline editor.
   Cursor + subtle hover are the only edit affordance (no glyph). */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  background: var(--locked-soft); color: var(--locked);
  border: 1px solid transparent; cursor: pointer;
  font-family: inherit;
  /* Force light rendering of the <button> regardless of OS dark mode so the
     filled background colour stays accurate on a dark system. */
  color-scheme: light;
  transition: filter .1s ease, transform .08s ease, box-shadow .12s ease;
}
.pill:hover:not([disabled]) { filter: brightness(.96); box-shadow: 0 0 0 3px rgba(17, 109, 255, .08); }
.pill:active:not([disabled]) { transform: translateY(1px); }
/* Per-status pill colours.
   pending  → soft blue (info, waiting)
   available→ stronger blue (ready to act)
   sent     → orange (out for action)
   signed / submitted / scheduled / done → green (complete)
   locked   → grey (not yet) */
.pill.pending {
  background: var(--navy-soft); color: var(--action-2);
  border-color: rgba(17, 109, 255, .25);
}
.pill.available {
  /* Distinct from .pill.pending — saturated blue so it reads as "do this now". */
  background: #d6e4fb; color: #0a3a99;
  border-color: rgba(17, 109, 255, .35);
}
@media (prefers-color-scheme: dark) {
  .pill.available { background: #25365e; color: #b9d0ff; border-color: rgba(94, 155, 255, .4); }
}
.pill.sent {
  background: var(--pending-soft); color: var(--pending);
  border-color: rgba(201, 122, 0, .3);
}
.pill.signed,
.pill.submitted,
.pill.scheduled,
.pill.done {
  background: var(--ok-soft); color: var(--ok);
  border-color: rgba(31, 138, 76, .25);
}
.pill.locked {
  background: var(--locked-soft); color: var(--locked);
}
.pill[disabled] { cursor: default; opacity: .85; }

/* Inline edit dropdown (replaces a pill while editing) */
.pill-edit {
  display: inline-flex; align-items: center; gap: 2px;
  height: 26px; padding: 0 4px; border: 1px solid var(--accent);
  border-radius: 999px; background: #fff;
  color-scheme: light;
  box-shadow: 0 0 0 3px rgba(17, 109, 255, .14);
}
.pill-edit select, .pill-edit input { color-scheme: light; }
.pill-edit select {
  border: 0; background: transparent; font-size: .74rem; font-weight: 700; color: var(--ink);
  padding: 0 6px; outline: none; text-transform: uppercase; letter-spacing: .4px;
  font-family: inherit; height: 22px;
}
.pill-edit button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border: 0; background: transparent; cursor: pointer; padding: 0;
  border-radius: 50%; line-height: 1;
}
.pill-edit button .icon { width: 12px; height: 12px; }
.pill-edit button.commit { color: var(--ok); }
.pill-edit button.cancel { color: var(--muted); }
.pill-edit button:hover { background: var(--bg-tint); }

/* Contract URL editor (NDA / BAA) — sits under the pill, small + quiet. */
.url-edit { margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.url-edit .url-link {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: .72rem; color: var(--action); text-decoration: none; font-weight: 600;
}
.url-edit .url-link:hover { text-decoration: underline; }
.url-edit .url-link .icon { opacity: .7; }
.url-edit .url-action {
  border: 0; background: transparent; padding: 0; cursor: pointer;
  font: inherit; font-size: .72rem; color: var(--action); font-weight: 600;
}
.url-edit .url-action:hover { text-decoration: underline; }
.url-edit .url-edit-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border: 0; background: transparent;
  cursor: pointer; padding: 0; border-radius: 4px; color: var(--muted);
}
.url-edit .url-edit-btn:hover { background: var(--bg-tint); color: var(--action); }
.url-edit-row {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--accent); border-radius: 999px; background: #fff;
  padding: 2px 4px 2px 10px;
  color-scheme: light;
  box-shadow: 0 0 0 3px rgba(17, 109, 255, .12);
  width: 100%; max-width: 280px;
}
.url-edit-row .url-input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font: inherit; font-size: .76rem; color: var(--ink); padding: 2px 0;
}
.url-edit-row button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border: 0; background: transparent;
  cursor: pointer; padding: 0; border-radius: 50%; line-height: 1; flex: 0 0 auto;
}
.url-edit-row button.commit { color: var(--ok); }
.url-edit-row button.cancel { color: var(--muted); }
.url-edit-row button:hover { background: var(--bg-tint); }

.alert {
  padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 12px;
  font-size: .88rem; line-height: 1.5;
}
.alert.info { background: var(--navy-soft); color: var(--navy-2); border: 1px solid var(--accent-soft); }
.alert.ok   { background: var(--ok-soft); color: var(--ok); border: 1px solid rgba(31, 138, 76, .18); }
.alert.warn { background: var(--pending-soft); color: var(--pending); border: 1px solid rgba(201, 122, 0, .25); }
.alert.err  { background: var(--overdue-soft); color: var(--overdue); border: 1px solid rgba(193, 39, 45, .2); }

/* Admin overview */
.admin-toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 12px 14px; background: linear-gradient(135deg, var(--bg-tint), var(--bg-tint-2));
  border: 1px solid var(--line); border-radius: 999px; margin-bottom: 16px;
}
.admin-toolbar .stat {
  font-size: .82rem; color: var(--muted); white-space: nowrap;
  padding: 0 4px 0 8px;
}
.admin-toolbar .stat strong { color: var(--navy); font-weight: 700; }
.admin-toolbar .stat .sep { opacity: .4; margin: 0 4px; }
.admin-toolbar .grow { flex: 1; min-width: 8px; }

.admin-toolbar .search-wrap {
  position: relative; flex: 1; min-width: 220px; max-width: 380px;
}
.admin-toolbar .search-wrap input {
  width: 100%; height: 36px;
  padding: 0 12px 0 34px; border: 1px solid var(--line-strong);
  border-radius: 999px; font-size: .85rem; background: #fff; color: var(--ink);
  font-family: inherit;
}
.admin-toolbar .search-wrap input:focus {
  outline: none; border-color: var(--action);
  box-shadow: 0 0 0 3px rgba(17, 109, 255, .15);
}
.admin-toolbar .search-wrap .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--muted); pointer-events: none;
}

/* Collapsible card (used by add-business form) */
.collapsible {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 16px;
}
.collapsible[hidden] { display: none; }
.collapsible h3 {
  background: linear-gradient(135deg, var(--bg-tint), var(--bg-tint-2));
  padding: 14px 18px; color: var(--navy); font-size: 1.1rem;
  border-bottom: 1px solid var(--line);
}
.collapsible .collapsible-body { padding: 18px; }

.copy-link {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--bg-tint); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .78rem; word-break: break-all;
}

/* Admin table — grouped by syndicate */
.admin-table-wrap {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table th {
  font-size: .66rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .8px; background: var(--bg-tint);
}
.admin-table tbody tr:hover td { background: var(--bg-tint); }
.admin-table .business-name { color: var(--navy); font-size: .95rem; font-family: var(--ff-display); font-weight: 400; }
.admin-table .business-meta { font-size: .76rem; color: var(--muted); margin-top: 2px; }
.admin-table .view-as-link {
  display: inline-flex; align-items: center; gap: 3px;
  margin-top: 6px; font-size: .72rem; color: var(--action); font-weight: 600;
  text-decoration: none;
}
.admin-table .view-as-link:hover { text-decoration: underline; }
.admin-table .view-as-link .icon { opacity: .7; }

/* View-as preview banner — admin sees this when ?as=<token> is active. */
.alert.view-as-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.alert.view-as-banner .view-as-exit {
  margin-left: auto; font-weight: 600; white-space: nowrap;
}
.admin-table-empty { padding: 36px 20px; text-align: center; color: var(--muted); font-size: .9rem; }

/* Group header row */
.group-row td {
  background: linear-gradient(90deg, var(--navy-soft), transparent 70%) !important;
  border-bottom: 1px solid var(--accent-soft);
}
.group-row .group-title {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--ff-display); color: var(--navy); font-size: .98rem;
}
.group-row .group-title .badge {
  background: var(--navy); color: #fff; padding: 2px 9px; border-radius: 999px;
  font-size: .68rem; font-weight: 700; letter-spacing: .5px;
}

.review-link {
  color: var(--action); font-weight: 600; cursor: pointer; background: none; border: 0;
  padding: 0; font-family: inherit; font-size: .8rem;
}
.review-link:hover { text-decoration: underline; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }

/* Survey form */
.survey-section { margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.survey-section:last-of-type { border-bottom: none; }
.survey-section h3 { color: var(--navy); font-size: 1.15rem; margin-bottom: 12px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .field-grid { grid-template-columns: 1fr; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  padding: 10px 16px; border-radius: var(--radius-sm); background: var(--navy); color: #fff;
  font-size: .88rem; box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .2s ease; z-index: 1000;
}
.toast.show { opacity: 1; }
.toast.err  { background: var(--overdue); }
.toast.ok   { background: var(--ok); }

/* Role tag in header */
.role-tag {
  display: inline-block; font-size: .62rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; padding: 3px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, .12); color: #fff; border: 1px solid rgba(255, 255, 255, .25);
  font-family: var(--ff-display); font-weight: 400;
}

/* Footer */
.footer-bar {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: .82rem; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
.signout-link { font-size: .82rem; color: var(--muted); text-decoration: underline; cursor: pointer; background: none; border: 0; padding: 0; font-family: inherit; }
.signout-link:hover { color: var(--ink); }

@media (max-width: 640px) {
  body { padding: 12px; }
  .container { border-radius: var(--radius-sm); }
  .header { padding: 18px 16px; gap: 12px; }
  .header .logo { width: 44px; height: 44px; }
  .header h1 { font-size: 1.4rem; }
  .content { padding: 14px; }
  .step { grid-template-columns: 32px 1fr; }
  .step .step-action { grid-column: 1 / -1; margin-top: 6px; }
}
