/* SG Sales Dashboard. Chart series colors validated (dataviz six checks):
   light: #1f7a4d (NetSuite) / #3b6fb5 (Bridge). */
:root {
  --green: #1f7a4d;
  --green-dark: #175f3c;
  --blue: #3b6fb5;
  --ink: #1c2320;
  --ink-2: #4c5a53;
  --muted: #7b8781;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --line: #e2e7e3;
  --amber-bg: #fdf3dc; --amber-ink: #7a5a12;
  --red-bg: #fbe7e5;   --red-ink: #8f2a20;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(28,35,32,.08);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.45;
}
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
a { color: var(--green); }
.muted { color: var(--muted); } .small { font-size: .85rem; }

/* ── login ── */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow);
  padding: 2.5rem 3rem; text-align: center; max-width: 22rem;
}
.brand-mark {
  width: 3rem; height: 3rem; margin: 0 auto 1rem; border-radius: 12px;
  background: var(--green); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 1.2rem;
}

/* ── shell ── */
header.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem; padding: 0 1rem;
  position: sticky; top: 0; z-index: 20; height: 3.3rem;
}
.topbar .brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; }
.topbar .brand .brand-mark { width: 1.9rem; height: 1.9rem; margin: 0; font-size: .8rem; border-radius: 8px; }
nav.tabs { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
nav.tabs a {
  padding: .45rem .8rem; border-radius: 8px; text-decoration: none;
  color: var(--ink-2); white-space: nowrap; font-weight: 500;
}
nav.tabs a.active { background: #e7efe9; color: var(--green-dark); }
.topbar .who { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.topbar select { border: 1px solid var(--line); border-radius: 8px; padding: .3rem .4rem; }

.banner { padding: .5rem 1rem; font-size: .88rem; text-align: center; }
.banner.staging { background: var(--amber-bg); color: var(--amber-ink); }
.banner.stale { background: var(--red-bg); color: var(--red-ink); }

main#view { max-width: 1180px; margin: 0 auto; padding: 1.2rem 1rem 4rem; }

.btn {
  display: inline-block; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); padding: .45rem .9rem;
  font: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--green); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-sm { padding: .25rem .6rem; font-size: .85rem; }

/* ── cards/kanban ── */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.lane { background: #edf1ee; border-radius: var(--radius); padding: .6rem; min-height: 12rem; }
.lane h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-2); padding: .2rem .4rem; display: flex; justify-content: space-between; }
.lane.drag-over { outline: 2px dashed var(--green); outline-offset: -4px; }
.card {
  background: var(--surface); border-radius: 8px; box-shadow: var(--shadow);
  padding: .65rem .75rem; margin-bottom: .6rem; cursor: grab; border-left: 3px solid var(--green);
}
.card.winback { border-left-color: var(--blue); }
.card.followup { border-left-color: #b58a2a; }
.card .name { font-weight: 600; }
.card .name a { color: inherit; text-decoration: none; }
.card .name a:hover { text-decoration: underline; }
.card .reason { font-size: .88rem; color: var(--ink-2); margin: .2rem 0 .35rem; }
.card .chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip {
  font-size: .72rem; background: #eef2ef; color: var(--ink-2);
  border-radius: 999px; padding: .1rem .5rem;
}
.chip.type-winback { background: #e8eef8; color: var(--blue); }
.chip.type-followup { background: var(--amber-bg); color: var(--amber-ink); }
.card .actions { display: none; gap: .4rem; margin-top: .5rem; }

/* ── KPI tiles / tables / drill-down ── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.tile { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; }
.tile .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tile .value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; margin: .15rem 0; }
.tile .delta { font-size: .85rem; }
.delta.up { color: var(--green-dark); } .delta.down { color: var(--red-ink); }

.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1.2rem; }
.panel h2 { font-size: 1.05rem; }
.chart-wrap { position: relative; height: 260px; }

table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-size: .75rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
table.data td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { font-size: .75rem; border-radius: 6px; padding: .12rem .45rem; font-weight: 600; }
.badge.held { background: var(--red-bg); color: var(--red-ink); }
.badge.pending { background: var(--amber-bg); color: var(--amber-ink); }
.badge.pushed { background: #e5f2ea; color: var(--green-dark); }
.badge.failed { background: var(--red-bg); color: var(--red-ink); }

.search-row { display: flex; gap: .6rem; margin-bottom: 1rem; }
.search-row input {
  flex: 1; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
textarea {
  width: 100%; min-height: 5rem; border: 1px solid var(--line); border-radius: 8px;
  padding: .55rem .7rem; font: inherit; resize: vertical;
}

/* leaderboard bars (single-hue magnitude, direct-labeled) */
.lb-row { display: grid; grid-template-columns: 11rem 1fr 7rem; align-items: center;
  gap: .7rem; padding: .35rem 0; }
.lb-bar { height: 14px; border-radius: 4px; background: var(--green); min-width: 2px; }
.lb-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,26,22,.45);
  display: grid; place-items: center; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; padding: 1.2rem 1.3rem;
  width: min(28rem, 92vw); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal .row { display: flex; gap: .6rem; justify-content: flex-end; margin-top: .9rem; }
.modal input[type="date"] { padding: .45rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

.legend { display: flex; gap: 1rem; font-size: .82rem; color: var(--ink-2); margin: .3rem 0 .6rem; }
.legend .swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }

/* ── mobile: kanban degrades to a tappable list (brief §8.7, test at 390px) ── */
@media (max-width: 640px) {
  header.topbar { flex-wrap: wrap; height: auto; padding: .45rem .6rem; row-gap: .3rem; }
  .topbar .who { display: none; }
  nav.tabs { order: 5; flex-basis: 100%; }
  .board { grid-template-columns: 1fr; }
  .card { cursor: default; }
  .card .actions { display: flex; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .lb-row { grid-template-columns: 7rem 1fr 5.5rem; }
  main#view { padding: .8rem .6rem 3rem; }
}
