/* ===========================================================================
   Intake → Onboarding — operations console
   Aesthetic: establishment-grade professional-services tool.
   Warm paper · deep ink-navy · brass accent · IBM Plex engineering type with a
   Bricolage Grotesque display · mono for all structured system output.
   =========================================================================== */

:root {
  --paper:      #f3efe6;   /* warm paper background */
  --paper-2:    #efe9dd;   /* recessed */
  --surface:    #fdfcf9;   /* card face */
  --surface-2:  #f8f5ee;   /* inset (record grid, kpi) */
  --ink:        #1a2331;   /* primary text */
  --ink-soft:   #414c5c;
  --muted:      #7a7566;   /* labels, secondary */
  --faint:      #a49d8c;
  --navy:       #1d3352;   /* primary brand */
  --navy-deep:  #142338;
  --navy-tint:  #e7ecf3;
  --brass:      #a97a2f;   /* accent */
  --brass-deep: #8a621f;
  --brass-tint: #f0e6d2;
  --line:       #e2dccc;   /* hairline on paper */
  --line-soft:  #ece7db;
  --line-strong:#d3ccb9;

  --conflict:   #a83a2c;
  --conflict-bg:#f6e5df;
  --deadline:   #a06d1c;
  --deadline-bg:#f2e7cf;
  --vendor:     #2f5d80;
  --vendor-bg:  #e0e9f0;
  --compliance: #55606f;
  --compliance-bg:#e7e7e6;
  --ok:         #3f6b52;

  --shadow-sm: 0 1px 2px rgba(20,35,56,.05), 0 1px 1px rgba(20,35,56,.04);
  --shadow-md: 0 1px 2px rgba(20,35,56,.05), 0 10px 26px -12px rgba(20,35,56,.16);

  --font-display: "Bricolage Grotesque", Georgia, serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --wrap: 1220px;
}

* { box-sizing: border-box; }
/* Author display rules (.reject{display:flex}, .btn{display:inline-flex}, etc.) otherwise
   override the UA [hidden] rule — force hidden elements to actually hide. */
[hidden] { display: none !important; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.5;
  font-feature-settings: "cv05" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-image:
    radial-gradient(1100px 460px at 72% -140px, rgba(255,255,255,.85), rgba(255,255,255,0) 70%),
    radial-gradient(900px 400px at 8% -60px, rgba(29,51,82,.05), rgba(29,51,82,0) 65%);
  min-height: 100vh;
}

/* faint paper grain overlay for warmth/depth */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 28px; position: relative; z-index: 1; }

/* kicker — the mono micro-label that sits above headings */
.kicker {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; color: var(--brass-deep);
}

/* ---------- masthead ---------- */
.masthead { position: relative; z-index: 2; padding-top: 26px; }
.masthead-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; padding-bottom: 18px; flex-wrap: wrap; }
.brand { min-width: 0; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center;
  color: #fff; background: linear-gradient(150deg, var(--navy) 0%, var(--navy-deep) 100%);
  border-radius: 11px; box-shadow: 0 2px 8px -2px rgba(20,35,56,.45), inset 0 1px 0 rgba(255,255,255,.12);
}
.brand-name {
  font-family: var(--font-display); font-weight: 700; font-size: 1.28rem; letter-spacing: -.01em;
  color: var(--ink); line-height: 1.05;
}
.brand-sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.masthead-badges { display: flex; gap: 8px; align-items: center; }
.badge {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; letter-spacing: .04em;
  padding: 5px 10px; border-radius: 999px; white-space: nowrap;
}
.badge-synthetic { color: var(--brass-deep); background: var(--brass-tint); border: 1px solid #e4d4b0; }
.rule { height: 2px; background: linear-gradient(90deg, var(--brass) 0%, rgba(169,122,47,.25) 32%, var(--line) 32%, var(--line) 100%); }

/* ---------- intro ---------- */
.intro { padding: 34px 0 8px; max-width: 820px; }
.intro-lead { font-size: 1.12rem; line-height: 1.55; color: var(--ink); margin: 0 0 10px; }
.intro-lead em { font-style: normal; color: var(--brass-deep); font-weight: 600; }
.intro-sub { font-size: .92rem; color: var(--muted); margin: 0; }

/* ---------- tabs ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 20px; }
.tab {
  appearance: none; cursor: pointer; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 16px; min-width: 210px; flex: 1 1 210px; max-width: 340px;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease, background .18s ease;
  position: relative;
}
.tab:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.tab .tab-kicker { display: block; }
.tab .tab-name {
  font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; color: var(--ink);
  margin: 3px 0 2px; letter-spacing: -.005em;
}
.tab .tab-blurb { font-size: .8rem; color: var(--muted); line-height: 1.4; }
.tab[aria-selected="true"] {
  background: linear-gradient(180deg, #fff, var(--surface));
  border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy), var(--shadow-md);
}
.tab[aria-selected="true"]::before {
  content: ""; position: absolute; left: 16px; right: 16px; bottom: -1px; height: 2px;
  background: var(--brass); border-radius: 2px;
}

/* ---------- console layout ---------- */
.console { display: grid; grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr); gap: 22px; align-items: start; min-width: 0; }
/* min-width:0 lets grid/flex children shrink below content width, so the wide KPI table
   and node chain scroll inside their own overflow-x containers instead of widening the page. */
