:root {
  --brand: #29aae1; --navy: #1d4568; --navy-2: #2a5a85;
  --bg: #f3f5f9; --card: #ffffff; --well: #e9edf4;
  --text: #1c2430; --sub: #6b7689; --line: #e1e5ec;
  --ok: #e3f6ea; --ok-t: #176639; --warn: #fff1c9; --warn-t: #7a5a00;
  --bad: #fde2d6; --bad-t: #8a2d00; --info: #e1f1fb; --info-t: #16517a;
  --r: 16px; --r-sm: 12px; --r-pill: 999px;
  --shadow: 0 1px 2px rgba(20,30,60,.05), 0 6px 20px rgba(20,30,60,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text);
  font-size: 14.5px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--navy-2); }

/* ---- top bar ---- */
header.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  background: #fff; padding: 0.55rem 1.25rem; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; color: var(--text); }
.brand img { height: 30px; display: block; }
.brand-name { font-weight: 700; font-size: 0.98rem; letter-spacing: -0.01em; color: var(--text); text-decoration: none; margin-right: auto; }
nav { display: flex; align-items: center; gap: 0.25rem; font-size: 0.9rem; }
nav a { color: var(--sub); text-decoration: none; font-weight: 600; padding: 0.4rem 0.8rem; border-radius: var(--r-pill); }
nav a:hover { color: var(--navy); background: var(--well); }
nav a.on { color: var(--navy); background: var(--well); }
nav .who { color: var(--sub); padding: 0 0.6rem 0 0.9rem; }

