/* =========================================================
   PROJECT PULSE — Interactive Prototype
   OpenEMIS-style shell (navy sidebar, white workspace)
   with Project PULSE red as the module colour.
   ========================================================= */

:root {
  --red: #D3111C;
  --red-deep: #A90E17;
  --red-soft: #FDECEC;
  --coral: #F25C54;
  --blue: #0B4EA2;
  --blue-soft: #E8F0FB;
  --yellow: #F7C948;
  --yellow-soft: #FFF6DB;
  --green: #0A8A43;
  --green-soft: #E5F5EC;
  --orange: #E07B12;
  --orange-soft: #FDF0E1;

  --navy: #14213D;
  --navy-2: #1C2B4D;
  --navy-3: #26385F;
  --ink: #14213D;
  --ink-soft: #4A5670;
  --muted: #6B7690;
  --line: #E3E7EE;
  --bg: #F2F4F8;
  --card: #FFFFFF;

  --font-head: "Lexend", "Segoe UI", system-ui, sans-serif;
  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(20,33,61,.05), 0 4px 14px rgba(20,33,61,.05);
  --shadow-lg: 0 20px 50px rgba(20,33,61,.18);
  --side-w: 248px;
  --top-h: 64px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-body); font-size: 16px; line-height: 1.55;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; line-height: 1.2; color: var(--ink); }
