/* ============================================================
   Greenco eSign
   app.css — Mobile-first, PWA-ready
   Colours: #8DC63F (green) | #1e2235 (dark) | #ffffff (white)
   Fonts: Plus Jakarta Sans (headings) | Inter (body)
   ============================================================ */

/* ── Reset & Root ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:        #8DC63F;
  --green-dark:   #6fa82e;
  --green-light:  #f0f8e6;
  --green-mid:    #c8e89a;
  --dark:         #1e2235;
  --dark-mid:     #2d3452;
  --dark-light:   #3d4466;
  --grey:         #6b7280;
  --grey-light:   #f4f5f7;
  --grey-mid:     #e5e7eb;
  --white:        #ffffff;
  --danger:       #dc2626;
  --danger-light: #fee2e2;
  --warning:      #f59e0b;
  --warning-light:#fff8e1;
  --info:         #3b82f6;
  --info-light:   #dbeafe;
  --success:      #10b981;
  --success-light:#d1fae5;

  --radius:       16px;
  --radius-sm:    10px;
  --radius-xs:    6px;
  --shadow:       0 2px 12px rgba(30,34,53,0.08);
  --shadow-md:    0 4px 20px rgba(30,34,53,0.12);
  --shadow-lg:    0 8px 32px rgba(30,34,53,0.16);

  --top-bar-h:    60px;
  --font-display: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
}

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

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--dark);
  background: var(--grey-light);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font-body); }

/* ── App Shell ─────────────────────────────────────────────── */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Top Bar ───────────────────────────────────────────────── */
.top-bar {
  position: fixed; top: 0; left: 0; right: 0;
  height: calc(var(--top-bar-h) + env(safe-area-inset-top, 0px));
  background: var(--dark);
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 16px calc(0px); padding-top: env(safe-area-inset-top, 0px);
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.top-bar > * { margin-bottom: 12px; }
.top-bar-left { display: flex; align-items: center; gap: 14px; }
.menu-toggle {
  background: none; border: none;
  display: flex; flex-direction: column; gap: 5px;
  padding: 10px 8px; margin: -6px -4px; cursor: pointer;
}
.menu-toggle span {
  display: block; width: 22px; height: 2px;
  background: var(--white); border-radius: 2px; transition: all 0.25s;
}
.top-bar-logo {
  font-family: var(--font-display); letter-spacing: -0.02em;
  font-size: 1.2rem; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.top-bar-logo svg { display: inline-block !important; vertical-align: middle; }
.logo-green { color: var(--white); }
.logo-co    { color: var(--green); }
.logo-sub {
  font-family: var(--font-body); font-size: 0.65rem;
  font-weight: 700; letter-spacing: 0.15em; text-transform: uppercase;
  color: rgba(255,255,255,0.5); margin-left: 0;
}
.top-bar-right { display: flex; align-items: center; gap: 10px; }

.avatar-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--green); color: white;
  font-weight: 700; font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: none; flex-shrink: 0;
  user-select: none; -webkit-user-select: none;
  transition: opacity 0.15s;
}
.avatar-btn:hover { opacity: 0.88; }

/* ── Company switcher badge ────────────────────────────────── */
.company-badge {
  background: rgba(141,198,63,0.15); color: var(--green);
  border-radius: 20px; padding: 4px 12px; font-size: 0.75rem; font-weight: 600;
  border: 1px solid rgba(141,198,63,0.3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px;
}

/* ── Side Navigation ───────────────────────────────────────── */
.side-nav {
  position: fixed; top: 0; left: -280px; bottom: 0; width: 280px;
  background: var(--dark); z-index: 200; transition: left 0.3s ease;
  display: flex; flex-direction: column; overflow-y: auto;
}
.side-nav.open { left: 0; }
.side-nav-inner { display: flex; flex-direction: column; min-height: 100%; padding: 0 0 24px; }

.side-nav-profile {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-top: 8px;
}
.side-nav-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--green); color: white;
  font-weight: 700; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.side-nav-name { font-weight: 600; color: var(--white); font-size: 0.9rem; }
