/* =====================================================================
   TessaMed app shell (v1): navy sidebar, cream canvas, labelled navigation.
   Brand Kit section 09. base.html lays out .tm-shell > .tm-side + .tm-main;
   the sidebar is templates/_sidebar.html. Page content is untouched.
   ===================================================================== */

.tm-shell { display: flex; min-height: 100vh; }
.tm-side {
  width: 248px; flex: 0 0 248px; background: var(--tm-night); color: var(--tm-on-night);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow: hidden;
}
.tm-side .tm-side-brand { padding: 20px 24px 16px; border-bottom: 1px solid var(--tm-hairline-night); flex: 0 0 auto; }
.tm-side .tm-side-brand a { text-decoration: none; }
.tm-side nav { padding: 10px 12px; flex: 1 1 auto; }
/* A practice with every module has some twenty items (16 Nov 2026: 39 practices moved across with 30
   modules each). The whole column used to scroll, which pushed the person's name and Sign out off the
   screen. Now only the list scrolls (.tm-side itself no longer does); the logo and the name stay put. */
.tm-side nav { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.22) transparent; }
.tm-side nav::-webkit-scrollbar { width: 8px; }
.tm-side nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 8px; }
.tm-side .tm-side-user { flex: 0 0 auto; }
/* More than twelve items: a slightly tighter list, so most of it fits a laptop screen without scrolling */
.tm-side nav:has(> .tm-nav-item:nth-of-type(13)) .tm-nav-item { padding-top: 7px; padding-bottom: 7px; margin: 1px 0; }
.tm-side nav:has(> .tm-nav-item:nth-of-type(13)) .tm-nav-label { padding-top: 12px; padding-bottom: 4px; }
.tm-side .tm-nav-label {
  font-family: var(--tm-font-mono); font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--tm-on-night-muted); padding: 16px 12px 6px;
}
.tm-nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; margin: 2px 0;
  color: var(--tm-on-night-muted); text-decoration: none; font-size: 15px; font-weight: 400; position: relative;
  transition: background var(--tm-dur-fast) var(--tm-ease), color var(--tm-dur-fast) var(--tm-ease);
}
.tm-nav-item i { font-size: 18px; width: 22px; text-align: center; flex: 0 0 22px; }
.tm-nav-item:hover, .tm-nav-item:focus-visible { color: var(--tm-on-night); background: rgba(255,255,255,.05); }
.tm-nav-item.active { color: var(--tm-on-night); background: rgba(255,255,255,.07); }
.tm-nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--tm-cobalt);
}
.tm-nav-item .tm-count {
  margin-left: auto; font-family: var(--tm-font-mono); font-size: 12px; padding: 1px 9px; border-radius: var(--tm-radius-pill);
  background: rgba(5,171,249,.18); color: #7FD0FF;
}
.tm-nav-item .tm-count.action { background: rgba(253,94,2,.22); color: #FFB08A; }
.tm-side .tm-side-user { border-top: 1px solid var(--tm-hairline-night); padding: 16px 24px; font-size: 14px; }
.tm-side .tm-side-user .muted { color: var(--tm-on-night-muted); font-size: 13px; }
.tm-side .tm-side-user a { color: var(--tm-on-night-muted); font-size: 13px; text-decoration: none; }
.tm-side .tm-side-user a:hover { color: var(--tm-on-night); }

.tm-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.tm-topbar {
  display: flex; align-items: center; gap: 16px; padding: 12px 32px; background: var(--tm-cream);
  border-bottom: 1px solid var(--tm-line); position: sticky; top: 0; z-index: 1020; min-height: 68px;
}
.tm-topbar .tm-menu-btn { display: none; }
.tm-topbar .navbar-brand { padding: 0; }
.tm-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 8px 32px;
  background: var(--tm-night); color: var(--tm-on-night); border-bottom: 1px solid var(--tm-hairline-night); }
