:root {
  --ocean: #206090; /* deep brand blue */
  --deep: #164a72;
  --teal: #2ba8a8; /* brand teal */
  --sky: #7fc8d8;
  --ink: #1f2937;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(22, 74, 114, 0.12), 0 6px 20px rgba(22, 74, 114, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(120deg, var(--deep), var(--ocean) 60%, var(--teal));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 5;
}
.logo-chip {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.logo-chip img { width: 30px; height: 30px; }
.app-title .brand { font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.app-title .sub { font-size: 11px; opacity: 0.85; }

#app { padding: 14px; display: flex; flex-direction: column; gap: 14px; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 13px; color: var(--ocean); text-transform: uppercase; letter-spacing: 0.04em; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Attachments */
.attachment-list { display: flex; flex-direction: column; gap: 8px; }
.att {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.att:hover { border-color: var(--teal); background: #f5fbfb; }
.att .doc { font-size: 20px; }
.att .name { font-weight: 600; }
.att .size { color: var(--muted); font-size: 12px; }

.or-upload { margin-top: 10px; }

/* Buttons */
button, .file-btn {
  font: inherit; cursor: pointer; border-radius: 9px; padding: 9px 14px;
  border: 1px solid transparent; transition: filter 0.15s, background 0.15s;
}
.primary { background: var(--ocean); color: #fff; }
.primary:hover { background: var(--deep); }
.primary.alt { background: var(--teal); }
.primary.alt:hover { filter: brightness(0.93); }
.ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.ghost:hover { border-color: var(--ocean); color: var(--ocean); }
.wide { width: 100%; }
.file-btn { display: inline-block; background: #fff; border: 1px dashed var(--sky); color: var(--ocean); text-align: center; }
.file-btn.wide { display: block; }

.row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.row.placed { justify-content: space-between; }
.spacer { flex: 1; }

/* PDF stage */
.pdf-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.pdf-toolbar .hint { color: var(--muted); font-size: 12px; }
#page-info { font-variant-numeric: tabular-nums; }
.pdf-stage {
  overflow: hidden; /* whole page is scaled to fit — never scroll */
  border: 1px solid var(--line); border-radius: 10px; background: #fafafa;
  display: flex; justify-content: center; align-items: flex-start;
  width: 100%; padding: 8px;
}
/* Holder hugs the canvas so the signature overlay can be positioned relative
   to the page (0,0 = top-left of the canvas) even when the page is centered. */
.pdf-holder { position: relative; line-height: 0; }
#pdf-canvas { display: block; }
.sig-overlay {
  position: absolute; top: 20px; left: 20px; width: 160px;
  cursor: move; user-select: none; touch-action: none;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}

/* Signature capture */
.sig-source { margin-top: 12px; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab { background: #eef2f6; color: var(--muted); }
.tab.active { background: var(--ocean); color: #fff; }
.sig-pad {
  width: 100%; height: 130px; background: #fff;
  border: 1px dashed var(--sky); border-radius: 10px; touch-action: none;
}
#sig-size { vertical-align: middle; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; font: inherit; color: var(--ink); }
.send-row { margin: 10px 0; }
.send-row .primary { flex: 1; }

/* Layout: single column by default (narrow task pane). */
.sign-grid { display: block; }
.pane-controls .sig-source { margin-top: 0; }
.send-block { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---- Full-screen mode: URL page or Outlook dialog — full-width, two columns ---- */
body.full-mode #app {
  max-width: 100%;
  margin: 0;
  padding: 12px 18px;
}
/* Full-page document view on the LEFT, all options on the RIGHT. */
body.full-mode .sign-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}
body.full-mode .pane-pdf { min-width: 0; }
body.full-mode .pane-controls {
  position: sticky;
  top: 12px;
  align-self: start;
}
body.full-mode .sig-pad { height: 160px; }
body.full-mode #step-sign { padding: 16px; border: none; box-shadow: none; }
/* Let the document fill the height of the window. */
body.full-mode .pdf-stage { background: #f8fafc; }

/* Status toast */
.status {
  position: sticky; bottom: 0; margin-top: 4px;
  padding: 10px 12px; border-radius: 10px; font-size: 13px;
}
.status.info { background: #eaf3fa; color: var(--deep); border: 1px solid #cfe3f2; }
.status.ok { background: #e9f7f2; color: #0f6b52; border: 1px solid #bfe8db; }
.status.err { background: #fdecec; color: #a12626; border: 1px solid #f6c9c9; }
