/**
 * USAWS Compact UI - Component Layer
 * Ported from the approved Sample B prototype
 * (public_html/prototype-compact-b.htm). Depends on ui/tokens.css.
 *
 * Design rules carried from the prototype:
 * - No colored left-border accent stripes anywhere. Color arrives
 *   via filled stubs, tonal chips, or dots.
 * - Nothing below 0.75rem (12px), the WCAG floor.
 * - Control heights 24-32px; WCAG AA minimum target is 24px.
 */

/* ── Pill buttons ─────────────────────────────────────────── */
.m-btn {
    display: inline-flex; align-items: center; gap: .35rem;
    height: 30px; padding: 0 .85rem;
    border: none; border-radius: var(--shape-full);
    font-family: var(--font-body); font-size: .78rem; font-weight: 600;
    text-decoration: none; cursor: pointer; white-space: nowrap;
    transition: filter var(--dur-short), background var(--dur-short);
}
.m-btn .msr { font-size: 16px; margin-left: -.2rem; }
.m-brand    { background: var(--md-primary); color: var(--md-on-primary); }
.m-brand:hover { filter: brightness(1.25); }
.m-claret   { background: var(--md-secondary); color: var(--md-on-secondary); }
.m-claret:hover { filter: brightness(1.25); }
.m-tonal    { background: var(--md-primary-container); color: var(--md-on-primary-container); }
.m-tonal:hover { filter: brightness(.96); }
.m-outlined { background: transparent; color: var(--md-primary); box-shadow: inset 0 0 0 1px var(--md-outline); }
.m-outlined:hover { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }
.m-text     { background: transparent; color: var(--md-primary); padding: 0 .6rem; }
.m-text:hover { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }
.m-btn .count {
    font-family: var(--font-mono); font-size: .75rem; font-weight: 600;
    background: color-mix(in srgb, currentColor 14%, transparent);
    border-radius: var(--shape-full); padding: .04rem .38rem; margin-right: -.3rem;
}
.m-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Status dot-chips ─────────────────────────────────────── */
.status {
    display: inline-flex; align-items: center; gap: .32rem;
    height: 22px; padding: 0 .6rem;
    border-radius: var(--shape-full);
    font-size: .75rem; font-weight: 700; letter-spacing: .02em;
    white-space: nowrap;
}
.status .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.success { background: var(--md-success-container); color: var(--md-success); }
.status.warning { background: var(--md-warning-container); color: var(--md-warning); }
.status.error   { background: var(--md-error-container);   color: var(--error); }
.status.info    { background: var(--md-info-container);    color: var(--md-info); }
.status.neutral { background: var(--md-surface-container-high); color: var(--text-muted); }