.pane { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-md); min-width: 0; }
.pane-input { padding: 22px 22px 24px; position: sticky; top: 18px; }
.pane-output { padding: 22px 22px 26px; min-height: 320px; }
.pane-head { margin-bottom: 14px; }
.pane-head-out { display: flex; align-items: center; justify-content: space-between; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); margin-bottom: 18px; }
.pane-title { font-family: var(--font-display); font-weight: 700; font-size: 1.32rem; margin: 6px 0 4px; letter-spacing: -.015em; line-height: 1.1; }
.pane-blurb { font-size: .86rem; color: var(--muted); margin: 0; line-height: 1.45; }

.field-label { display: block; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 4px 0 7px; }
.intake-box {
  width: 100%; min-height: 268px; resize: vertical;
  font-family: var(--font-mono); font-size: 12.6px; line-height: 1.62; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 15px; outline: none; transition: border-color .16s ease, box-shadow .16s ease;
  white-space: pre-wrap;
}
.intake-box:focus { border-color: #a9bdd6; box-shadow: 0 0 0 3px var(--navy-tint); background: #fff; }

.run-row { display: flex; align-items: center; gap: 10px; margin-top: 15px; }
.btn {
  appearance: none; cursor: pointer; font-family: var(--font-body); font-weight: 600; font-size: .94rem;
  border-radius: 10px; padding: 11px 18px; border: 1px solid transparent; transition: all .16s ease;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary { background: var(--navy); color: #fff; box-shadow: 0 2px 10px -3px rgba(29,51,82,.6), inset 0 1px 0 rgba(255,255,255,.1); }
.btn-primary:hover { background: var(--navy-deep); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .55; cursor: default; transform: none; }
.btn-caret { transition: transform .16s ease; }
.btn-primary:hover .btn-caret { transform: translateX(2px); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--line-strong); }

.live-note { margin-top: 18px; padding: 15px 15px 16px; background: var(--brass-tint); border: 1px solid #e6d5af; border-radius: var(--radius-sm); }
.live-note-head { font-size: .86rem; color: var(--ink-soft); margin-bottom: 12px; }
.live-note-head strong { color: var(--brass-deep); }
.code-row { display: flex; flex-direction: column; gap: 6px; }
.code-input {
  font-family: var(--font-mono); font-size: 13px; letter-spacing: .04em;
  border: 1px solid #ddca9f; border-radius: 8px; padding: 10px 12px; background: #fff; outline: none; color: var(--ink);
}
.code-input:focus { border-color: var(--brass); box-shadow: 0 0 0 3px rgba(169,122,47,.16); }
.code-input.err { border-color: var(--conflict); box-shadow: 0 0 0 3px rgba(168,58,44,.14); }
.code-hint { font-size: .76rem; color: var(--muted); }

/* ---------- progress ---------- */
.progress { padding: 8px 2px 4px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.steps li {
  display: flex; align-items: center; gap: 12px; padding: 9px 4px;
  font-size: .92rem; color: var(--faint); transition: color .3s ease;
}
.steps li .tick {
  width: 20px; height: 20px; flex: 0 0 auto; border-radius: 50%; border: 1.5px solid var(--line-strong);
  display: grid; place-items: center; transition: all .3s ease; position: relative;
}
.steps li.active { color: var(--ink); }
.steps li.active .tick { border-color: var(--navy); }
.steps li.active .tick::after {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--navy);
  animation: pulse 1s ease-in-out infinite;
}
.steps li.done { color: var(--ink-soft); }
.steps li.done .tick { border-color: var(--ok); background: var(--ok); }
.steps li.done .tick::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 1.8px 1.8px 0; transform: rotate(43deg) translateY(-1px); }
@keyframes pulse { 0%,100% { transform: scale(.7); opacity: .5; } 50% { transform: scale(1); opacity: 1; } }

/* ---------- reject ---------- */
.reject { display: flex; gap: 14px; padding: 20px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); align-items: flex-start; }
.reject-icon { color: var(--deadline); flex: 0 0 auto; margin-top: 1px; }
.reject-body h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; margin: 0 0 5px; }
.reject-body p { margin: 0; font-size: .92rem; color: var(--ink-soft); line-height: 1.5; }

