/* Palette pulled directly from pinestudio.cloud's own CSS variables
   (--sage/--pine/--ink/--muted/--white), extended with tinted status colors. */
:root {
  --sage: #E6EDE3;
  --pine: #2F4A3A;
  --pine-dark: #203328;
  --pine-tint: #DCE8E0;
  --ink: #141A16;
  --muted: #5E6B62;
  --white: #FBFCFA;
  --border: #DCE4DC;

  --ok-bg: #DCEAE1; --ok-ink: #26543F;
  --warn-bg: #FBE7C2; --warn-ink: #8A5A12;
  --info-bg: #E3EAE6; --info-ink: #41554B;
  --bad-bg: #FBE1DE; --bad-ink: #93281F;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 26, 22, 0.04), 0 10px 28px rgba(20, 26, 22, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-weight: 400;
  background: var(--sage);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--pine);
  color: #fff;
  padding: 26px 16px;
  display: flex;
  flex-direction: column;
}
.sidebar .brand { font-weight: 600; font-size: 1.1rem; margin-bottom: 30px; color: #fff; letter-spacing: -.01em; padding: 0 12px; }
.sidebar .brand small { display: block; font-weight: 400; font-size: 0.72rem; color: var(--sage); opacity: .65; margin-top: 2px; text-transform: uppercase; letter-spacing: .06em; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  color: var(--sage);
  opacity: .85;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background .15s ease, opacity .15s ease;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.08); opacity: 1; text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,0.14); color: #fff; opacity: 1; font-weight: 600; }
.sidebar .user-box { border-top: 1px solid rgba(255,255,255,0.14); padding: 14px 12px 0; margin-top: 10px; font-size: 0.85rem; color: var(--sage); }
.sidebar .user-box div:first-child { font-weight: 600; color: #fff; }
.sidebar .user-box a { color: var(--sage); opacity: .8; font-size: 0.82rem; }
.sidebar .user-box a:hover { opacity: 1; }

.main { flex: 1; min-width: 0; }
.content { padding: 36px 44px; max-width: 1080px; }

h1, h2, h3 { color: var(--ink); line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; font-weight: 600; margin: 0 0 6px; }
h2 { font-size: 1.1rem; font-weight: 600; }
.page-intro { color: var(--muted); margin: 0 0 26px; font-size: 0.95rem; }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat .num { font-size: 1.9rem; font-weight: 600; color: var(--pine); letter-spacing: -.02em; }
.stat .label { color: var(--muted); font-size: 0.84rem; margin-top: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 0.74rem; font-weight: 600; letter-spacing: .01em; }
.badge-planning, .badge-draft, .badge-todo { background: var(--info-bg); color: var(--info-ink); }
.badge-in_progress, .badge-sent { background: var(--warn-bg); color: var(--warn-ink); }
.badge-review { background: #E4E9F0; color: #3C5273; }
.badge-completed, .badge-paid, .badge-done, .badge-active, .badge-signed { background: var(--ok-bg); color: var(--ok-ink); }
.badge-on_hold, .badge-void, .badge-inactive { background: var(--bad-bg); color: var(--bad-ink); }

.progress-bar { height: 7px; background: var(--pine-tint); border-radius: 999px; overflow: hidden; }
.progress-bar > div { height: 100%; background: var(--pine); border-radius: 999px; }

.btn {
  display: inline-block;
  background: var(--pine);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: var(--pine-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }
.btn-secondary { background: var(--white); color: var(--pine); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--pine-tint); }
.btn-danger { background: var(--bad-ink); }
.btn-danger:hover { background: #701e17; }
.btn-sm { padding: 7px 13px; font-size: 0.82rem; }

.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-weight: 600; font-size: 0.84rem; margin-bottom: 6px; color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.94rem;
  font-family: inherit;
  background: var(--white);
  color: var(--ink);
  transition: border-color .15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--pine);
  box-shadow: 0 0 0 3px var(--pine-tint);
}
textarea { resize: vertical; min-height: 90px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 0.92rem; }
.alert-success { background: var(--ok-bg); color: var(--ok-ink); }
.alert-error { background: var(--bad-bg); color: var(--bad-ink); }

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, #243a2d 0%, var(--pine-dark) 45%, var(--ink) 100%);
  padding: 20px;
}
.auth-card {
  background: var(--white);
  width: 100%;
  max-width: 380px;
  padding: 38px 34px;
  border-radius: 20px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.3);
}
.auth-card .brand { text-align: center; font-weight: 600; font-size: 1.35rem; color: var(--ink); margin-bottom: 4px; letter-spacing: -.01em; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 0.86rem; margin-bottom: 26px; }
.auth-card .btn { width: 100%; text-align: center; margin-top: 6px; padding: 11px 18px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 0.85rem; color: var(--muted); }

