/* ============================================================
   Truemerge — Taskpane Design System
   Metaphor: paper, ink, and postage — a document is drafted,
   stamped with data, and sent. Every visual choice traces back
   to that: paper backgrounds, ink typography, a bold black
   "stamp" accent for the one truly primary action per screen,
   and dashed-border "fill in the blank" tag pills that look
   like mail-merge fields on a paper form.
   Monochrome: black, white, and gray only — no hue anywhere.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,500;8..60,600&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500&display=swap');

:root {
  /* Color */
  --ink:        #111111;   /* primary text, headers */
  --ink-soft:   #5C5C5C;   /* secondary text */
  --paper:      #F7F7F7;   /* app background */
  --paper-raised: #FFFFFF; /* card surfaces, sit slightly "above" paper */
  --stamp:      #000000;   /* single primary accent — bold black "stamp" */
  --stamp-soft: #EAEAEA;   /* stamp tint for subtle backgrounds */
  --slate:      #444444;   /* secondary interactive color (links, refresh, focus) */
  --slate-soft: #EFEFEF;
  --sage:       #454545;   /* "complete" state — distinct from --stamp (active) by weight, not hue */
  --sage-soft:  #F2F2F2;
  --line:       #DDDDDD;   /* dividers, borders */
  --line-strong:#BBBBBB;

  /* Type */
  --font-display: 'Source Serif 4', Georgia, serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', Consolas, monospace;

  /* Scale (compact — taskpanes are ~320-380px wide) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --radius: 6px;
  --radius-sm: 4px;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.pane {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-5);
}

/* ---------- Identity strip ---------- */
.signed-in {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
}
.signed-in .avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--slate-soft);
  color: var(--slate);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.signed-in .who {
  font-size: 11px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Toast — quick "what's happening" ping, independent of which tab is open ---------- */
.toast {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #fff;
  background: var(--ink);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-3);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.15s ease, max-height 0.15s ease, padding 0.15s ease, margin 0.15s ease;
}
/* No red for errors in a monochrome theme -- invert to white-on-black-border instead. */
.toast.error {
  background: #FFFFFF;
  color: var(--ink);
  border: 1px solid var(--ink);
  font-weight: 600;
}
.toast.visible {
  max-height: 60px;
  opacity: 1;
  padding: 8px var(--space-3);
  margin-bottom: var(--space-3);
}
.signed-in .who strong {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- Cards / step sections ---------- */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.card.active   { border-left-color: var(--stamp); }
.card.complete { border-left-color: var(--sage); }

.step-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  text-transform: uppercase;
  margin-bottom: var(--space-1);
}

.card h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  margin: 0 0 var(--space-2);
  color: var(--ink);
}

.card .hint {
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0 0 var(--space-3);
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: #EFEFEF; }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--stamp);
  border-color: var(--stamp);
  color: #FFF;
}
.btn-primary:hover { background: #2B2B2B; }

.btn-row { display: flex; gap: var(--space-2); }
.btn-row .btn { flex: 1; }

.btn-icon {
  padding: 8px 10px;
  font-size: 12px;
}

/* ---------- Status summary (Excel: connected data) ---------- */
.status-connected {
  background: var(--sage-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin-top: var(--space-3);
}
.status-connected .status-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink);
  margin-bottom: var(--space-2);
}
.status-connected .status-title .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--sage);
  flex-shrink: 0;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.chip {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--paper-raised);
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  border-radius: 3px;
  padding: 2px 6px;
}
.chip.required {
  background: var(--stamp-soft);
  border-color: var(--ink-soft);
  color: var(--ink);
  font-weight: 500;
}

.note {
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--line-strong);
}
.note code {
  font-family: var(--font-mono);
  background: var(--stamp-soft);
  color: var(--ink);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10.5px;
}

/* ---------- Form controls ---------- */
.field { margin-bottom: var(--space-3); }
.field label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: var(--space-1);
}
select, input[type="text"], textarea {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
}
select:focus, input:focus, textarea:focus {
  outline: 2px solid var(--slate);
  outline-offset: 1px;
  border-color: var(--slate);
}
textarea { resize: vertical; min-height: 56px; }
input::placeholder, textarea::placeholder { color: #A0A0A0; }

.select-row { display: flex; gap: var(--space-2); }
.select-row select {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Target toggle (Document / Subject / Body / Filename) ---------- */
.toggle-group {
  display: flex;
  background: #EDEDED;
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: var(--space-3);
}
.toggle-group button {
  flex: 1;
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 4px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 3px;
  cursor: pointer;
}
.toggle-group button.on {
  background: var(--ink);
  color: #FFF;
}

/* ---------- Tag pills — the signature element ---------- */
.tag-hint {
  font-size: 11px;
  color: var(--ink-soft);
  margin-bottom: var(--space-2);
}
#tag-search {
  margin-bottom: var(--space-2);
}
.tag-grid {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  max-height: 96px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px;
  margin-bottom: var(--space-3);
}
.tag-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
  background: var(--paper);
  border: 1px dashed var(--line-strong);
  border-radius: 3px;
  padding: 5px 8px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.tag-pill:hover {
  border-color: var(--stamp);
  border-style: solid;
  background: var(--stamp-soft);
  color: var(--ink);
}
.tag-pill.required {
  border-color: var(--ink-soft);
  background: var(--stamp-soft);
  color: var(--ink);
  border-style: solid;
  font-weight: 600;
}

/* ---------- Log ---------- */
.log-card {
  background: var(--ink);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
}
.log-card .step-label { color: #999999; margin-bottom: var(--space-2); }
.log-line {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #CCCCCC;
  line-height: 1.6;
}
.log-line .ts { color: #777777; margin-right: 6px; }
.log-line.error { color: #FFFFFF; font-weight: 600; }

/* ---------- Divider caption ---------- */
.field-caption {
  font-size: 10.5px;
  color: var(--ink-soft);
  margin-top: var(--space-1);
}

/* ---------- Validation checklist ---------- */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.checklist-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink);
  cursor: pointer;
}
.checklist-item input[type="checkbox"] {
  width: auto;
  accent-color: var(--stamp);
  flex-shrink: 0;
}
.checklist-item.locked {
  color: var(--ink-soft);
  cursor: default;
}

/* ---------- Report list — one card per recipient, no horizontal overflow ---------- */
.report-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.report-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}
.report-item-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 6px;
}
.report-item-index {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-soft);
  flex-shrink: 0;
}
.report-item-email {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  word-break: break-all;
}
.report-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 3px 0;
  font-size: 11.5px;
  color: var(--ink-soft);
}
.report-row .report-detail {
  display: block;
  font-size: 10.5px;
  color: var(--ink-soft);
  margin-top: 1px;
}
.report-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.report-icon.ok {
  color: #FFF;
  background: var(--ink);
}
.report-icon.fail {
  color: var(--ink);
  border: 1.5px solid var(--ink);
}

/* ---------- Auth gate ---------- */
#auth-gate .card { text-align: center; }
#auth-retry { width: 100%; margin-top: var(--space-2); }