p { margin: 0 0 .8em; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Boot loader ---------- */
.boot {
  position: fixed; inset: 0; z-index: 2000; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem;
  transition: opacity .5s var(--ease), visibility .5s;
}
.boot.is-done { opacity: 0; visibility: hidden; }
.boot img { animation: beat 1.1s var(--ease) infinite; transform-origin: 50% 60%; }
.boot__ecg { width: min(420px, 80vw); height: 50px; }
.boot__ecg path { fill: none; stroke: var(--red); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 900; stroke-dashoffset: 900; animation: trace 1.6s var(--ease) infinite; }
.boot p { font-family: var(--font-head); color: var(--muted); margin: 0; }
.boot__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; display: flex; background: var(--bg); }
.boot__bar i { flex: 1; transform: scaleX(0); transform-origin: left; animation: grow .45s linear forwards; }
.boot__bar i:nth-child(1) { background: var(--blue); }
.boot__bar i:nth-child(2) { background: var(--yellow); animation-delay: .45s; }
.boot__bar i:nth-child(3) { background: var(--red); animation-delay: .9s; }
.boot__bar i:nth-child(4) { background: var(--green); animation-delay: 1.35s; }
@keyframes trace { 0% { stroke-dashoffset: 900; } 70% { stroke-dashoffset: 0; opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes beat { 0%,100% { transform: scale(1); } 14% { transform: scale(1.08); } 28% { transform: scale(1); } 42% { transform: scale(1.05); } 70% { transform: scale(1); } }
@keyframes grow { to { transform: scaleX(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Buttons & form controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 42px; padding: .55rem 1.1rem; border-radius: 10px; border: 1.5px solid transparent;
  font-family: var(--font-head); font-weight: 500; font-size: .95rem; line-height: 1.2;
  cursor: pointer; text-decoration: none; background: none; transition: background-color .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn--primary { background: var(--red); color: #fff; }
.btn--primary:hover { background: var(--red-deep); }
.btn--navy { background: var(--navy); color: #fff; }
.btn--navy:hover { background: var(--navy-3); }
.btn--blue { background: var(--blue); color: #fff; }
.btn--blue:hover { background: #083c7d; }
.btn--green { background: var(--green); color: #fff; }
.btn--green:hover { background: #076a33; }
.btn--outline { border-color: var(--line); color: var(--ink); background: #fff; }
.btn--outline:hover { border-color: var(--ink); }
.btn--ghost { color: var(--ink-soft); }
.btn--ghost:hover { background: var(--bg); color: var(--ink); }
.btn--sm { min-height: 34px; padding: .35rem .8rem; font-size: .88rem; border-radius: 8px; }
.btn--lg { min-height: 52px; padding: .8rem 1.5rem; font-size: 1.05rem; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }

.field { display: grid; gap: .4rem; margin-bottom: 1.25rem; }
.field > label, .field__label { font-family: var(--font-head); font-weight: 500; font-size: .98rem; }
.field__hint { font-size: .9rem; color: var(--muted); margin: 0; }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: .65rem .9rem; border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11,78,162,.15); }
.input.is-invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(211,17,28,.12); }
.error-text { color: var(--red); font-size: .92rem; margin: 0; }

/* Chips (multi / single select) */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem .9rem; border-radius: 999px; border: 1.5px solid var(--line); background: #fff;
  cursor: pointer; font-size: .95rem; transition: all .15s;
}
.chip:hover { border-color: var(--ink-soft); }
.chip[aria-pressed="true"], .chip.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Option cards (radio-like) */
.options { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.option {
  display: flex; align-items: center; gap: .75rem; text-align: left;
  padding: .9rem 1rem; border: 1.5px solid var(--line); border-radius: var(--r); background: #fff; cursor: pointer;
}
.option:hover { border-color: var(--ink-soft); }
.option[aria-checked="true"] { border-color: var(--red); background: var(--red-soft); box-shadow: inset 0 0 0 1px var(--red); }
.option__dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.option[aria-checked="true"] .option__dot { border: 5px solid var(--red); }
.option strong { display: block; font-family: var(--font-head); font-weight: 500; }
.option small { color: var(--muted); }

/* Mood picker */
.moods { display: grid; grid-template-columns: repeat(5, 1fr); gap: .6rem; }
.mood {
  display: grid; justify-items: center; gap: .45rem; padding: 1rem .5rem;
  border: 1.5px solid var(--line); border-radius: var(--r-lg); background: #fff; cursor: pointer;
  font-family: var(--font-head); font-size: .92rem; transition: all .15s;
}
.mood:hover { border-color: var(--ink-soft); transform: translateY(-1px); }
.mood svg { width: 42px; height: 42px; }
.mood[aria-checked="true"] { border-color: var(--mc); background: color-mix(in srgb, var(--mc) 10%, #fff); box-shadow: inset 0 0 0 1px var(--mc); }

/* Range */
.range { display: grid; gap: .35rem; }
.range input { width: 100%; accent-color: var(--red); height: 28px; }
.range__ends { display: flex; justify-content: space-between; font-size: .88rem; color: var(--muted); }
.range__value { font-family: var(--font-head); font-weight: 500; color: var(--ink); }

/* Toggle switch */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch__text strong { display: block; font-family: var(--font-head); font-weight: 500; }
.switch__text span { font-size: .92rem; color: var(--muted); }
.toggle { position: relative; width: 46px; height: 26px; border-radius: 999px; background: var(--line); border: 0; cursor: pointer; flex: none; transition: background .2s; }
.toggle::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s var(--ease); }
.toggle[aria-checked="true"] { background: var(--green); }
.toggle[aria-checked="true"]::after { transform: translateX(20px); }

/* ---------- Badges / pills ---------- */
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; font-family: var(--font-head); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--red { background: var(--red-soft); color: var(--red-deep); }
.pill--orange { background: var(--orange-soft); color: #9A5207; }
.pill--yellow { background: var(--yellow-soft); color: #7A5A00; }
.pill--green { background: var(--green-soft); color: var(--green); }
.pill--blue { background: var(--blue-soft); color: var(--blue); }
.pill--grey { background: var(--bg); color: var(--ink-soft); }
.badge-proto {
  font-family: var(--font-head); font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  padding: .2rem .5rem; border-radius: 6px; background: var(--yellow); color: var(--navy);
}

/* ---------- Gate pages (access / roles) ---------- */
.gate { min-height: 100vh; display: flex; flex-direction: column; background: #fff; }
.gate__top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--line); }
.gate__brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); }
.gate__brand img { width: 42px; }
.brandword { display: flex; flex-direction: column; line-height: 1; font-family: var(--font-head); }
.brandword small { font-size: .78rem; font-weight: 400; }
.brandword b { font-size: 1.25rem; font-weight: 800; color: var(--red); letter-spacing: .02em; }
.gate__ribbon { display: flex; height: 4px; }
.gate__ribbon i { flex: 1; }
.gate__ribbon i:nth-child(1) { background: var(--blue); } .gate__ribbon i:nth-child(2) { background: var(--yellow); }
.gate__ribbon i:nth-child(3) { background: var(--red); } .gate__ribbon i:nth-child(4) { background: var(--green); }
.gate__main { flex: 1; display: grid; place-items: center; padding: clamp(2rem, 6vw, 4rem) clamp(1rem, 4vw, 2.5rem); }
.gate__foot { padding: 1.25rem clamp(1rem, 4vw, 2.5rem); border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.gate__foot img { width: 70px; }

.access { width: min(1040px, 100%); display: grid; grid-template-columns: 1.1fr 1fr; gap: clamp(2rem, 5vw, 4rem); align-items: center; }
.access h1 { font-size: clamp(2rem, 4.4vw, 3rem); font-weight: 800; letter-spacing: -.025em; margin-bottom: 1rem; }
.access__sub { font-size: 1.2rem; color: var(--ink-soft); font-family: var(--font-head); font-weight: 300; line-height: 1.5; }
.access__card { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: clamp(1.5rem, 4vw, 2.25rem); box-shadow: var(--shadow-lg); }
.access__card h2 { font-size: 1.25rem; margin-bottom: 1rem; }
.access__note { font-size: .88rem; color: var(--muted); margin: 1rem 0 0; }
.notice {
  display: flex; gap: .8rem; align-items: flex-start;
  padding: 1rem 1.1rem; border-radius: var(--r); background: var(--yellow-soft); border: 1px solid #F1DFA3; color: #4D3A06;
  font-size: .95rem;
}
.notice svg { width: 20px; height: 20px; flex: none; margin-top: .15rem; }
.notice p { margin: 0; }
.notice strong { display: block; font-family: var(--font-head); }
.notice--red { background: var(--red-soft); border-color: #F5C2C4; color: #6D0A10; }
.notice--blue { background: var(--blue-soft); border-color: #C9DAF3; color: #0A3A78; }
.access__status { margin-top: 1.25rem; font-size: .95rem; color: var(--ink-soft); }

.roles { width: min(1120px, 100%); }
.roles__head { text-align: center; max-width: 640px; margin: 0 auto 2.5rem; }
.roles__head h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -.02em; margin-bottom: .6rem; }
.roles__head p { color: var(--ink-soft); font-size: 1.1rem; }
.roles__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.role-card {
  display: flex; flex-direction: column; gap: 1rem; text-align: left;
  padding: 1.75rem; border-radius: 20px; background: #fff; border: 1.5px solid var(--line);
  cursor: pointer; transition: border-color .2s, box-shadow .2s, transform .2s; position: relative; overflow: hidden;
}
.role-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--rc); }
.role-card:hover { border-color: var(--rc); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.role-card__icon { width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; background: color-mix(in srgb, var(--rc) 12%, #fff); color: var(--rc); }
.role-card__icon svg { width: 30px; height: 30px; }
.role-card h2 { font-size: 1.35rem; }
.role-card p { color: var(--ink-soft); margin: 0; flex: 1; }
.role-card .btn { align-self: flex-start; background: var(--rc); color: #fff; }
.roles__foot { text-align: center; color: var(--muted); font-size: .92rem; margin-top: 2rem; }
.roles__who { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--muted); }

/* ---------- App shell ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); grid-template-rows: auto auto 1fr; background: linear-gradient(to right, var(--navy) var(--side-w), var(--bg) var(--side-w)); }
.topbar {
  grid-column: 1 / -1; position: sticky; top: 0; z-index: 50;
  height: var(--top-h); display: flex; align-items: center; gap: 1rem; padding: 0 1rem 0 0;
  background: #fff; border-bottom: 1px solid var(--line);
}
.topbar__brand { width: var(--side-w); height: 100%; display: flex; align-items: center; gap: .6rem; padding: 0 1.1rem; background: var(--navy); color: #fff; text-decoration: none; flex: none; }
.topbar__brand img { width: 36px; background: #fff; border-radius: 8px; padding: 3px; }
.topbar__brand .brandword small { color: rgba(255,255,255,.75); }
.topbar__brand .brandword b { color: #fff; font-size: 1.1rem; }
.topbar__brand .badge-proto { margin-left: auto; }
.topbar__crumbs { display: flex; align-items: center; gap: .5rem; font-family: var(--font-head); font-size: .92rem; color: var(--muted); min-width: 0; }
.topbar__crumbs b { color: var(--ink); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__emis { font-weight: 600; color: var(--ink-soft); }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.role-chip { display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .75rem .3rem .3rem; border-radius: 999px; background: var(--bg); font-family: var(--font-head); font-size: .88rem; }
.role-chip__av { font-size: .72rem; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--rc, var(--red)); color: #fff; font-weight: 600; font-size: .8rem; }
.role-chip small { display: block; color: var(--muted); font-size: .74rem; line-height: 1; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink-soft); }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn__count { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: var(--red); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; }
.menu-btn { display: none; }

.protobar {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: .6rem;
  padding: .45rem 1rem; background: var(--yellow-soft); border-bottom: 1px solid #F1DFA3; color: #4D3A06; font-size: .88rem; text-align: center;
}
.protobar svg { width: 16px; height: 16px; flex: none; }

.sidebar { background: var(--navy); color: #fff; padding: 1rem .75rem 2rem; position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto; }
.sidebar__module { display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; margin-bottom: .75rem; border-radius: 10px; background: rgba(255,255,255,.06); font-family: var(--font-head); font-size: .85rem; color: rgba(255,255,255,.8); }
.sidebar__module span { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 4px rgba(242,92,84,.25); }
.sidebar__label { font-family: var(--font-head); font-size: .74rem; letter-spacing: .06em; color: rgba(255,255,255,.45); padding: .9rem .8rem .4rem; }
.side-link {
  display: flex; align-items: center; gap: .75rem; width: 100%;
  padding: .62rem .8rem; border-radius: 10px; border: 0; background: none; cursor: pointer;
  color: rgba(255,255,255,.78); font-family: var(--font-head); font-size: .94rem; text-align: left; text-decoration: none;
}
.side-link svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.side-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-link.is-active { background: var(--red); color: #fff; }
.side-link.is-active svg { opacity: 1; }
.side-link__count { margin-left: auto; background: rgba(255,255,255,.16); border-radius: 999px; font-size: .74rem; padding: .05rem .5rem; }
.side-link.is-active .side-link__count { background: rgba(255,255,255,.25); }
.sidebar__sep { height: 1px; background: rgba(255,255,255,.1); margin: 1rem .5rem; }

.main { min-width: 0; padding: clamp(1rem, 3vw, 2rem); }
.main__inner { max-width: 1240px; margin: 0 auto; animation: fadeUp .25s var(--ease); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { font-size: clamp(1.45rem, 2.6vw, 1.9rem); font-weight: 700; letter-spacing: -.015em; }
.page-head p { margin: .3rem 0 0; color: var(--ink-soft); }

/* ---------- Cards & grids ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(1.1rem, 2.4vw, 1.5rem); box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 0; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card__head h2, .card__head h3 { font-size: 1.08rem; font-weight: 600; }
.card__sub { color: var(--muted); font-size: .9rem; margin: .15rem 0 0; }
.grid { display: grid; gap: 1.25rem; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: grid; gap: 1.25rem; }
.mt { margin-top: 1.25rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

.stat { display: flex; flex-direction: column; gap: .35rem; position: relative; overflow: hidden; }
.stat__label { font-family: var(--font-head); font-size: .9rem; color: var(--ink-soft); padding-right: 48px; }
.stat__value { font-family: var(--font-head); font-size: clamp(1.7rem, 3vw, 2.2rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat__foot { font-size: .86rem; color: var(--muted); display: flex; align-items: center; gap: .35rem; }
.stat__icon { position: absolute; right: 1rem; top: 1rem; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--sc, var(--red)) 12%, #fff); color: var(--sc, var(--red)); }
.stat__icon svg { width: 22px; height: 22px; }
.stat--click { cursor: pointer; transition: border-color .15s; }
.stat--click:hover { border-color: var(--ink-soft); }
.trend-up { color: var(--green); } .trend-down { color: var(--red); }
.demo-tag { display: inline-block; font-size: .72rem; font-family: var(--font-head); color: var(--muted); border: 1px dashed var(--line); border-radius: 6px; padding: .05rem .4rem; }

/* Welcome banner (student) */
.welcome {
  display: grid; grid-template-columns: 1fr auto; gap: 1.5rem; align-items: center;
  background: linear-gradient(120deg, var(--red) 0%, var(--coral) 100%); color: #fff; border: 0; position: relative; overflow: hidden;
}
.welcome::after { content: ""; position: absolute; right: -60px; bottom: -80px; width: 260px; height: 260px; border-radius: 50%; border: 40px solid rgba(255,255,255,.12); }
.welcome h1 { color: #fff; font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 700; margin-bottom: .3rem; }
.welcome p { margin: 0; font-size: 1.1rem; color: rgba(255,255,255,.9); font-family: var(--font-head); font-weight: 300; }
.welcome .btn { background: #fff; color: var(--red); position: relative; z-index: 1; }

/* Action tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1rem; }
.tile {
  display: flex; flex-direction: column; gap: .8rem; align-items: flex-start; text-align: left;
  padding: 1.25rem; border-radius: var(--r-lg); border: 1px solid var(--line); background: #fff; cursor: pointer;
  box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--tc); transform: translateY(-2px); }
.tile__icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--tc) 12%, #fff); color: var(--tc); }
.tile__icon svg { width: 24px; height: 24px; }
.tile strong { font-family: var(--font-head); font-weight: 600; font-size: 1.02rem; }
.tile span { color: var(--muted); font-size: .9rem; line-height: 1.4; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list__item { display: flex; align-items: center; gap: .9rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.list__item:last-child { border-bottom: 0; }
.list__item--click { cursor: pointer; border-radius: 10px; padding: .8rem .6rem; margin: 0 -.6rem; }
.list__item--click:hover { background: var(--bg); }
.list__icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--bg); color: var(--ink-soft); }
.list__icon svg { width: 20px; height: 20px; }
.list__body { flex: 1; min-width: 0; }
.list__body strong { display: block; font-family: var(--font-head); font-weight: 500; }
.list__body span { color: var(--muted); font-size: .9rem; }
.list__end { margin-left: auto; display: flex; align-items: center; gap: .5rem; flex: none; }
.mood-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 calc(clamp(1.1rem, 2.4vw, 1.5rem) * -1); padding: 0 clamp(1.1rem, 2.4vw, 1.5rem); }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; min-width: 640px; }
.table th { text-align: left; font-family: var(--font-head); font-weight: 500; font-size: .84rem; color: var(--muted); padding: .7rem .75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .85rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.is-click { cursor: pointer; }
.table tbody tr.is-click:hover td { background: #F8F9FC; }
.table .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .9rem; font-weight: 600; }
.bar-cell { display: flex; align-items: center; gap: .6rem; min-width: 120px; }
.bar-cell__track { flex: 1; height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar-cell__fill { height: 100%; border-radius: 99px; background: var(--bc, var(--blue)); }

/* Tabs / segmented */
.tabs { display: inline-flex; gap: .25rem; padding: .25rem; background: var(--bg); border-radius: 12px; flex-wrap: wrap; }
.tab { border: 0; background: none; padding: .45rem .95rem; border-radius: 9px; cursor: pointer; font-family: var(--font-head); font-size: .9rem; color: var(--ink-soft); }
.tab[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(20,33,61,.12); font-weight: 500; }
.toolbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.toolbar .input { max-width: 280px; min-height: 40px; }

/* Charts */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-head); font-size: 11px; fill: var(--muted); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .val { fill: var(--ink); font-weight: 500; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .86rem; color: var(--ink-soft); margin-top: .75rem; }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.hbars { display: grid; gap: .7rem; }
.hbar { display: grid; grid-template-columns: 140px 1fr 48px; gap: .75rem; align-items: center; font-size: .93rem; }
.hbar__track { height: 12px; border-radius: 99px; background: var(--bg); overflow: hidden; }
.hbar__fill { height: 100%; border-radius: 99px; background: var(--c, var(--red)); transition: width .5s var(--ease); }
.hbar b { font-family: var(--font-head); font-weight: 500; text-align: right; }
.gauge { display: grid; place-items: center; position: relative; }
.gauge__label { position: absolute; text-align: center; }
.gauge__label b { display: block; font-family: var(--font-head); font-size: 1.8rem; font-weight: 700; }
.gauge__label span { font-size: .82rem; color: var(--muted); }

/* Messages */
.chat { display: grid; grid-template-columns: 300px 1fr; min-height: 560px; padding: 0; overflow: hidden; }
.chat--single { grid-template-columns: 1fr; }
.chat__list { border-right: 1px solid var(--line); overflow-y: auto; }
.chat__thread { display: flex; gap: .75rem; align-items: center; padding: 1rem; border-bottom: 1px solid var(--line); cursor: pointer; width: 100%; background: none; border-left: 3px solid transparent; text-align: left; border-top: 0; border-right: 0; }
.chat__thread:hover { background: var(--bg); }
.chat__thread.is-active { background: var(--red-soft); border-left-color: var(--red); }
.chat__thread strong { font-family: var(--font-head); font-weight: 500; display: block; }
.chat__thread span { font-size: .86rem; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.chat__unread { margin-left: auto; width: 10px; height: 10px; border-radius: 50%; background: var(--red); flex: none; }
.chat__pane { display: flex; flex-direction: column; min-width: 0; }
.chat__head { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.chat__head strong { font-family: var(--font-head); font-weight: 600; display: block; }
.chat__head span { font-size: .86rem; color: var(--muted); }
.chat__note { padding: .5rem 1rem; background: var(--yellow-soft); color: #4D3A06; font-size: .84rem; text-align: center; }
.chat__body { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem; background: #FAFBFD; max-height: 520px; }
.bubble { max-width: min(78%, 520px); padding: .7rem 1rem; border-radius: 16px; background: #fff; border: 1px solid var(--line); animation: fadeUp .2s var(--ease); }
.bubble small { display: block; font-size: .76rem; color: var(--muted); margin-top: .3rem; }
.bubble--me { align-self: flex-end; background: var(--navy); color: #fff; border-color: var(--navy); border-bottom-right-radius: 4px; }
.bubble--me small { color: rgba(255,255,255,.65); }
.bubble--them { border-bottom-left-radius: 4px; }
.bubble--system { align-self: center; background: none; border: 0; color: var(--muted); font-size: .84rem; padding: .2rem; }
.chat__form { display: flex; gap: .6rem; padding: 1rem; border-top: 1px solid var(--line); background: #fff; }
.chat__form .input { flex: 1; }
.typing { display: inline-flex; gap: 4px; padding: .9rem 1rem; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; font-family: var(--font-head); font-weight: 600; font-size: .85rem; color: #fff; background: var(--ac, var(--blue)); }

/* Resource cards */
.resources { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.resource { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: var(--r-lg); padding: 0; cursor: pointer; overflow: hidden; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; display: flex; flex-direction: column; }
.resource:hover { transform: translateY(-2px); border-color: var(--rc); }
.resource__top { height: 90px; display: grid; place-items: center; background: color-mix(in srgb, var(--rc) 12%, #fff); color: var(--rc); }
.resource__top svg { width: 36px; height: 36px; }
.resource__body { padding: 1rem 1.1rem 1.2rem; }
.resource__body strong { font-family: var(--font-head); font-weight: 600; display: block; margin-bottom: .3rem; }
.resource__body span { color: var(--muted); font-size: .9rem; }

/* Success state */
.success { text-align: center; padding: clamp(1.5rem, 4vw, 2.5rem); }
.success__icon { width: 72px; height: 72px; margin: 0 auto 1rem; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft); color: var(--green); }
.success__icon svg { width: 36px; height: 36px; }
.success h2 { font-size: 1.5rem; margin-bottom: .5rem; }
.success p { color: var(--ink-soft); max-width: 52ch; margin-left: auto; margin-right: auto; }
.success .btn-row { justify-content: center; margin-top: 1.25rem; }
.suggest { text-align: left; margin: 1.5rem auto 0; max-width: 560px; padding: 1.1rem 1.25rem; border-radius: var(--r); border: 1px solid var(--line); background: #fff; }
.suggest--warm { background: var(--red-soft); border-color: #F5C2C4; }
.suggest--calm { background: var(--green-soft); border-color: #BFE3CD; }
.suggest--blue { background: var(--blue-soft); border-color: #C9DAF3; }
.suggest p { margin: 0 0 .8rem; color: var(--ink); }

/* Steps indicator */
.stepper { display: flex; gap: .5rem; margin-bottom: 1.5rem; }
.stepper i { flex: 1; height: 5px; border-radius: 99px; background: var(--line); }
.stepper i.is-done { background: var(--red); }
.q { padding: 1.4rem 0; border-bottom: 1px solid var(--line); }
.q:first-of-type { padding-top: 0; }
.q:last-of-type { border-bottom: 0; }
.q h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: .9rem; }
.q h3 small { font-weight: 400; color: var(--muted); font-size: .88rem; margin-left: .35rem; }

/* Case drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(20,33,61,.45); z-index: 900; animation: fade .2s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: #fff; z-index: 901; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slideIn .25s var(--ease); }
.drawer__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--line); }
.drawer__head h2 { font-size: 1.3rem; }
.drawer__body { flex: 1; overflow-y: auto; padding: 1.25rem 1.5rem 2rem; }
.drawer__foot { padding: 1rem 1.5rem; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: .5rem; background: #FAFBFD; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .9rem 1.25rem; margin-bottom: 1.5rem; }
.kv dt { font-size: .82rem; color: var(--muted); font-family: var(--font-head); }
.kv dd { margin: .1rem 0 0; font-weight: 600; }
.section-title { font-family: var(--font-head); font-weight: 600; font-size: .98rem; margin: 1.5rem 0 .75rem; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1rem .6rem; font-size: .93rem; }
.timeline li::before { content: ""; position: absolute; left: -1.55rem; top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--tl, var(--muted)); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.timeline li span { display: block; font-size: .82rem; color: var(--muted); }
@keyframes fade { from { opacity: 0; } }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,33,61,.5); z-index: 950; display: grid; place-items: center; padding: 1rem; animation: fade .2s; }
.modal { background: #fff; border-radius: 20px; width: min(640px, 100%); max-height: calc(100vh - 2rem); overflow-y: auto; box-shadow: var(--shadow-lg); animation: fadeUp .25s var(--ease); }
.modal--wide { width: min(860px, 100%); }
.modal__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.4rem 1.5rem 0; }
.modal__head h2 { font-size: 1.35rem; }
.modal__body { padding: 1.25rem 1.5rem 1.5rem; }
.modal__body p, .modal__body li { color: var(--ink-soft); }
.modal__body ul { padding-left: 1.2rem; }
.modal__foot { padding: 0 1.5rem 1.5rem; display: flex; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; }

/* Notifications dropdown */
.notif { position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, calc(100vw - 2rem)); background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); z-index: 100; overflow: hidden; animation: fadeUp .18s var(--ease); }
.notif__head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1rem; border-bottom: 1px solid var(--line); font-family: var(--font-head); font-weight: 600; }
.notif__item { display: flex; gap: .75rem; padding: .9rem 1rem; border-bottom: 1px solid var(--line); cursor: pointer; width: 100%; text-align: left; background: #fff; border-left: 0; border-right: 0; border-top: 0; }
.notif__item:hover { background: var(--bg); }
.notif__item strong { display: block; font-family: var(--font-head); font-weight: 500; font-size: .93rem; }
.notif__item span { font-size: .85rem; color: var(--muted); }
.notif__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex: none; margin-top: .45rem; }
.notif__empty { padding: 2rem 1rem; text-align: center; color: var(--muted); font-size: .93rem; }
.relative { position: relative; }

/* Report preview (fake PDF) */
.report-paper { background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 10px 30px rgba(20,33,61,.12); padding: 2rem; font-size: .93rem; }
.report-paper__head { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid var(--red); padding-bottom: 1rem; margin-bottom: 1.25rem; gap: 1rem; }
.report-paper__head img { width: 44px; }
.report-paper h3 { font-size: 1.3rem; }
.report-paper h4 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.report-paper table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.report-paper td, .report-paper th { border-bottom: 1px solid var(--line); padding: .45rem .3rem; text-align: left; }
.report-paper__foot { margin-top: 1.5rem; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: .75rem; }
.watermark { color: var(--red); font-family: var(--font-head); font-weight: 700; font-size: .78rem; letter-spacing: .08em; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--red); animation: spin .8s linear infinite; margin: 0 auto 1rem; }
.report-card { display: flex; flex-direction: column; gap: .75rem; }
.report-card__icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); }
.report-card__icon svg { width: 24px; height: 24px; }
.report-card h3 { font-size: 1.05rem; font-weight: 600; }
.report-card p { color: var(--ink-soft); font-size: .93rem; margin: 0; flex: 1; }

/* Access matrix */
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.yes { color: var(--green); font-weight: 700; } .no { color: var(--red); font-weight: 700; } .part { color: var(--orange); font-weight: 700; }

/* Toasts */
.toasts { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); z-index: 1000; display: grid; gap: .5rem; width: min(440px, calc(100vw - 2rem)); }
.toast { display: flex; align-items: center; gap: .7rem; padding: .85rem 1.1rem; background: var(--navy); color: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .95rem; animation: fadeUp .2s var(--ease); }
.toast svg { width: 20px; height: 20px; flex: none; color: #7BE0A5; }

/* Empty */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty svg { width: 44px; height: 44px; margin: 0 auto .75rem; opacity: .5; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .tiles { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 1024px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: var(--bg); }
  .menu-btn { display: grid; }
  .topbar { padding-left: .5rem; }
  .topbar__brand { width: auto; background: none; color: var(--ink); padding: 0 .4rem; }
  .topbar__brand img { background: none; padding: 0; }
  .topbar__brand .brandword small { color: var(--ink); }
  .topbar__brand .brandword b { color: var(--red); }
  .topbar__crumbs { display: none; }
  .sidebar { position: fixed; left: 0; top: var(--top-h); bottom: 0; height: auto; width: 270px; z-index: 60; transform: translateX(-100%); transition: transform .25s var(--ease); }
  .sidebar.is-open { transform: none; box-shadow: var(--shadow-lg); }
  .side-backdrop { position: fixed; inset: var(--top-h) 0 0 0; background: rgba(20,33,61,.4); z-index: 55; }
  .grid--main, .grid--3, .grid--2 { grid-template-columns: minmax(0,1fr); }
  .access { grid-template-columns: 1fr; }
  .roles__grid { grid-template-columns: 1fr; max-width: 560px; margin: 0 auto; }
  .chat { grid-template-columns: 1fr; }
  .chat__list { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .chat__thread { min-width: 230px; border-bottom: 0; border-right: 1px solid var(--line); }
}
@media (max-width: 680px) {
  .grid--4, .tiles { grid-template-columns: minmax(0,1fr); }
  .moods { grid-template-columns: repeat(3, 1fr); }
  .role-chip, .topbar [data-exit] { display: none; }
  .topbar { gap: .25rem; padding-right: .5rem; }
  .topbar__brand { gap: .4rem; padding: 0 .2rem; }
  .topbar__brand img { width: 30px; }
  .topbar__brand .brandword small { display: none; }
  .topbar .btn__text { display: none; }
  .topbar .btn { padding: .4rem .55rem; min-height: 38px; }
  .badge-proto { font-size: .62rem; padding: .18rem .4rem; }
  .welcome { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 100px 1fr 40px; }
  .kv { grid-template-columns: 1fr; }
  .protobar { font-size: .8rem; }
  .report-paper { padding: 1.1rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
  body * { visibility: hidden; }
  .report-paper, .report-paper * { visibility: visible; }
  .report-paper { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; border: 0; }
}