.side-nav-role { font-size: 0.75rem; color: rgba(255,255,255,0.4); text-transform: capitalize; }
.side-nav-company { font-size: 0.7rem; color: var(--green); margin-top: 2px; }

.nav-links { list-style: none; padding: 12px 12px 0; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65); font-size: 0.9rem; font-weight: 500;
  transition: all 0.2s; margin-bottom: 2px;
}
.nav-link:hover { background: rgba(255,255,255,0.07); color: var(--white); }
.nav-link.active { background: var(--green); color: var(--white); }
.nav-link.active svg { stroke: var(--white); }
.nav-link svg { flex-shrink: 0; opacity: 0.8; }

.nav-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 8px 12px; }
.nav-section-label {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: rgba(255,255,255,0.3);
  padding: 8px 12px 4px;
}

.side-nav-footer {
  padding: 16px 12px 0; border-top: 1px solid rgba(255,255,255,0.08); margin-top: 16px;
}
.logout-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.5); font-size: 0.85rem;
  transition: all 0.2s;
}
.logout-link:hover { color: var(--danger); background: rgba(220,38,38,0.08); }

.nav-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 150;
}
.nav-overlay.visible { display: block; }

/* ── Page Content ──────────────────────────────────────────── */
.page-content {
  margin-top: var(--top-bar-h);
  padding: 20px 16px 24px;
  flex: 1;
}

@media (min-width: 768px) {
  .page-content { padding: 24px 28px 40px; }
}
@media (min-width: 1024px) {
  .side-nav { left: 0; top: var(--top-bar-h); box-shadow: none; }
  .menu-toggle { display: none; }
  .page-content { margin-left: 280px; padding: 28px 32px 40px; }
  .nav-overlay { display: none !important; }
  .side-nav-brand { display: none; }
}


