/* NUMI design system — spec §9.1 (brand #8439D9), premium & restrained */
:root {
  --primary: #8439D9;
  --primary-hover: #6E2BBF;
  --primary-deep: #5A23A0;
  --primary-tint: #E7D8F8;
  --primary-faint: #F5EFFC;
  --bg: #F5F3F9;
  --panel: #FFFFFF;
  --line: #EAE6F1;
  --line-strong: #DDD6EA;
  --text: #1E1330;
  --muted: #756E85;
  --success: #1D9E75;
  --warn: #BA7517;
  --danger: #D64545;
  --plum: #241533;
  --plum-2: #2E1A44;
  --radius: 12px;
  --shadow-xs: 0 1px 2px rgba(36, 21, 51, 0.05);
  --shadow-sm: 0 1px 2px rgba(36, 21, 51, 0.04), 0 3px 10px rgba(36, 21, 51, 0.05);
  --shadow-md: 0 8px 28px rgba(36, 21, 51, 0.10);
  --ease: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; transition: color var(--ease); }
a:hover { color: var(--primary-hover); }

/* Split-panel auth (spec §10): brand art side + form side */
.auth-split { display: flex; min-height: 100vh; }
.auth-brand {
  flex: 1.1; background: linear-gradient(155deg, #2E1A44 0%, #1C0F2B 100%); color: #fff;
  padding: 52px 56px; display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.auth-brand::before, .auth-brand::after {
  content: ''; position: absolute; border: 1.5px solid rgba(201, 168, 239, 0.16); border-radius: 50%;
}
.auth-brand::before { width: 440px; height: 440px; right: -140px; top: -140px; }
.auth-brand::after { width: 300px; height: 300px; left: -110px; bottom: -110px; border-color: rgba(201, 168, 239, 0.10); }
.brand-mark { font-size: 24px; font-weight: 600; letter-spacing: 0.22em; color: #C79BF0; }
.auth-brand-copy { margin-top: 26vh; position: relative; }
.auth-brand-copy h2 { font-size: 33px; font-weight: 600; line-height: 1.2; margin: 0 0 14px; max-width: 380px; letter-spacing: -0.01em; }
.auth-brand-copy p { color: #C9B8E8; max-width: 360px; line-height: 1.65; margin: 0; }
.auth-brand-foot { margin-top: auto; color: #8E7BAE; font-size: 13px; position: relative; }
.auth-side { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--bg); }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 40px; width: 100%; max-width: 410px; box-shadow: var(--shadow-md); }
@media (max-width: 900px) { .auth-brand { display: none; } }
.brand { font-size: 24px; font-weight: 600; color: var(--primary); letter-spacing: 0.12em; margin-bottom: 2px; }
.auth-card h1 { font-size: 20px; font-weight: 600; margin: 2px 0 20px; letter-spacing: -0.01em; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin: -14px 0 20px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 5px; font-weight: 500; }
input, select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line-strong); border-radius: 10px;
  font: inherit; background: #fff; color: var(--text); transition: border-color var(--ease), box-shadow var(--ease);
}
input::placeholder { color: #A9A2B8; }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }

.btn {
  display: inline-block; width: 100%; margin-top: 20px; padding: 12px 16px;
  background: var(--primary); color: #fff; border: 0; border-radius: 10px;
  font: inherit; font-weight: 500; cursor: pointer; text-align: center;
  box-shadow: 0 2px 8px rgba(132, 57, 217, 0.28); transition: background var(--ease), transform var(--ease), box-shadow var(--ease);
}
.btn:hover { background: var(--primary-hover); box-shadow: 0 4px 14px rgba(132, 57, 217, 0.34); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 4px rgba(132, 57, 217, 0.3); }
.btn-plain { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; transition: color var(--ease); }
.btn-plain:hover { color: var(--text); }

.error { background: #FCEBEB; color: #A32B2B; border-radius: 10px; padding: 11px 13px; font-size: 13px; margin-bottom: 10px; border: 1px solid #F5D6D6; }
.notice { background: var(--primary-faint); color: var(--primary-deep); border-radius: 10px; padding: 11px 13px; font-size: 13px; margin-bottom: 10px; border: 1px solid var(--primary-tint); }
.auth-foot { margin-top: 18px; font-size: 13px; color: var(--muted); text-align: center; }

.topbar {
  background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 14px 28px;
}
.topbar .brand { font-size: 18px; margin: 0; }
.topbar .who { font-size: 13px; color: var(--muted); }
.container { max-width: 960px; margin: 28px auto; padding: 0 20px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.cards .card { transition: transform var(--ease), box-shadow var(--ease); }
.cards .card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 500; }
.card .v { font-size: 28px; font-weight: 600; margin-top: 6px; letter-spacing: -0.02em; }
.card .v.hold { color: var(--warn); }
.card .v.ok { color: var(--success); }
.tier { display: inline-block; background: var(--primary-tint); color: var(--primary-deep); border-radius: 999px; padding: 3px 12px; font-size: 12px; font-weight: 500; text-transform: capitalize; }
.reflink { display: flex; gap: 8px; margin-top: 8px; }
.reflink input { font-size: 13px; color: var(--muted); }
.reflink button { width: auto; margin: 0; padding: 11px 16px; }
.muted-note { color: var(--muted); font-size: 13px; margin-top: 24px; }

.qr { display: block; margin: 12px auto; border: 1px solid var(--line); border-radius: 10px; }
.secret { font-family: ui-monospace, monospace; background: var(--primary-faint); color: var(--primary-deep); padding: 8px 12px; border-radius: 8px; text-align: center; font-size: 13px; letter-spacing: 0.04em; }

/* Portal shell — deep-plum sidebar */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 218px; flex-shrink: 0; background: linear-gradient(185deg, #2A1740 0%, #1C0F2B 100%);
  display: flex; flex-direction: column; padding: 22px 14px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 2px 10px 22px; color: #fff; }
.sidebar .brand span { color: #A48CC8; font-weight: 500; }
.sidebar nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: #B4A2D4; font-size: 14px; position: relative; transition: background var(--ease), color var(--ease);
}
.sidebar nav a svg { width: 18px; height: 18px; }
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar nav a.on { background: var(--primary); color: #fff; font-weight: 500; box-shadow: 0 4px 14px rgba(132, 57, 217, 0.4); }
.side-foot { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 2px; border-top: 1px solid rgba(255, 255, 255, 0.1); margin-top: 8px; }
.side-name { font-size: 13px; font-weight: 500; margin-bottom: 4px; color: #fff; }
.side-foot svg { width: 17px; height: 17px; }
.sidebar .tier { background: rgba(132, 57, 217, 0.45); color: #EAD9F9; }
.sidebar .btn-plain { color: #B4A2D4; }
.sidebar .btn-plain:hover { color: #fff; }

.main { flex: 1; padding: 24px 30px; min-width: 0; }
.pagehead { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.pagehead h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.02em; }
.pagehead .pid { font-size: 13px; color: var(--muted); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.card h2 { font-size: 14px; font-weight: 600; margin: 0 0 12px; letter-spacing: -0.01em; }

table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th {
  text-align: left; color: var(--muted); font-weight: 500; padding: 8px 8px;
  border-bottom: 1px solid var(--line); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
}
table.list td { padding: 9px 8px; border-bottom: 1px solid var(--line); }
table.list tbody tr { transition: background var(--ease); }
table.list tbody tr:hover { background: var(--primary-faint); }
table.list tr:last-child td { border-bottom: 0; }
.amount { font-variant-numeric: tabular-nums; font-weight: 500; }
.neg { color: var(--danger); }

.badge { display: inline-block; border-radius: 999px; padding: 2px 11px; font-size: 12px; font-weight: 500; }
.badge.ok { background: #E1F5EE; color: #085041; }
.badge.hold { background: #FAEEDA; color: #633806; }
.badge.muted { background: #EFECF4; color: var(--muted); }

.progress { height: 9px; background: var(--primary-faint); border-radius: 999px; overflow: hidden; margin: 7px 0 4px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), #A25CE6); border-radius: 999px; transition: width var(--ease); }
.progress-label { font-size: 12px; color: var(--muted); }

.level-head { display: flex; align-items: center; gap: 10px; margin: 20px 0 8px; }
.level-head .lvl { background: var(--primary-tint); color: var(--primary-deep); border-radius: 8px; padding: 3px 11px; font-size: 13px; font-weight: 500; }
.level-head .cnt { color: var(--muted); font-size: 13px; }

.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 130px; }
.inline-form .btn { width: auto; margin-top: 0; padding: 11px 18px; }
.empty { color: var(--muted); font-size: 13px; padding: 16px 0; text-align: center; }

/* Genealogy org chart — top-down boxes with connector lines */
.org-scroll { overflow-x: auto; padding: 12px 4px 18px; }
ul.org, .org ul { display: flex; justify-content: center; list-style: none; margin: 0; padding: 28px 0 0; position: relative; }
ul.org { padding-top: 0; min-width: max-content; margin: 0 auto; }
.org li { display: flex; flex-direction: column; align-items: center; position: relative; padding: 28px 12px 0; }
ul.org > li { padding-top: 0; }
.org li::before, .org li::after {
  content: ''; position: absolute; top: 0; right: 50%;
  border-top: 2px solid var(--line-strong); width: 50%; height: 28px;
}
.org li::after { right: auto; left: 50%; border-left: 2px solid var(--line-strong); }
.org li:only-child::before, .org li:only-child::after { display: none; }
.org li:only-child { padding-top: 28px; }
ul.org > li:only-child { padding-top: 0; }
.org li:first-child::before, .org li:last-child::after { border-top: 0; }
.org li:last-child::before { border-right: 2px solid var(--line-strong); border-radius: 0 10px 0 0; }
.org li:first-child::after { border-radius: 10px 0 0 0; }
.org ul::before { content: ''; position: absolute; top: 0; left: 50%; border-left: 2px solid var(--line-strong); height: 28px; }

.org-node {
  background: var(--panel); border: 1.5px solid var(--line-strong); border-radius: 16px;
  padding: 14px 18px 12px; min-width: 156px; max-width: 196px; box-shadow: var(--shadow-xs);
  display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center;
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}
a.org-node:hover { border-color: var(--primary); color: inherit; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.org-root > .org-node, .org-root > a.org-node { border-color: var(--primary); background: var(--primary-faint); box-shadow: 0 4px 16px rgba(132, 57, 217, 0.16); }
.org-avatar {
  width: 46px; height: 46px; border-radius: 50%; margin-bottom: 4px;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 15px;
}
.av-none { background: #EDE8F4; color: var(--muted); }
.av-basic { background: var(--primary-tint); color: var(--primary-deep); }
.av-mastery { background: var(--primary); color: #fff; }
.av-certified { background: linear-gradient(150deg, #2E1A44, #4A2A6E); color: #E7D8F8; }
.org-name { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3; }
.org-meta { font-size: 11px; color: var(--muted); }
.org-toggle {
  margin-top: 9px; border: 0; background: var(--primary-faint); color: var(--primary-deep);
  border-radius: 999px; padding: 3px 12px; font: inherit; font-size: 11px; font-weight: 500; cursor: pointer;
  transition: background var(--ease);
}
.org-toggle:hover { background: var(--primary-tint); }
li.collapsed > ul { display: none; }
.org-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; font-size: 12px; color: var(--muted); align-items: center; }
.org-legend .org-avatar { width: 16px; height: 16px; font-size: 0; margin: 0; }

/* Course / product source pills */
.pill-course { display: inline-block; border-radius: 999px; padding: 2px 11px; font-size: 12px; font-weight: 500; background: var(--primary-tint); color: var(--primary-deep); }
.pill-product { display: inline-block; border-radius: 999px; padding: 2px 11px; font-size: 12px; font-weight: 500; background: #E1F5EE; color: #085041; }

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 12px; }
  .sidebar .brand { padding: 0 12px 0 4px; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar nav a span { display: none; }
  .side-foot { border: 0; padding: 0 0 0 8px; margin: 0; }
  .side-me { display: none; }
  .main { padding: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