/* ── Micro flag chips ─────────────────────────────────────── */
.flag {
    display: inline-flex; align-items: center; gap: .28rem;
    height: 22px; padding: 0 .55rem;
    border-radius: var(--shape-full);
    font-size: .75rem; font-weight: 700; white-space: nowrap;
    text-decoration: none;
}
.flag .msr { font-size: 14px; }
.flag.navy    { background: var(--md-primary-container);   color: var(--md-on-primary-container); }
.flag.claret  { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.flag.warning { background: var(--md-warning-container);   color: var(--md-warning); }
.flag.error   { background: var(--md-error-container);     color: var(--error); }
.flag.muted   { background: var(--md-surface-container-high); color: var(--text-muted); }

/* ── Type chips (subject / content-type tonal fills) ─────── */
.tchip {
    display: inline-flex; align-items: center;
    height: 18px; padding: 0 .45rem;
    border-radius: var(--shape-xs);
    font-size: .75rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
    white-space: nowrap;
}
.tchip.webdev  { background: var(--webdev-c);  color: var(--webdev); }
.tchip.math    { background: var(--math-c);    color: var(--math); }
.tchip.science { background: var(--science-c); color: var(--science); }
.tchip.ela     { background: var(--ela-c);     color: var(--ela); }
.tchip.deck    { background: var(--md-info-container);      color: var(--md-info); }
.tchip.quiz    { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.tchip.lesson  { background: var(--md-tertiary-container);  color: var(--md-on-tertiary-container); }
.tchip.hw      { background: var(--md-warning-container);   color: var(--md-warning); }
.tchip.neutral { background: var(--md-surface-container-high); color: var(--text-muted); }

/* ── Code chip (class codes, ids) ─────────────────────────── */
.codechip {
    font-family: var(--font-mono); font-size: .75rem;
    background: var(--md-inverse-surface); color: var(--md-inverse-on-surface);
    padding: .06rem .4rem; border-radius: var(--shape-xs); letter-spacing: .03em;
}

/* ── Score chips ──────────────────────────────────────────── */
.score {
    display: inline-block; min-width: 44px; text-align: center;
    font-family: var(--font-mono); font-size: .75rem; font-weight: 600;
    padding: .08rem .4rem; border-radius: var(--shape-xs);
}
.score.good { background: var(--md-success-container); color: var(--md-success); }
.score.warn { background: var(--md-warning-container); color: var(--md-warning); }
.score.bad  { background: var(--md-error-container);   color: var(--error); }
.score.na   { background: var(--md-surface-container-high); color: var(--text-muted); }

/* ── Cards ────────────────────────────────────────────────── */
.mcard {
    background: var(--md-surface-container-lowest);
    border: 1px solid var(--border);
    border-radius: var(--shape-md);
}
.mcard-h {
    display: flex; align-items: center; gap: .5rem;
    padding: .45rem .7rem;
    border-bottom: 1px solid var(--border);
}
.mcard-h h2, .mcard-h h3 { margin: 0; font-size: .92rem; font-weight: 600; }
.mcard-h .msr { font-size: 17px; color: var(--md-primary); }
.mcard-h .aux { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.mcard-b { padding: .55rem .7rem; }

/* ── Tickets: boarding-pass card ──────────────────────────────
   The border is drawn by an ::after overlay ring, not a real
   border: a real border sits outside the overflow clip region, so
   the notch circles could never cover the straight line crossing
   them. The overlay ring paints above the stub fill, and the
   notch circles stack above the ring, erasing it locally and
   drawing their own border arc. No outer box-shadow ever: it
   would trace the silhouette straight across the notches. ───── */
.ticket {
    position: relative; display: flex;
    background: var(--md-surface-container-lowest);
    border-radius: var(--shape-md);
    overflow: hidden;
}
.ticket::after {
    content: ''; position: absolute; inset: 0;
    border: 1px solid var(--border);
    border-radius: var(--shape-md);
    pointer-events: none; z-index: 2;
}
.ticket-stub {
    flex: 0 0 74px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .15rem; padding: .6rem .3rem;
    background: var(--md-primary-container); color: var(--md-on-primary-container);
    text-align: center;
}
.ticket-stub .msr { font-size: 19px; }
.ticket-stub b { font-family: var(--font-mono); font-size: 1.15rem; font-weight: 600; line-height: 1; }
.ticket-stub span {
    font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; opacity: .85;
}
.ticket-stub .stub-sub {
    margin-top: .3rem; padding-top: .3rem; width: 74%;
    border-top: 1px dashed color-mix(in srgb, currentColor 35%, transparent);
    font-family: var(--font-mono); font-style: normal; font-size: .75rem; font-weight: 600;
}
.ticket-stub .stub-sub small {
    display: block; font-family: var(--font-body);
    font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; opacity: .8;
}
.ticket-perf {
    flex: 0 0 0; position: relative; z-index: 3;
    border-left: 2px dashed color-mix(in srgb, var(--md-on-primary-container) 35%, transparent);
}
.ticket-perf::before, .ticket-perf::after {
    content: ''; position: absolute; left: -8px;
    box-sizing: border-box;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 3px rgba(0,0,0,.3), inset 0 -1px 1px rgba(255,255,255,.12);
}
.ticket-perf::before { top: -7px; }
.ticket-perf::after  { bottom: -7px; }
.ticket-main { flex: 1; min-width: 0; padding: .55rem .8rem .6rem; }
.ticket-main h4 { margin: 0; font-size: .95rem; font-weight: 600; line-height: 1.2; }

.ticket.subj-webdev  .ticket-stub { background: var(--webdev-c);  color: var(--webdev); }
.ticket.subj-webdev  .ticket-perf { border-left-color: color-mix(in srgb, var(--webdev) 40%, transparent); }
.ticket.subj-math    .ticket-stub { background: var(--math-c);    color: var(--math); }
.ticket.subj-math    .ticket-perf { border-left-color: color-mix(in srgb, var(--math) 40%, transparent); }
.ticket.subj-science .ticket-stub { background: var(--science-c); color: var(--science); }
.ticket.subj-science .ticket-perf { border-left-color: color-mix(in srgb, var(--science) 40%, transparent); }
.ticket.subj-ela     .ticket-stub { background: var(--ela-c);     color: var(--ela); }
.ticket.subj-ela     .ticket-perf { border-left-color: color-mix(in srgb, var(--ela) 40%, transparent); }

.ticket.row .ticket-stub { flex-basis: 96px; }
.ticket.row .ticket-main { padding: .6rem .9rem .65rem; }
.ticket-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.ticket-head .titles { min-width: 0; display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.ticket-head h4 { font-size: 1rem; }
.ticket-head .meta {
    margin-top: .15rem; font-size: .75rem; color: var(--text-muted);
    display: flex; align-items: center; gap: .3rem .6rem; flex-wrap: wrap;
}
.ticket-head .meta b { font-family: var(--font-mono); font-weight: 500; }
.ticket-cols {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: .3rem 1.6rem; margin: .45rem 0 .5rem;
}
.col-h {
    font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-muted); margin: 0 0 .15rem;
}
.manifest-row {
    display: flex; align-items: baseline; gap: .4rem;
    font-size: .76rem; padding: .16rem 0;
}
.manifest-row .label { color: var(--text-muted); white-space: nowrap; }
.manifest-row .leader { flex: 1; border-bottom: 1px dotted var(--border); margin-bottom: .22rem; }
.manifest-row .value { font-family: var(--font-mono); font-weight: 600; white-space: nowrap; }
.manifest-row .value.good { color: var(--md-success); }
.manifest-row .value.warn { color: var(--md-warning); }
.manifest-row .value.bad  { color: var(--error); }
.ticket-actions {
    display: flex; flex-wrap: wrap; align-items: center; gap: .45rem;
    padding-top: .5rem;
    border-top: 1.5px dashed var(--border);
}
.ticket-actions .m-btn { height: 28px; font-size: .75rem; }
.ticket-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .6rem; }

/* ── Goal ring: zero-JS conic donut, --pct set inline ─────── */
.goal-ring {
    --pct: 50;
    position: relative; width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
    background: conic-gradient(var(--ring, var(--md-primary)) calc(var(--pct) * 1%), var(--md-surface-container-highest) 0);
    display: grid; place-items: center;
}
.goal-ring .hole {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--md-surface-container-lowest);
    display: grid; place-items: center;
    font-family: var(--font-mono); font-weight: 600; font-size: .75rem; color: var(--text);
}

/* ── Day strip: mono time gutter schedule rows ────────────── */
.day-strip { display: flex; flex-direction: column; }
.period {
    display: flex; align-items: center; gap: .55rem;
    padding: .26rem .7rem;
    font-size: .78rem;
    border-bottom: 1px solid var(--md-surface-container);
}
.period:last-child { border-bottom: none; }
.period time { font-family: var(--font-mono); font-size: .75rem; color: var(--text-muted); width: 3.6em; flex-shrink: 0; }
.period b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.period .now-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--md-success); flex-shrink: 0; }
.period.now { background: var(--md-surface-container-low); }
.period .aux { margin-left: auto; flex-shrink: 0; }

