/* ===================================================================
   AI Integration — Pipeline Board
   Palette intentionally mirrors the studio's Miro board:
   warm cream canvas, charcoal stage headers, calm semantic lanes.
   =================================================================== */

:root {
  /* surfaces — dark navy theme */
  --paper:      #0E1A2E;   /* canvas */
  --paper-2:    #16243C;   /* raised surface: toolbar, inputs */
  --panel:      #1A2A45;   /* modals */
  --ink:        #0A1322;   /* deepest navy: stage headers */
  --ink-2:      #0E1B2E;
  --line:       #25344C;
  --line-2:     #31435F;

  /* text */
  --text:       #E8EDF4;
  --text-soft:  #9EABC1;
  --text-faint: #6B7A93;

  /* one restrained accent — teal, brightened for the dark canvas */
  --accent:     #46AEA0;
  --accent-2:   #5FC2B4;
  --accent-tint:#15322D;

  /* status */
  --ok:   #46AE72;
  --ok-bg:#16311F;
  --bad:  #E06A52;
  --bad-bg:#371B16;

  /* lane colours: light, soft chips that lift off the navy canvas.
     bg = subtle dark hue band, card = soft tint, bd = border, strip = the saturated identity edge */
  --input-bg:#182335;  --input-card:#E6DBC1;  --input-bd:#CDC0A2;  --input-strip:#A79E8C;
  --trad-bg:#15281F;   --trad-card:#A3D693;   --trad-bd:#79BC67;   --trad-strip:#6E9A63;
  --ai-bg:#152740;     --ai-card:#9FCBF1;     --ai-bd:#6FAAE0;     --ai-strip:#5E89AC;
  --fullai-bg:#232011; --fullai-card:#F4D571; --fullai-bd:#D9B638; --fullai-strip:#BE9C44;
  --auto-bg:#241A12;   --auto-card:#F4B783;   --auto-bd:#E18F4F;   --auto-strip:#BE7E50;

  --rowlabel-w: 116px;
  --col-w: 300px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.28);
  --shadow-lift: 0 10px 28px rgba(0,0,0,.55);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ----------------------------- top bar --------------------------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14px; letter-spacing: .2px; }
