:root {
  --purple: #822DDA;
  --purple-dark: #6f22bd;
  --purple-050: #f7f2fd;
  --purple-100: #efe6fb;
  --ink: #241a33;
  --muted: #6b6280;
  --line: #ece7f5;
  --bg: #f6f4fb;
  --card: #ffffff;
  --danger: #d62828;
  --ok: #1a8f4c;
  --star: #f4b400;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
}
.boot, .loading, .empty, .error { padding: 48px 0; text-align: center; color: var(--muted); }
.error { color: var(--danger); }
.muted { color: var(--muted); }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(1200px 600px at 50% -10%, #efe0ff 0%, var(--bg) 60%); }
.auth-card { width: 400px; max-width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 26px; box-shadow: 0 24px 70px rgba(60,30,110,0.12); }
.brandmark { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.brandmark-logo { width: 34px; height: 34px; }
.brandmark-name { font-weight: 800; font-size: 20px; letter-spacing: 0.3px; }
.auth-title { font-size: 22px; margin: 4px 0 2px; }
.auth-sub { color: var(--muted); margin: 0 0 16px; font-size: 13px; }
.auth-switch { margin-top: 16px; font-size: 13px; color: var(--muted); text-align: center; }
.auth-switch a { color: var(--purple); font-weight: 600; text-decoration: none; }
.field-label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin: 12px 0 4px; }
.form-err { color: var(--danger); font-size: 12px; min-height: 16px; margin: 8px 0 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.role-row { display: flex; gap: 8px; }
.role-opt { flex: 1; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; cursor: pointer; font-size: 13px; font-weight: 600; }
.role-opt:has(input:checked) { border-color: var(--purple); background: var(--purple-050); color: var(--purple); }

.inp { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; color: var(--ink); background: #fff; }
.inp:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(130,45,218,0.15); }

/* ---------- buttons ---------- */
.btn { appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px; padding: 10px 14px; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn:hover { background: var(--purple-050); }
.btn.primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn.primary:hover { background: var(--purple-dark); }
.btn.primary:disabled { opacity: 0.6; cursor: default; }
.btn.ghost { border-style: dashed; color: var(--purple); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: #fdeaea; }
.btn.small { padding: 7px 11px; font-size: 12px; }
.btn.block { width: 100%; margin-top: 12px; }

/* ---------- topbar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 22px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-brand { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.topbar-logo { width: 26px; height: 26px; }
.topbar-name { font-weight: 800; font-size: 17px; letter-spacing: 0.3px; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.tu-text { text-align: right; line-height: 1.2; }
.tu-name { font-weight: 700; font-size: 13px; }
.tu-co { font-size: 11px; color: var(--muted); }

.view { max-width: 900px; margin: 0 auto; padding: 22px 22px 48px; }

/* ---------- tabs ---------- */
.tabs { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.tab { border: none; background: transparent; color: var(--muted); font-weight: 700; font-size: 13px; padding: 8px 16px; border-radius: 9px; cursor: pointer; }
.tab.active { background: var(--purple); color: #fff; }

/* ---------- insights ---------- */
.insights { margin-bottom: 22px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.tile-num { font-size: 26px; font-weight: 800; color: var(--purple); }
.tile-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.panel-title { font-weight: 700; font-size: 13px; margin-bottom: 12px; }
.dist { display: flex; flex-direction: column; gap: 8px; }
.dist-row { display: grid; grid-template-columns: 110px 1fr 34px; align-items: center; gap: 10px; }
.dist-label { font-size: 12px; color: var(--muted); text-align: right; }
.dist-track { background: var(--purple-100); border-radius: 6px; height: 12px; overflow: hidden; }
.dist-fill { height: 100%; background: linear-gradient(90deg, var(--purple), #a25cec); border-radius: 6px; }
.dist-n { font-size: 12px; font-weight: 700; color: var(--ink); }

/* ---------- deal list ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.list-title { font-size: 18px; margin: 0; }
.deal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.deal-card { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; cursor: pointer; transition: box-shadow .15s, transform .05s, border-color .15s; }
.deal-card:hover { border-color: #d4befe; box-shadow: 0 8px 24px rgba(130,45,218,0.12); }
.deal-card:active { transform: translateY(1px); }
.deal-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.deal-domain { font-weight: 800; font-size: 15px; word-break: break-all; }
.deal-owner { font-size: 11px; color: var(--muted); white-space: nowrap; }
.deal-subject { color: var(--muted); font-size: 13px; margin: 4px 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-foot { display: flex; align-items: center; gap: 8px; }
.pill { background: var(--purple-050); color: var(--purple); font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 20px; }
.pill-star { background: #fff7e0; color: #a67c00; }
.deal-date { margin-left: auto; font-size: 11px; color: var(--muted); }

/* ---------- detail ---------- */
.back { border: none; background: none; color: var(--purple); font-weight: 700; cursor: pointer; padding: 0; margin-bottom: 14px; font-size: 13px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.detail-domain { font-size: 22px; font-weight: 800; word-break: break-all; }
.detail-subject { color: var(--muted); margin-top: 2px; }
.detail-owner { font-size: 12px; color: var(--muted); margin-top: 4px; }
.detail-actions { display: flex; gap: 8px; flex-shrink: 0; }
.readonly-note { background: #fff7e0; border: 1px solid #f4e2a8; color: #8a6d00; border-radius: 10px; padding: 8px 12px; font-size: 12px; margin: 8px 0 14px; }

.committee { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px 16px; margin: 14px 0; }
.dept { margin: 14px 0 6px; font-size: 11px; font-weight: 800; letter-spacing: 0.6px; color: var(--purple); border-bottom: 1px solid var(--line); padding-bottom: 4px; }

/* read-only rows */
.row { padding: 8px 4px; }
.row-name { font-weight: 700; }
.row-role { color: var(--muted); }
.row-star { color: var(--star); }
.row-email { color: #9089a0; font-size: 12px; }
.row-notes { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* editable rows */
.row-edit { border: 1px solid var(--line); border-radius: 11px; padding: 10px; margin: 8px 0; }
.row-edit:focus-within { border-color: #cdb4f2; box-shadow: 0 3px 14px rgba(130,45,218,0.08); }
.row-edit-top { display: flex; align-items: center; gap: 6px; }
.row-in-name { flex: 1; border: none; font-size: 14px; font-weight: 700; padding: 2px; background: transparent; }
.row-in-name:focus { outline: none; }
.star-btn { border: none; background: none; cursor: pointer; font-size: 18px; color: #cfc7dd; padding: 2px; }
.star-btn.on { color: var(--star); }
.row-del { border: none; background: none; color: #c0b8cf; cursor: pointer; font-size: 13px; padding: 2px 4px; }
.row-del:hover { color: var(--danger); }
.row-in-email { width: 100%; border: none; border-bottom: 1px dashed var(--line); background: transparent; font-size: 12px; color: #8a82a0; padding: 2px 2px 6px; margin: 3px 0 9px; }
.row-in-email:focus { outline: none; border-bottom-color: var(--purple); }
.row-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row-in { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; background: #fbfaff; margin-top: 8px; }
.row-edit-grid .row-in { margin-top: 0; }
.row-in:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(130,45,218,0.12); background: #fff; }

.save-note { text-align: center; font-size: 12px; min-height: 18px; margin-top: 6px; }

/* ---------- main nav ---------- */
.mainnav { max-width: 900px; margin: 0 auto; padding: 12px 22px 0; display: flex; gap: 6px; }
.navitem { border: none; background: transparent; color: var(--muted); font-weight: 700; font-size: 14px; padding: 10px 14px; border-radius: 10px 10px 0 0; cursor: pointer; border-bottom: 2px solid transparent; }
.navitem:hover { color: var(--ink); }
.navitem.active { color: var(--purple); border-bottom-color: var(--purple); }

.small { font-size: 12px; }
.inp.small, .row-in { font-size: 13px; }
.inp.small { padding: 7px 10px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.list-head-right { display: flex; align-items: center; gap: 12px; }

/* ---------- one-line deals ---------- */
.deal-lines { display: flex; flex-direction: column; gap: 8px; }
.deal-line { display: flex; align-items: center; justify-content: space-between; gap: 14px; text-align: left; background: #fff; border: 1px solid var(--line); border-left: 4px solid transparent; border-radius: 12px; padding: 12px 16px; cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.deal-line:hover { box-shadow: 0 6px 18px rgba(130,45,218,0.10); border-color: #d4befe; }
.deal-line.flag { border-left-color: var(--danger); }
.dl-main { min-width: 0; flex: 1; }
.dl-top { display: flex; align-items: center; gap: 10px; }
.dl-domain { font-weight: 800; font-size: 15px; }
.dl-subject { color: var(--muted); font-size: 13px; margin: 2px 0 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-meta { text-align: right; flex-shrink: 0; }
.dl-owner { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.dl-pills { display: flex; gap: 6px; justify-content: flex-end; }
.dl-date { font-size: 11px; color: var(--muted); margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { background: var(--purple-050); color: var(--purple); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.small.muted { font-size: 11px; }

.cov { font-size: 11px; font-weight: 700; white-space: nowrap; }
.cov-red { color: var(--danger); }
.cov-amber { color: #e08e0b; }
.cov-green { color: var(--ok); }
.tile-warn .tile-num { color: var(--danger); }

/* ---------- people table ---------- */
.people-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.ptable { width: 100%; border-collapse: collapse; font-size: 13px; }
.ptable th { text-align: left; padding: 10px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); border-bottom: 1px solid var(--line); }
.ptable td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prow { cursor: pointer; }
.prow:hover { background: var(--purple-050); }
.pname { font-weight: 700; }
.pemail { font-size: 11px; color: #9089a0; }

/* ---------- team ---------- */
.invite-row { display: flex; gap: 8px; margin: 6px 0; max-width: 520px; }
.invite-row .inp { flex: 1; }
.members { display: flex; flex-direction: column; gap: 4px; }
.member { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.member:last-child { border-bottom: none; }
.role-badge { font-size: 11px; font-weight: 700; color: var(--muted); background: #f0eef5; border-radius: 20px; padding: 3px 10px; }
.role-badge.mgr { color: var(--purple); background: var(--purple-050); }
.tag-you { font-size: 11px; color: var(--purple); font-weight: 700; }
.tag-pending { font-size: 11px; color: #e08e0b; font-weight: 700; }

/* ---------- critical map ---------- */
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.map-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.map-dept { font-weight: 600; font-size: 13px; }
.map-actions { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.legend { display: flex; gap: 16px; margin-top: 14px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend-item .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- checklist panel ---------- */
.checklist { margin: 14px 0; }
.check-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.check-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line); font-size: 13px; }
.check-item .check-icon { font-weight: 800; }
.check-item .check-dept { font-weight: 600; flex: 1; }
.check-item .check-level { font-size: 11px; font-weight: 700; }
.check-item.ok { background: #edf9f1; border-color: #bfe6cd; }
.check-item.ok .check-icon { color: var(--ok); }
.check-item.miss-critical { background: #fdecec; border-color: #f4bcbc; }
.check-item.miss-critical .check-icon { color: var(--danger); }
.check-item.miss-important { background: #fdf4e6; border-color: #f2d9a6; }
.check-item.miss-important .check-icon { color: #e08e0b; }
.check-item.miss-optional { background: #f6f5f9; }
.check-item.miss-optional .check-icon { color: var(--muted); }
