/* THE COMPACT LAYOUT (Dr. Katz, 2026-11-15, after reviewing the Patient Forms and Hospice Census previews: "layout much
   better. Start building. I want you to rearrange all pages under new layout").
   His rules, written in docs/ui-style.md section 10:
     one title (the top bar) and one Back; one tab row, a second level as one line, never wrapping;
     explanations folded under "About this page" (public/ui-compact.js); thin rows, small buttons, the width used.
   On every page in production since 2026-11-15 ("Turn it on", at the deploy door), like plum.css.
   Every rule is scoped to the signed-in frame (.main) so the sign-in page and printouts are untouched. The sizing rules
   (padding, headings, buttons, rows, cards, messages) also need body.el-compact, which head.ejs leaves off the Compliance
   pages (the Compliance chat's terms, 2026-11-15: chips, legend bands and sticky headings stay exactly as they are). */

/* ---- one Back: the top bar's. A page's own "< Hospice" / "< Your access" link above its heading goes. ---------- */
body:has(.topbar .back-btn) .main main a.back,
body:has(.topbar .back-btn) .main main p:has(> a.back:only-child),
body:has(.topbar .back-btn) .main main .crumbs { display: none !important; }

/* ---- less air around the page ---------------------------------------------------------------------------- */
html:not([data-home-layout="sections"]) body.el-compact .main main { padding: 18px 26px 22px; }
@media (max-width: 700px) { html:not([data-home-layout="sections"]) body.el-compact .main main { padding: 14px 12px; } }

/* ---- headings: the page name is in the top bar, so what is left in the page is smaller ------------------------ */
html:not([data-home-layout="sections"]) body.el-compact .main main h1 { font-size: 1.45rem; margin: .1rem 0 .45rem; line-height: 1.25; }
html:not([data-home-layout="sections"]) body.el-compact .main main h2 { font-size: 1.1rem; margin: 1rem 0 .45rem; line-height: 1.3; }
html:not([data-home-layout="sections"]) body.el-compact .main main h3 { font-size: 1rem; margin: .8rem 0 .35rem; }
body.el-compact .main main h1:first-child, body.el-compact .main main h2:first-child { margin-top: 0; }

/* ---- tab rows: on a phone ONE line that swipes sideways; on a wider screen a row that does not fit WRAPS, so no tab is
   ever cut off out of sight (Dr. Katz on production, 2026-11-16, My file: "look like some tabs cut off fix it") ---- */