.brand-text span { font-size: 11px; color: var(--text-soft); }
.conn {
  margin-left: 6px; font-size: 11px; font-weight: 600;
  white-space: nowrap; color: var(--text-soft);
  padding: 2px 8px; border-radius: 999px;
  background: rgba(255, 255, 255, .05);
}
.login-back {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg, #0b1120);
}
.login-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  width: min(360px, 90vw); padding: 34px 30px;
  background: var(--panel, #131c2e);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 16px; box-shadow: var(--shadow-lift, 0 20px 60px rgba(0,0,0,.5));
  text-align: center;
}
.login-card h2 { font-size: 16px; margin: 4px 0 0; }
.login-card p { font-size: 13px; color: var(--text-soft); margin: 0; }
.login-card input {
  width: 100%; padding: 11px 12px; font-size: 14px;
  color: var(--text, #e8eefc);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .12); border-radius: 9px;
}
.login-card input:focus { outline: none; border-color: var(--accent, #6c8cff); }
.login-card .btn { width: 100%; justify-content: center; padding: 10px; }
.login-err { font-size: 12px; color: #ff6b6b; }
#saveBtn.saved {
  background: #39d98a; border-color: #39d98a; color: #06210f;
  transition: background .15s ease;
}

.tabs { display: flex; gap: 4px; background: rgba(0,0,0,.28); padding: 4px; border-radius: 10px; }
.tab {
  border: 0; background: transparent; cursor: pointer;
  font: 600 13px/1 var(--font); color: var(--text-soft);
  padding: 8px 16px; border-radius: 7px; transition: .15s;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

.actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 2px; }

.btn {
  border: 1px solid transparent; cursor: pointer;
  font: 600 12.5px/1 var(--font);
  padding: 9px 14px; border-radius: 8px;
  background: var(--accent); color: #fff; transition: .15s;
}
.btn:hover { background: var(--accent-2); }
.btn.ghost { background: var(--panel); color: var(--text); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.ghost.danger:hover { border-color: var(--bad); color: var(--bad); }
.btn.active { background: var(--accent-2); color: #fff; border-color: transparent; }

/* ----------------------------- legend ---------------------------- */
.legend { display: flex; gap: 16px; padding: 8px 18px; flex-wrap: wrap; align-items: center; }
.legend .item { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-soft); }
.legend .chip { width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(0,0,0,.08); }
.legend .lg-ic { display: inline-flex; }
.legend .lg-ic svg { width: 14px; height: 14px; }
.legend .lg-ic.ok { color: var(--ok); }
.legend .lg-ic.bad { color: var(--bad); }

/* ----------------------------- board ----------------------------- */
.board-wrap { flex: 1; min-height: 0; padding: 0 18px 18px; }
.board-scroll {
  position: relative;
  height: 100%;
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03);
  cursor: grab;            /* hand: drag the board background to pan sideways */
}
.board-scroll.panning { cursor: grabbing; user-select: none; }
.board-scroll.panning .card { pointer-events: none; }
/* prominent horizontal scrollbar, slim vertical */
.board-scroll::-webkit-scrollbar { height: 15px; width: 9px; }
.board-scroll::-webkit-scrollbar-thumb {
  background: #384964; border-radius: 9px; border: 3px solid var(--paper);
}
.board-scroll::-webkit-scrollbar-thumb:hover { background: #46597A; }
.board-scroll::-webkit-scrollbar-track { background: transparent; }
.board {
  display: grid;
  position: relative;
  min-width: max-content;
}

/* sticky stage header row */
.stage-head {
  position: sticky; top: 0; z-index: 6;
  background: var(--ink); color: #fff;
  font: 700 13px/1.25 var(--font);
  letter-spacing: .4px; text-transform: uppercase;
  padding: 16px 14px; text-align: center;
  display: flex; align-items: center; justify-content: center;
  border-right: 2px solid var(--paper);
}
.stage-head.corner {
  position: sticky; left: 0; z-index: 8;
  background: var(--ink-2);
  border-right: 2px solid var(--paper);
}
.stage-head .ghost-stage { opacity: .55; font-weight: 600; text-transform: none; letter-spacing: 0; }

/* sticky row-label column */
.row-label {
  position: sticky; left: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  writing-mode: vertical-rl; transform: rotate(180deg);
  font: 700 12px/1 var(--font); letter-spacing: .5px;
  text-transform: uppercase; color: #fff;
  border-right: 2px solid var(--paper);
  padding: 10px 0;
}
.row-label.r-input      { background: var(--input-strip); }
.row-label.r-traditional{ background: var(--trad-strip); }
.row-label.r-ai         { background: var(--ai-strip); }
.row-label.r-fullai     { background: var(--fullai-strip); }
.row-label.r-automated  { background: var(--auto-strip); }

/* cells */
.cell {
  min-height: 52px;
  padding: 9px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
  transition: background .12s;
}
.cell.r-input      { background: var(--input-bg); }
.cell.r-traditional{ background: var(--trad-bg); }
.cell.r-ai         { background: var(--ai-bg); }
.cell.r-fullai     { background: var(--fullai-bg); }
.cell.r-automated  { background: var(--auto-bg); }
.cell.drop-hot { background: var(--accent-tint); box-shadow: inset 0 0 0 2px var(--accent); }

.cell-add {
  margin-top: auto; align-self: flex-start;
  border: 1px dashed var(--line-2); background: transparent;
  color: var(--text-faint); cursor: pointer;
  font: 600 11px/1 var(--font); padding: 5px 9px; border-radius: 7px;
  opacity: 0; transition: .12s;
}
.cell:hover .cell-add { opacity: 1; }
.cell-add:hover { color: var(--accent); border-color: var(--accent); }

/* ----------------------------- card ------------------------------ */
.card {
  --card: var(--input-card); --card-bd: var(--input-bd); --card-strip: var(--input-strip);
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--card);
  border: 1px solid var(--card-bd);
  border-left: 4px solid var(--card-strip);
  border-radius: 8px;
  padding: 6px 9px;
  min-height: 30px;
  box-shadow: var(--shadow);
  cursor: grab;
  transition: box-shadow .12s;
}
.card-main { display: flex; align-items: center; gap: 8px; }
.card-skillbar { height: 3px; border-radius: 999px; background: rgba(0,0,0,.12); overflow: hidden; }
.card-skillbar > i { display: block; height: 100%; border-radius: 999px; transition: width .2s, background .2s; }
.card-skillbar.s-bad  > i { background: var(--bad); }
.card-skillbar.s-warn > i { background: #E6B53D; }
.card-skillbar.s-ok   > i { background: var(--ok); }
.card:hover { box-shadow: var(--shadow-lift); }
.card:active { cursor: grabbing; }
.card.dragging { opacity: .45; }
.card.row-traditional { --card: var(--trad-card); --card-bd: var(--trad-bd); --card-strip: var(--trad-strip); }
.card.row-ai          { --card: var(--ai-card);  --card-bd: var(--ai-bd);  --card-strip: var(--ai-strip); }
.card.row-fullai      { --card: var(--fullai-card); --card-bd: var(--fullai-bd); --card-strip: var(--fullai-strip); }
.card.row-automated   { --card: var(--auto-card); --card-bd: var(--auto-bd); --card-strip: var(--auto-strip); }
.card.route-hot { box-shadow: 0 0 0 2px var(--accent), var(--shadow-lift); }

.card-title {
  flex: 1; min-width: 0;
  font: 600 12px/1.3 var(--font); color: #20242b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status-icons { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; }
.sicon {
  width: 22px; height: 22px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.65); color: var(--bad);
  border: 1px solid rgba(0,0,0,.05);
}
.sicon.ok  { color: var(--ok); }
.sicon.bad { color: var(--bad); }
.sicon svg { width: 14px; height: 14px; }
.sicon.btn-like { cursor: pointer; }
.sicon.btn-like:hover { background: #fff; border-color: rgba(0,0,0,.18); }

.avatar {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  background: var(--ink); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font: 700 9px/1 var(--font);
}
.link-handle {
  cursor: pointer; color: var(--accent); flex-shrink: 0;
  font: 700 10px/1 var(--font); letter-spacing: .3px;
  border: 1px solid var(--accent); border-radius: 6px;
  padding: 4px 6px; background: rgba(255,255,255,.7);
}
.connect-mode .card { cursor: crosshair; }
.card.connect-src { box-shadow: 0 0 0 2px var(--accent), var(--shadow-lift); }

/* ----------------------------- links svg ------------------------- */
.links { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.links path { fill: none; stroke: var(--accent); stroke-width: 2; opacity: .55; pointer-events: stroke; cursor: pointer; }
.links path:hover { opacity: 1; stroke-width: 3; }
.links path.route-hot { stroke: var(--bad); opacity: 1; stroke-width: 3; }

/* ----------------------------- hint bar -------------------------- */
.hint {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: var(--ink); color: #fff; z-index: 20;
  padding: 10px 14px; border-radius: 10px; font-size: 12.5px;
  display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-lift);
}
.hint .btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); padding: 6px 10px; }

/* ----------------------------- modals ---------------------------- */
.modal-back {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(30,28,22,.42);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--panel); width: min(640px, 100%); max-height: 90vh; overflow: auto;
  border-radius: 16px; box-shadow: var(--shadow-lift); display: flex; flex-direction: column;
}
.modal.narrow { width: min(460px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-title { flex: 1; border: 0; background: transparent; font: 700 17px/1.2 var(--font); color: var(--text); outline: none; }
.modal-title::placeholder { color: var(--text-faint); }
.modal-title:focus { border-bottom: 2px solid var(--accent); }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 16px; color: var(--text-soft); padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--line); }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }
.grow { flex: 1; }

.field { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.field > span { font: 600 11px/1 var(--font); color: var(--text-soft); text-transform: uppercase; letter-spacing: .4px; }
.field input, .field select, .field textarea, .times input {
  font: 400 13px/1.4 var(--font); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 10px; background: var(--paper-2); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus, .times input:focus { border-color: var(--accent); background: #fff; }
.field textarea { resize: vertical; }
.field-row { display: flex; gap: 12px; }

.toggles { display: flex; gap: 10px; flex-wrap: wrap; }
.status-toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--paper-2);
  padding: 9px 13px; border-radius: 10px; font: 600 12.5px/1 var(--font); color: var(--text);
}
.status-toggle .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--bad); transition: .12s; }
.status-toggle[data-on="true"] { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.status-toggle[data-on="true"] .dot { background: var(--ok); }
.status-toggle[data-on="false"] { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }

.times { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 14px; margin: 0; }
.times legend { font: 600 11px/1 var(--font); color: var(--text-soft); text-transform: uppercase; letter-spacing: .4px; padding: 0 6px; }
.times-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.times-grid label { display: flex; flex-direction: column; gap: 5px; font: 600 11px/1 var(--font); color: var(--text-soft); }
.times-grid input { width: 100%; }
.swatch { width: 100%; height: 6px; border-radius: 3px; }
.swatch.t-traditional { background: var(--trad-strip); }
.swatch.t-ai { background: var(--ai-strip); }
.swatch.t-fullai { background: var(--fullai-strip); }
.swatch.t-automated { background: var(--auto-strip); }
.times-note { font-size: 11.5px; color: var(--text-soft); margin: 10px 0 0; }

/* team-skill tracker inside the card modal */
.skill-section { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 14px; margin: 0; }
.skill-section legend { font: 600 11px/1 var(--font); color: var(--text-soft); text-transform: uppercase; letter-spacing: .4px; padding: 0 6px; }
.skill-bar { height: 9px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; }
.skill-bar-fill { height: 100%; width: 0; border-radius: 999px; transition: width .25s ease, background .25s; }
.skill-bar-fill.skill-bad  { background: var(--bad); }
.skill-bar-fill.skill-warn { background: #E6B53D; }
.skill-bar-fill.skill-ok   { background: var(--ok); }
.skill-bar-label { font: 600 11.5px/1 var(--font); color: var(--text-soft); margin-top: 7px; }
.skill-bar-label b { color: var(--text); }
.skill-add { margin-top: 11px; width: 100%;
  font: 400 13px/1.4 var(--font); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 10px; background: var(--paper-2); outline: none; }
.skill-add:focus { border-color: var(--accent); }
.skill-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.skill-name {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 7px 9px; border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--paper-2); color: var(--text-soft);
  font: 600 12px/1 var(--font); transition: .12s; user-select: none;
}
.skill-name:hover { border-color: var(--accent); }
.skill-name .chk {
  width: 17px; height: 17px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid var(--text-faint); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.skill-name .chk svg { width: 11px; height: 11px; opacity: 0; }
.skill-name.has { color: var(--text); border-color: rgba(70,174,114,.55); background: rgba(70,174,114,.12); }
.skill-name.has .chk { background: var(--ok); border-color: var(--ok); }
.skill-name.has .chk svg { opacity: 1; }

.muted { color: var(--text-soft); font-size: 12.5px; margin-top: 0; }
.route-result { margin-top: 6px; display: flex; flex-direction: column; gap: 8px; }
.route-path {
  border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px;
  font-size: 12.5px; cursor: pointer; background: var(--paper-2);
}
.route-path:hover { border-color: var(--accent); }
.route-path .total { font-weight: 700; color: var(--accent); }
.route-path .steps { color: var(--text-soft); margin-top: 4px; }
@media (max-width: 560px) {
  .field-row { flex-direction: column; }
  .times-grid { grid-template-columns: repeat(2, 1fr); }
  .skill-grid { grid-template-columns: repeat(2, 1fr); }
}