/* ---------- results ---------- */
.results { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 19px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-count, .card-note { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .04em; color: var(--faint); }

/* reveal animation */
.reveal { opacity: 0; transform: translateY(10px); }
.reveal.in { animation: rise .5s cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* record */
.record-title { font-family: var(--font-mono); font-weight: 600; font-size: 1rem; color: var(--navy-deep); margin: 0 0 14px; line-height: 1.35; letter-spacing: -.005em; }
.record-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); overflow: hidden; }
.record-grid .rf { background: var(--surface-2); padding: 10px 13px; }
.record-grid .rf.full { grid-column: 1 / -1; }
.rf dt { font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.rf dd { margin: 0; font-size: .9rem; color: var(--ink); line-height: 1.42; }
.rf dd.na { color: var(--faint); font-style: italic; }

/* checklist */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: grid; grid-template-columns: 22px 1fr; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.checklist li:last-child { border-bottom: 0; padding-bottom: 2px; }
.chk-box { width: 18px; height: 18px; margin-top: 1px; border: 1.5px solid var(--line-strong); border-radius: 5px; background: var(--surface-2); }
.chk-main { min-width: 0; }
.chk-task { font-size: .93rem; color: var(--ink); font-weight: 500; line-height: 1.4; }
.chk-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.owner-chip {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; letter-spacing: .02em;
  color: var(--navy-deep); background: var(--navy-tint); border: 1px solid #cfdaea;
  padding: 3px 8px; border-radius: 6px; white-space: nowrap;
}
.chk-timing { font-size: .8rem; color: var(--muted); }
.chk-note { font-size: .8rem; color: var(--faint); font-style: italic; margin-top: 4px; line-height: 1.4; }

/* email */
.email { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); overflow: hidden; }
.email-meta { padding: 12px 15px; border-bottom: 1px solid var(--line-soft); background: #fff; }
.email-meta > div { display: flex; gap: 10px; font-size: .87rem; padding: 2px 0; }
.email-k { font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); width: 58px; flex: 0 0 auto; padding-top: 2px; }
.email-v { color: var(--ink); font-weight: 500; }
.email-body { padding: 15px 16px; font-size: .92rem; line-height: 1.62; color: var(--ink-soft); white-space: pre-wrap; }
.copy-btn { appearance: none; cursor: pointer; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; transition: all .15s ease; }
.copy-btn:hover { color: var(--navy); border-color: var(--navy); }
.copy-btn.copied { color: var(--ok); border-color: var(--ok); }

/* kpi */
.kpi-scroll { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.kpi-table { border-collapse: collapse; width: 100%; font-family: var(--font-mono); font-size: 11.5px; white-space: nowrap; }
.kpi-table th { text-align: left; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; font-size: 9.5px; color: var(--muted); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--line); }
.kpi-table td { padding: 10px 12px; color: var(--ink); border-right: 1px solid var(--line-soft); }
.kpi-table th:not(:last-child) { border-right: 1px solid var(--line-soft); }
.kpi-table td:last-child { border-right: 0; }
.kpi-table td.na { color: var(--faint); font-style: italic; }