/* ── Page Header ───────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-header-left {}
.page-title {
  font-family: var(--font-display); font-size: 1.5rem;
  font-weight: 800; letter-spacing: -0.02em; color: var(--dark);
  line-height: 1.2;
}
.page-subtitle { color: var(--grey); font-size: 0.875rem; margin-top: 4px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--white); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.card-title {
  font-family: var(--font-display); font-size: 1rem;
  font-weight: 700; color: var(--dark);
}

/* ── Stats Grid ────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
  background: var(--white); border-radius: var(--radius);
  padding: 18px 16px; box-shadow: var(--shadow);
}
.stat-value {
  font-family: var(--font-display); font-size: 2rem;
  font-weight: 800; color: var(--dark); line-height: 1;
}
.stat-label { font-size: 0.75rem; color: var(--grey); margin-top: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.info  .stat-value { color: var(--info); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 600; border: none;
  cursor: pointer; transition: all 0.2s; text-decoration: none;
  white-space: nowrap; font-family: var(--font-body);
}
.btn:active { transform: scale(0.97); }
.btn-primary  { background: var(--green);  color: var(--white); }
.btn-primary:hover  { background: var(--green-dark); }
.btn-secondary { background: var(--grey-mid); color: var(--dark); }
.btn-secondary:hover { background: #d1d5db; }
.btn-danger  { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--grey); border: 1px solid var(--grey-mid); }
.btn-ghost:hover { background: var(--grey-light); color: var(--dark); }
.btn-sm { padding: 7px 14px; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.85rem; font-weight: 600; color: var(--dark);
  margin-bottom: 6px;
}
.form-label-link { font-weight: 400; color: var(--green); font-size: 0.8rem; }
.form-label-link:hover { text-decoration: underline; }

.form-input, .form-select, .form-textarea {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--grey-mid); border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 0.9rem; color: var(--dark);
  background: var(--white); transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none; -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(141,198,63,0.15);
}
.form-textarea { resize: vertical; min-height: 100px; }

.input-password-wrap { position: relative; }
.input-password-wrap .form-input { padding-right: 44px; }
.password-toggle {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 4px; color: var(--grey); cursor: pointer;
}

.form-hint { font-size: 0.78rem; color: var(--grey); margin-top: 5px; }
.form-error-text { font-size: 0.78rem; color: var(--danger); margin-top: 5px; }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: 0.875rem; margin-bottom: 16px;
}
.alert-error   { background: var(--danger-light); color: var(--danger); }
.alert-success { background: var(--success-light); color: #065f46; }
.alert-warning { background: var(--warning-light); color: #92400e; }
.alert-info    { background: var(--info-light); color: #1e40af; }

/* ── Status Badges ─────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-sent      { background: var(--info-light); color: #1e40af; }
.badge-partial   { background: var(--warning-light); color: #92400e; }
.badge-completed { background: var(--success-light); color: #065f46; }
.badge-voided    { background: var(--grey-mid); color: var(--grey); }
.badge-expired   { background: var(--danger-light); color: var(--danger); }
.badge-draft     { background: var(--grey-mid); color: var(--grey); }
.badge-pending   { background: var(--info-light); color: #1e40af; }
.badge-signed    { background: var(--success-light); color: #065f46; }
.badge-declined  { background: var(--danger-light); color: var(--danger); }
.badge-admin     { background: rgba(141,198,63,0.15); color: var(--green-dark); }
.badge-sender    { background: var(--grey-mid); color: var(--grey); }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: var(--white); }
thead { background: var(--dark); }
thead th {
  padding: 12px 16px; text-align: left;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: rgba(255,255,255,0.6);
}
tbody tr { border-bottom: 1px solid var(--grey-mid); transition: background 0.15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--grey-light); }
tbody td { padding: 13px 16px; font-size: 0.875rem; vertical-align: middle; }
.td-meta { font-size: 0.78rem; color: var(--grey); margin-top: 2px; }

/* ── Document list item (mobile card style) ────────────────── */
.doc-list { display: flex; flex-direction: column; gap: 10px; }
.doc-item {
  background: var(--white); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px;
  transition: box-shadow 0.2s; cursor: pointer;
}
.doc-item:hover { box-shadow: var(--shadow-md); }
.doc-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  background: var(--green-light); color: var(--green);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.doc-info { flex: 1; min-width: 0; }
.doc-title { font-weight: 600; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta  { font-size: 0.78rem; color: var(--grey); margin-top: 2px; }
.doc-status { flex-shrink: 0; }

/* ── Progress indicator (signing flow) ────────────────────── */
.sign-progress {
  display: flex; align-items: center; justify-content: center;
  gap: 0; margin-bottom: 32px;
}
.sign-step {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  flex: 1; max-width: 100px;
}
.sign-step-dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; border: 2px solid var(--grey-mid);
  background: var(--white); color: var(--grey); transition: all 0.3s;
}
.sign-step.active .sign-step-dot  { border-color: var(--green); background: var(--green); color: var(--white); }
.sign-step.done .sign-step-dot    { border-color: var(--green); background: var(--green-light); color: var(--green); }
.sign-step-label { font-size: 0.68rem; font-weight: 600; color: var(--grey); text-align: center; }
.sign-step.active .sign-step-label { color: var(--green); }

.sign-step-line {
  flex: 1; height: 2px; background: var(--grey-mid); margin-top: -20px;
}
.sign-step-line.done { background: var(--green); }