@media (max-width: 760px) {
  .main .el-tabs, .main .el-subtabs, .main .tabs, .main nav.tabs, .main .subtabs, .main .tab-row, .main [role="tablist"],
  .main main nav:has(> a + a) {
    flex-wrap: nowrap !important; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .main .el-tabs::-webkit-scrollbar, .main .el-subtabs::-webkit-scrollbar, .main .tabs::-webkit-scrollbar,
  .main [role="tablist"]::-webkit-scrollbar { display: none; }
}
@media (min-width: 761px) {
  .main .el-tabs, .main .el-subtabs, .main .tabs, .main nav.tabs, .main .subtabs, .main .tab-row, .main [role="tablist"],
  .main main nav:has(> a + a) { flex-wrap: wrap !important; overflow: visible; }
}
.main .el-tab, .main .el-subtab, .main .tabs > a, .main [role="tablist"] > *, .main main nav:has(> a + a) > a { white-space: nowrap; flex: 0 0 auto; }
.main .el-tab { padding: .45rem .75rem; }
.main .el-subtabs { padding: .25rem .3rem; }
.main .el-subtab { padding: .3rem .65rem; font-size: .9rem; }

/* ---- smaller buttons ------------------------------------------------------------------------------------- */
body.el-compact .main main .el-btn, body.el-compact .main main .btn, body.el-compact .main main button.primary, body.el-compact .main main .button {
  min-height: 2rem; padding: .3rem .8rem; font-size: .9rem; border-radius: 8px;
}

/* ---- thin rows ------------------------------------------------------------------------------------------- */
body.el-compact .main main table th, body.el-compact .main main table td { padding: .42rem .6rem; }
body.el-compact .main main table th { font-size: .8rem; }

/* ---- cards hold less air -------------------------------------------------------------------------------- */
body.el-compact .main main .el-card, html:not([data-home-layout="sections"]) body.el-compact .main main .ui-card, body.el-compact .main main .card {
  padding: 14px 16px; margin-bottom: 14px;
}

/* ---- a warning is one line, not a big box ---------------------------------------------------------------- */
body.el-compact .main main .banner, body.el-compact .main main .el-msg, body.el-compact .main main .alert, body.el-compact .main main .flash, body.el-compact .main main .pf-alert {
  padding: .45rem .75rem; margin: 0 0 .7rem; font-size: .92rem; border-width: 1px; border-left-width: 3px;
}

/* ---- "About this page": today's explanations, folded (public/ui-compact.js builds it) ------------------------ */
details.el-about { margin: 0 0 .6rem; font-size: .9rem; color: var(--el-muted, #6b6475); }
details.el-about > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: .3rem;
  font-size: .85rem; color: var(--el-muted, #6b6475); user-select: none; }
details.el-about > summary::-webkit-details-marker { display: none; }
details.el-about > summary::after { content: "\203A"; transition: transform .15s; display: inline-block; }
details.el-about[open] > summary::after { transform: rotate(90deg); }
details.el-about[open] { padding: .45rem .7rem; background: var(--el-surface-2, #f4f1f7); border-radius: 8px; }
details.el-about > p { margin: .35rem 0 0; }

/* ---- the quiet link to an area's settings at the end of its tab row ------------------------------------------ */
.el-tabs-wrap { display: flex; align-items: flex-end; gap: .5rem; }
.el-tabs-wrap > .el-tabs { flex: 1 1 auto; min-width: 0; }
.el-tabs-settings { flex: 0 0 auto; font-size: .85rem; color: var(--el-muted, #6b6475); padding: .45rem .2rem; white-space: nowrap;
  text-decoration: none; border-bottom: 1px solid var(--el-line, #e6e1ec); }
.el-tabs-settings:hover { color: var(--el-ink, #241b2f); }

/* ---- the side bar: Administration folds (his note, 2026-11-15) ----------------------------------------------- */
.sidebar nav .nav-fold { display: flex; align-items: center; }
.sidebar nav .nav-fold > a { flex: 1 1 auto; }
.sidebar nav .nav-fold-btn { flex: 0 0 auto; background: none; border: 0; cursor: pointer; padding: .25rem .5rem; color: inherit;
  font-size: .9rem; line-height: 1; transition: transform .15s; }
.sidebar nav .nav-fold-btn[aria-expanded="false"] { transform: rotate(-90deg); }
.sidebar nav.subs-folded a.nav-sub { display: none; }

/* A loud status line is amber, not red (he does not want red for status), and one line. */
body.el-compact .main main .pf-alert { background: var(--el-warn-soft, #fff4dc); border: 1px solid var(--el-warn-line, #f0d9a8); border-left: 3px solid var(--el-warn, #a66a00); color: inherit; }

/* The big coloured band that only held the page's name: the name is in the top bar now, so the band goes quiet. */
body.el-compact .main main .group-band { background: none !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; min-height: 0 !important; margin: 0 0 .5rem !important; }
body.el-compact .main main .group-band::before, body.el-compact .main main .group-band::after { display: none !important; }
body.el-compact .main main .group-page { margin: 0; }

/* A group's page (Hospice Operations ...): its agents as thin rows, two side by side, not big cards three across; the
   Agent status numbers on one line. The same words, buttons and folds as before. */
body.el-compact .group-page .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(26rem, 1fr)); gap: .5rem .9rem; }
body.el-compact .group-page .card.launch { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: .9rem; align-items: center;
  padding: .6rem .85rem; margin: 0; min-height: 0; background-image: none; }
body.el-compact .group-page .card.launch > h3 { grid-column: 1; margin: 0; font-size: 1rem; }
body.el-compact .group-page .card.launch > p { grid-column: 1; margin: .1rem 0 0; font-size: .85rem; }
body.el-compact .group-page .card.launch > .launch-foot { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; margin: 0; }
body.el-compact .group-page .card.launch > .launch-foot > p { margin: 0; text-align: right; max-width: 16rem; font-size: .82rem; }
body.el-compact .group-page .card.launch details { font-size: .8rem; }
body.el-compact .group-page .agent-status { padding: .6rem .85rem; }
body.el-compact .group-page .agent-status .stat-row { flex-wrap: nowrap; overflow-x: auto; }
body.el-compact .group-page .agent-status .stat { flex: 1 1 0; min-width: 7rem; padding: .2rem .6rem; }
body.el-compact .group-page .agent-status .stat-n { font-size: 1.15rem; }
body.el-compact .group-page .agent-status .stat-n.when { font-size: .9rem; }
@media (max-width: 700px) {
  body.el-compact .group-page .grid { grid-template-columns: 1fr; }
  body.el-compact .group-page .agent-status .stat-row { flex-wrap: wrap; }
}
body.el-compact .main main .group-band .group-butterfly { display: none; }

/* Number lines (.el-lines) side by side instead of one full-width row each (Trends: six rows for six numbers). Each line
   keeps its number, its words and its link. Not on Compliance (body.el-compact is off there). */
body.el-compact .el-lines:has(.el-line-num) { display: grid; grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); }
body.el-compact .el-lines:has(.el-line-num) > .el-line { border-top: 0; border-left: 1px solid var(--el-line); padding: .55rem .8rem; gap: .6rem; }
body.el-compact .el-line-num { min-width: 2.6rem; }
@media (max-width: 700px) { body.el-compact .el-lines:has(.el-line-num) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* A list of things (each line a name, a small second line and "Open"): thin rows, two columns on a wide screen, one on a
   phone; a long name gets the room to sit on one or two lines (Dr. Katz on Policies > HR Forms, 2026-11-15). */
body.el-compact .el-lines:not(:has(.el-line-num)) { display: grid; grid-template-columns: repeat(auto-fill, minmax(26rem, 1fr)); column-gap: 1.2rem; }
body.el-compact .el-lines:not(:has(.el-line-num)) > .el-line { padding: .45rem .9rem; align-items: center; border-top: 0; border-bottom: 1px solid var(--el-line); }
body.el-compact .el-lines:not(:has(.el-line-num)) .el-go { margin-left: auto; flex: 0 0 auto; }
@media (max-width: 700px) { body.el-compact .el-lines:not(:has(.el-line-num)) { grid-template-columns: 1fr; } }

/* IDG (Dr. Katz on staging, 2026-11-15: "Again empty space"). A warning is its headline on one line, the explanation one
   tap away; the team table fits the width (a team's description under its name); the roster box uses the width. */
body.el-compact details.idg-fold > summary { cursor: pointer; list-style: none; }
body.el-compact details.idg-fold > summary::-webkit-details-marker { display: none; }
body.el-compact details.idg-fold > summary::after { content: " A  why"; font-size: .85rem; color: var(--el-muted, #6b6475); }
body.el-compact details.idg-fold[open] > summary::after { content: ""; }
body.el-compact .idg-teams { width: 100%; table-layout: auto; }
body.el-compact .idg-teams td:first-child small { display: block; max-width: 34rem; }
body.el-compact .main main:has(.idg-teams) { overflow-x: auto; }
body.el-compact .idg-seed { max-width: none !important; }

/* Patient Forms > Due (Dr. Katz on staging, 2026-11-15: "a lot of spaces which could be redesigned"). A kind nobody owes is
   one thin line (its heading and "Nobody owes one right now"); a panel with rows keeps them, with less air around. */
body.el-compact .pf-panel { padding: .7rem 1rem; margin: 0 0 .8rem; border-radius: 12px; box-shadow: none; }
body.el-compact .pf-phead h2 { font-size: 1.05rem; }
body.el-compact .pf-panel:has(> .pf-empty) { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem 1rem; padding: .5rem 1rem; }
body.el-compact .pf-panel:has(> .pf-empty) > .pf-phead { flex: 0 1 auto; }
body.el-compact .pf-panel:has(> .pf-empty) > .el-about,
body.el-compact .pf-panel:has(> .pf-empty) > .pf-sub { order: 9; flex-basis: 100%; margin: 0; }
body.el-compact .pf-panel > .pf-empty { background: none; padding: 0; margin: 0; }

/* Tabs instead of a long page (ui-compact.js, data-el-tabs / data-el-pane): one part at a time once the tab row is drawn. */
.el-tabs-on > [data-el-pane]:not(.is-on) { display: none !important; }
.main .el-panetabs { margin: .2rem 0 .7rem; }

/* Unusual occurrence trends (Dr. Katz on staging, 2026-11-15: "smaller sizes and tabs rather than long page"): the
   filters and the two buttons on one line, the eight numbers as one row of small tiles, the charts in tabs. */
body.el-compact .tr-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem 1rem; margin: 0 0 .6rem; }
body.el-compact .tr-controls form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; margin: 0; }
body.el-compact .tr-controls select { padding: .25rem .4rem; }
body.el-compact h2.tr-period { font-size: 1rem; margin: .4rem 0 .4rem; }
body.el-compact .tr-cardrow { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .5rem; margin: 0 0 .7rem; }
body.el-compact .tr-cardrow > .tr-cards { display: contents; }
body.el-compact .tr-cardrow .card { padding: .5rem .7rem; margin: 0; min-height: 0; }
body.el-compact .tr-cardrow .card .k { font-size: .68rem; }
body.el-compact .tr-cardrow .card .v { font-size: 1.25rem; line-height: 1.2; }
body.el-compact .tr-cardrow .card .d { font-size: .75rem; }
body.el-compact .tr-panel { padding: .7rem .9rem; }
body.el-compact .tr-panel h3 { font-size: .95rem; margin: 0 0 .4rem; }

/* The Visit Board's Recert numbers use the width (Dr. Katz on staging, 2026-11-15: "a lot empty spaces"). */
body.el-compact .hc section:not(.hc-runline) .stat-row { display: grid !important; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .4rem .8rem; }

/* Trends: the From/To range sits on one line under the period tabs. */
body.el-compact .trends-range { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem .8rem; margin: .3rem 0 .6rem; }
body.el-compact .trends-range input[type="date"] { padding: .25rem .4rem; }

/* IDG, who sits at the meeting (Dr. Katz, 2026-11-15: "a lot of empty real estate, should be 2 or 3 columns"). */
body.el-compact .idg-discipline-list { columns: 3 16rem; column-gap: 2rem; }
body.el-compact .idg-discipline-list > li { break-inside: avoid; }
