* { box-sizing: border-box; }
:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --brand: #4f46e5; --ok: #10b981; --warn: #f59e0b; --bad: #ef4444;
}
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1rem; margin: .75rem 0 .35rem; }
p { margin: .35rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* header */
header { position: sticky; top: 0; z-index: 20; background: #111827; color: #fff; }
.bar { display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; flex-wrap: wrap; }
.bar .brand { font-weight: 700; color: #fff; }
.bar nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.bar nav a { color: #d1d5db; padding: .3rem .6rem; border-radius: 6px; font-size: .9rem; }
.bar nav a.on, .bar nav a:hover { background: #374151; color: #fff; text-decoration: none; }
.bar select { background: #1f2937; color: #fff; border: 1px solid #374151; border-radius: 6px; padding: .3rem; }

main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
main.wide { max-width: none; }

/* cards and grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.stats { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin: .75rem 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .75rem; }
.stat .v { font-size: 1.6rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.stack > * + * { margin-top: .6rem; }

/* list rows */
.list { display: flex; flex-direction: column; gap: .5rem; }
.item { display: block; background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: 8px; padding: .7rem .85rem; color: inherit; }
a.item:hover { text-decoration: none; border-color: #c7d2fe; }
.item .t { font-weight: 600; }

/* pills */
.pill { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; background: #eef2ff; color: #3730a3; white-space: nowrap; }
.pill.dot::before { content: ""; display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: currentColor; margin-right: .3rem; vertical-align: middle; }
.pill.bad { background: #fee2e2; color: #991b1b; }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.ok { background: #d1fae5; color: #065f46; }
.pill.grey { background: #f3f4f6; color: #374151; }

/* SLA meter */
.meter { height: 8px; background: #e5e7eb; border-radius: 99px; overflow: hidden; min-width: 80px; }
.meter > i { display: block; height: 100%; background: var(--ok); }
.meter.l1 > i { background: #eab308; } .meter.l2 > i { background: var(--warn); } .meter.l3 > i { background: var(--bad); }

/* forms */
label { display: block; font-size: .8rem; color: var(--muted); margin: .5rem 0 .2rem; }
input, select, textarea { width: 100%; font: inherit; padding: .45rem .55rem; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; }
input[type=checkbox] { width: auto; }
input[type=color] { padding: 0; height: 2.2rem; }
textarea { min-height: 80px; }
.check { display: flex; gap: .4rem; align-items: center; font-size: .9rem; color: var(--ink); margin: .5rem 0; }
.two { display: grid; gap: .5rem; grid-template-columns: 1fr 1fr; }
button, .btn { font: inherit; border: 1px solid #d1d5db; background: #fff; color: var(--ink); padding: .45rem .8rem; border-radius: 6px; cursor: pointer; display: inline-block; }
button:hover, .btn:hover { background: #f9fafb; text-decoration: none; }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: #4338ca; }
button.danger { color: #b91c1c; border-color: #fecaca; }
button:disabled { opacity: .5; cursor: default; }

/* landing */
.hero { background: linear-gradient(135deg, #1e1b4b, #312e81); color: #e0e7ff; border-radius: 14px; padding: 1.5rem; }
.hero h1 { color: #fff; font-size: 1.7rem; }
.hero .concerns { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 1rem; }
.hero .concern { background: rgba(255,255,255,.08); border-radius: 10px; padding: .85rem; }
.hero .concern b { color: #fff; display: block; margin-bottom: .25rem; }
.persona { cursor: pointer; transition: transform .1s; }
.persona:hover { transform: translateY(-2px); border-color: #a5b4fc; }
.persona .avatar { font-size: 2rem; }

/* ticket page */
.story { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; }
.story .arrow { color: var(--muted); }
.reply { border-left: 3px solid var(--line); padding: .35rem .7rem; margin: .4rem 0; }
.reply.open { border-color: var(--warn); }
.cols { display: grid; gap: 1rem; grid-template-columns: 2fr 1fr; }

/* workflow editor */
.editor { display: grid; grid-template-columns: 1fr 340px; height: calc(100vh - 52px); }
.canvas-wrap { position: relative; background: #fafafa; overflow: hidden; border-right: 1px solid var(--line); }
.canvas-wrap svg { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; }
.canvas-tools { position: absolute; top: .6rem; left: .6rem; display: flex; gap: .35rem; flex-wrap: wrap; z-index: 2; }
.canvas-tools button { padding: .3rem .6rem; font-size: .85rem; }
.canvas-help { position: absolute; bottom: .6rem; left: .6rem; font-size: .78rem; color: var(--muted); background: rgba(255,255,255,.9); padding: .3rem .5rem; border-radius: 6px; }
.panel { overflow: auto; padding: 1rem; background: #fff; }
.node rect { stroke-width: 2; cursor: grab; }
.node.sel rect { stroke: #111827 !important; stroke-width: 3; }
.node text { pointer-events: none; font-size: 13px; }
.node .handle { fill: #fff; stroke: #4f46e5; stroke-width: 2; cursor: crosshair; }
.node:hover .handle { fill: #4f46e5; }
.edge path.line { fill: none; stroke: #9ca3af; stroke-width: 2; }
.edge path.hit { fill: none; stroke: transparent; stroke-width: 14; cursor: pointer; }
.edge.sel path.line { stroke: #4f46e5; stroke-width: 3; }
.edge text { font-size: 11px; fill: #374151; pointer-events: none; }
.edge .lbl-bg { fill: #fff; stroke: #e5e7eb; }
.edge .bend { fill: #4f46e5; cursor: move; }
.fx { border: 1px solid var(--line); border-radius: 8px; padding: .5rem; margin: .4rem 0; }

/* the story on the landing page */
.storyline { list-style: none; padding: 0; margin: 1rem 0; position: relative; }
.storyline::before { content: ""; position: absolute; left: 1.05rem; top: .5rem; bottom: .5rem; width: 2px; background: #c7d2fe; }
.chapter { display: flex; gap: .85rem; margin: 0 0 .85rem; position: relative; }
.chapter .num { flex: 0 0 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; display: grid; place-items: center; z-index: 1; }
.chapter .body { flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .75rem .9rem; }
.chapter .who { background: #eef2ff; color: #3730a3; border-radius: 999px; padding: .05rem .55rem; font-size: .8rem; }
.chapter .params { background: #f9fafb; border-radius: 6px; padding: .35rem .5rem; }

/* business hours: a 24-hour strip and the week */
.hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; margin: .5rem 0; }
.hours span { height: 26px; background: #e5e7eb; border-radius: 3px; font-size: .65rem; color: var(--muted); padding: 2px; }
.hours span.open { background: #a7f3d0; color: #065f46; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: .5rem 0; }
.week span { text-align: center; padding: .3rem 0; border-radius: 6px; background: #e5e7eb; color: var(--muted); font-size: .8rem; }
.week span.open { background: #a7f3d0; color: #065f46; font-weight: 600; }

/* an SLA tier's clock: zones, thresholds, one dot per open ticket */
.track { position: relative; height: 22px; margin: 1.6rem 0 .6rem; border-radius: 6px; background: #f3f4f6; }
.track .zone { position: absolute; top: 0; bottom: 0; }
.track .z0 { background: #d1fae5; border-radius: 6px 0 0 6px; } .track .z1 { background: #fef9c3; }
.track .z2 { background: #fde68a; } .track .z3 { background: #fecaca; border-radius: 0 6px 6px 0; }
.track .tick { position: absolute; top: -4px; bottom: -4px; width: 2px; background: #374151; }
.track .tick span { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: .7rem; white-space: nowrap; color: #374151; }
.track .dot { position: absolute; top: 4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #374151; }
.track .dot:hover { transform: scale(1.3); }

/* sliders */
.slider { margin: .6rem 0; }
.slider label { margin: 0; }
.slider input[type=range] { padding: 0; border: 0; accent-color: var(--brand); }

/* escalation ladder */
.ladder { display: flex; flex-direction: column; gap: .4rem; }
.rung { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--c); border-radius: 8px; padding: .55rem .75rem; color: inherit; }
a.rung:hover { text-decoration: none; border-color: var(--c); }
.rung b { flex: 1 1 10rem; }

/* a ticket's journey through its workflow */
.journey { display: flex; flex-wrap: wrap; gap: .3rem; margin: .5rem 0; }
.journey .step { position: relative; padding: .25rem .6rem; border-radius: 6px; font-size: .8rem; background: #f3f4f6; color: var(--muted); border: 1px solid var(--line); }
.journey .step.here { background: var(--c); border-color: var(--c); color: #fff; font-weight: 700; box-shadow: 0 0 0 3px #e0e7ff; }
.journey .step.next { border: 2px dashed var(--c); color: var(--ink); }
.journey .step small { font-weight: 400; opacity: .85; }

/* the customer's plan picker and conversation */
.tiers { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tier-pick { display: flex; flex-direction: column; gap: .15rem; margin: 0; color: var(--ink); font-size: .9rem; border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: 8px; padding: .55rem; cursor: pointer; }
.tier-pick:has(input:checked) { border-color: var(--c); background: #f9fafb; box-shadow: 0 0 0 2px var(--c); }
.tier-pick input { width: auto; }
.reply.mine { border-color: var(--brand); background: #f5f3ff; }

#toast { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); background: #111827; color: #fff; padding: .5rem 1rem; border-radius: 8px; font-size: .9rem; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 100; }
#toast.on { opacity: 1; }
#toast.err { background: #b91c1c; }

@media (max-width: 760px) {
  .cols, .two { grid-template-columns: 1fr; }
  .editor { grid-template-columns: 1fr; grid-template-rows: 60vh auto; height: auto; }
  .canvas-wrap { border-right: 0; border-bottom: 1px solid var(--line); }
  main { padding: .75rem; }
  .hero { padding: 1rem; }
  .rung { margin-left: 0 !important; }
  .hours span { font-size: 0; }
  .storyline::before { left: .85rem; }
  .chapter .num { flex-basis: 1.8rem; height: 1.8rem; }
}