/* ── Signature Pad ─────────────────────────────────────────── */
.sig-pad-wrap {
  border: 2px solid var(--grey-mid); border-radius: var(--radius-sm);
  background: var(--white); position: relative; overflow: hidden;
}
.sig-pad-wrap:focus-within { border-color: var(--green); }
#signaturePad { display: block; width: 100%; touch-action: none; }
.sig-clear-btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,0.9); border: 1px solid var(--grey-mid);
  border-radius: var(--radius-xs); padding: 4px 10px;
  font-size: 0.75rem; color: var(--grey); cursor: pointer;
}
.sig-clear-btn:hover { color: var(--danger); border-color: var(--danger); }
.sig-type-tabs {
  display: flex; gap: 0; margin-bottom: 12px;
  border: 1.5px solid var(--grey-mid); border-radius: var(--radius-sm); overflow: hidden;
}
.sig-type-tab {
  flex: 1; padding: 9px; font-size: 0.82rem; font-weight: 600;
  background: none; border: none; cursor: pointer; color: var(--grey);
  transition: all 0.2s;
}
.sig-type-tab.active { background: var(--green); color: var(--white); }

/* ── Audit log ─────────────────────────────────────────────── */
.audit-list { display: flex; flex-direction: column; gap: 0; }
.audit-item {
  display: flex; gap: 14px; padding: 12px 0;
  border-bottom: 1px solid var(--grey-mid);
}
.audit-item:last-child { border-bottom: none; }
.audit-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--green);
  flex-shrink: 0; margin-top: 5px;
}
.audit-action { font-weight: 600; font-size: 0.875rem; color: var(--dark); }
.audit-detail { font-size: 0.78rem; color: var(--grey); margin-top: 2px; }
.audit-time   { font-size: 0.72rem; color: var(--grey); margin-top: 2px; }

/* ── Auth pages ────────────────────────────────────────────── */
.auth-body { background: var(--grey-light); min-height: 100vh; }
.auth-shell {
  min-height: 100vh; display: flex; flex-direction: column;
}
@media (min-width: 768px) {
  .auth-shell { flex-direction: row; }
}

.auth-brand {
  background: var(--dark); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  padding: 48px 40px;
}
@media (min-width: 768px) {
  .auth-brand { width: 42%; min-height: 100vh; position: sticky; top: 0; }
}
.auth-brand-inner { max-width: 340px; }
.auth-logo {
  font-family: var(--font-display); font-size: 2.5rem;
  font-weight: 800; letter-spacing: -0.03em;
}
.auth-logo .logo-green { color: var(--white); }
.auth-logo .logo-co    { color: var(--green); }
.auth-brand-sub {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.18em;
  text-transform: uppercase; color: rgba(255,255,255,0.35); margin-top: 4px;
}
.auth-brand-tagline {
  font-size: 1.2rem; font-weight: 400; line-height: 1.5;
  color: rgba(255,255,255,0.75); margin-top: 28px;
}
.auth-brand-tagline strong { color: var(--green); font-weight: 700; }
.auth-brand-tagline em { font-style: normal; color: var(--white); font-weight: 600; }
.auth-brand-features { margin-top: 32px; display: flex; flex-direction: column; gap: 12px; }
.auth-brand-feature {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.875rem; color: rgba(255,255,255,0.65);
}
.auth-brand-feature-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(141,198,63,0.15); color: var(--green);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.auth-brand-dots { display: flex; gap: 6px; margin-top: 40px; }
.auth-brand-dots span {
  width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.2);
}
.auth-brand-dots span:first-child { background: var(--green); }

.auth-form-panel {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 32px 24px; min-height: 100vh;
}
.auth-form-inner { width: 100%; max-width: 400px; }

.auth-logo-mobile {
  display: block; font-family: var(--font-display); font-size: 1.6rem;
  font-weight: 800; letter-spacing: -0.02em; margin-bottom: 24px;
}
.auth-logo-mobile .logo-green { color: var(--dark); }
.auth-logo-mobile .logo-co    { color: var(--green); }
.auth-logo-mobile-sub {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--grey); margin-left: 6px; vertical-align: middle;
}
@media (min-width: 768px) { .auth-logo-mobile { display: none; } }

