/* =============================================================================
   Curio Scaffold — App console design system
   -----------------------------------------------------------------------------
   The authenticated admin console (sidebar + top bar shell). Shares the brand
   tokens with the marketing site (public/assets/site.css) and adds app-only
   semantic tokens (alert/warning) and console components (cards, tables, pills,
   stat tiles). Vanilla CSS, no framework.
   ========================================================================== */

:root {
  --evergreen: #005439;
  --mid-green: #6c7e64;
  --charcoal: #414141;
  --black: #0f130f;
  --white: #ffffff;
  --off-white: #e2e6e9;
  --egg-shell: #fcf6ef;
  --yellow: #ffcc73;
  --muted: #5c6b64;
  /* App semantic accents */
  --alert: #f65536;   /* attention / danger */
  --warning: #6b5c1a; /* at-risk / mid-range */
  --level3: #16455d;  /* Level 3 tier badge */
  --sidebar-w: 260px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  color: var(--charcoal);
  background: var(--egg-shell);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* Layout ------------------------------------------------------------------ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* Sidebar ----------------------------------------------------------------- */
.sidebar { background: var(--evergreen); color: #fff; padding: 20px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.sidebar__brand { padding: 8px 6px 0; }
.sidebar__brand img { height: 22px; filter: brightness(0) invert(1); }
.nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 8px; font-size: 15px; font-weight: 500; color: rgba(255,255,255,0.75); }
.nav a .ico { width: 20px; height: 20px; border-radius: 6px; background: rgba(255,255,255,0.5); flex: none; display: grid; place-items: center; font-size: 12px; color: var(--evergreen); }
.nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav a.is-active { background: rgba(255,255,255,0.14); color: #fff; }
.nav a.is-active .ico { background: rgba(255,255,255,0.9); }
.usercard { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,0.08); border-radius: 10px; padding: 12px; }
.usercard__avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--yellow); color: var(--evergreen); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.usercard__name { font-size: 14px; font-weight: 600; color: #fff; }
.usercard__org { font-size: 12px; color: rgba(255,255,255,0.6); }

/* Top bar ----------------------------------------------------------------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--off-white); padding: 20px 36px; display: flex; align-items: center; justify-content: space-between; gap: 16px; position: sticky; top: 0; z-index: 10; }
.topbar__title { display: flex; align-items: center; gap: 16px; }
.topbar__title h1 { font-size: 22px; font-weight: 700; color: var(--black); margin: 0; }
.scope { display: inline-flex; align-items: center; gap: 8px; background: var(--off-white); border: 0; border-radius: 100px; padding: 8px 14px; font: 500 14px 'Manrope', sans-serif; color: var(--charcoal); cursor: pointer; }
.scope__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--evergreen); }
.topbar__right { display: flex; align-items: center; gap: 16px; }
.search { display: flex; align-items: center; gap: 8px; width: 220px; height: 42px; padding: 0 14px; background: var(--egg-shell); border: 1px solid var(--off-white); border-radius: 10px; color: var(--muted); }
.search input { border: 0; outline: 0; background: transparent; font: 400 14px 'Manrope', sans-serif; flex: 1; color: var(--charcoal); }
.topbar__avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--evergreen); color: #fff; display: grid; place-items: center; font-weight: 700; }

/* Buttons ----------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 14px 'Manrope', sans-serif; padding: 11px 20px; border-radius: 9px; border: 1.5px solid transparent; cursor: pointer; }
.btn--primary { background: var(--evergreen); color: #fff; }
.btn--primary:hover { filter: brightness(1.1); }
.btn--outline { background: transparent; color: var(--evergreen); border-color: var(--evergreen); }
.btn--outline:hover { background: var(--egg-shell); }
.btn:focus-visible { outline: 3px solid var(--evergreen); outline-offset: 2px; }

/* Content ----------------------------------------------------------------- */
.body { padding: 36px; display: flex; flex-direction: column; gap: 28px; }
.welcome h2 { font-size: 28px; font-weight: 500; color: var(--black); margin: 0 0 6px; }
.welcome p { font-size: 16px; color: var(--charcoal); margin: 0; }

/* Stat cards -------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.stat { background: #fff; border: 1px solid var(--off-white); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 8px; }
.stat__label { font-size: 14px; font-weight: 500; color: var(--charcoal); }
.stat__value { font-size: 42px; font-weight: 200; color: var(--black); line-height: 1; letter-spacing: -1px; }
.stat__delta { font-size: 13px; font-weight: 600; color: var(--mid-green); }
.stat__delta.is-alert { color: var(--alert); }

/* Generic card + table ---------------------------------------------------- */
.cols { display: grid; grid-template-columns: 1fr 360px; gap: 20px; }
.card { background: #fff; border: 1px solid var(--off-white); border-radius: 14px; }
/* Padded region for loose card content (text, buttons, form fields) that isn't a
   full-bleed section like .card__head / .table. Use inside a .card so content
   doesn't sit flush against the card edge. When it follows a .card__head, the
   head already supplies the top padding. */
.card__body { padding: 24px; }
.card__head + .card__body { padding-top: 0; }
/* Inside a padded body, row lists align to the body padding (not the card edge). */
.card__body .issue { padding-left: 0; padding-right: 0; }
.card__head { display: flex; align-items: center; justify-content: space-between; padding: 24px; }
.card__head h3 { font-size: 17px; font-weight: 700; color: var(--black); margin: 0; }
.card__head a { font-size: 14px; font-weight: 600; color: var(--evergreen); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 14px 24px; border-top: 1px solid var(--off-white); font-size: 15px; }
.table thead th { background: var(--egg-shell); border-top: 0; font-size: 13px; font-weight: 600; color: rgba(65,65,65,0.7); }
.table td.num, .table th.num { text-align: left; }
.table .course { font-weight: 600; color: var(--black); }
.table__scroll { overflow-x: auto; }

/* Status / quality pills -------------------------------------------------- */
.pill { display: inline-block; border-radius: 100px; padding: 5px 12px; font-size: 13px; font-weight: 600; }
.pill--green { background: rgba(0,84,57,0.16); color: var(--evergreen); }
.pill--charcoal { background: rgba(65,65,65,0.16); color: var(--charcoal); }
.pill--alert { background: rgba(246,85,54,0.16); color: var(--alert); }
.pill--amber { background: rgba(107,92,26,0.18); color: var(--warning); }
.q-green { color: var(--evergreen); font-weight: 600; }
.q-amber { color: var(--warning); font-weight: 600; }
.q-alert { color: var(--alert); font-weight: 600; }
.q-none { color: var(--charcoal); opacity: 0.6; }

/* Quick actions ----------------------------------------------------------- */
.quick { padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.quick h3 { font-size: 17px; font-weight: 700; color: var(--black); margin: 0 0 4px; }
.action { display: flex; align-items: center; gap: 14px; background: var(--egg-shell); border-radius: 10px; padding: 14px 16px; font-size: 15px; font-weight: 500; color: var(--black); }
.action:hover { background: var(--off-white); }
.action__ico { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-size: 15px; flex: none; }
.action__ico--eg { background: var(--evergreen); }
.action__ico--mg { background: var(--mid-green); }
.action__ico--yl { background: var(--yellow); color: var(--evergreen); }
.action .arrow { margin-left: auto; color: var(--charcoal); }

@media (max-width: 1080px) { .stats { grid-template-columns: repeat(2, 1fr); } .cols { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .app { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; } .nav { flex-direction: row; flex-wrap: wrap; } .usercard { display: none; } }

/* ===== Block library ================================================= */
.banner { background: var(--evergreen); color: #fff; border-radius: 12px; padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.banner__pill { display: inline-block; background: var(--yellow); color: var(--evergreen); font-size: 12px; font-weight: 700; letter-spacing: 0.5px; border-radius: 100px; padding: 4px 12px; margin-bottom: 10px; }
.banner__text p { margin: 0; font-size: 15px; }
.banner__text p + p { color: rgba(255,255,255,0.8); }
.btn--white { background: #fff; color: var(--evergreen); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.toolbar .search { width: 320px; height: 44px; background: #fff; }
.toolbar__count { font-size: 14px; color: var(--muted); }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters__label { font-size: 14px; font-weight: 600; color: var(--charcoal); margin-right: 4px; }
.filter-chip { border: 1px solid var(--off-white); background: #fff; color: var(--charcoal); border-radius: 100px; padding: 8px 16px; font: 500 14px 'Manrope', sans-serif; cursor: pointer; }
.filter-chip.is-active { background: var(--evergreen); color: #fff; border-color: var(--evergreen); }
.filter-chip.locked { opacity: 0.75; }
.clib-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.clib-card { position: relative; background: #fff; border: 1px solid var(--off-white); border-radius: 14px; overflow: hidden; }
.clib-card__preview { position: relative; height: 120px; background: var(--egg-shell); display: grid; place-items: center; }
.clib-card__preview span { width: 100px; height: 14px; border-radius: 7px; background: var(--mid-green); opacity: 0.7; }
.clib-card__info { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; }
.clib-card__title { font-size: 16px; font-weight: 700; color: var(--black); }
.clib-card__cat { font-size: 13px; color: var(--charcoal); opacity: 0.65; }
.tier-badge { position: absolute; top: 12px; left: 12px; border-radius: 100px; padding: 3px 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.3px; color: #fff; z-index: 2; }
.tier-badge--l1 { background: var(--mid-green); }
.tier-badge--l2 { background: var(--evergreen); }
.tier-badge--l3 { background: var(--level3); }
.tier-badge--custom { background: var(--alert); color: #111; }
.clib-btn { border-radius: 8px; padding: 8px 14px; font: 600 13px 'Manrope', sans-serif; cursor: pointer; border: 1.5px solid transparent; white-space: nowrap; }
.clib-btn--add { background: var(--evergreen); color: #fff; }
.clib-btn--added { background: transparent; color: var(--evergreen); border-color: var(--mid-green); }
.clib-btn--upgrade { background: transparent; color: rgba(65,65,65,0.7); border-color: rgba(65,65,65,0.3); }
.clib-card.locked .clib-card__preview span { opacity: 0.4; }
.lock-overlay { position: absolute; top: 42px; left: 50%; transform: translateX(-50%); width: 36px; height: 36px; border-radius: 50%; background: #fff; display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
@media (max-width: 1080px) { .clib-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .clib-grid { grid-template-columns: 1fr; } }

/* ===== Scaffold Advisor ================================================== */
.advisor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.advisor-head h2 { font-size: 28px; font-weight: 500; color: var(--black); margin: 0; }
.advisor-head__meta { font-size: 14px; color: var(--muted); margin-top: 4px; }
.advisor-head__right { display: flex; align-items: center; gap: 16px; }
.scorecard { display: flex; align-items: center; gap: 16px; background: #fff; border: 1px solid var(--off-white); border-radius: 14px; padding: 14px 20px; }
.scorecard__num { font-size: 44px; font-weight: 200; color: var(--black); line-height: 1; }
.scorecard__label { font-size: 13px; color: var(--charcoal); }
.issue { display: flex; align-items: center; gap: 14px; padding: 16px 24px; border-top: 1px solid var(--off-white); }
.issue__dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.dot--high { background: var(--alert); } .dot--med { background: var(--warning); } .dot--low { background: var(--evergreen); }
.issue__title { font-size: 15px; font-weight: 600; color: var(--black); }
.issue__sub { font-size: 13px; color: var(--charcoal); opacity: 0.7; }
.issue__action { margin-left: auto; font-size: 14px; font-weight: 600; color: var(--evergreen); }
.issue__action.passed { color: rgba(65,65,65,0.6); }
.breakdown { padding: 8px 24px 24px; }
.breakdown__row { padding: 14px 0; }
.breakdown__row .lbl { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px; color: var(--charcoal); }
.breakdown__row .lbl b { color: var(--black); font-weight: 700; }
.bar { height: 8px; background: var(--off-white); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 4px; }

/* ===== Rollout panel + team roster ====================================== */
.rollout { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.rollout__row { display: flex; align-items: center; gap: 12px; background: var(--egg-shell); border-radius: 10px; padding: 12px 14px; }
.rollout__title { font-size: 14px; font-weight: 600; color: var(--black); }
.rollout__sub { font-size: 13px; color: var(--charcoal); opacity: 0.7; }
.roster { padding: 8px 24px 24px; }
.team-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--off-white); }
.team-row:first-child { border-top: 0; }
.team-av { width: 34px; height: 34px; border-radius: 50%; background: var(--mid-green); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.team-name { font-size: 15px; font-weight: 600; color: var(--black); }
.team-role { font-size: 13px; color: var(--charcoal); opacity: 0.7; }

/* Console log-out button (appended to the sidebar user card by auth-guard.js). */
.usercard__logout {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: var(--white);
  border-radius: 8px;
  padding: 5px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.usercard__logout:hover { background: rgba(255, 255, 255, 0.12); }
