/* AMT Tracker — design system.
 *
 * Ported from wireframes/AMT-Tracker-Wireframes.html so the screens can carry the wireframe's
 * markup unchanged. Bootstrap 5 does the heavy lifting; everything here is either a token, a
 * Bootstrap override, or a component the wireframe invents (path cards, funnel flowchart,
 * AI banner, assistant panel).
 *
 * Class names deliberately match the wireframe's. Resist renaming them — the wireframe is the
 * spec, and a diff against it is how we check fidelity.
 */

:root {
  --bg: #f4f5fa;
  --panel: #ffffff;
  --ink: #2d3a4f;
  --muted: #7b88a8;
  --line: #e6e8f0;
  --accent: #6c5ce7;
  --accent-dark: #5b4bd0;
  --accent-tint: #f1f0fe;
  --good: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;

  --topbar-h: 56px;
  --sidebar-w: 230px;
}

body { background: var(--bg); color: var(--ink); font-size: 14px; }

/* ---- shell ------------------------------------------------------------- */

.topbar {
  background: var(--panel); border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(30, 40, 80, .05);
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 10;
  display: flex; align-items: center; padding: 0 16px; gap: 14px;
}
.topbar .user-toggle { color: var(--ink); text-decoration: none; }

.brand { display: flex; align-items: center; gap: 9px; }
.brand .name { font-weight: 800; font-size: 17px; color: var(--ink); letter-spacing: .5px; }
.brand .wordmark { font-weight: 600; font-size: 10px; color: var(--muted); letter-spacing: 3px; }

.sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  min-height: 100vh; width: var(--sidebar-w);
  position: fixed; top: 0; left: 0; padding-top: var(--topbar-h);
  overflow-y: auto;
}
.sidebar a {
  color: var(--muted); display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; text-decoration: none; font-size: 14px;
}
.sidebar a:hover { background: #f0f1f9; color: var(--ink); }
.sidebar a.active {
  color: var(--accent); background: var(--accent-tint);
  border-left: 3px solid var(--accent); font-weight: 600;
  /* Keep the label from shifting 3px when the border appears. */
  padding-left: 15px;
}
.nav-parent { cursor: pointer; }
.nav-parent .nav-caret { margin-left: auto; font-size: 11px; transition: transform .15s; }
.nav-parent.collapsed .nav-caret { transform: rotate(-90deg); }
.nav-sub a { padding-left: 42px; font-size: 13px; }
.nav-sub a.active { padding-left: 39px; }
.nav-sub.hide { display: none; }

.main { margin-left: var(--sidebar-w); padding: 74px 24px 40px; }

/* ---- primitives -------------------------------------------------------- */

.card { background: var(--panel); border: 1px solid var(--line); color: var(--ink); box-shadow: 0 1px 3px rgba(30, 40, 80, .04); }
h4.scr { font-weight: 700; }
.sub { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.help { color: #aebacf; cursor: help; font-size: 12px; margin-left: 3px; }
.dropdown-item { font-size: 13px; }
datalist { color: var(--ink); }

.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-outline-primary { color: var(--accent); border-color: var(--accent); }
.btn-outline-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.text-primary { color: var(--accent) !important; }

.form-control, .form-select { background: #fff; border-color: #d8dbe8; color: var(--ink); }
.form-control::placeholder { color: #9aa6c0; }

.page-link { color: var(--accent); }
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); }

table { color: var(--ink); }
.table { --bs-table-bg: transparent; --bs-table-color: var(--ink); --bs-table-border-color: var(--line); }
.table thead th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; border-color: var(--line); }
.table td, .table th { border-color: var(--line); vertical-align: middle; }

.badge-live { background: var(--good); }
.badge-paused { background: #94a3b8; }
.roi-pos { color: var(--good); font-weight: 600; }
.roi-neg { color: var(--bad); font-weight: 600; }

.pill { background: #f0f1f9; border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px; font-size: 12px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.urlbox { background: #f7f8fc; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-family: monospace; font-size: 12px; color: var(--accent-dark); word-break: break-all; }
.ai-card { border-left: 3px solid var(--accent); }
.nav-tabs .nav-link { color: var(--muted); }
.nav-tabs .nav-link.active { background: var(--panel); color: var(--ink); border-color: var(--line) var(--line) var(--panel); }

/* KPI tiles */
.kpi { padding: 14px 16px; }
.kpi .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; }
.kpi .val { font-size: 24px; font-weight: 700; margin-top: 2px; }
.kpi .delta { font-size: 12px; }
.kpi .delta.up { color: var(--good); }
.kpi .delta.down { color: var(--bad); }

/* ---- AI banner (topbar) ------------------------------------------------ */

.ai-banner {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 7px;
  border: 1px solid; border-radius: 20px; padding: 5px 11px; font-size: 13px; cursor: pointer;
}
.ai-banner.t-warn { background: #fff4e5; border-color: #f6c768; color: #9a6700; }
.ai-banner.t-danger { background: #fdecea; border-color: #f1a9a0; color: #b02a1a; }
.ai-banner.t-good { background: #e8f6ee; border-color: #9bd6b0; color: #1a7d43; }
.ai-banner.t-info { background: #eef0fe; border-color: #b9c0f5; color: #3a2fb0; }
.ai-banner .ai-banner-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.ai-banner .badge { background: rgba(0, 0, 0, .16); color: inherit; font-weight: 600; }
.ai-banner .ai-banner-nav, .ai-banner .ai-banner-close { font-size: 15px; opacity: .55; }
.ai-banner .ai-banner-nav:hover, .ai-banner .ai-banner-close:hover { opacity: 1; }
.ai-banner-pulse { animation: aiPulse 1.6s ease-in-out infinite; }
@keyframes aiPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.18); opacity: .6; }
}
/* The banner is absolutely centred on the topbar, so it will sit under the brand/user on a
   narrow window. Drop it rather than overlap them. */
@media (max-width: 1100px) { .ai-banner { display: none; } }

/* ---- AI assistant (FAB + panel) ---------------------------------------- */

.asst-fab {
  position: fixed; right: 22px; bottom: 22px; width: 54px; height: 54px; border-radius: 50%;
  border: none; background: var(--accent); color: #fff; font-size: 22px;
  box-shadow: 0 6px 18px rgba(108, 92, 231, .45); z-index: 1050; cursor: pointer;
}
.asst-panel {
  display: none; position: fixed; right: 22px; bottom: 88px; width: 370px; max-height: 580px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 14px 36px rgba(30, 40, 80, .20); z-index: 1050;
  flex-direction: column; overflow: hidden;
}
.asst-panel.open { display: flex; }
.asst-head { display: flex; align-items: center; gap: 6px; padding: 11px 14px; border-bottom: 1px solid var(--line); font-weight: 700; color: var(--ink); }
.asst-body { padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.asst-msg { padding: 8px 11px; border-radius: 11px; font-size: 13px; max-width: 90%; line-height: 1.45; }
.asst-msg.user { align-self: flex-end; background: #efeefe; color: #3a2fb0; }
.asst-msg.bot { align-self: flex-start; background: #f4f6f8; color: var(--ink); }
.asst-cite { font-size: 11px; color: var(--muted); margin-top: 5px; }
.asst-input { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }

/* ---- lists (crud factory) ---------------------------------------------- */

.copy-cell { cursor: pointer; }
.copy-cell .bi { color: var(--muted); }
.copy-cell:hover .bi { color: var(--accent); }

/* ---- flow builder ------------------------------------------------------ */

.pathcard { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; background: #fbfcfe; overflow: hidden; }
.pathcard.pc-rule { border-left: 4px solid var(--warn); }
.pathcard.pc-default { border-left: 4px solid #94a3b8; }
.pathcard.seq-mode { border-left: 4px solid #0e9bb0; }
.pathcard-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #f4f6fa; border-bottom: 1px solid var(--line); font-size: 13px; }
.pathcard-body { display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 12px; }
.path-grip { cursor: grab; color: #9aa6bf; }
.pathcard.dragging-path { opacity: .4; }
.pathcard.path-error { border-color: #dc3545; box-shadow: 0 0 0 2px rgba(220, 53, 69, .18); }
.path-toggle { cursor: pointer; transition: transform .15s; color: #7a8aa3; }
.pathcard.collapsed .path-toggle { transform: rotate(-90deg); }
.pathcard.collapsed .pathcard-body,
.pathcard.collapsed .seq-steps { display: none; }
.ptype .btn { padding: 1px 8px; font-size: 11px; }

.lander-flow { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; border-top: 1px dashed #e6eaf2; }
.lander-flow:first-child { border-top: 0; padding-top: 2px; }
.lf-lander { min-width: 185px; flex-shrink: 0; }
.lf-arrow { align-self: center; color: #9aa6bf; font-size: 18px; }
.lf-offers { flex: 1; min-width: 0; }
.add-lander-row { align-self: flex-start; margin-top: 10px; }

.cta-group { border: 1px dashed #cdd5e5; border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; background: #fcfdff; }
.cta-group-head { font-size: 11.5px; color: var(--accent-dark); font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 5px; }
.cta-badge { font-size: 10.5px; background: #eef0fb; color: var(--accent-dark); border-radius: 7px; padding: 0 6px; }
.add-cta-offer, .add-offer-btn { font-size: 11px; text-decoration: none; }

.minicard { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; margin-bottom: 6px; font-size: 12.5px; display: flex; align-items: center; gap: 5px; box-shadow: 0 1px 2px rgba(30, 40, 80, .05); cursor: default; }
.minicard.dragging { opacity: .4; }
/* Landers and offers are weighted, not ordered — no drag handle inside a minicard. */
.minicard .drag-grip { display: none; }
.mc-del.del-off { opacity: .25; cursor: not-allowed; }
.wt2 { margin-left: auto; font-size: 11px; background: #efeefe; color: var(--accent-dark); border-radius: 9px; padding: 0 7px; }
.mini-col { min-width: 160px; }
.mini-list { min-height: 42px; }
.drag-grip { color: #c2cad8; cursor: grab; margin-right: 3px; }

.seq-steps { padding: 12px; }
.seq-step { border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; overflow: hidden; }
.seq-head { display: flex; align-items: center; gap: 8px; padding: 7px 11px; background: #f4f6fa; border-bottom: 1px solid var(--line); font-size: 13px; }
.seq-num { width: 21px; height: 21px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.seq-grip { cursor: grab; color: #9aa6bf; }
.seq-ctas { padding: 8px 11px; }
.seq-cta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 6px; font-size: 12.5px; }
.seq-tag { font-size: 10.5px; background: #fff4e5; color: #9a6b00; border: 1px solid #f0d9b5; border-radius: 7px; padding: 1px 7px; font-weight: 600; }
.seq-conn { text-align: center; color: #b3bbd0; font-size: 16px; line-height: 1.1; }

/* ---- reports ----------------------------------------------------------- */

.rep-ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rep-caret { cursor: pointer; color: #7a8aa3; transition: transform .12s; display: inline-block; }
.rep-caret.open { transform: rotate(90deg); }
.rep-caret-sp { display: inline-block; width: 12px; }
.rep-dim-tag { font-size: 10px; background: #eef0fb; color: var(--accent-dark); border-radius: 6px; padding: 0 5px; margin-left: 4px; }
.rep-tot td { font-weight: 700; background: #f7f8fc; }
.rep-row:hover td { background: #fafbff; }
.rep-crumb { cursor: pointer; color: var(--accent-dark); }
.rep-crumb:hover { text-decoration: underline; }
.rep-drillable { cursor: zoom-in; }
.rep-drillable:hover td { background: #f3f1fe; }
td.rep-flag { background: #fdecea !important; color: #b02a1a; font-weight: 600; }
.rep-flag-ic { color: #dc3545; font-size: 11px; }
.col-menu { max-height: 320px; overflow: auto; min-width: 180px; }
.dim-list label { display: block; padding: 4px 0; color: var(--ink); font-size: 13px; }

.delta { font-size: 10px; border-radius: 7px; padding: 0 5px; margin-left: 5px; white-space: nowrap; }
.delta.up { background: #e8f7ee; color: #137a3a; }
.delta.dn { background: #fdecea; color: #b02a1a; }

.flex-chip { font-size: 11px; background: #eef0fb; color: var(--accent-dark); border-radius: 8px; padding: 1px 4px 1px 8px; display: inline-flex; align-items: center; gap: 2px; }
.flex-chip .bi-x { cursor: pointer; }
.filt-chip { font-size: 11px; background: #fff4e5; color: #9a6b00; border: 1px solid #f0d9b5; border-radius: 8px; padding: 1px 4px 1px 8px; display: inline-flex; align-items: center; gap: 3px; }
.filt-chip .bi-x { cursor: pointer; }
.orsep { color: #9a6b00; font-weight: 700; font-size: 10px; margin: 0 1px; }
.andsep { color: var(--accent-dark); font-weight: 800; font-size: 10px; letter-spacing: .5px; }

/* ---- funnel flowchart -------------------------------------------------- */

.fc { background: radial-gradient(1200px 400px at 50% -50px, #efeafe, transparent), linear-gradient(180deg, #fbfaff, #f5f6fc); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.fc-node { border-radius: 12px; background: #fff; box-shadow: 0 6px 18px rgba(70, 60, 140, .12); overflow: hidden; display: inline-block; }
.fc-node .hd { padding: 7px 12px; color: #fff; font-weight: 700; font-size: 12.5px; display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.fc-node .bd { padding: 9px 12px; }
.hd-src { background: linear-gradient(90deg, #5b4bd0, #8b7cf0); }
.hd-lan { background: linear-gradient(90deg, #0e9bb0, #26c0d4); }
.hd-off { background: linear-gradient(90deg, #1f9d57, #39c074); }
.hd-tot { background: linear-gradient(90deg, #2b3446, #49546b); }
.fc-src { display: block; max-width: 520px; margin: 0 auto; }
.fc-arrow { text-align: center; color: #b3bbd0; font-size: 22px; margin: 6px 0; }
.fc-router { text-align: center; }
.fc-router .pill { background: #fff; border: 1px dashed #c3c0ea; color: var(--accent-dark); border-radius: 20px; padding: 4px 14px; font-size: 12px; font-weight: 600; box-shadow: 0 2px 8px rgba(70, 60, 140, .08); }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #f3f4fb; border-radius: 20px; padding: 1px 9px; font-size: 11px; margin: 2px 5px 2px 0; color: #54607a; }
.chip b { color: #1f2733; }

.lane { border: 1px solid var(--line); border-radius: 13px; margin: 14px 0; background: #fff; overflow: hidden; box-shadow: 0 3px 12px rgba(60, 50, 130, .07); }
.lane-hd { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; padding: 10px 14px; font-size: 13px; }
.lane.rule .lane-hd { background: linear-gradient(90deg, #fff4e2, #fffdf9); border-left: 5px solid var(--warn); }
.lane.def .lane-hd { background: linear-gradient(90deg, #eceff5, #f8fafc); border-left: 5px solid #94a3b8; }
.lane-bd { padding: 14px; display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.lane-pct { margin-left: auto; font-size: 12px; color: var(--muted); }
.lane-pct b { color: var(--accent-dark); font-size: 15px; }
.lcol { min-width: 235px; flex: 1; }
.lbar { height: 5px; border-radius: 3px; background: #e9e6fb; overflow: hidden; margin: 6px 0 2px; }
.lbar > span { display: block; height: 100%; background: linear-gradient(90deg, #6c5ce7, #9b8cf2); }
.ctaln { display: flex; align-items: center; gap: 7px; margin-top: 8px; flex-wrap: wrap; }
.cta-pill { background: #fff4e5; border: 1px solid #f0d9b5; color: #9a6b00; border-radius: 9px; padding: 3px 9px; font-size: 11px; font-weight: 600; white-space: nowrap; }

/* ---- timeline (incident detail) ---------------------------------------- */

.tl { list-style: none; margin: 6px 0; padding: 0; border-left: 2px solid var(--line); margin-left: 6px; }
.tl li { position: relative; padding: 0 0 12px 18px; font-size: 13px; }
.tl li:before { content: ""; position: absolute; left: -7px; top: 3px; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; }
.tl li.done:before { background: #1f9d57; }
.tl li.open:before { background: #e8a13a; }
.tl .t { color: var(--muted); font-size: 11px; }

/* ---- help -------------------------------------------------------------- */

.doc-link { display: block; padding: 4px 0; text-decoration: none; font-size: 13px; color: var(--muted); }
.doc-link.active { color: var(--accent); font-weight: 600; }
.doc-link:hover { color: var(--accent); }

/* ---- narrow screens ---------------------------------------------------- */

@media (max-width: 768px) {
  .sidebar { width: 56px; }
  .sidebar a span, .sidebar .nav-caret { display: none; }
  .nav-sub a { padding-left: 18px; }
  .main { margin-left: 56px; padding: 74px 12px 40px; }
}