.auth-title {
  font-family: var(--font-display); font-size: 1.75rem;
  font-weight: 800; letter-spacing: -0.02em; color: var(--dark); margin-bottom: 6px;
}
.auth-subtitle { color: var(--grey); font-size: 0.9rem; margin-bottom: 28px; }
.auth-form { display: flex; flex-direction: column; gap: 0; }
.auth-help { font-size: 0.8rem; color: var(--grey); margin-top: 20px; text-align: center; line-height: 1.6; }
.auth-help a { color: var(--green); }
.auth-help a:hover { text-decoration: underline; }

/* ── OTP input ─────────────────────────────────────────────── */
.otp-input {
  text-align: center; font-size: 2rem; font-weight: 800;
  letter-spacing: 0.3em; padding: 16px;
}
/* ── Toggle switch ─────────────────────────────────────────── */
.toggle-label {
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.toggle-label input[type="checkbox"] { display: none; }
.toggle-switch {
  position: relative; width: 44px; height: 24px;
  background: var(--grey-mid); border-radius: 12px;
  transition: background 0.2s; flex-shrink: 0;
}
.toggle-switch::after {
  content: ''; position: absolute;
  top: 3px; left: 3px; width: 18px; height: 18px;
  background: white; border-radius: 50%;
  transition: left 0.2s; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle-label input:checked ~ .toggle-switch { background: var(--green); }
.toggle-label input:checked ~ .toggle-switch::after { left: 23px; }
.toggle-text { font-size: 0.88rem; font-weight: 500; color: var(--dark); }


/* ── Sign pages (public) ───────────────────────────────────── */
.sign-body {
  background: #f8f9fb; min-height: 100vh;
  font-family: var(--font-body);
}
.sign-header {
  background: var(--white); border-bottom: 1px solid var(--grey-mid);
  padding: 16px 20px; display: flex; align-items: center; justify-content: space-between;
}
.sign-header-logo {
  font-family: var(--font-display); font-size: 1.2rem; font-weight: 800;
}
.sign-trust-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.72rem; color: var(--grey); font-weight: 600;
}
.sign-trust-badge svg { stroke: var(--green); }

.sign-container { max-width: 720px; margin: 0 auto; padding: 24px 16px 48px; }
.sign-card {
  background: var(--white); border-radius: var(--radius);
  padding: 28px 24px; box-shadow: var(--shadow-md); margin-bottom: 16px;
}
.sign-doc-name {
  font-family: var(--font-display); font-size: 1.2rem;
  font-weight: 700; color: var(--dark); margin-bottom: 4px;
}
.sign-doc-meta { font-size: 0.82rem; color: var(--grey); }

.sign-footer {
  text-align: center; padding: 20px;
  font-size: 0.75rem; color: var(--grey); line-height: 1.7;
}
.sign-footer a { color: var(--green); }

/* ── PDF Viewer embed ──────────────────────────────────────── */
.pdf-embed {
  width: 100%; height: 700px; border: 1.5px solid var(--grey-mid);
  border-radius: var(--radius-sm); background: var(--grey-light);
}
@media (min-width: 768px) { .pdf-embed { height: 860px; } }

/* ── Field placer ──────────────────────────────────────────── */
.field-placer-wrap {
  position: relative; border: 1.5px solid var(--grey-mid);
  border-radius: var(--radius-sm); overflow: hidden; user-select: none;
  background: var(--white);
}
.field-placer-wrap img { width: 100%; display: block; pointer-events: none; }
.field-overlay { position: absolute; inset: 0; }
.sig-field {
  position: absolute; border: 2px dashed var(--green);
  background: rgba(141,198,63,0.1); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 600; color: var(--green);
  cursor: move; min-width: 80px; min-height: 36px;
}
.sig-field-label { pointer-events: none; text-align: center; padding: 4px; }
.sig-field-del {
  position: absolute; top: -8px; right: -8px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--danger); color: white;
  font-size: 0.7rem; font-weight: 700; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; line-height: 1;
}
.page-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.page-tab {
  padding: 6px 14px; border-radius: 20px; font-size: 0.8rem; font-weight: 600;
  border: 1.5px solid var(--grey-mid); background: var(--white); color: var(--grey); cursor: pointer;
}
.page-tab.active { background: var(--dark); color: var(--white); border-color: var(--dark); }

