.page-grid{display:flex;flex-direction:column;gap:var(--space-6);}
.kpi-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:var(--space-4);}
.card,.panel{background:var(--surface);border:1px solid var(--border-subtle);border-radius:var(--radius-lg);padding:var(--space-5);}
.card{transition:border-color var(--transition-fast);}
.card:hover{border-color:var(--border);}
.card-label{color:var(--text-muted);font-size:var(--text-xs);font-weight:600;text-transform:uppercase;letter-spacing:.6px;}
.card-value{font-family:var(--font-mono);font-variant-numeric:tabular-nums;font-size:var(--text-2xl);font-weight:700;margin-top:var(--space-2);}
.card-sub{color:var(--text-dim);font-size:var(--text-sm);margin-top:var(--space-1);}
.panel-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:var(--space-4);}
.panel-title{font-size:var(--text-base);font-weight:600;color:var(--text-muted);letter-spacing:.3px;}
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:var(--space-6);}
@media (max-width:900px){.grid-2{grid-template-columns:1fr;}}
table.data{width:100%;border-collapse:collapse;font-size:var(--text-sm);}
table.data th{text-align:left;color:var(--text-dim);font-weight:600;text-transform:uppercase;font-size:var(--text-xs);letter-spacing:.5px;padding:var(--space-3);border-bottom:1px solid var(--border);}
table.data td{padding:var(--space-3);border-bottom:1px solid var(--border-subtle);}
table.data tr:hover td{background:var(--surface-2);}
.badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:var(--radius-pill);font-size:var(--text-xs);font-weight:600;letter-spacing:.3px;}
.badge-success{background:var(--success-dim);color:var(--success);}
.badge-warn{background:var(--warn-dim);color:var(--warn);}
.badge-danger{background:var(--danger-dim);color:var(--danger);}
.badge-info{background:var(--info-dim);color:var(--info);}
.badge-muted{background:var(--surface-2);color:var(--text-muted);}
.btn{padding:8px 14px;border:1px solid var(--border);background:var(--surface-2);color:var(--text);border-radius:var(--radius);font-size:var(--text-base);font-weight:500;transition:background var(--transition-fast);}
.btn:hover{background:var(--surface-3);}
.btn-primary{background:var(--accent);border-color:var(--accent);color:#fff;}
.btn-primary:hover{background:var(--accent-hover);}
.range-pills{display:inline-flex;gap:var(--space-1);}
.range-btn{padding:6px 12px;background:transparent;border:1px solid var(--border);border-radius:var(--radius);color:var(--text-muted);font-size:var(--text-sm);}
.range-btn.active{background:var(--accent);color:#fff;border-color:var(--accent);font-weight:600;}
.chart-box{position:relative;height:300px;}
.chart-box canvas{max-height:300px;}
/* Skeletons */
.skel{background:linear-gradient(90deg,var(--surface-2) 25%,var(--surface-3) 37%,var(--surface-2) 63%);background-size:400% 100%;animation:shimmer 1.4s infinite;border-radius:var(--radius);}
@keyframes shimmer{0%{background-position:100% 0;}100%{background-position:-100% 0;}}
.skel-line{height:12px;margin:var(--space-2) 0;}
.skel-kpi{height:96px;}
.skel-chart{height:300px;}
/* Panel error */
.panel-error{text-align:center;color:var(--text-muted);padding:var(--space-8);}
.panel-error .btn{margin-top:var(--space-3);}
/* Empty */
.empty{text-align:center;color:var(--text-dim);padding:var(--space-8);font-size:var(--text-base);}
/* Login */
#login-screen{display:flex;align-items:center;justify-content:center;min-height:100vh;padding:var(--space-5);}
.login-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-xl);padding:48px 40px;max-width:380px;width:100%;text-align:center;}
.login-card h1{font-size:var(--text-xl);margin-bottom:var(--space-2);background:linear-gradient(135deg,var(--accent),var(--accent-hover));-webkit-background-clip:text;-webkit-text-fill-color:transparent;}
.login-card p{color:var(--text-muted);margin-bottom:var(--space-5);font-size:var(--text-sm);}
.login-card input{width:100%;padding:12px 14px;background:var(--surface-2);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);margin-bottom:var(--space-4);}
.login-card input:focus{border-color:var(--accent);}
.login-card input:focus:not(:focus-visible){outline:none;}
.login-card input:focus-visible{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-dim);}
.login-error{color:var(--danger);font-size:var(--text-sm);margin-top:var(--space-2);display:none;}
/* Full-screen overlay */
#app-overlay{position:fixed;inset:0;z-index:500;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-4);background:var(--bg);transition:opacity var(--transition);}
#app-overlay.hide{opacity:0;pointer-events:none;visibility:hidden;}
.spinner{width:40px;height:40px;border:3px solid var(--surface-3);border-top-color:var(--accent);border-radius:50%;animation:spin .8s linear infinite;}
.spinner-sm{width:16px;height:16px;border-width:2px;display:inline-block;vertical-align:middle;}
@keyframes spin{to{transform:rotate(360deg);}}
.overlay-brand{font-family:var(--font-mono);font-weight:700;color:var(--text-muted);}
/* Ticket board */
.row-click{cursor:pointer;}
.row-click:hover td{background:var(--surface-2);}
.coach-strip{display:flex;gap:var(--space-2);flex-wrap:wrap;margin-bottom:var(--space-4);}
.coach-chip{display:flex;flex-direction:column;gap:2px;padding:8px 14px;background:var(--surface-2);border:1px solid var(--border);border-radius:var(--radius);min-width:110px;cursor:pointer;transition:background var(--transition-fast);}
.coach-chip:hover{background:var(--surface-3);}
.coach-chip.active{border-color:var(--accent);background:var(--accent-dim);}
.coach-chip .name{font-weight:600;font-size:var(--text-sm);}
.coach-chip .meta{font-size:var(--text-xs);color:var(--text-muted);font-family:var(--font-mono);}
.coach-chip .meta .hot{color:var(--danger);font-weight:700;}
.msg-preview{max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text-muted);font-size:var(--text-sm);display:inline-block;vertical-align:middle;}
/* Thread drawer */
.drawer-backdrop{position:fixed;inset:0;z-index:400;background:rgba(0,0,0,.55);display:flex;justify-content:flex-end;}
.drawer-panel{width:min(560px,95vw);height:100%;background:var(--surface);border-left:1px solid var(--border);display:flex;flex-direction:column;animation:drawer-in .18s ease-out;}
@keyframes drawer-in{from{transform:translateX(24px);opacity:0;}to{transform:none;opacity:1;}}
.drawer-head{display:flex;align-items:center;justify-content:space-between;gap:var(--space-3);padding:var(--space-4) var(--space-5);border-bottom:1px solid var(--border);}
.drawer-head h3{font-size:var(--text-lg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.drawer-close{padding:4px 10px;}
.drawer-body{flex:1;overflow-y:auto;padding:var(--space-4) var(--space-5);}
.drawer-status{display:flex;align-items:center;gap:var(--space-2);flex-wrap:wrap;margin-bottom:var(--space-4);font-size:var(--text-sm);color:var(--text-muted);}
.thread{display:flex;flex-direction:column;gap:var(--space-3);}
.bubble{border:1px solid var(--border);border-radius:var(--radius);padding:10px 12px;background:var(--surface-2);max-width:92%;}
.bubble .who{display:flex;gap:var(--space-2);align-items:baseline;margin-bottom:4px;font-size:var(--text-xs);color:var(--text-muted);}
.bubble .who .author{font-weight:700;color:var(--text);}
.bubble .txt{font-size:var(--text-sm);white-space:pre-wrap;word-break:break-word;}
.bubble.mentee{border-left:3px solid var(--accent);align-self:flex-start;}
.bubble.coach{border-left:3px solid var(--success);align-self:flex-end;background:var(--surface-3);}
.bubble.bot{opacity:.6;align-self:flex-end;}
.bubble .attach{margin-top:4px;font-size:var(--text-xs);color:var(--info);}

/* coach view v2: My coaching + Disputes */
.coach-head{display:flex;align-items:center;gap:var(--space-3);flex-wrap:wrap;margin-bottom:var(--space-3);}
.coach-head h2{margin:0;}
.coach-tabs{display:flex;gap:var(--space-2);flex-wrap:wrap;margin-bottom:var(--space-3);}
/* Coach Stats: three tables whose number columns line up down the page. */
.stat-tables table.data{table-layout:fixed;width:100%;}
.stat-tables table.data th:first-child{width:40%;}
/* My coaching: clickable tiles and the 12-week graphs. */
.coach-tiles{margin-bottom:var(--space-4);}
.card-click{cursor:pointer;transition:border-color .15s;}
.card-click:hover,.card-click:focus-visible{border-color:var(--accent,var(--info));outline:none;}
.coach-charts{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:var(--space-4);}
.coach-chart .card-label{margin-bottom:var(--space-2);}
.coach-picker,.field{background:var(--surface-2);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);padding:8px 10px;font:inherit;}
.field{width:100%;margin-bottom:var(--space-3);}
.incident-list{display:flex;flex-direction:column;gap:var(--space-3);}
.incident{border:1px solid var(--border);border-radius:var(--radius);padding:var(--space-3);background:var(--surface-2);}
.incident-tags,.incident-foot,.incident-links{display:flex;gap:var(--space-2);align-items:center;flex-wrap:wrap;}
.incident-story{margin:var(--space-2) 0;}
.incident-quote{margin:0 0 var(--space-2);padding-left:var(--space-3);border-left:2px solid var(--border);color:var(--text-muted);white-space:pre-wrap;overflow-wrap:anywhere;}
.form-error{color:var(--danger);min-height:1.2em;margin-bottom:var(--space-2);}
.apply-result{margin-bottom:var(--space-3);}
.nav-count{margin-left:auto;background:var(--warn);color:#000;border-radius:999px;padding:0 7px;font-size:12px;}
.muted{color:var(--text-muted);}
/* Phone: at 390px the page was 593px wide (2026-09-29 review). Wide tables now
   scroll inside their panel, flex/grid children may shrink, and long names wrap. */
.panel{min-width:0;overflow-x:auto;}
.page-grid>*,.grid-2>*{min-width:0;}
.card-value{overflow-wrap:anywhere;}
table.data td.num,table.data th.num{text-align:right;font-variant-numeric:tabular-nums;}
.drill-hint{font-size:var(--text-xs);color:var(--text-dim);margin-top:var(--space-2);}
/* Section tables share one set of column widths (colgroup) so numbers line up. */
table.data.fixed{table-layout:fixed;}
table.data.fixed td:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
/* Charts sized to their rows get the height they ask for. */
.chart-box[style] canvas{max-height:none;}
/* The column guide under the Coaches table: readable on phones, where hover text is not. */
.column-hints{margin-top:var(--space-4);font-size:var(--text-sm);color:var(--text-muted);}
.column-hints summary{cursor:pointer;color:var(--text-dim);font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.5px;}
.column-hints dl{display:grid;grid-template-columns:max-content 1fr;gap:var(--space-1) var(--space-3);margin:var(--space-2) 0 0;}
.column-hints dt{font-weight:600;color:var(--text);}
.column-hints dd{margin:0;}
@media (max-width:560px){.column-hints dl{grid-template-columns:1fr;}.column-hints dd{margin-bottom:var(--space-2);}}
/* Phone: section tables scroll inside their card at natural widths (fixed columns at
   390 px left 41 px per column and headers ran into each other). */
@media (max-width:860px){
  table.data.fixed{table-layout:auto;min-width:600px;}
  table.data.fixed th,table.data.fixed td{white-space:nowrap;}
}
.heatmap-legend{display:flex;align-items:center;gap:var(--space-2);margin-top:var(--space-3);font-size:var(--text-xs);color:var(--text-muted);}
.heatmap-legend-bar{display:inline-block;width:120px;height:10px;border-radius:3px;}
.table-scroll{overflow-x:auto;max-width:100%;}
.mistake-summary{display:flex;flex-wrap:wrap;gap:var(--space-4);margin-bottom:var(--space-3);color:var(--text-muted);}
.week-fold{border:1px solid var(--border);border-radius:var(--radius);padding:var(--space-3);margin-bottom:var(--space-3);background:var(--surface);}
.week-fold > summary{cursor:pointer;list-style:revert;margin-bottom:var(--space-2);}
.incident-story,.incident-quote{overflow-wrap:anywhere;}
/* My coaching: one plain line under each graph title and each stats label */
.chart-hint{color:var(--text-dim);font-size:var(--text-sm);margin:calc(-1 * var(--space-1)) 0 var(--space-2);}
.stat-hint{color:var(--text-dim);font-size:var(--text-sm);font-weight:400;}
/* My coaching: graph span switch and the two-bar bonus card */
.span-pills{display:flex;gap:var(--space-2);flex-wrap:wrap;}
.coach-graphs-head{flex-wrap:wrap;gap:var(--space-2);}
.bonus-card{display:flex;flex-direction:column;gap:var(--space-3);}
.bonus-status{font-size:var(--text-lg);font-weight:600;}
.bonus-achieved{color:var(--success);}
.bonus-replies{color:var(--warn);}
.bonus-points{color:var(--text);}
.bonus-rows{display:flex;flex-direction:column;gap:var(--space-3);}
.bonus-row-click{cursor:pointer;border-radius:8px;padding:4px;margin:-4px;}
.bonus-row-click:hover,.bonus-row-click:focus-visible{background:var(--border-subtle);outline:none;}
.bonus-label{display:flex;justify-content:space-between;gap:var(--space-2);font-size:var(--text-sm);margin-bottom:var(--space-1);}
.bonus-track{position:relative;height:12px;border-radius:999px;background:var(--border-subtle);overflow:visible;}
.bonus-fill{height:100%;border-radius:999px;}
.bonus-fill.bonus-go{background:var(--chart-1);}
.bonus-fill.bonus-done{background:var(--success);}
.bonus-mark{position:absolute;top:-3px;bottom:-3px;width:2px;background:var(--text-dim);}
.coach-bonus{margin-bottom:var(--space-4);}
.bonus-fill.bonus-under{background:var(--warn);}
.bonus-track-marked{margin-bottom:22px;}
.bonus-mark-label{position:absolute;top:18px;left:50%;transform:translateX(-50%);white-space:nowrap;font-size:11px;color:var(--text-dim);}
.bonus-mark:last-child .bonus-mark-label{transform:none;left:4px;}
.bonus-mark:nth-last-child(2) .bonus-mark-label{transform:translateX(-100%);left:-4px;}
/* My coaching: compact mistake rows (2026-10-05), shared by Mistakes and the reply time drawer */
.btn-sm{padding:4px 10px;font-size:var(--text-sm);}
.field-sm{margin-bottom:0;padding:6px 10px;font-size:var(--text-sm);width:auto;min-width:0;}
.chip-row{display:flex;gap:var(--space-2);flex-wrap:wrap;align-items:center;}
.check{display:inline-flex;gap:6px;align-items:center;font-size:var(--text-sm);color:var(--text-muted);cursor:pointer;}
.mistake-kpis{margin-bottom:var(--space-3);}
.mistake-kpi{text-align:left;font:inherit;color:inherit;cursor:pointer;}
.mistake-kpi.is-on{border-color:var(--chart-1);box-shadow:0 0 0 1px var(--chart-1) inset;}
.mistake-controls{display:flex;justify-content:space-between;gap:var(--space-3);flex-wrap:wrap;align-items:center;margin-bottom:var(--space-3);}
.mistake-tools{display:flex;gap:var(--space-2);flex-wrap:wrap;align-items:center;}
.mrow-list{display:flex;flex-direction:column;border:1px solid var(--border-subtle);border-radius:var(--radius);overflow:hidden;margin-top:var(--space-2);}
.mrow{display:grid;grid-template-columns:110px minmax(90px,1.1fr) 120px 64px minmax(0,2.4fr) 92px;gap:var(--space-3);align-items:center;padding:8px 12px;font-size:var(--text-sm);}
.mrow-head{color:var(--text-dim);font-size:11px;text-transform:uppercase;letter-spacing:.4px;background:var(--surface-2);}
.mrow-item{border-top:1px solid var(--border-subtle);}
.mrow-item > summary{list-style:none;cursor:pointer;}
.mrow-item > summary::-webkit-details-marker{display:none;}
.mrow-item > summary:hover{background:var(--surface-2);}
.mrow-item[open] > summary{background:var(--surface-2);}
.mrow-student,.mrow-msg{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.mrow-msg{color:var(--text-muted);}
.mrow-wait.is-warn{color:var(--warn);}
.mrow-wait.is-bad{color:var(--danger);font-weight:600;}
.mrow-action{justify-self:end;}
.mrow-detail{padding:4px 12px 12px;display:flex;flex-direction:column;gap:6px;background:var(--surface-2);font-size:var(--text-sm);}
.mrow-more{margin:8px;align-self:center;}
.rt-kpis{margin-bottom:var(--space-3);}
.rt-late-head{display:flex;justify-content:space-between;align-items:center;gap:var(--space-2);flex-wrap:wrap;margin-top:var(--space-3);}
@media (max-width:860px){
  .mrow{grid-template-columns:1fr auto;grid-template-areas:"student action" "what wait" "when when" "msg msg";row-gap:4px;}
  .mrow-head{display:none;}
  .mrow-student{grid-area:student;font-weight:600;}
  .mrow-action{grid-area:action;}
  .mrow > span:nth-child(3){grid-area:what;}
  .mrow-wait{grid-area:wait;justify-self:end;}
  .mrow-when{grid-area:when;color:var(--text-dim);}
  .mrow-msg{grid-area:msg;white-space:normal;}
}
.rt-kpis{grid-template-columns:repeat(3,minmax(0,1fr));}
.rt-kpis .card{padding:var(--space-3);}
/* Inside a drawer the list is narrow: always the stacked layout. */
.mrow-list-stacked .mrow{grid-template-columns:1fr auto;grid-template-areas:"student action" "what wait" "when when" "msg msg";row-gap:4px;}
.mrow-list-stacked .mrow-head{display:none;}
.mrow-list-stacked .mrow-student{grid-area:student;font-weight:600;}
.mrow-list-stacked .mrow-action{grid-area:action;}
.mrow-list-stacked .mrow > span:nth-child(3){grid-area:what;}
.mrow-list-stacked .mrow-wait{grid-area:wait;justify-self:end;}
.mrow-list-stacked .mrow-when{grid-area:when;color:var(--text-dim);}
.mrow-list-stacked .mrow-msg{grid-area:msg;white-space:normal;}
/* Reply check (2026-10-05): the student's full turn, the cleared line, the notice */
.turn{display:flex;flex-direction:column;gap:4px;border-left:2px solid var(--border);padding-left:var(--space-3);}
.turn-head{font-size:11px;text-transform:uppercase;letter-spacing:.4px;color:var(--text-dim);}
.turn-msg{display:flex;gap:var(--space-2);overflow-wrap:anywhere;}
.turn-time{color:var(--text-dim);flex:none;font-size:11px;padding-top:2px;}
.cleared-line{color:var(--success);}
.notice{border:1px solid var(--border);background:var(--surface-2);border-radius:var(--radius);padding:10px 12px;margin-bottom:var(--space-3);font-size:var(--text-sm);}
.form-row{display:block;}
.wh-card{display:flex;flex-direction:column;gap:var(--space-3);}
.wh-head{display:flex;gap:var(--space-3);align-items:center;flex-wrap:wrap;}
.wh-modes{display:flex;gap:var(--space-6);flex-wrap:wrap;}
.wh-modes label{display:flex;gap:6px;align-items:center;cursor:pointer;}
.wh-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:var(--space-2) var(--space-4);}
.wh-grid.wh-dim{opacity:.5;}
.wh-day{display:flex;gap:var(--space-2);align-items:center;}
.wh-day .field{margin-bottom:0;}
.wh-dayname{width:36px;flex:none;color:var(--text-muted);font-size:var(--text-sm);}
.wh-actions{display:flex;gap:var(--space-3);align-items:center;flex-wrap:wrap;}