.empty { color: var(--muted); font-style: italic; padding: 20px 0; font-size: 0.92rem; }
.text-muted { color: var(--muted); }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-gap { margin-top: 30px; }

.doc-viewer iframe { width: 100%; height: 62vh; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.doc-download { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; padding: 40px 20px; border: 1px dashed var(--border); border-radius: var(--radius-sm); background: var(--sage); text-align: center; }

.sig-pad-wrap { border: 1px dashed var(--border); border-radius: var(--radius-sm); background: #fff; overflow: hidden; }
.sig-canvas { width: 100%; height: 170px; display: block; cursor: crosshair; touch-action: none; }
.sig-pad-foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-top: 1px solid var(--border); font-size: 0.78rem; color: var(--muted); }

.consent-box { background: var(--sage); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; font-size: 0.85rem; color: var(--muted); line-height: 1.5; }
.consent-box label { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; color: var(--ink); cursor: pointer; }
.consent-box label input { margin-top: 3px; width: auto; }
.consent-box + .consent-box { margin-top: 10px; }

.cert-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.cert-row:last-child { border-bottom: none; }
.cert-row .k { color: var(--muted); }
.cert-row .v { font-weight: 600; text-align: right; }
.sig-img { max-width: 280px; display: block; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; background: #fff; }


/* ---------- E-signature: document frame + signature page ---------- */
.esign-steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 22px; flex-wrap: wrap; counter-reset: step; }
.esign-steps li { counter-increment: step; display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted); background: var(--white); border: 1px solid var(--border); padding: 6px 12px 6px 6px; border-radius: 999px; }
.esign-steps li::before { content: counter(step); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--pine-tint); color: var(--pine); font-weight: 600; font-size: .74rem; }
.esign-steps li.done { color: var(--ok-ink); }
.esign-steps li.done::before { content: "✓"; background: var(--pine); color: #fff; }
.esign-steps li.current { color: var(--ink); font-weight: 600; border-color: var(--pine); box-shadow: 0 0 0 3px var(--pine-tint); }

.doc-frame { background: #EEF1EC; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 22px; box-shadow: var(--shadow); }
.doc-frame-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 0 4px 12px; font-size: .86rem; color: var(--muted); }
.doc-frame iframe { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: 6px; background: #fff; display: block; }
.doc-frame .doc-download { background: #fff; }

.sig-page { background: #fff; border: 1px solid var(--border); border-radius: 6px; margin-top: 14px; padding: 44px 48px 40px; box-shadow: 0 2px 10px rgba(20,26,22,.06); font-family: Georgia, "Times New Roman", serif; color: #1d231f; }
.sig-page-head { text-align: center; max-width: 560px; margin: 0 auto 34px; }
.sig-page-kicker { font-family: 'Onest', sans-serif; text-transform: uppercase; letter-spacing: .16em; font-size: .7rem; color: var(--muted); }
.sig-page-title { font-size: 1.45rem; margin: 6px 0 12px; }
.sig-page-head p { font-style: italic; color: #4a554d; font-size: .95rem; line-height: 1.6; margin: 0; }
.sig-blocks { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 40px; }
.sig-block-org { font-family: 'Onest', sans-serif; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.sig-block-org strong { color: var(--ink); }
.sig-line { position: relative; height: 92px; border-bottom: 1.5px solid #1d231f; display: flex; align-items: flex-end; justify-content: flex-start; }
.sig-line img { max-height: 84px; max-width: 100%; margin-bottom: -10px; }
.sig-line img[hidden] { display: none; }
.sig-line img.sig-preview { opacity: .5; }
.sig-preview-label { position: absolute; right: 0; top: 4px; font-family: 'Onest', sans-serif; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #8A5A12; background: var(--warn-bg); padding: 3px 8px; border-radius: 999px; }
.sig-preview-label[hidden] { display: none; }
.sig-pending { font-family: 'Onest', sans-serif; font-size: .8rem; color: var(--muted); font-style: italic; padding-bottom: 8px; }
.sign-here-tag { position: absolute; left: 0; bottom: 12px; font-family: 'Onest', sans-serif; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: #4a3200; background: #F6C344; padding: 8px 18px 8px 12px; border-radius: 4px 0 0 4px; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); animation: signPulse 1.8s ease-in-out infinite; }
.sign-here-tag:hover { text-decoration: none; background: #F2B51E; }
.sign-here-tag[hidden] { display: none; }
@keyframes signPulse { 0%,100% { transform: translateX(0); } 50% { transform: translateX(5px); } }
.sig-meta { margin: 10px 0 0; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; font-family: 'Onest', sans-serif; }
.sig-meta div { min-width: 0; }
.sig-meta dt { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sig-meta dd { margin: 2px 0 0; font-size: .86rem; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.sig-stamp { margin-top: 12px; font-family: 'Onest', sans-serif; font-size: .74rem; color: var(--ok-ink); background: var(--ok-bg); display: inline-block; padding: 4px 10px; border-radius: 999px; }

.sign-banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; background: var(--pine); color: #fff; padding: 16px 20px; border-radius: var(--radius); margin-bottom: 18px; }
.sign-banner div div { opacity: .8; font-size: .88rem; margin-top: 2px; }
.sign-banner .btn { background: #F6C344; color: #4a3200; }
.sign-banner .btn:hover { background: #F2B51E; }
.sender-note { background: var(--white); border: 1px solid var(--border); border-left: 4px solid var(--pine); border-radius: var(--radius-sm); padding: 14px 18px; margin-bottom: 18px; font-size: .94rem; line-height: 1.55; }
.sender-note-from { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: 4px; }

/* ---------- Adopt your signature ---------- */
.adopt-card { border-color: var(--pine); box-shadow: 0 0 0 3px var(--pine-tint), var(--shadow); }
.adopt-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.adopt-tabs { display: inline-flex; background: var(--sage); border-radius: var(--radius-sm); padding: 4px; margin: 4px 0 14px; }
.adopt-tabs button { border: 0; background: transparent; font: inherit; font-weight: 600; font-size: .86rem; color: var(--muted); padding: 7px 18px; border-radius: 7px; cursor: pointer; }
.adopt-tabs button.active { background: var(--white); color: var(--pine); box-shadow: 0 1px 3px rgba(20,26,22,.12); }
.font-choices { display: grid; gap: 10px; }
.font-choice { display: flex; align-items: center; gap: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 16px; cursor: pointer; background: #fff; transition: border-color .15s, box-shadow .15s; }
.font-choice:has(input:checked) { border-color: var(--pine); box-shadow: 0 0 0 3px var(--pine-tint); }
.font-choice input { width: auto; accent-color: var(--pine); }
.font-sample { font-size: 2rem; color: #1B2A4A; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: .76rem; font-weight: 400 !important; overflow-wrap: anywhere; }


/* ---------- Signing-link (no account) pages ---------- */
.public-bar { background: var(--pine); color: #fff; }
.public-bar-inner { max-width: 980px; margin: 0 auto; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; }
.public-brand { font-weight: 600; font-size: 1.05rem; letter-spacing: -.01em; }
.public-secure { font-size: .8rem; opacity: .8; }
.public-main { max-width: 980px; margin: 0 auto; padding: 30px 20px 40px; }
.public-foot { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 30px; }

.tag-guest { display: inline-block; font-size: .7rem; font-weight: 600; color: var(--info-ink); background: var(--info-bg); padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.seg-choice { display: grid; gap: 8px; }
.seg-choice label { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; cursor: pointer; font-weight: 600; background: #fff; margin: 0; }
.seg-choice label span { font-weight: 400; color: var(--muted); }
.seg-choice label:has(input:checked) { border-color: var(--pine); box-shadow: 0 0 0 3px var(--pine-tint); }
.seg-choice input { width: auto; accent-color: var(--pine); }
[data-recipient][hidden] { display: none; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: ui-monospace, Menlo, monospace; font-size: .78rem; }

@media (max-width: 640px) {
  .sig-page { padding: 28px 20px; }
  .adopt-grid { grid-template-columns: 1fr; }
  .font-sample { font-size: 1.6rem; }
}

@media print {
  .sig-page { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .cert-sheet { box-shadow: none; break-inside: avoid; }
  .sign-here-tag { animation: none; }
}

@media print {
  .sidebar, .no-print, .public-bar, .public-foot { display: none !important; }
  .public-main { padding: 0 !important; }
  .main, .content { padding: 0 !important; margin: 0 !important; max-width: none !important; }
  body { background: #fff !important; }
}

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .content { padding: 20px; }
}