/* ── Dense data rows ──────────────────────────────────────── */
.row-header {
    display: grid; align-items: center;
    padding: .28rem .7rem;
    font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--md-outline);
}
.grid-rows details.drow, .grid-rows .drow { border-bottom: 1px solid var(--md-surface-container); }
.grid-rows details.drow:last-child, .grid-rows .drow:last-child { border-bottom: none; }
.grid-rows > details.drow:nth-of-type(even) > summary,
.grid-rows > .drow:nth-of-type(even) { background: var(--stripe); }
details.drow > summary {
    list-style: none; cursor: pointer;
    display: grid; align-items: center;
    padding: .3rem .7rem;
    font-size: .82rem;
}
details.drow > summary::-webkit-details-marker { display: none; }
/* Highlight ring via outline, not border + margin: a border and
   margin take layout space and push the expanded row's grid columns
   out of alignment with the rows above and below. */
details.drow[open] {
    outline: 1px solid var(--md-primary);
    outline-offset: -1px;
    border-radius: var(--shape-sm);
    overflow: hidden;
}
/* The last row sits flush against the parent section's rounded
   bottom corners; match the parent's inner radius so the outline
   follows the same curve the parent clips at. */
.grid-rows > details.drow[open]:last-of-type {
    border-bottom-left-radius: calc(var(--shape-md) - 1px);
    border-bottom-right-radius: calc(var(--shape-md) - 1px);
}
details.drow[open] > summary { background: var(--md-primary-container); color: var(--md-on-primary-container); }
/* Border-drawn triangle, not a text glyph: a glyph's ink sits
   off-center in its line box, so rotating it always drifts. */
