/* CRM Pros brand, operate-tool density. Brand tokens shared with the other Reimer demo apps.
   Motion: transform and opacity only. One radius (6px) for controls, 4px for table media. */
:root {
  --blue: #0427E6; --blue-2: #0320B8; --blue-soft: #EEF1FF; --ink: #05070F; --ground: #FBFCFF;
  --bg: #FBFCFF; --panel: #FFFFFF; --txt: #05070F; --muted: #5B6176; --edge: #DDE2F0; --hair: #ECEFF7;
  --code: #F3F5FB; --focus: #0427E6; --danger: #B42323; --ok: #157A47; --warn: #8A5A00; --warn-bg: #FFF7DB;
  --on-blue: #fff;
  --f-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --pad: 24px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #05070F; --panel: #0B0F1E; --txt: #F4F6FC; --muted: #9AA3C0; --edge: #1E2540; --hair: #151A30; --code: #090C18;
    --focus: #7F95FF; --blue-soft: #0F1738; --danger: #FF8A8A; --ok: #5AD48F; --warn: #F2C45A; --warn-bg: #2A2410;
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--txt); font: 400 14px/1.5 var(--f-ui); -webkit-font-smoothing: antialiased; min-height: 100vh; padding-bottom: 44px; }
h1, h2, h3 { font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin: 0; }
h2 { font-size: 18px; } h3 { font-size: 14px; letter-spacing: -.005em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.only-dark { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .only-light { display: none; } :root:not([data-theme="light"]) .only-dark { display: block; } }
.mono, .mono-label, td.mono, .tc { font-family: var(--f-mono); }
.mono-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); }
.tc { font-size: 12px; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skiplink { position: absolute; left: -999px; top: 6px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 6px; z-index: 300; }
.skiplink:focus { left: 8px; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px var(--pad); border-bottom: 1px solid var(--edge); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand img { display: block; height: 26px; width: auto; }
.brand .sep { width: 1px; height: 22px; background: var(--edge); }
.brand h1 { font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.health { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.hd { display: inline-flex; align-items: center; gap: 7px; font: 500 11px/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hd i { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--ok); display: inline-block; position: relative; }
.hd i::after { content: ""; position: absolute; inset: 1px; border-radius: 50%; background: var(--ok); }
.hd.off i { border-color: var(--muted); } .hd.off i::after { background: transparent; }

/* stepper: three horizontal stages joined by a hairline */
.stepper { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--edge); background: var(--panel); }
.step { display: flex; align-items: center; gap: 12px; text-align: left; background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px var(--pad); cursor: pointer; margin-bottom: -1px;
  transition: background-color .14s var(--ease), border-color .14s var(--ease); }
.step:hover { background: var(--blue-soft); }
.step:active { background: var(--hair); }
.step[aria-current="step"] { border-bottom-color: var(--blue); }
.step .num { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--edge); display: grid; place-items: center; font: 600 12px/1 var(--f-mono); color: var(--muted); flex: none; }
.step[aria-current="step"] .num { background: var(--blue); border-color: var(--blue); color: #fff; }
.step.done .num { border-color: var(--ok); color: var(--ok); }
.st-label { display: flex; flex-direction: column; font-weight: 600; font-size: 14px; line-height: 1.2; }
.st-label small { font: 400 12px/1.3 var(--f-mono); color: var(--muted); margin-top: 2px; }

/* work surface */
.surface { padding: 20px var(--pad) 28px; max-width: 1480px; margin: 0 auto; outline: none; }
.view[hidden] { display: none; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.view-head p { color: var(--muted); max-width: 70ch; margin-top: 4px; }

/* buttons: one shape. solid blue primary, outlined secondary */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--edge); background: var(--panel); color: var(--txt); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: transform .14s var(--ease), background-color .14s var(--ease), border-color .14s var(--ease), opacity .14s var(--ease); }
.btn:hover { border-color: var(--blue); background: var(--blue-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn.primary:hover { background: var(--blue-2); border-color: var(--blue-2); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn[disabled]:hover { background: var(--panel); border-color: var(--edge); }
.btn.primary[disabled]:hover { background: var(--blue); border-color: var(--blue); }

.input { width: 100%; min-height: 36px; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--edge); background: var(--panel); transition: border-color .14s var(--ease), box-shadow .14s var(--ease); }
.input:hover { border-color: #B9C3E6; }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input.mono { font-family: var(--f-mono); font-size: 12.5px; }
textarea.input { min-height: 84px; resize: vertical; }
.field-err { color: var(--danger); font-weight: 600; font-size: 13px; margin-top: 6px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--blue); margin: 0; }

/* source bar */
.sourcebar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; border: 1px solid var(--edge); border-radius: 6px; background: var(--panel); padding: 14px; margin-bottom: 14px; }
.sb-left { display: grid; gap: 10px; min-width: 0; }
.sb-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sb-row .input { flex: 1 1 280px; }
.drop { width: 260px; border: 1px dashed #A9B6EE; border-radius: 6px; display: grid; place-items: center; padding: 10px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; position: relative;
  background: radial-gradient(circle at 92% 50%, var(--blue-soft) 0 12px, transparent 13px 20px, var(--blue-soft) 21px 22px, transparent 23px) center / 100% 100% no-repeat;
  transition: border-color .14s var(--ease), background-color .14s var(--ease); }
.drop:hover, .drop[data-over="true"] { border-color: var(--blue); background-color: var(--blue-soft); }
.drop strong { color: var(--txt); display: block; font-size: 13px; }

/* tables */
.tablewrap { border: 1px solid var(--edge); border-radius: 6px; background: var(--panel); overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; padding: 9px 12px; font: 500 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--edge); background: var(--code); white-space: nowrap; position: sticky; top: 0; }
td { padding: 8px 12px; border-bottom: 1px solid var(--hair); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color .14s var(--ease); }
tbody tr:hover { background: var(--code); }
td.thumbcell { width: 110px; padding-right: 0; }
.thumb { display: block; width: 96px; aspect-ratio: 16/10; object-fit: cover; border-radius: 4px; background: var(--hair); border: 1px solid var(--edge); }
.old { font-family: var(--f-mono); font-size: 12px; color: var(--muted); word-break: break-all; max-width: 220px; }
td .input { min-width: 300px; }
.why { color: var(--muted); font-size: 12px; max-width: 280px; }
.tag { display: inline-block; font: 600 10.5px/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; padding: 4px 7px; border-radius: 4px; border: 1px solid var(--edge); color: var(--muted); white-space: nowrap; }
.tag.blue { border-color: var(--blue); color: var(--blue); }
.tag.ok { border-color: var(--ok); color: var(--ok); } .tag.bad { border-color: var(--danger); color: var(--danger); } .tag.warn { border-color: var(--warn); color: var(--warn); background: var(--warn-bg); }
.edited { font: 600 10px/1 var(--f-mono); color: var(--blue); letter-spacing: .06em; margin-left: 6px; }

.actions { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 14px; }
.actions .left, .actions .right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.note { border: 1px solid #C7D0F5; background: var(--blue-soft); border-radius: 6px; padding: 10px 12px; font-size: 13px; }
.note.bad { border-color: var(--danger); background: var(--panel); color: var(--danger); font-weight: 600; }
.note.ok { border-color: var(--ok); background: var(--panel); }
.note .mono { font-size: 12px; word-break: break-all; }

.empty { border: 1px dashed var(--edge); border-radius: 6px; padding: 36px 20px; text-align: center; color: var(--muted);
  background: radial-gradient(circle at 96% 50%, var(--blue-soft) 0 16px, transparent 17px 26px, var(--blue-soft) 27px 29px, transparent 30px) center / 100% 100% no-repeat; }
.empty strong { display: block; color: var(--txt); margin-bottom: 4px; font-size: 15px; }
.skel { background: linear-gradient(90deg, var(--hair), var(--code), var(--hair)); background-size: 200% 100%; border-radius: 4px; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }
tr.working td { opacity: .85; }

/* sort: bucket ledger and contact sheets */
.ledger { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border: 1px solid var(--edge); border-radius: 6px; background: var(--panel); margin-bottom: 18px; }
.ledger > div { padding: 12px 14px; border-right: 1px solid var(--hair); min-width: 0; }
.ledger > div:last-child { border-right: 0; }
.ledger .n { font: 600 24px/1 var(--f-mono); margin: 6px 0 4px; letter-spacing: -.02em; }
.ledger .o { font: 400 11px/1.3 var(--f-mono); color: var(--muted); }
.bucket { margin-bottom: 20px; }
.bucket > header { display: flex; align-items: baseline; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--edge); margin-bottom: 10px; flex-wrap: wrap; }
.bucket > header p { color: var(--muted); font-size: 12px; }
.sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0; border-left: 1px solid var(--hair); border-top: 1px solid var(--hair); }
.frame { border-right: 1px solid var(--hair); border-bottom: 1px solid var(--hair); padding: 10px; display: grid; gap: 6px; align-content: start; background: var(--panel); min-width: 0; }
.frame .thumb { width: 100%; }
.frame .nm { font: 500 11.5px/1.3 var(--f-mono); word-break: break-all; }
.frame .rs { font-size: 12px; color: var(--muted); line-height: 1.4; }
.frame .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* usages: pipeline list + stage */
.ugrid > * { min-width: 0; }
.pipe .needs, .pipe .does, .pipe .ttl { overflow-wrap: anywhere; }
.ugrid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 20px; align-items: start; }
.panel { border: 1px solid var(--edge); border-radius: 6px; background: var(--panel); }
.panel > header { padding: 10px 14px; border-bottom: 1px solid var(--edge); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel .pad { padding: 14px; }
.pipe { list-style: none; margin: 0; padding: 0; position: relative; }
.pipe li { display: grid; grid-template-columns: 22px 34px minmax(0, 1fr) auto; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--hair); align-items: start; transition: background-color .14s var(--ease); }
.pipe li:last-child { border-bottom: 0; }
.pipe li:hover { background: var(--code); }
.pipe .idx { font: 600 12px/22px var(--f-mono); color: var(--muted); }
.pipe .ttl { font-weight: 600; line-height: 22px; }
.pipe .does { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.pipe .needs { font: 400 11.5px/1.4 var(--f-mono); margin-top: 4px; color: var(--muted); }
.pipe .needs b { color: var(--txt); font-weight: 500; }
.pipe .state { font: 500 11px/22px var(--f-mono); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.st-queued { color: var(--muted); } .st-running { color: var(--blue); } .st-done { color: var(--ok); } .st-failed { color: var(--danger); } .st-skipped { color: var(--muted); }
.st-running::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--blue); margin-right: 6px; animation: pulse 1s var(--ease) infinite; }
@keyframes pulse { 0% { transform: scale(.7); opacity: 1; } 100% { transform: scale(1.4); opacity: .2; } }
.inputs { display: grid; gap: 12px; }
.inputs label { display: grid; gap: 5px; }
.plans { display: grid; gap: 10px; }
.plan-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.plan-row .st { font: 400 11.5px/1.3 var(--f-mono); color: var(--muted); grid-column: 2 / 4; margin-top: -4px; word-break: break-all; }
.cmds { margin: 8px 0 0; padding: 10px; background: var(--code); border: 1px solid var(--hair); border-radius: 4px; font: 400 11.5px/1.5 var(--f-mono); white-space: pre-wrap; word-break: break-all; max-height: 220px; overflow: auto; }
.player { width: 100%; background: #05070F; border-radius: 4px; aspect-ratio: 9/16; max-height: 62vh; display: block; margin: 0 auto; }
.player-empty { aspect-ratio: 16/9; display: grid; place-items: center; background: var(--code); border: 1px dashed var(--edge); border-radius: 4px; color: var(--muted); text-align: center; padding: 16px; }
.stack { display: grid; gap: 12px; }
select.input { padding-right: 28px; }

/* log drawer */
.drawer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--ink); color: #DDE3FF; border-top: 1px solid #1E2540; }
.drawer-bar { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 40px; padding: 0 var(--pad); background: transparent; border: 0; color: inherit; cursor: pointer; text-align: left; transition: background-color .14s var(--ease); }
.drawer-bar:hover { background: #10142A; }
.drawer-bar .mono-label { color: #8E99C4; }
.drawer-title { font: 400 12px/1 var(--f-mono); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { width: 8px; height: 8px; border-right: 2px solid #8E99C4; border-top: 2px solid #8E99C4; transform: rotate(-45deg); transition: transform .24s var(--ease); }
.drawer[data-open="true"] .chev { transform: rotate(135deg); }
.drawer-body { margin: 0; padding: 0 var(--pad); height: 0; overflow: auto; font: 400 12px/1.55 var(--f-mono); white-space: pre-wrap; word-break: break-all; }
.drawer[data-open="true"] .drawer-body { height: 28vh; padding: 10px var(--pad) 14px; }
.toast { position: fixed; left: 50%; bottom: 56px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 6px; font-weight: 600; z-index: 150; max-width: calc(100vw - 32px); font-size: 13px; }
.toast.bad { background: var(--danger); }

/* opener: rings contract onto a clip strip, then the app appears. Once per session, under 2 s. */
.opener { position: fixed; inset: 0; z-index: 400; background: var(--ink); display: grid; place-items: center; animation: opener-out .3s var(--ease) 1.55s forwards; }
.opener[hidden] { display: none; }
.opener-art { width: min(440px, 80vw); }
.opener .rings circle { fill: none; stroke: #4A63F0; stroke-width: 1.5; transform-origin: center; transform-box: fill-box; opacity: 0; animation: ring-in 1.1s var(--ease) forwards; }
.opener .rings circle:nth-child(2) { animation-delay: .06s; } .opener .rings circle:nth-child(3) { animation-delay: .12s; } .opener .rings circle:nth-child(4) { animation-delay: .18s; }
@keyframes ring-in { 0% { transform: scale(2.1); opacity: 0; } 25% { opacity: 1; } 100% { transform: scale(.55); opacity: .0; } }
.opener .strip rect { fill: none; stroke: #fff; stroke-width: 1.5; opacity: 0; transform-origin: center; transform-box: fill-box; animation: strip-in .6s var(--ease) .75s forwards; }
.opener .strip rect:first-child { stroke: #0427E6; stroke-width: 2.5; }
.opener .strip rect + rect { fill: #0427E6; stroke: none; }
@keyframes strip-in { from { opacity: 0; transform: scaleX(.4); } to { opacity: 1; transform: scaleX(1); } }
@keyframes opener-out { to { opacity: 0; visibility: hidden; } }
.opener .btn { position: absolute; right: 20px; top: 20px; color: #8E99C4; }
.opener .btn:hover { background: #10142A; border-color: #1E2540; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .opener { display: none; }
  .skel { animation: none; }
}

/* phone: stack the surface */
@media (max-width: 900px) {
  .ugrid { grid-template-columns: minmax(0, 1fr); }
  .ledger { grid-template-columns: repeat(2, 1fr); }
  .ledger > div { border-bottom: 1px solid var(--hair); }
}
@media (max-width: 640px) {
  :root { --pad: 16px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .health { justify-content: flex-start; gap: 10px; }
  .step { padding: 10px 8px; gap: 8px; flex-direction: column; align-items: flex-start; }
  .st-label small { display: none; }
  .sourcebar { grid-template-columns: 1fr; }
  .drop { width: 100%; }
  .tablewrap { border: 0; background: transparent; overflow: visible; }
  table, thead, tbody, tr, td { display: block; }
  thead { position: absolute; left: -9999px; }
  tbody tr { border: 1px solid var(--edge); border-radius: 6px; background: var(--panel); margin-bottom: 10px; padding: 10px; display: grid; grid-template-columns: 96px 1fr; gap: 4px 12px; }
  td { border: 0; padding: 2px 0; }
  td.thumbcell { grid-row: span 3; width: auto; padding: 0; }
  td .input { min-width: 0; }
  tr > td:nth-child(2), tr > td:nth-child(3), tr > td:nth-child(n+4) { grid-column: 2; }
  td.why { max-width: none; }
  td.wide { grid-column: 1 / -1 !important; }
  .pipe li { grid-template-columns: 22px 1fr; }
  .pipe .idx { display: none; }
  .pipe .state { grid-column: 2; }
  .plan-row { grid-template-columns: 1fr; }
  .plan-row .st { grid-column: 1; }
  .actions .right, .actions .left { width: 100%; }
  .actions .btn { flex: 1; }
}

/* recorded-run banner and replay label (added for the Cloudflare Pages showcase) */
.recorded { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px var(--pad); background: var(--warn-bg); border-bottom: 1px solid var(--edge); color: var(--txt); }
.recorded p { margin: 0; }
.rec-main { font-size: 13px; line-height: 1.45; }
.rec-main b { font-weight: 700; }
.rec-sub { font-size: 12px; line-height: 1.45; color: var(--muted); margin-top: 2px !important; max-width: 110ch; }
.replay { display: inline-flex; align-items: center; gap: 8px; flex: none; font: 600 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--on-blue); background: var(--blue); padding: 8px 12px; border-radius: 6px; }
.replay[hidden] { display: none; }
.replay i { width: 8px; height: 8px; border-radius: 50%; background: #fff; display: inline-block; animation: replay-pulse 1s var(--ease) infinite; }
@keyframes replay-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .recorded { color: var(--txt); } }
@media (max-width: 640px) { .recorded { flex-direction: column; align-items: flex-start; gap: 8px; } }