.tm-toolbar .tm-toolbar-left { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.tm-toolbar .tm-toolbar-right { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.tm-toolbar.is-empty { display: none; }
/* Count badge on toolbar buttons: solid, so it reads on the navy strip (5.4:1) */
.tm-count-badge { background: var(--tm-orange-text); color: #fff; }
.tm-content { padding: 28px 32px 48px; flex: 1 1 auto; }

/* Active patient banner (templates/_active_patient_banner.html): navy strip under the top bar */
.active-patient-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 32px;
  background: var(--tm-night); color: var(--tm-on-night); font-size: 14px; border-bottom: 1px solid var(--tm-hairline-night);
}
.active-patient-banner .details { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.active-patient-banner .tm-eyebrow { color: var(--tm-on-night-muted); }
.active-patient-banner .name { font-size: 16px; font-weight: 600; }
.active-patient-banner .meta { color: var(--tm-on-night-muted); font-size: 13px; border-left: 1px solid var(--tm-hairline-night); padding-left: 12px; }
.active-patient-banner .actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.active-patient-banner .btn { font-size: 13px; white-space: nowrap; }
/* On another patient's page (16 Nov 2026): the amber of "needs a look", navy text (8.6:1), and the
   words. The strip must not look like the calm one when it names someone the page is not about. */
.active-patient-banner.is-other { background: var(--tm-amber); color: var(--tm-night); border-bottom-color: var(--tm-amber-text); }
.active-patient-banner.is-other .tm-eyebrow { color: var(--tm-night); }
.active-patient-banner.is-other .warn { font-weight: 600; border-left: 1px solid rgba(27,31,59,.35); padding-left: 12px; }
.active-patient-banner.is-other .btn-light { background: var(--tm-night); border-color: var(--tm-night); color: var(--tm-cream); }
.active-patient-banner.is-other .btn-outline-light {
  --bs-btn-color: var(--tm-night); --bs-btn-border-color: var(--tm-night);
  --bs-btn-hover-color: var(--tm-cream); --bs-btn-hover-bg: var(--tm-night); --bs-btn-hover-border-color: var(--tm-night);
}

/* Search box: the "I'm looking for" partial restyled for the cream top bar */
.tm-topbar .lf-wrap { flex: 1 1 520px; max-width: 640px; display: block; }
.tm-topbar .lf-input {
  width: 100%; max-width: none; height: 44px; padding: 8px 44px 8px 42px; border-radius: var(--tm-radius-pill);
  border: 1.5px solid var(--tm-input-border); background: var(--tm-white); color: var(--tm-body); font-size: 15px;
}
.tm-topbar .lf-input::placeholder { color: var(--tm-muted); }
.tm-topbar .lf-input:focus { width: 100%; background: var(--tm-white); border-color: var(--tm-night); box-shadow: var(--tm-focus-ring); }
.tm-topbar .lf-icon { left: 16px; color: var(--tm-muted); font-size: 15px; }
.tm-topbar .lf-kbd {
  right: 14px; font-family: var(--tm-font-mono); font-size: 12px; color: var(--tm-muted);
  border: 1px solid var(--tm-border); border-radius: 6px; padding: 1px 7px; background: var(--tm-off);
}
.tm-topbar .lf-drop { width: 100%; max-width: 640px; border: 1px solid var(--tm-border); box-shadow: none; }
.tm-topbar .lf-hit:hover, .tm-topbar .lf-hit.on { background: var(--tm-sand); }
.tm-topbar .lf-hit .l { color: var(--tm-night); font-weight: 500; }
.tm-topbar .lf-hit .b { color: var(--tm-secondary); }
.tm-topbar .lf-section { font-family: var(--tm-font-mono); font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--tm-muted); padding: 8px 13px 2px; background: var(--tm-off); }

/* Segmented view switch (Clinical / Front desk) */
.tm-seg { display: inline-flex; border: 1.5px solid var(--tm-night); border-radius: var(--tm-radius-pill); overflow: hidden; }
.tm-seg a, .tm-seg span { color: var(--tm-night); padding: 7px 18px; font-weight: 500; font-size: 14px; text-decoration: none; line-height: 1.4; }
.tm-seg .on { background: var(--tm-night); color: var(--tm-cream); }
.tm-seg a:hover { background: var(--tm-off); }
/* The diary's Day / Week / Month / Year switch carried four near-identical calendar icons; the words
   are the label, and without the icons the date row fits one line (16 Nov 2026) */
.tm-seg .bi { display: none; }

/* Page header, eyebrow, stat tiles */
.tm-eyebrow { font-family: var(--tm-font-mono); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--tm-muted); }
.tm-h1 { font-size: 28px; font-weight: 300; letter-spacing: -0.6px; color: var(--tm-night); margin: 0; }
.tm-tile {
  background: var(--tm-white); border: 1px solid var(--tm-border); border-radius: var(--tm-radius-card); padding: 18px 22px; height: 100%;
  text-decoration: none; color: inherit; display: block; transition: border-color var(--tm-dur-fast) var(--tm-ease);
}
.tm-tile:hover { border-color: var(--tm-night); color: inherit; }
.tm-tile .tm-num { font-size: 34px; font-weight: 300; letter-spacing: -1px; color: var(--tm-night); line-height: 1.1; }
.tm-tile .tm-sub { font-size: 14px; color: var(--tm-secondary); margin-top: 4px; }

/* Status pills in the text-safe tones (never red) */
.tm-pill { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: var(--tm-radius-pill); white-space: nowrap; line-height: 1.5; }
.tm-pill-new { background: var(--tm-status-new-bg); color: var(--tm-status-new-fg); }
.tm-pill-proc { background: var(--tm-status-processing-bg); color: var(--tm-status-processing-fg); }
.tm-pill-pend { background: var(--tm-status-pending-bg); color: var(--tm-status-pending-fg); }
.tm-pill-act { background: var(--tm-status-action-bg); color: var(--tm-status-action-fg); }
.tm-pill-room { background: var(--tm-room-og); color: var(--tm-cobalt-text); }
.tm-pill-plain { background: var(--tm-off); color: var(--tm-secondary); }

/* Patient safety strip (record header, script writer): allergies may be a long list, so pills wrap */
.tm-safety { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tm-safety .tm-pill { white-space: normal; }

/* Patient table */
.tm-table td { vertical-align: middle; padding: 12px 14px; }
.tm-table th { padding: 10px 14px; }
.tm-table tbody tr:hover { background: var(--tm-sand); }
.tm-table .tm-file { font-family: var(--tm-font-mono); font-size: 12.5px; color: var(--tm-muted); white-space: nowrap; }
.tm-table .tm-name { font-weight: 500; color: var(--tm-night); font-size: 15px; }
.tm-table .tm-name a { color: inherit; text-decoration: none; }
.tm-table .tm-name a:hover { color: var(--tm-cobalt-text); }
.tm-table .tm-meta { font-size: 13px; color: var(--tm-secondary); }
.tm-table .btn-sm { font-size: 13px; padding: 5px 14px; white-space: nowrap; }
.tm-table .dropdown-toggle::after { display: none; }
.tm-group-row td {
  font-family: var(--tm-font-mono); font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--tm-muted); background: var(--tm-off); padding: 6px 14px;
}
.tm-group-row.priority td { color: var(--tm-amber-text); background: var(--tm-room-op); }
.tm-filters .btn { font-size: 13px; padding: 5px 14px; }
.tm-filters .btn-outline-primary { border-width: 1px; }

/* Small screens: the sidebar becomes an offcanvas menu */
@media (max-width: 991.98px) {
  .tm-side { display: none; }
  .tm-topbar { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .tm-topbar .lf-wrap { flex: 1 1 100%; order: 3; max-width: none; }   /* search gets its own row */
  .tm-topbar .ms-auto { margin-left: auto; }
  .tm-seg a, .tm-seg span { padding: 6px 12px; font-size: 13px; white-space: nowrap; }
  .tm-topbar .tm-menu-btn { display: inline-flex; }
  .tm-toolbar, .tm-content, .active-patient-banner { padding-left: 16px; padding-right: 16px; }
  .tm-offcanvas { background: var(--tm-night); color: var(--tm-on-night); width: 280px; }
  .tm-offcanvas .tm-side { display: flex; width: 100%; flex: 1 1 auto; height: 100%; position: static; }
  /* Screen space (19 Oct 2026): a tighter top bar, a one-line patient banner, a smaller greeting */
  .tm-topbar { padding: 8px 16px; min-height: 0; }
  .tm-topbar .lf-input { height: 40px; }
  .active-patient-banner { padding-top: 6px; padding-bottom: 6px; }
  .active-patient-banner .details { flex-wrap: nowrap; overflow: hidden; }
  .active-patient-banner .tm-eyebrow, .active-patient-banner .meta { display: none; }
  .active-patient-banner .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  /* the warning is the point of the amber strip: on a phone it wraps under the name instead of being cut */
  .active-patient-banner.is-other .details { flex-wrap: wrap; row-gap: 2px; }
  .active-patient-banner.is-other .tm-eyebrow { display: block; flex: 1 1 100%; }   /* say whose name it is */
  .active-patient-banner.is-other .warn { border-left: 0; padding-left: 0; flex: 1 1 100%; font-size: 13px; }
  .tm-h1 { font-size: 22px; }
}
/* Phones (16 Nov 2026): a stat tile is one compact row, its label and note on the left and the number
   on the right, so the three dashboard tiles take about 200 px instead of 400 before the patient list */
@media (max-width: 767.98px) {
  .tm-tile { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px; padding: 12px 16px; }
  .tm-tile .tm-eyebrow { grid-column: 1; grid-row: 1; }
  .tm-tile .tm-sub { grid-column: 1; grid-row: 2; margin-top: 2px; font-size: 13px; }
  .tm-tile .tm-num { grid-column: 2; grid-row: 1 / span 2; font-size: 30px; }
}
/* The patient list's one shared row menu (partials/_patient_menu.html), placed by its script */
.tm-row-menu { position: fixed; z-index: 1060; }

/* Patient list on small screens: each row becomes a card - name on top, then status,
   file number, phone and actions (19 Oct 2026) */
@media (max-width: 991.98px) {
  #patientTable thead { display: none; }
  #patientTable, #patientTable tbody { display: block; width: 100%; }
  #patientTable tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 16px; border-bottom: 1px solid var(--tm-line); }
  #patientTable tbody tr > td { display: block; padding: 0; border: 0; text-align: left; background: transparent; box-shadow: none; }
  #patientTable tbody tr.tier-divider > td { flex: 1 1 100%; }
  #patientTable tbody tr > td:nth-child(2) { order: 1; flex: 1 1 100%; }
  #patientTable tbody tr > td:nth-child(3) { order: 2; flex: 1 1 100%; }
  #patientTable tbody tr > td:nth-child(1) { order: 3; }
  #patientTable tbody tr > td:nth-child(4) { order: 4; }
  #patientTable tbody tr > td:nth-child(5) { display: none; }
  #patientTable tbody tr > td:nth-child(6) { order: 5; margin-left: auto; }
}
@media print { .tm-side, .tm-topbar, .tm-toolbar { display: none !important; } .tm-content { padding: 0; } }
/* Inside TessaMed installed as an app (services/app_install.py) the links that offer the install have done their job */
@media (display-mode: standalone) { .tm-only-browser { display: none !important; } }