main { max-width: 1200px; margin: 1.25rem auto; padding: 0 1.25rem 2rem; }
h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; margin: 0; display: flex; align-items: center; gap: 0.6rem; }
h2 { font-size: 1.02rem; font-weight: 700; margin: 0 0 0.7rem; display: flex; align-items: center; gap: 0.5rem; }
p { margin: 0.4rem 0; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* ---- surfaces ---- */
.card { background: var(--card); border-radius: var(--r); padding: 1.1rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.tight { padding: 0.35rem 0.5rem; overflow-x: auto; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
.login-card { max-width: 400px; margin: 12vh auto; text-align: center; padding: 2rem 1.6rem; }
.login-card h1 { justify-content: center; margin-bottom: 1rem; }
.login-logo { height: 56px; margin-bottom: 0.6rem; }
details.card summary { cursor: pointer; font-weight: 700; color: var(--navy); font-size: 1.02rem; list-style: none; }
details.card summary::-webkit-details-marker { display: none; }

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.6rem 1.15rem; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: #fff; color: var(--text); text-decoration: none; font: inherit; font-weight: 600;
  cursor: pointer; transition: background .12s, color .12s, border-color .12s; }
.btn:hover { border-color: var(--navy-2); color: var(--navy); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
.btn.small { padding: 0.36rem 0.85rem; font-size: 0.82rem; }
.btn.ghost { border-color: transparent; color: var(--sub); }
.btn.ghost:hover { background: var(--well); color: var(--navy); }
.btn.danger { color: var(--bad-t); border-color: #f0c2ae; }
.btn.danger:hover { background: var(--bad); border-color: var(--bad-t); color: var(--bad-t); }
input, select { font: inherit; color: var(--text); }
input[type=search], input[type=text], input[type=email], select {
  padding: 0.55rem 0.95rem; border: 1px solid var(--line); border-radius: var(--r-pill); background: #fff; outline: none; }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(41,170,225,.18); }
select { padding-right: 2rem; appearance: none; -webkit-appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7689' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.8rem center; }
form.inline { display: inline-flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
label.chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.85rem; border-radius: var(--r-pill);
  background: #fff; border: 1px solid var(--line); font-size: 0.85rem; font-weight: 600; color: var(--sub); cursor: pointer; }
label.chip:has(input:checked) { background: var(--navy); border-color: var(--navy); color: #fff; }
label.chip input { position: absolute; opacity: 0; width: 0; height: 0; }

/* ---- pills ---- */
.pill { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.16rem 0.6rem; border-radius: var(--r-pill);
  font-size: 0.74rem; font-weight: 600; white-space: nowrap; line-height: 1.5; }
.pill.soft { background: var(--well); color: var(--sub); }
.pill.ok, .pill.w2 { background: var(--ok); color: var(--ok-t); }
.pill.warn, .pill.future { background: var(--warn); color: var(--warn-t); }
.pill.bad, .pill.terminated { background: var(--bad); color: var(--bad-t); }
.pill.contractor { background: var(--info); color: var(--info-t); }
.pill.unmapped { background: var(--well); color: var(--sub); }
.pill.dept-sales { background: #ede7fb; color: #4b2f9e; }
.pill.dept-production { background: #fdebd3; color: #8a4b00; }
.pill.dept-office { background: var(--well); color: #3c4860; }
.pill.tool { background: var(--well); color: var(--text); font-weight: 500; }
.pill.tool b { font-weight: 700; color: var(--navy); }
.banner { padding: 0.6rem 1rem; border-radius: var(--r-sm); font-weight: 600; margin-bottom: 1rem; }
.banner.ok { background: var(--ok); color: var(--ok-t); }
.error { background: var(--bad); color: var(--bad-t); padding: 0.6rem 0.9rem; border-radius: var(--r-sm); margin: 0.8rem 0; }
.mono { font-family: Consolas, "SF Mono", monospace; font-size: 0.82rem; }

/* ---- tables ---- */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.88rem; }
th { text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--sub);
  padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); font-weight: 700; }
td { padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }

/* ---- toolbar + tabs ---- */
.toolbar { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.9rem; }
.toolbar .search { flex: 1 1 240px; }
.toolbar .search input { width: 100%; }
.toolbar-right { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.tabs { display: inline-flex; gap: 0.25rem; padding: 0.25rem; background: var(--well); border-radius: var(--r-pill);
  margin-bottom: 0.9rem; max-width: 100%; overflow-x: auto; }
.tab { border: none; background: none; padding: 0.45rem 0.95rem; font: inherit; font-weight: 600; color: var(--sub);
  cursor: pointer; border-radius: var(--r-pill); white-space: nowrap; transition: background .12s, color .12s; }
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); background: #fff; box-shadow: 0 1px 3px rgba(20,30,60,.12); }
.tab .count { font-weight: 600; font-size: 0.74rem; color: var(--sub); margin-left: 0.2rem; }
.panel { display: none; } .panel.active { display: block; }

/* ---- vertical boards ---- */
body.pinned { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
body.pinned header.topbar { flex: none; }
body.pinned main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  width: 100%; max-width: 1500px; margin: 0.9rem auto 0; padding: 0 1.25rem 0.75rem; }
body.pinned .toolbar, body.pinned .tabs { flex: none; }
.panel.active { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.kanban { flex: 1 1 auto; min-height: 0; display: flex; gap: 12px; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x proximity; padding-bottom: 4px; }
.kanban::-webkit-scrollbar { height: 8px; }
.kanban::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }
.kcol { flex: 1 0 290px; display: flex; flex-direction: column; min-height: 0; scroll-snap-align: start;
  background: var(--well); border-radius: var(--r); padding: 0.45rem; }
.colhead { flex: none; display: flex; justify-content: space-between; align-items: center;
  padding: 0.45rem 0.6rem 0.6rem; font-weight: 700; color: var(--navy); font-size: 0.9rem; }
.colhead .cn::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 0.5rem; background: var(--sub); vertical-align: 1px; }
.col-future .colhead .cn::before { background: #e0a800; }
.col-w2 .colhead .cn::before { background: #2aa05a; }
.col-contractor .colhead .cn::before { background: var(--brand); }
.col-terminated .colhead .cn::before { background: #d9603a; }
.colhead .count { font-weight: 600; font-size: 0.76rem; color: var(--sub); background: #fff; border-radius: var(--r-pill); padding: 0.05rem 0.55rem; }
.kbody { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 2px 2px 8px; }
.kbody::-webkit-scrollbar { width: 6px; }
.kbody::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }
@media (max-width: 759px) { .kcol { flex: 0 0 86vw; } }

.person { flex: none; background: #fff; border-radius: var(--r-sm); padding: 0.75rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.45rem; box-shadow: 0 1px 2px rgba(20,30,60,.06); }
.person-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.6rem; }
.person .name { font-weight: 700; letter-spacing: -0.01em; }
.person .pos { font-size: 0.82rem; color: var(--sub); }
.person-contact { display: flex; flex-direction: column; gap: 0.1rem; font-size: 0.85rem; }
.person-contact a { color: var(--navy-2); text-decoration: none; }
.person-contact a:hover { text-decoration: underline; }
.person-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.78rem; color: var(--sub); }
.person-meta .date { margin-left: auto; font-weight: 600; }
.person.bucket-terminated { opacity: 0.72; }

/* ---- access ---- */
table.access td .name { font-weight: 700; }
table.access td .sub { font-size: 0.8rem; color: var(--sub); }
table.access td.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; min-height: 2.6rem; align-items: center; border-bottom: none; }
table.access tr.left td { color: var(--sub); }
table.access td.acts { white-space: nowrap; text-align: right; }
table.access .status { display: inline-block; margin-left: 0.5rem; font-size: 0.78rem; font-weight: 600; min-width: 3rem; }
table.access .status.ok { color: var(--ok-t); } table.access .status.bad { color: var(--bad-t); }
.pop { position: fixed; z-index: 40; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(380px, 92vw); max-height: 90vh; overflow-y: auto; background: #fff; border-radius: var(--r);
  box-shadow: 0 16px 60px rgba(20,30,60,.28); padding: 1rem; }
.pop-back { position: fixed; inset: 0; z-index: 39; background: rgba(20,30,60,.25); }
.pop-title { font-weight: 700; margin: 0 0.2rem 0.6rem; }
.pop-list { display: flex; flex-direction: column; gap: 0.3rem; }
.pop-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.6rem; border-radius: var(--r-sm); cursor: pointer; }
.pop-row:hover { background: var(--well); }
.pop-row.on { background: var(--info); }
.pop-row .pt { width: 17px; height: 17px; accent-color: var(--navy); margin: 0; }
.pop-row .pop-label { flex: 1 1 auto; font-weight: 600; font-size: 0.88rem; }
.pop-row .pr { padding: 0.25rem 1.8rem 0.25rem 0.7rem; font-size: 0.8rem; visibility: hidden; background-position: right 0.55rem center; }
.pop-row.on .pr { visibility: visible; }
.pop-actions { display: flex; justify-content: flex-end; gap: 0.4rem; margin-top: 0.7rem; }