.r-arrow {
    flex: none; display: inline-grid; place-items: center;
    width: 1em; height: 1em;
    color: var(--text-muted); transition: transform .15s ease;
}
.r-arrow::before {
    content: ''; width: 0; height: 0;
    border-left: 5px solid currentColor;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
}
details.drow[open] .r-arrow { transform: rotate(90deg); color: currentColor; }
.r-name-cell { display: flex; align-items: center; gap: .35rem; overflow: hidden; min-width: 0; }
.r-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-detail {
    border-top: 1px solid var(--border);
    background: var(--md-surface-container-lowest);
    padding: .5rem .8rem .6rem;
    font-size: .78rem;
}
table.kv { border-collapse: collapse; font-size: .78rem; width: 100%; }
table.kv td { padding: .1rem .3rem; vertical-align: top; }
table.kv td:first-child { color: var(--text-muted); width: 38%; }

/* ── Collapsible tonal sections (results pattern) ─────────── */
details.class-section {
    background: var(--md-surface-container-lowest);
    border: 1px solid var(--border);
    border-radius: var(--shape-md);
    margin-bottom: .55rem; overflow: hidden;
}
details.class-section > summary {
    list-style: none; cursor: pointer;
    display: grid; grid-template-columns: 1fr 110px 96px;
    align-items: center; gap: .6rem;
    padding: .42rem .8rem;
}
details.class-section > summary::-webkit-details-marker { display: none; }
.cs-name-cell { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.cs-name { font-family: var(--font-display); font-weight: 600; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-arrow {
    flex: none; display: inline-grid; place-items: center;
    width: 1em; height: 1em;
    transition: transform .15s ease;
}
.c-arrow::before {
    content: ''; width: 0; height: 0;
    border-left: 5px solid currentColor;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
}
details.class-section[open] > summary .c-arrow { transform: rotate(90deg); }
.cs-pill {
    font-size: .75rem; font-weight: 600; justify-self: start;
    color: inherit; background: color-mix(in srgb, currentColor 16%, transparent);
    padding: .08rem .55rem; border-radius: var(--shape-full); white-space: nowrap;
}
.cs-pill.mono { font-family: var(--font-mono); font-weight: 500; }
details.class-section.subj-webdev  > summary { background: var(--webdev-c);  color: var(--webdev); }
details.class-section.subj-math    > summary { background: var(--math-c);    color: var(--math); }
details.class-section.subj-science > summary { background: var(--science-c); color: var(--science); }
details.class-section.subj-ela     > summary { background: var(--ela-c);     color: var(--ela); }

/* ── Toolbar (filter + segmented control) ─────────────────── */
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .55rem; }
.toolbar input[type="text"], .toolbar input[type="search"] {
    flex: 1; min-width: 200px; height: 30px;
    padding: 0 .6rem;
    border: 1px solid var(--md-outline); border-radius: var(--shape-sm);
    background: var(--md-surface-container-lowest); color: var(--text);
    font-family: var(--font-body); font-size: .8rem;
}
.toolbar input::placeholder { color: var(--text-muted); }
.segmented {
    display: inline-flex; height: 30px;
    border: 1px solid var(--md-outline); border-radius: var(--shape-full);
    overflow: hidden;
}
.segmented button, .segmented a {
    display: inline-flex; align-items: center;
    border: none; border-left: 1px solid var(--md-outline);
    padding: 0 .8rem; background: var(--md-surface-container-lowest); color: var(--text);
    font-size: .75rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.segmented button:first-child, .segmented a:first-child { border-left: none; }
.segmented button:hover, .segmented a:hover { background: var(--md-surface-container); }
.segmented .on { background: var(--md-primary-container); color: var(--md-on-primary-container); }
.match-count { font-size: .75rem; color: var(--text-muted); }

/* ── Page header ──────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: .6rem; }
.page-head h1 { margin: 0; font-size: 1.25rem; font-weight: 700; color: var(--md-primary); line-height: 1.15; }
.page-head .sub { font-size: .76rem; color: var(--text-muted); margin: .1rem 0 0; }
.page-head .actions { display: flex; align-items: center; gap: .45rem; flex-shrink: 0; flex-wrap: wrap; }

/* ── Urgency bucket headers ───────────────────────────────── */
.bucket-h {
    display: flex; align-items: center; gap: .4rem;
    padding: .32rem .7rem .22rem;
    font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--md-outline-variant);
}
.bucket-h.overdue { color: var(--error); }
.bucket-h .bcount {
    font-family: var(--font-mono); font-size: .75rem; font-weight: 600;
    background: var(--md-surface-container-high); color: var(--text-muted);
    border-radius: var(--shape-full); padding: .02rem .4rem;
}
.bucket-h.overdue .bcount { background: var(--md-error-container); color: var(--error); }

/* ── Work list rows ───────────────────────────────────────── */
.work-row {
    display: grid;
    grid-template-columns: 20px minmax(180px, 1fr) 92px 74px 76px 86px;
    gap: .5rem; align-items: center;
    padding: .3rem .7rem; font-size: .82rem;
}
.work-row .msr { font-size: 16px; }
.work-row .wtitle { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-row .wclass { justify-self: start; }
.work-row .wdue { font-family: var(--font-mono); font-size: .75rem; color: var(--text-muted); }
.work-row .wdue.late { color: var(--error); font-weight: 600; }
.work-row .m-btn { height: 24px; padding: 0 .7rem; font-size: .75rem; justify-self: end; }

/* ── Study shelf pills ────────────────────────────────────── */
.shelf { display: flex; gap: .45rem; flex-wrap: wrap; padding: .5rem .7rem .6rem; }
.shelf a {
    display: inline-flex; align-items: center; gap: .35rem;
    height: 26px; padding: 0 .7rem;
    border: 1px solid var(--border); border-radius: var(--shape-full);
    background: var(--md-surface-container-lowest);
    text-decoration: none; font-size: .75rem; font-weight: 600; color: var(--text);
}
.shelf a .msr { font-size: 15px; color: var(--md-primary); }
.shelf a:hover { background: var(--md-primary-container); color: var(--md-on-primary-container); border-color: transparent; }

/* ── Player pieces (deck/quiz playback) ───────────────────── */
.pbar { flex: 1; height: 6px; border-radius: var(--shape-full); background: var(--md-surface-container-highest); overflow: hidden; min-width: 120px; }
.pbar i { display: block; height: 100%; background: var(--md-primary); border-radius: var(--shape-full); }
.pcount { font-family: var(--font-mono); font-size: .75rem; color: var(--text-muted); white-space: nowrap; }
.opt {
    display: flex; align-items: center; gap: .55rem;
    padding: .42rem .65rem; margin-bottom: .35rem;
    border: 1px solid var(--border); border-radius: var(--shape-sm);
    font-size: .9rem; cursor: pointer;
    background: var(--md-surface-container-low);
}
.opt:hover { border-color: var(--md-primary); }
.opt .k {
    font-family: var(--font-mono); font-size: .75rem; font-weight: 600;
    width: 20px; height: 20px; border-radius: var(--shape-xs);
    display: grid; place-items: center; flex-shrink: 0;
    background: var(--md-surface-container-high); color: var(--text-muted);
}
.opt.sel { border-color: var(--md-primary); background: var(--md-primary-container); color: var(--md-on-primary-container); }
.opt.sel .k { background: var(--md-primary); color: var(--md-on-primary); }
.opt.correct { border-color: var(--md-success); background: var(--md-success-container); color: var(--md-on-surface); }
.opt.correct .k { background: var(--success); color: var(--success-c); }
.feedback {
    display: flex; align-items: center; gap: .45rem;
    margin-top: .25rem; padding: .4rem .65rem;
    border-radius: var(--shape-sm);
    background: var(--md-success-container); color: var(--md-success);
    font-size: .8rem; font-weight: 600;
}
.saved { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; color: var(--text-muted); }
.saved .msr { font-size: 15px; color: var(--md-success); }

.ui-hidden { display: none !important; }

/* ── Roster sections (teacher/students) ───────────────────── */
.class-body { padding: 0 .45rem .35rem; }
details.class-section.subj-homeroom > summary { background: var(--md-primary-container); color: var(--md-on-primary-container); }
details.class-section.subj-neutral  > summary { background: var(--md-surface-container-high); color: var(--text); }
details.class-section.subj-muted    > summary { background: var(--md-surface-container); color: var(--text-muted); }
.r-flags { display: inline-flex; gap: .2rem; flex-wrap: wrap; margin-left: .35rem; }
.r-mono { font-family: var(--font-mono); font-size: .75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-email { font-family: var(--font-mono); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-center { justify-self: center; }
.r-end { justify-self: end; }
details.drow[open] > summary .r-mono, details.drow[open] > summary .r-email { color: inherit; }

/* ── Micro badges (IEP / PLP / EC / EL / medical) ─────────── */
.badge {
    display: inline-flex; align-items: center; height: 17px; padding: 0 .32rem;
    border-radius: var(--shape-xs);
    font-size: .75rem; font-weight: 700; line-height: 1; letter-spacing: .02em; white-space: nowrap;
}
.badge-iep { background: var(--info-c);                   color: var(--info); }
.badge-plp { background: var(--md-secondary-container);   color: var(--md-on-secondary-container); }
.badge-med { background: var(--error-c);                  color: var(--error); }
.badge-ec  { background: var(--md-tertiary-container);    color: var(--md-on-tertiary-container); }
.badge-el  { background: var(--warning-c);                color: var(--warning); }

/* ── Detail panel blocks (identity / flags / contacts / logins) */
.detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .5rem; }
.detail-actions .m-btn { height: 26px; font-size: .75rem; }
.detail-actions .spacer { flex: 1; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-bottom: .5rem; }
@media (max-width: 760px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-block h4 {
    margin: 0 0 .25rem; padding-bottom: .2rem;
    font-family: var(--font-body); font-size: .75rem; font-weight: 700;
    letter-spacing: .04em; text-transform: uppercase;
    color: var(--md-primary); border-bottom: 1px solid var(--border);
}
.detail-block.full { margin-bottom: .5rem; }
.detail-block.full:last-child { margin-bottom: 0; }
.missing { color: var(--text-muted); font-style: italic; }
.hint { color: var(--text-muted); font-size: .75rem; }
.contact-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .5rem; }
.contact-card {
    border: 1px solid var(--border); border-radius: var(--shape-sm);
    padding: .4rem .55rem; background: var(--md-surface-container-lowest); font-size: .78rem;
}
.contact-card .cc-name { font-weight: 600; margin-bottom: .08rem; }
.contact-card .cc-rel { font-weight: 400; color: var(--text-muted); font-size: .75rem; }
.contact-card .cc-line { margin: .06rem 0; word-break: break-word; }
.contact-card .cc-line a { color: var(--md-primary); text-decoration: none; }
.contact-card .cc-line a:hover { text-decoration: underline; }
.contact-card .cc-label { font-size: .75rem; color: var(--text-muted); }
.contact-card .cc-tags { margin-top: .2rem; font-size: .75rem; color: var(--text-muted); }
table.logins, table.dense { width: 100%; border-collapse: collapse; font-size: .78rem; }
table.logins th, table.dense th {
    text-align: left; padding: .18rem .3rem;
    color: var(--text-muted); font-weight: 700; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em;
    border-bottom: 1px solid var(--md-outline);
}
table.logins td, table.dense td { padding: .18rem .3rem; border-bottom: 1px solid var(--md-surface-container); vertical-align: top; }
table.logins tr:last-child td, table.dense tr:last-child td { border-bottom: none; }
table.logins .mono, table.dense .mono { font-family: var(--font-mono); }
table.dense th { padding: .28rem .6rem; }
table.dense td { padding: .3rem .6rem; vertical-align: middle; }
table.dense tbody tr:nth-child(even) { background: var(--stripe); }

/* ── Form fields (compact) ────────────────────────────────── */
.fld { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.fld > label { font-size: .75rem; font-weight: 600; color: var(--text-muted); }
.fld > label .req { color: var(--error); }
.inp {
    width: 100%; height: 30px; padding: 0 .55rem;
    border: 1px solid var(--md-outline); border-radius: var(--shape-sm);
    background: var(--md-surface-container-lowest); color: var(--text);
    font-family: var(--font-body); font-size: .8rem;
}
select.inp { padding-right: 1.4rem; }
textarea.inp { height: auto; min-height: 58px; padding: .4rem .55rem; resize: vertical; line-height: 1.35; }
.inp::placeholder { color: var(--text-muted); }
.inp:focus { outline: 2px solid var(--md-primary); outline-offset: -1px; border-color: var(--md-primary); }
.inp.mono { font-family: var(--font-mono); }
.inp:disabled { opacity: .6; cursor: not-allowed; }
.fld-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .55rem .7rem; }
.fld-grid .span2 { grid-column: span 2; }
@media (max-width: 520px) { .fld-grid .span2 { grid-column: span 1; } }
.chk { display: inline-flex; align-items: center; gap: .4rem; min-height: 24px; font-size: .8rem; cursor: pointer; }
.chk input { width: 15px; height: 15px; margin: 0; accent-color: var(--md-primary); }
.chk-row { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; margin-top: .7rem; }
.form-note { font-size: .75rem; color: var(--text-muted); margin: .3rem 0 0; }
.icon-btn {
    display: inline-grid; place-items: center; width: 28px; height: 28px;
    border: none; border-radius: var(--shape-full); background: transparent;
    color: var(--text-muted); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--md-surface-container-high); color: var(--text); }
.icon-btn .msr { font-size: 18px; }
.rep-rows { display: flex; flex-direction: column; gap: .35rem; }
.rep-row { display: grid; grid-template-columns: 1.2fr 1.3fr 1fr 1.3fr 30px; gap: .4rem; align-items: center; }
@media (max-width: 720px) { .rep-row { grid-template-columns: 1fr 1fr; } .rep-row .icon-btn { justify-self: end; } }
.rep-head { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }

/* ── Dialog ───────────────────────────────────────────────── */
dialog.dlg {
    border: 1px solid var(--border); border-radius: var(--shape-md);
    background: var(--md-surface-container-lowest); color: var(--text);
    padding: 0; width: min(440px, calc(100% - 2rem));
    box-shadow: var(--elev-2);
}
dialog.dlg::backdrop { background: var(--md-scrim); }
.dlg-h { padding: .6rem .85rem; border-bottom: 1px solid var(--border); font-family: var(--font-display); font-size: .95rem; font-weight: 600; }
.dlg-b { padding: .6rem .85rem; font-size: .82rem; line-height: 1.4; }
.dlg-b p { margin: 0 0 .4rem; }
.dlg-b p:last-child { margin-bottom: 0; }
.dlg-f { padding: .5rem .85rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .45rem; }