/* flags */
.flags { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.flag { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid; align-items: start; }
.flag-badge { font-family: var(--font-mono); font-size: 9.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding: 4px 8px; border-radius: 5px; white-space: nowrap; align-self: start; margin-top: 1px; }
.flag-main { min-width: 0; }
.flag-label { font-size: .9rem; font-weight: 600; color: var(--ink); line-height: 1.35; }
.flag-detail { font-size: .84rem; color: var(--ink-soft); line-height: 1.45; margin-top: 3px; }
.flag-action { font-size: .82rem; color: var(--muted); margin-top: 5px; display: flex; gap: 6px; }
.flag-action::before { content: "→"; color: var(--brass); font-weight: 600; }
.flag.t-conflict { background: var(--conflict-bg); border-color: #e7cabf; }
.flag.t-conflict .flag-badge { color: #fff; background: var(--conflict); }
.flag.t-deadline { background: var(--deadline-bg); border-color: #e6d3a6; }
.flag.t-deadline .flag-badge { color: #fff; background: var(--deadline); }
.flag.t-vendor { background: var(--vendor-bg); border-color: #c8d7e2; }
.flag.t-vendor .flag-badge { color: #fff; background: var(--vendor); }
.flag.t-compliance { background: var(--compliance-bg); border-color: #d4d4d2; }
.flag.t-compliance .flag-badge { color: #fff; background: var(--compliance); }

/* chain (n8n/make node diagram) */
.card-chain { background: linear-gradient(180deg, var(--surface), var(--surface-2)); }
.chain-note { font-size: .84rem; color: var(--muted); margin: 0 0 15px; line-height: 1.5; }
.chain-note strong { color: var(--ink); }
.chain-scroll { overflow-x: auto; padding: 4px 2px 8px; }
.chain { list-style: none; margin: 0; padding: 0; display: flex; align-items: stretch; gap: 0; min-width: min-content; }
.chain li { display: flex; align-items: center; }
.chain .node {
  font-size: .78rem; font-weight: 500; color: var(--ink); background: #fff;
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 12px; line-height: 1.25;
  width: 118px; min-height: 52px; display: flex; align-items: center; box-shadow: var(--shadow-sm);
  position: relative;
}
.chain li:first-child .node { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy), var(--shadow-sm); }
.chain li:nth-child(3) .node { border-color: var(--brass); box-shadow: 0 0 0 1px rgba(169,122,47,.5), var(--shadow-sm); }
.chain .node .node-i { font-family: var(--font-mono); font-size: 9px; color: var(--faint); position: absolute; top: 5px; right: 8px; }
.chain .conn { width: 26px; height: 2px; background: var(--line-strong); position: relative; flex: 0 0 auto; }
.chain .conn::after { content: ""; position: absolute; right: -1px; top: -3px; border: 4px solid transparent; border-left-color: var(--line-strong); }

/* ---------- footer ---------- */
.footer { margin: 40px 0 48px; padding-top: 22px; border-top: 1px solid var(--line); text-align: center; }
.foot-line { font-size: .84rem; color: var(--muted); }
.foot-hygiene { display: inline-flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.foot-hygiene .dot { color: var(--faint); }
.foot-contact { margin-top: 9px; color: var(--ink-soft); }
.foot-contact a { color: var(--brass-deep); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .15s; }
.foot-contact a:hover { border-bottom-color: var(--brass); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .console { grid-template-columns: 1fr; }
  .pane-input { position: static; }
  .intake-box { min-height: 200px; }
  .record-grid { grid-template-columns: 1fr; }
  .wrap { padding: 0 18px; }
  .intro-lead { font-size: 1.04rem; }
  .masthead-inner { align-items: flex-start; }
}
@media (max-width: 560px) {
  body { font-size: 15px; }
  .brand-sub { display: none; }
  .tab { min-width: 100%; max-width: none; }
  .pane-input, .pane-output { padding: 18px 15px; }
  .intro { padding-top: 26px; }
}

/* ---------- print (a COO may PDF the output) ---------- */
@media print {
  .grain, .tabs, .pane-input, .masthead-badges, .copy-btn, .card-chain, .progress { display: none !important; }
  body { background: #fff; }
  .console { grid-template-columns: 1fr; }
  .pane, .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .reveal { opacity: 1 !important; transform: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .05ms !important; }
  .reveal { opacity: 1; transform: none; }
}