/* ── Recipient rows ────────────────────────────────────────── */
.recipient-row {
  display: grid; grid-template-columns: 1fr 1fr auto;
  gap: 10px; align-items: start; margin-bottom: 10px;
}
@media (min-width: 640px) {
  .recipient-row { grid-template-columns: 1fr 1fr 160px 36px; }
}
.remove-recipient {
  width: 36px; height: 36px; border-radius: var(--radius-xs);
  background: var(--danger-light); border: none; color: var(--danger);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  flex-shrink: 0; margin-top: 26px;
}
.remove-recipient:hover { background: var(--danger); color: var(--white); }

/* ── Responsive helpers ────────────────────────────────────── */
.hidden-mobile  { display: none !important; }
.col-hide-mobile { display: none; }
.hidden-desktop { display: block !important; }
@media (min-width: 768px) {
  .hidden-mobile  { display: revert !important; }
  .hidden-desktop { display: none !important; }
  .col-hide-mobile { display: table-cell; }
}

/* ── Utilities ─────────────────────────────────────────────── */
.text-green  { color: var(--green); }
.text-grey   { color: var(--grey); }
.text-danger { color: var(--danger); }
.text-small  { font-size: 0.8rem; }
.text-bold   { font-weight: 700; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-2 { gap: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap { display: flex; align-items: center; gap: 10px; }
.d-none { display: none; }

/* ── Phase 2 additions ───────────────────────────────────── */

/* Field placer fields — coloured by type */
.sig-field {
  position: absolute;
  border: 2px dashed #8DC63F;
  border-radius: 4px;
  background: rgba(141,198,63,0.08);
  cursor: default;
  display: flex;
  align-items: center;
  padding: 0 4px;
  min-height: 22px;
  pointer-events: auto;
}
.sig-field-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: white;
  background: #8DC63F;
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 20px);
}
.sig-field-del {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Remove recipient button */
.remove-recipient {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--danger);
  padding: 2px 4px;
  display: flex;
  align-items: center;
}

/* Sequence selector */
.seq-option {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 2px solid var(--grey-mid);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--grey);
  transition: all 0.15s;
  user-select: none;
}
.seq-option.active {
  border-color: var(--green);
  color: var(--dark);
  background: var(--green-light);
}

/* Recipient row */
.recipient-row {
  border: 1px solid var(--grey-mid);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
}
.recipient-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

/* Autocomplete */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: 340px;
  background: white;
  border: 1px solid var(--grey-mid);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}
.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.875rem;
}
.autocomplete-item:hover { background: var(--grey-light); }
.autocomplete-item span {
  display: block;
  font-size: 0.75rem;
  color: var(--grey);
}

/* CC badge */
.cc-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--grey-mid);
  color: var(--grey);
  padding: 2px 7px;
  border-radius: 4px;
}

/* Contacts page */
.contact-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ── Mobile layout fixes ─────────────────────────────────── */
@media (max-width: 767px) {
  .page-title { font-size: 1.25rem; }
  .page-subtitle { font-size: 0.8rem; }
  .stats-grid { gap: 8px; margin-bottom: 16px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.5rem; }
  .card { padding: 16px; margin-bottom: 14px; }
  .page-header { margin-bottom: 14px; }
  .nav-section-label { font-size: 0.6rem; padding: 6px 12px 2px; }
}

/* ── Stage 4 QA fixes ──────────────────────────────────────── */
/* Auth form panel: remove forced min-height on mobile */
@media (max-width: 767px) {
  .auth-form-panel { min-height: unset; padding: 24px 20px; }
  /* Hide the brand panel on mobile — mobile logo already shows in form panel */
  .auth-brand { display: none; }
}
