/* ==========================================================================
   Portal (app.html) · clean workspace (Evalato-style)
   Deep purple sidebar, light canvas, crisp tables and status tags,
   gold reserved for highlights.
   ========================================================================== */
body.app-body { background: #f6f4fa; }
.app { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }

/* Sidebar */
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px; background: var(--night); color: rgba(255,255,255,.75); overflow-y: auto; }
.side .brand { padding: 0 8px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.side .brand .emblem { width: 38px; height: 38px; }
.side__role { margin: 18px 10px 8px; font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--gold-2); }
.side__nav { display: grid; gap: 2px; }
.side__nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-weight: 700; font-size: .93rem; }
.side__nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side__nav a[aria-current="page"] { background: #fff; color: var(--violet); }
.side__nav .count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--gold); color: var(--night); font-size: .74rem; font-weight: 800; text-align: center; }
.side__foot { margin-top: auto; padding: 16px 10px 4px; border-top: 1px solid rgba(255,255,255,.1); font-size: .86rem; }
.side__foot strong { display: block; font-family: var(--serif); font-weight: 600; color: #fff; font-size: 1.6rem; line-height: 1.15; }
.side__foot a { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; font-weight: 800; color: var(--gold-2); }

/* Top bar */
.main { min-width: 0; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; height: 68px; padding: 0 32px; background: #fff; border-bottom: 1px solid var(--line); }
.top h1 { font-size: 1.15rem; letter-spacing: -.01em; }
.top__sub { color: var(--muted); font-size: .86rem; }
.top__right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.usermenu { position: relative; }
.usermenu > button { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 999px; font-weight: 800; color: var(--ink); }
.usermenu > button:hover { background: var(--violet-tint); }
.usermenu__menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.usermenu__menu a, .usermenu__menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px; font-weight: 700; font-size: .92rem; text-align: left; }
.usermenu__menu a:hover, .usermenu__menu button:hover { background: var(--violet-tint); color: var(--violet); }
.usermenu__menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.app-toggle { display: none; }

.view { padding: 28px 32px 48px; max-width: 1260px; }
.view--narrow { max-width: 980px; }

/* Welcome card */
.welcome { position: relative; display: flex; align-items: center; gap: 28px; padding: 26px 28px 26px 34px; border-radius: var(--r-lg); background: #fff; border: 1px solid var(--line); overflow: hidden; }
.welcome::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--gold); }
.welcome img { order: 2; flex-shrink: 0; width: 230px; height: 140px; margin-left: auto; border-radius: var(--r); object-fit: cover; }
.welcome h2 { font-family: var(--serif); font-weight: 600; font-size: 1.9rem; }
.welcome p { margin-top: 6px; max-width: 580px; color: var(--muted); }
.welcome .hero__actions { margin-top: 18px; }
.welcome .btn--outline-white { border-color: var(--line-2); color: var(--ink); }
.welcome .btn--outline-white:hover { border-color: var(--violet); color: var(--violet); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 18px; }
.stat { padding: 18px 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
.stat__n { font-size: 1.9rem; font-weight: 800; color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums; }
.stat__l { margin-top: 8px; font-size: .86rem; color: var(--muted); font-weight: 700; }

/* Panels */
.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; margin-top: 18px; align-items: start; }
.grid-even { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.panel + .panel { margin-top: 18px; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.panel__head h2, .panel__head h3 { font-size: 1.02rem; letter-spacing: -.005em; }
.panel__body { padding: 20px 22px; }
.panel__body > p + p { margin-top: 10px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

/* Rows */
.rows { display: grid; }
.rowi { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center; padding: 14px 22px; border-bottom: 1px solid var(--line); }
.rowi:last-child { border-bottom: 0; }
.rowi:hover { background: var(--violet-tint); }
.rowi__title { font-weight: 800; color: var(--ink); }
.rowi__meta { grid-column: 1; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .85rem; color: var(--muted); }
.rowi__meta span { display: inline-flex; align-items: center; gap: 6px; }
.rowi__right { grid-row: 1 / span 2; grid-column: 2; display: flex; align-items: center; gap: 10px; color: var(--violet); }
.empty { padding: 40px 22px; text-align: center; color: var(--muted); }
.empty h3 { font-size: 1.1rem; margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }

/* Tables */
.tablewrap { overflow-x: auto; }
.dtable { width: 100%; border-collapse: collapse; font-size: .92rem; }
.dtable th, .dtable td { padding: 12px 16px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.dtable th { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); font-weight: 800; background: #fbfaff; }
.dtable td.wrap { white-space: normal; min-width: 220px; }
.dtable tbody tr:hover { background: var(--violet-tint); }
.dtable tbody tr[data-href] { cursor: pointer; }
.dtable .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; }
.dtable .strike { text-decoration: line-through; color: var(--soft); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filters .select, .filters .input { width: auto; min-width: 200px; padding: 8px 12px; font-size: .9rem; }

/* Stage tracker */
.tracker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; }
.tracker li { position: relative; padding-top: 26px; font-size: .82rem; font-weight: 800; color: var(--soft); }
.tracker li::before { content: ""; position: absolute; top: 7px; left: 0; right: 0; height: 3px; background: var(--line); }
.tracker li::after { content: ""; position: absolute; top: 0; left: 0; width: 17px; height: 17px; border-radius: 50%; background: #fff; border: 3px solid var(--line-2); }
.tracker li.is-done { color: var(--ink); }
.tracker li.is-done::before { background: var(--violet); }
.tracker li.is-done::after { background: var(--violet); border-color: var(--violet); }
.tracker li.is-now { color: var(--violet); }
.tracker li.is-now::after { border-color: var(--gold); background: var(--gold); }
.tracker li.is-bad { color: var(--bad); }
.tracker li.is-bad::after { border-color: var(--bad); background: var(--bad); }

/* Wizard */
.wizard { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.stepper { display: flex; gap: 0; margin-bottom: 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; }
.stepper button { display: flex; align-items: center; gap: 8px; flex: 1; padding: 13px 14px; font-size: .88rem; font-weight: 800; color: var(--muted); white-space: nowrap; border-bottom: 3px solid transparent; }
.stepper button + button { border-left: 1px solid var(--line); }
.stepper button span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--violet-tint); font-size: .78rem; }
.stepper button.is-done span { background: var(--violet); color: #fff; }
.stepper button[aria-current="step"] { color: var(--ink); border-bottom-color: var(--gold); background: var(--violet-tint); }
.stepper button[aria-current="step"] span { background: var(--gold); color: var(--night); }
.stepper button:disabled { opacity: .5; cursor: not-allowed; }
.wizard .panel__body { padding: 28px; }
.wizard__foot { display: flex; justify-content: space-between; gap: 12px; padding: 16px 22px; border-top: 1px solid var(--line); background: #fbfaff; }
.saved { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.qblock + .qblock { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.qblock h3 { font-size: 1rem; line-height: 1.4; display: flex; gap: 10px; }
.qblock h3 b { color: var(--gold-dk); font-family: var(--serif); font-size: 1.15rem; }
.qblock .hint { margin: 6px 0 12px; font-size: .88rem; color: var(--muted); }
.wc { margin-top: 6px; font-size: .8rem; color: var(--soft); text-align: right; }
.wc--max { color: #b4441b; font-weight: 700; }

/* AI assist */
.ai-box { border-color: #ddd0f5; }
.ai-box .panel__head { background: #faf7ff; border-color: #ebe2fa; }
.ai-head { display: flex; align-items: center; gap: 8px; }
.ai-head .icon { color: var(--violet); }
.ai-source { padding: 10px 22px 16px; font-size: .78rem; color: var(--soft); }
.matches { display: grid; gap: 8px; }
.match { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: center; padding: 14px 16px; background: #fff; border: 1.5px solid var(--line); border-radius: var(--r); text-align: left; width: 100%; }
.match:hover { border-color: var(--violet); }
.match.is-picked { border-color: var(--violet); background: var(--violet-tint); }
.match strong { color: var(--ink); }
.match__fit { grid-row: 1 / span 2; grid-column: 2; font-weight: 800; color: var(--violet); font-size: 1.1rem; }
.match__why { font-size: .84rem; color: var(--muted); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .92rem; }
.loading::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--violet); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ready { display: grid; gap: 10px; }
.ready__item { display: grid; grid-template-columns: 10px 1fr auto; gap: 2px 10px; align-items: start; font-size: .88rem; }
.ready__dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; }
.ready__dot.strong { background: var(--good); }
.ready__dot.some { background: var(--gold); }
.ready__dot.missing { background: var(--bad); }
.ready__item b { color: var(--ink); }
.ready__item small { grid-column: 2 / -1; color: var(--muted); }
.ready__w { color: var(--soft); font-weight: 800; }
.meter { height: 10px; border-radius: 999px; background: var(--violet-soft); overflow: hidden; margin: 8px 0 18px; }
.meter span { display: block; height: 100%; border-radius: 999px; background: var(--violet); }
.meter-n { display: flex; justify-content: space-between; align-items: baseline; }
.meter-n strong { font-size: 1.8rem; font-weight: 800; color: var(--ink); }

/* Evidence */
.evid { display: grid; gap: 8px; }
.evid__row { display: grid; grid-template-columns: 26px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r); background: #fff; }
.evid__row.is-done { border-color: #bde3cf; background: #f4fbf7; }
.evid__row.is-done > .icon { color: var(--good); }
.evid__row > .icon { color: var(--soft); }
.evid__name { font-weight: 800; color: var(--ink); }
.evid__file { font-size: .84rem; color: var(--muted); }
.drop { display: grid; place-items: center; gap: 6px; padding: 26px; border: 2px dashed var(--line-2); border-radius: var(--r); text-align: center; color: var(--muted); cursor: pointer; background: #fbfaff; }
.drop:hover, .drop.is-over { border-color: var(--violet); background: var(--violet-tint); color: var(--ink); }
.drop .icon { width: 26px; height: 26px; color: var(--violet); }

/* Review summary */
.summary dt { font-size: .74rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--soft); margin-top: 16px; }
.summary dd { margin: 4px 0 0; color: var(--text); white-space: pre-wrap; }

/* Judge scoring */
.scoring { display: grid; grid-template-columns: 1fr 440px; gap: 18px; align-items: start; }
.scoring__card { position: sticky; top: 86px; max-height: calc(100vh - 104px); overflow-y: auto; }
.crit { padding: 15px 22px; border-bottom: 1px solid var(--line); }
.crit__head { display: flex; justify-content: space-between; gap: 10px; font-weight: 800; color: var(--ink); font-size: .93rem; }
.crit__head span { flex-shrink: 0; align-self: flex-start; white-space: nowrap; color: var(--soft); }
.scale { display: grid; grid-template-columns: repeat(11, 1fr); gap: 3px; margin-top: 10px; }
.scale button { height: 32px; border-radius: 6px; border: 1px solid var(--line-2); background: #fff; font-size: .82rem; font-weight: 800; color: var(--muted); }
.scale button:hover:not(:disabled) { border-color: var(--violet); color: var(--violet); }
.scale button[aria-pressed="true"] { background: var(--violet); border-color: var(--violet); color: #fff; }
.crit__pts { margin-top: 6px; font-size: .8rem; color: var(--muted); }
.totalbar { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; background: var(--night); color: rgba(255,255,255,.7); }
.totalbar strong { font-family: var(--serif); font-size: 2rem; font-weight: 600; color: var(--gold-2); font-variant-numeric: tabular-nums; }
.totalbar .muted, .totalbar .small { color: rgba(255,255,255,.65); }
.answer + .answer { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.answer h4 { font-size: .97rem; line-height: 1.4; }
.answer p { margin-top: 8px; white-space: pre-wrap; }

/* Committee */
.pipeline { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-top: 18px; }
.pipe { padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
a.pipe:hover { border-color: var(--violet); }
.pipe__n { font-size: 1.8rem; font-weight: 800; color: var(--ink); line-height: 1; }
.pipe__l { margin-top: 6px; font-size: .86rem; font-weight: 800; color: var(--muted); }
.pipe__s { margin-bottom: 10px; font-size: .7rem; color: var(--gold-dk); text-transform: uppercase; letter-spacing: .12em; font-weight: 800; }
.stagecard { border-left: 4px solid var(--line-2); }
.stagecard.is-active { border-left-color: var(--gold); }
.stagecard.is-done { border-left-color: var(--violet); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.judgepick { display: grid; gap: 8px; }
.judgepick .check small { display: block; color: var(--muted); }
.leader { display: grid; grid-template-columns: 36px 1fr auto auto; gap: 14px; align-items: center; padding: 14px 22px; border-bottom: 1px solid var(--line); }
.leader:last-child { border-bottom: 0; }
.leader__rank { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--violet-tint); font-weight: 800; color: var(--ink); }
.panel__head + .leader .leader__rank { background: var(--gold); color: var(--night); }
.leader__score { font-size: 1.2rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.flag { display: inline-flex; align-items: center; gap: 6px; color: var(--warn); font-weight: 800; font-size: .85rem; }

/* Sign-in screen */
.gate { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; background: #fff; }
.gate__img { position: relative; isolation: isolate; display: flex; align-items: flex-end; padding: 48px; color: #fff; background: var(--night); overflow: hidden; }
.gate__img img { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; }
.gate__img::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgba(22,11,51,.94), rgba(22,11,51,.45)); }
.gate__img h2 { font-family: var(--serif); font-weight: 600; color: #fff; font-size: 2.6rem; max-width: 14ch; }
.gate__img p { margin-top: 12px; max-width: 44ch; color: rgba(255,255,255,.82); }
.gate__form { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(24px, 6vw, 96px); }
.gate__form h1 { font-family: var(--serif); font-weight: 600; font-size: 2.3rem; margin-top: 40px; }

@media (max-width: 1180px) {
  .wizard, .scoring { grid-template-columns: 1fr; }
  .scoring__card { position: static; max-height: none; }
  .pipeline { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; z-index: 60; width: 280px; transform: translateX(-100%); transition: transform .25s; }
  .app.is-nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(14,7,34,.5); }
  .app-toggle { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line-2); border-radius: 50%; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2, .grid-even { grid-template-columns: 1fr; }
  .gate { grid-template-columns: 1fr; }
  .gate__img { min-height: 260px; }
  .welcome img { display: none; }
}
@media (max-width: 640px) {
  .view, .top { padding-inline: 14px; }
  .top__sub { display: none; }
  .pipeline { grid-template-columns: repeat(2, 1fr); }
  .tracker { grid-template-columns: repeat(3, 1fr); row-gap: 14px; }
  .scale button { height: 30px; font-size: .74rem; }
  .welcome { padding: 22px; }
  /* headers with badges and buttons wrap instead of running off the screen */
  .panel__head { flex-wrap: wrap; padding-inline: 16px; }
  .panel__head > * { min-width: 0; }
  .panel__head > div:last-child:not(:first-child) { justify-content: flex-start !important; }
  .filters .select, .filters .input { flex: 1 1 100%; width: 100%; min-width: 0; }
  .filters [data-export] { margin-left: 0 !important; }
  /* list rows: the status badge goes under the title instead of squeezing it */
  .rowi { grid-template-columns: minmax(0, 1fr); padding-inline: 16px; }
  .rowi__right { grid-row: auto; grid-column: 1; }
  .rowi__title, .rowi__meta span { overflow-wrap: anywhere; }
}
.side .brand__text span { font-size: .66rem; letter-spacing: .08em; }

/* AI adjudication + awardees */
.ai-adj { padding: 16px; border-radius: var(--r); background: #faf7ff; border: 1px solid #ebe2fa; }
.ai-adj__head { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.ai-adj__head .icon { color: var(--violet); }
.ai-adj__head .pill { margin-left: auto; font-size: .9rem; }
.ai-adj details summary { list-style: none; }
.ai-adj details summary::-webkit-details-marker { display: none; }
.formula { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; padding: 14px; border-radius: var(--r); background: var(--night); color: rgba(255,255,255,.7); }
.formula div { display: grid; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.07); }
.formula span { font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.formula b { font-size: 1.25rem; color: #fff; }
.formula i { font-style: normal; font-weight: 800; color: var(--gold-2); }
.formula__final { margin-left: auto; background: var(--gold) !important; }
.formula__final span, .formula__final b { color: var(--night); }
.awd-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.awd-title { font-family: var(--serif); font-weight: 600; font-size: 1.8rem; }

/* Prototype role switcher (remove with Supabase Auth) */
.roleswitch { display: flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .82rem; }
.roleswitch span { padding: 0 8px 0 10px; color: var(--muted, #6b6480); font-weight: 600; }
.roleswitch button { border: 0; background: none; padding: 6px 12px; border-radius: 999px; font: inherit; font-weight: 700; color: var(--ink); cursor: pointer; }
.roleswitch button:hover { background: var(--violet-tint, #f7f4fc); }
.roleswitch button[aria-pressed="true"] { background: var(--violet); color: #fff; }
@media (max-width: 760px) { .roleswitch span { display: none; } .roleswitch button { padding: 6px 9px; } }

/* ---------- Phone: top bar wraps, role switch gets its own row ---------- */
@media (max-width: 640px) {
  .top { flex-wrap: wrap; height: auto; min-height: 60px; padding-block: 10px; row-gap: 10px; }
  .top > div:not(.top__right) { flex: 1; min-width: 0; }
  .top h1 { font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top__right { display: contents; }
  .usermenu { order: 2; }
  .usermenu > button > span:not(.avatar), .usermenu > button > svg { display: none; }
  .usermenu > button { padding: 0; }
  .usermenu__menu { right: 0; }
  .roleswitch { order: 3; width: 100%; justify-content: space-between; }
  .roleswitch button { flex: 1; }
}

/* Team: actions per member */
.dtable.team td { vertical-align: top; }
.team-actions { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .dtable.team thead { display: none; }
  .dtable.team, .dtable.team tbody, .dtable.team tr, .dtable.team td { display: block; width: 100%; }
  .dtable.team tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .dtable.team td { padding: 3px 0; border: 0; white-space: normal; }
  .dtable.team td:nth-child(2) br { display: none; }
  .dtable.team td:nth-child(2) .small { margin-left: 8px; }
  .team-actions { margin-top: 6px; }
}
.dinner-bar--portal .dinner-bar__in { max-width: none; padding-inline: 28px; }
@media (max-width: 640px) { .dinner-bar--portal .dinner-bar__in { padding-inline: 14px; } }
