/* Tehfeez Management System — design system.

   Pine ink + teal for structure and action, on warm paper. Brass is the one
   decorative accent and is used sparingly, so it stays special. Status colours
   are always paired with a word or a dot, never relied on alone. */

@font-face {
  font-family: "Montserrat";
  src: url("../fonts/montserrat-latin-wght-normal.311d352d9323.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Montserrat";
  src: url("../fonts/montserrat-latin-wght-italic.7921052ef928.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

:root {
  interpolate-size: allow-keywords;

  /* Structure */
  --tms-pine-950: #081c19;
  --tms-pine-900: #0d2a26;
  --tms-pine-800: #133a34;
  --tms-pine-700: #1c4f47;
  --tms-ink: #12322d;

  /* Action */
  --tms-accent: #0f6b5e;
  --tms-accent-light: #38a08f;
  --tms-accent-strong: #0a5247;
  --tms-accent-soft: #d6ebe6;
  --tms-accent-grad: linear-gradient(135deg, #14806f 0%, #0a5247 100%);
  --tms-pine-grad: linear-gradient(160deg, var(--tms-pine-700) 0%, var(--tms-pine-900) 55%, var(--tms-pine-950) 100%);
  --tms-glow: 0 8px 22px rgba(15, 107, 94, 0.28);

  /* Decorative */
  --tms-brass: #b98a3e;
  --tms-brass-light: #e0c088;

  /* Surfaces */
  --tms-bg: #e4dbc8;
  --tms-paper: #f8f3e8;
  --tms-tint: #dfe9df;
  --tms-fill: #ebe3d2;
  --tms-fill-strong: #ded4be;
  --tms-border: #dacfb8;
  --tms-surface: var(--tms-paper);
  --tms-surface-raised: #f0e9da;
  --tms-field-bg: #fcf8f0;

  /* Text */
  --tms-text: #1b2623;
  --tms-text-muted: #545e58;
  --tms-on-pine: #e8f1ee;
  --tms-on-pine-muted: rgba(232, 241, 238, 0.62);

  /* Status */
  --tms-danger: #b23f2d;
  --tms-danger-soft: #fbece9;
  --tms-success: #1b7a52;
  --tms-success-soft: #e2f3ea;
  --tms-warn: #8f5d0e;
  --tms-warn-soft: #fbf1dd;

  /* Shape */
  --tms-radius-sm: 9px;
  --tms-radius: 12px;
  --tms-radius-lg: 16px;
  --tms-radius-xl: 24px;
  --tms-shadow-sm: 0 1px 2px rgba(13, 42, 38, 0.05);
  --tms-shadow: 0 1px 2px rgba(13, 42, 38, 0.04), 0 6px 18px rgba(13, 42, 38, 0.05);
  --tms-shadow-lift: 0 4px 12px rgba(13, 42, 38, 0.08), 0 18px 44px rgba(13, 42, 38, 0.13);

  /* Layout */
  --tms-sidebar-width: 286px;
  --tms-topbar-height: 70px;
  --tms-bottomnav-height: 62px;

  /* Motion */
  --tms-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --tms-fast: 0.16s;
  --tms-med: 0.28s;

  /* The serif is for moments, the sans is for work. */
  --tms-font: "Montserrat", "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  --tms-font-display: "Montserrat", "Segoe UI", sans-serif;
}

@view-transition { navigation: auto; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: 15.5px; }

body {
  margin: 0;
  font-family: var(--tms-font);
  background: var(--tms-bg);
  color: var(--tms-text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: 0.002em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
a:not([class]) { color: var(--tms-accent); font-weight: 500; }
a:not([class]):hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--tms-accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--tms-accent-soft); color: var(--tms-ink); }

/* `clip`, not `hidden`: hidden makes a scroll container and breaks sticky. */
html, body { max-width: 100%; overflow-x: clip; }

.tms-table td, .tms-table th { overflow-wrap: normal; word-break: normal; }

/* Cells wrap so a table fits its container without pushing the page sideways.
   overflow-x is auto (not hidden) as a last-resort safety net: if a table
   genuinely can't fit — many columns with unbreakable content — its own
   wrapper scrolls rather than CLIPPING controls out of reach (an off-screen
   Approve button can never be clicked). The page body still never scrolls
   sideways; only this wrapper does, and only when it must. */

.tms-tablewrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
}

.tms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  table-layout: auto;
}

/* Long values wrap instead of forcing the table wider than the page. Cells
   that explicitly opt into nowrap (via inline style) still win where a value
   must stay on one line (short dates, times). */

.tms-table td, .tms-table th { white-space: normal; }

/* A table of editable rows is the wrong shape for a phone: seven columns of
   inputs can only be reached by scrolling sideways, and the first column gets
   squeezed to nothing. Below 720px a .tms-table--stack row becomes a card,
   each cell a labelled line. The label comes from data-label on the <td>, so
   the header row can be hidden without losing what each field means. */

@media (max-width: 720px) {
  /* Global safety net: on a phone nothing may push content sideways. Long
     unbreakable strings (ITS IDs, emails, a reason with no spaces) wrap
     instead of overflowing their card, and the page itself never scrolls
     horizontally. Applies to every tab, not just the ones we spot-fixed. */
  .tms-shell { overflow-x: clip; }
  .tms-card, .tms-content, .tms-detail-row, .tms-table td { overflow-wrap: break-word; word-break: normal; }

  /* EVERY data table stacks into labelled cards on a phone, not just the ones
     tagged .tms-table--stack. A five-column table crammed into 360px squeezes
     each column to three or four letters — unreadable. Stacking gives each
     cell a full-width line; where a <td> carries data-label it also gets a
     caption. (--stack is kept as a harmless alias for tables already using it.) */
  .tms-table,
  .tms-table tbody,
  .tms-table tr,
  .tms-table td { display: block; width: auto; min-width: 0; }

  .tms-table thead { display: none; }

  .tms-table tr {
    border: 1px solid var(--tms-border);
    border-radius: var(--tms-radius);
    background: var(--tms-paper);
    padding: 6px 12px 10px;
    margin-bottom: 12px;
  }

  .tms-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--tms-fill-strong);
    padding: 9px 0;
    white-space: normal;
    /* A long value (a long student name, a big reason) wraps to the next line
       and breaks if needed, instead of pushing out past the card edge. */
    flex-wrap: wrap;
    overflow-wrap: break-word;
  }

  .tms-table tr td:last-child { border-bottom: none; }

  .tms-table td[data-label]::before {
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tms-text-muted);
    flex: 0 0 auto;
  }

  /* The first cell is the row's identity — give it the full width. */
  .tms-table td:first-child { display: block; }
  .tms-table td:first-child[data-label]::before { display: block; margin-bottom: 5px; }
  .tms-table td:first-child .tms-input { width: 100%; }

  /* An empty cell would otherwise leave a stray bordered blank line in the
     card — collapse cells that have neither a label nor content to show. */
  .tms-table td:empty { display: none; }

  /* Fingers, not a mouse: give the small action buttons a real tap target
     on phones. Kept inside the breakpoint so dense desktop toolbars are
     unchanged. */
  .tms-btn-link--sm,
  .tms-btn-link--lg,
  .tms-table td .tms-btn-link {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* An input inside a table must keep a usable width. Without a floor the
   table compresses them to fit the viewport — on a phone the shift Name
   field collapsed to a single visible character. With a floor, the table
   grows past the viewport and .tms-tablewrap scrolls instead, which is
   what it exists for. */

.tms-table .tms-input { min-width: 6.5rem; }

.tms-table td:first-child .tms-input { min-width: 11rem; }

.tms-table th, .tms-table td {
  text-align: left;
  padding: 11px 13px;
  border-bottom: 1px solid var(--tms-border);
  /* Wrap by default so a wide table (e.g. a Shifts column listing five slabs)
     reflows to fit instead of clipping. Cells that must stay on one line —
     short dates, times, money — opt in with .tms-nowrap or an inline style. */
  white-space: normal;
  /* Tabular figures: every digit takes the same width, so amounts, counts and
     dates line up down a column instead of drifting. Montserrat carries true
     tabular figures, which a screen full of money depends on. */
  font-variant-numeric: tabular-nums;
}

.tms-table th.tms-nowrap, .tms-table td.tms-nowrap { white-space: nowrap; }

/* Money and counts read correctly right-aligned — units line up under units.
   Add .tms-num to a th and its matching td. Ignored once the table stacks
   into cards on a phone, where each cell is a labelled line. */

.tms-table th.tms-num, .tms-table td.tms-num { text-align: right; }

/* A section header row inside a table — e.g. a shift's name above its
   students. Reads as a band across the table, not another data row. */

.tms-table tr.tms-table__group th {
  background: var(--tms-surface-raised);
  color: var(--tms-ink);
  font-size: 0.82rem;
  text-transform: none;
  letter-spacing: 0;
  padding-top: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--tms-border);
}

.tms-table th {
  color: var(--tms-text-muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: transparent;
  border-bottom: 1.5px solid var(--tms-border);
}

.tms-table tbody tr { transition: background 0.12s ease; }

.tms-table tbody tr:last-child td, .tms-table tr:last-child td { border-bottom: none; }

.tms-table tr:hover td { background: rgba(15, 107, 94, 0.06); }

.tms-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }

/* A form row that mixes labelled fields with a submit button: bottom-align
   them so the button sits level with the inputs, not with their labels. */

.tms-filterbar {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tms-filterbar .tms-field { margin-bottom: 0; }

/* On a phone, wrapped action buttons end up as ragged rows of different
   widths because each is sized by its label ("Income" beside "Generate
   Monthly Invoices"). A grid gives every action the same target size, which
   is easier to hit with a thumb and reads as one set rather than a run-on
   sentence. */

@media (max-width: 720px) {
  .tms-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    align-items: stretch;
  }
  .tms-actions > .tms-btn-link,
  .tms-actions > form > .tms-btn-link {
    width: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  /* A button wrapped in a <form> (e.g. Reset Device) is a grid item via its
     form — stretch the form and let its button fill it, so it matches the
     plain button links instead of shrinking to its text. */
  .tms-actions > form { display: flex; }
}

.tms-bar-chart { display: flex; flex-direction: column; gap: 9px; }

.tms-bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 50px;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
}

.tms-bar-track {
  background: var(--tms-fill);
  border-radius: 6px;
  height: 16px;
  overflow: hidden;
}

.tms-bar-fill {
  background: linear-gradient(90deg, var(--tms-accent-strong), var(--tms-accent));
  height: 100%;
  border-radius: 6px;
}

/* Combined attendance analytics — a small stacked-bar chart per day. */

.tms-swatch {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  vertical-align: -1px;
  margin-right: 4px;
}

.tms-attn-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 160px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tms-attn-col {
  flex: 1 0 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.tms-attn-bar {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 1px;
  min-width: 10px;
}

.tms-attn-seg { width: 100%; border-radius: 2px 2px 0 0; }

.tms-attn-day {
  font-size: 0.62rem;
  color: var(--tms-text-muted);
  margin-top: 4px;
}

/* A stat card that reveals a list of names on hover / tap (focus). */

.tms-hovercard { position: relative; outline: none; }

.tms-hovercard[tabindex] { cursor: pointer; }

.tms-hovercard__pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  min-width: 220px;
  max-width: min(340px, 88vw);
  max-height: 320px;
  overflow-y: auto;
  background: var(--tms-paper);
  border: 1px solid var(--tms-border);
  border-radius: var(--tms-radius);
  box-shadow: 0 10px 28px rgba(13, 42, 38, 0.18);
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--tms-text);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.tms-hovercard:hover .tms-hovercard__pop,
.tms-hovercard:focus .tms-hovercard__pop,
.tms-hovercard:focus-within .tms-hovercard__pop {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.tms-hovercard__pop ul,
.tms-hovercard__pop ol { margin: 6px 0 0; padding-left: 20px; }

.tms-hovercard__pop li { margin: 3px 0; }

/* Monthly attendance-rate trend — one bar per month. */

.tms-trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 190px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tms-trend-col {
  flex: 1 0 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  outline: none;
}

.tms-trend-val {
  font-size: 0.6rem;
  color: var(--tms-text-muted);
  height: 13px;
  margin-bottom: 2px;
}

.tms-trend-bar-wrap {
  flex: 1;
  width: 62%;
  min-width: 14px;
  display: flex;
  align-items: flex-end;
}

.tms-trend-bar {
  width: 100%;
  background: var(--tms-accent-light);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.tms-trend-col--current .tms-trend-bar { background: var(--tms-accent); }

.tms-trend-label {
  font-size: 0.64rem;
  color: var(--tms-text-muted);
  margin-top: 5px;
}

/* ---------- Short-staffed shifts ---------- */

/* A status list, not a chart: the counts are tiny (0 of 1), so a ratio in
   text beats a meter. Colour is reinforcement only — every pill states its
   meaning in words, because the danger and warning tokens are too close to
   be distinguished by hue alone. */

.tms-staffing {
  border: 1px solid var(--tms-border);
  border-left: 4px solid var(--tms-danger);
  border-radius: var(--tms-radius);
  background: var(--tms-danger-soft);
  padding: 14px 16px 10px;
  margin-bottom: 16px;
}

.tms-staffing__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.tms-staffing__title {
  font-weight: 700;
  color: var(--tms-ink);
}

.tms-staffing__summary {
  font-size: 0.8rem;
  color: var(--tms-text-muted);
}

.tms-staffing__table { background: transparent; }

.tms-staffing__table th { font-size: 0.7rem; }

.tms-staffing__table td { vertical-align: middle; }

.tms-staffing__name { font-weight: 600; display: block; }

.tms-staffing__when {
  font-size: 0.74rem;
  display: block;
}

.tms-staffing__ratio {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tms-staffing__foot {
  font-size: 0.75rem;
  margin: 10px 0 0;
}

/* Status pills. Each carries its own word, so the colour is never load-bearing. */

.tms-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}

.tms-pill--bad {
  color: var(--tms-danger);
  background: var(--tms-paper);
  border-color: var(--tms-danger);
}

.tms-pill--ok {
  color: var(--tms-success);
  background: var(--tms-success-soft);
  border-color: var(--tms-accent-soft);
}

.tms-pill--none {
  color: var(--tms-text-muted);
  background: var(--tms-paper);
  border-color: var(--tms-border);
  font-weight: 600;
}

/* ---------- Settings sections ---------- */

/* Related settings sit side by side on a wide screen and stack on a phone,
   so a section reads as one group rather than a column of inputs. */

.tms-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 18px;
}

/* Day picker shared by the attendance pages (base/_date_nav.html). */

.tms-daynav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* A compact box, not a full-width bar: .tms-input is width:100% by default,
   and even at auto width the standard padding made it read as a slab. */

.tms-daynav__input {
  width: auto;
  max-width: 150px;
  flex: 0 0 auto;
  padding: 7px 10px;
  font-size: 0.85rem;
}

/* ---------- Month calendar (roster, my roster, my schedule) ---------- */

.tms-cal__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tms-cal__picker { display: flex; align-items: center; gap: 8px; }

.tms-cal__picker-label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--tms-ink);
}

.tms-cal__picker .tms-input { width: auto; min-width: 190px; margin: 0; }

.tms-cal__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.tms-cal__month {
  font-weight: 700;
  color: var(--tms-ink);
  font-size: 1rem;
}

.tms-cal__hint { margin-top: 0; font-size: 0.85rem; }

.tms-cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.tms-cal__dow {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tms-text-muted);
  padding: 4px 0 6px;
}

.tms-cal__day {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 84px;
  padding: 8px 8px 9px;
  border: 1px solid var(--tms-fill-strong);
  border-radius: var(--tms-radius);
  background: var(--tms-paper);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.tms-cal__day:hover:not(.tms-cal__day--empty):not(.tms-cal__day--static) {
  border-color: var(--tms-accent);
  box-shadow: var(--tms-shadow);
}

.tms-cal__day--static { cursor: default; }

.tms-cal__day--empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
  min-height: 0;
}

.tms-cal__day--today { background: var(--tms-tint); }

.tms-cal__day--holiday {
  background: repeating-linear-gradient(
    135deg,
    var(--tms-fill) 0,
    var(--tms-fill) 8px,
    var(--tms-fill-strong) 8px,
    var(--tms-fill-strong) 10px
  );
}

.tms-cal__day--today .tms-cal__daynum {
  color: var(--tms-accent-strong);
  font-weight: 800;
}

.tms-cal__day--selected {
  border-color: var(--tms-accent-strong);
  background: var(--tms-accent-soft);
  box-shadow: inset 0 0 0 2px var(--tms-accent-strong);
}

.tms-cal__day--selected .tms-cal__daynum { color: var(--tms-accent-strong); }

/* A ticked corner so selection reads without relying on colour alone. */

.tms-cal__day--selected::after {
  content: "✓";
  position: absolute;
  top: 5px;
  right: 7px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--tms-accent-strong);
}

/* The checkbox drives state but the whole cell is the hit target. */

.tms-cal__check {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.tms-cal__check:focus-visible + .tms-cal__daynum {
  outline: 2px solid var(--tms-accent-strong);
  outline-offset: 2px;
  border-radius: 4px;
}

.tms-cal__daynum {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--tms-ink);
}

.tms-cal__body { display: flex; flex-direction: column; gap: 3px; }

.tms-cal__chip {
  background: var(--tms-fill);
  border: 1px solid var(--tms-fill-strong);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--tms-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tms-cal__chip--primary {
  background: var(--tms-ink);
  color: var(--tms-paper);
  border-color: var(--tms-ink);
}

/* Substitute cover — distinct from the navy primary chip so a temporary
   standing assignment is legible at a glance. */

.tms-cal__chip--substitute {
  background: var(--tms-accent-strong);
  color: var(--tms-paper);
  border-color: var(--tms-accent-strong);
}

.tms-cal__none { color: var(--tms-text-muted); font-size: 0.78rem; }

/* A day that opens a detail panel when tapped (teacher's My Roster). */

.tms-cal__day--tappable { cursor: pointer; }

.tms-cal__day--tappable:hover {
  border-color: var(--tms-accent);
  box-shadow: var(--tms-shadow-sm);
}

.tms-cal__day--tappable:focus-visible {
  outline: 2px solid var(--tms-accent-strong);
  outline-offset: 2px;
}

/* The expanded day's details, shown under the grid at readable size. */

.tms-daypanel {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--tms-border);
  border-left: 4px solid var(--tms-accent-strong);
  border-radius: var(--tms-radius);
  background: var(--tms-surface-raised);
}

.tms-daypanel__title {
  font-weight: 700;
  color: var(--tms-ink);
  margin-bottom: 8px;
}

/* A holiday label ("Sunday", or any declared title) is a nowrap pill, so on a
   narrow column it painted straight out of its cell and over the one beside
   it. The grid track is already minmax(0, 1fr) — it was the content that
   overflowed, not the column. Clip at the cell and ellipsise the pill. */

.tms-cal__day { overflow: hidden; }

.tms-cal__body .tms-badge {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tms-roster-actions {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 14px;
}

.tms-roster-actions__field { margin-bottom: 0; flex: 1; min-width: 240px; }

@media (max-width: 720px) {
  .tms-cal { gap: 4px; }
  .tms-cal__day { min-height: 68px; padding: 6px 5px; }
  .tms-cal__chip { font-size: 0.65rem; padding: 1px 4px; }
  .tms-cal__dow { font-size: 0.62rem; }
  .tms-cal__body .tms-badge { font-size: 0.6rem; padding: 1px 5px; }
}

/* ------------------------------------------------------------------ *
 *  Selects & searchable combobox
 *
 *  Two layers, both matching the gold/navy field styling:
 *   1. Every native <select.tms-input> gets a custom chevron so it
 *      stops rendering the bare OS control (works with zero JS).
 *   2. Large pickers marked data-searchable are progressively enhanced
 *      by combobox.js into a searchable dropdown. The real <select>
 *      stays in the DOM as the form's value; if JS never runs, the
 *      styled native select from layer 1 is the graceful fallback.
 * ------------------------------------------------------------------ */

select.tms-input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%230f6b5e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

select.tms-input::-ms-expand { display: none; }

/* Combobox — the JS-enhanced searchable version. */

.tms-combo { position: relative; width: 100%; }

/* Keep the native <select> in the DOM (so its value posts) but out of
 * sight once enhanced. Not display:none — that would drop it from some
 * form serialisers and break focus. */

.tms-combo__native {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.tms-combo__control {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  border: 1.5px solid var(--tms-border);
  border-radius: var(--tms-radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--tms-field-bg);
  color: var(--tms-text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.tms-combo__control:hover { border-color: var(--tms-accent-light); }

.tms-combo__control:focus,
.tms-combo--open .tms-combo__control {
  outline: none;
  border-color: var(--tms-accent);
  background: var(--tms-paper);
  box-shadow: 0 0 0 3px rgba(15, 107, 94, 0.18);
}

.tms-combo__value {
  /* min-width:0 lets the ellipsis kick in inside the flex control — without it
   * a long value overflows the box instead of truncating. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tms-combo__value--placeholder { color: var(--tms-text-muted); }

.tms-combo__chev {
  flex: 0 0 auto;
  width: 14px; height: 14px;
  color: var(--tms-accent-strong);
  transition: transform 0.15s ease;
}

.tms-combo--open .tms-combo__chev { transform: rotate(180deg); }

.tms-combo__panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  /* At least as wide as the control, but grow to fit the longest option so
   * names never wrap — capped so it can't overflow a phone screen. */
  min-width: max(100%, 240px);
  width: max-content;
  max-width: min(380px, 92vw);
  background: var(--tms-paper);
  border: 1.5px solid var(--tms-accent-soft);
  border-radius: var(--tms-radius);
  box-shadow: var(--tms-shadow-lift);
  padding: 8px;
  display: none;
}

.tms-combo--open .tms-combo__panel { display: block; }

.tms-combo__search {
  width: 100%;
  padding: 9px 11px;
  border: 1.5px solid var(--tms-border);
  border-radius: var(--tms-radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--tms-field-bg);
  color: var(--tms-text);
  margin-bottom: 6px;
}

.tms-combo__search:focus {
  outline: none;
  border-color: var(--tms-accent);
  background: var(--tms-paper);
}

.tms-combo__list {
  list-style: none;
  margin: 0; padding: 0;
  max-height: 240px;
  overflow-y: auto;
}

.tms-combo__option {
  padding: 9px 11px;
  border-radius: var(--tms-radius-sm);
  font-size: 0.92rem;
  cursor: pointer;
  color: var(--tms-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Optgroup header inside the combobox list (e.g. roster "Available to assign"). */

.tms-combo__group {
  padding: 8px 11px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tms-accent-strong);
}

.tms-combo__group:not(:first-child) { border-top: 1px solid var(--tms-border); margin-top: 4px; }

.tms-combo__control[disabled], .tms-combo__control:disabled {
  opacity: 0.55; cursor: not-allowed; background: var(--tms-fill);
}

.tms-combo__option:hover,
.tms-combo__option--active {
  background: var(--tms-fill);
}

.tms-combo__option--selected {
  color: var(--tms-accent-strong);
  font-weight: 600;
}

.tms-combo__option--selected::after {
  content: "✓";
  float: right;
  color: var(--tms-accent-strong);
}

.tms-combo__empty {
  padding: 12px 11px;
  font-size: 0.88rem;
  color: var(--tms-text-muted);
  text-align: center;
}

/* ------------------------------------------------------------------ *
 *  List search bar + pagination
 * ------------------------------------------------------------------ */

.tms-searchbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tms-searchbar .tms-input {
  flex: 1 1 220px;
  width: auto;
  margin: 0;
}

/* Search on the left, a single Filter button on the right that opens a panel
   of criteria (shift, marhala, teacher, …). Built on <details> so it needs no
   JavaScript. */

.tms-filterbar {
  display: flex;
  gap: 10px;
  /* flex-end so a bare submit button (e.g. "Show") lines up with the date
     inputs beside it, whose labels sit above them — not floating at the top.
     Dropdown-toggle filter bars have equal-height items, so this is a no-op
     for them. */
  align-items: flex-end;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tms-filter { position: relative; flex: 0 0 auto; }

.tms-filter__toggle {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.tms-filter__toggle::-webkit-details-marker { display: none; }

.tms-filter__toggle .tms-navlink__badge { margin-left: 2px; }

.tms-filter__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  width: 340px;
  max-width: 92vw;
  background: var(--tms-paper);
  border: 1px solid var(--tms-border);
  border-radius: var(--tms-radius);
  box-shadow: 0 10px 28px rgba(13, 42, 38, 0.16);
  padding: 14px;
}

.tms-filter__grid {
  display: grid;
  /* minmax(0, …) lets each column shrink BELOW its widest option's width —
   * otherwise a long option (e.g. a full teacher name) forces the track wider
   * than the panel and the select's text spills outside the box. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.tms-filter__grid .tms-field { min-width: 0; }

.tms-filter__grid .tms-field > span {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tms-text-muted);
  margin-bottom: 4px;
}

.tms-filter__grid .tms-field .tms-input { width: 100%; }

.tms-filter__actions { display: flex; gap: 8px; margin-top: 12px; }

@media (max-width: 560px) {
  .tms-filter { position: static; width: 100%; }
  .tms-filter__panel {
    position: static;
    width: 100%;
    max-width: none;
    box-shadow: none;
    margin-top: 8px;
  }
  .tms-filter__grid { grid-template-columns: 1fr; }
}

.tms-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.tms-pager__link {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: var(--tms-radius-sm);
  border: 1.5px solid var(--tms-border);
  background: var(--tms-field-bg);
  color: var(--tms-accent-strong);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.tms-pager__link:hover { border-color: var(--tms-accent-light); background: var(--tms-paper); }

.tms-pager__link--disabled {
  color: var(--tms-text-muted);
  opacity: 0.5;
  cursor: default;
}

.tms-pager__status { font-size: 0.86rem; color: var(--tms-text); }

/* ------------------------------------------------------------------ *
 *  Date picker (styled calendar over <input type="date">)
 * ------------------------------------------------------------------ */

.tms-dp { position: relative; width: 100%; }

.tms-dp__native {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.tms-dp__control {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 13px;
  border: 1.5px solid var(--tms-border);
  border-radius: var(--tms-radius-sm);
  font-size: 0.95rem; font-family: inherit;
  background: var(--tms-field-bg); color: var(--tms-text);
  cursor: pointer; text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.tms-dp__control:hover { border-color: var(--tms-accent-light); }

.tms-dp__control:focus,
.tms-dp--open .tms-dp__control {
  outline: none; border-color: var(--tms-accent);
  background: var(--tms-paper); box-shadow: 0 0 0 3px rgba(15, 107, 94, 0.18);
}

.tms-dp__value--placeholder { color: var(--tms-text-muted); }

.tms-dp__icon { flex: 0 0 auto; display: inline-flex; color: var(--tms-accent-strong); }

.tms-dp__pop {
  position: absolute; z-index: 40;
  top: calc(100% + 6px); left: 0;
  width: max-content; max-width: 92vw;
  background: var(--tms-paper);
  border: 1.5px solid var(--tms-accent-soft);
  border-radius: var(--tms-radius);
  box-shadow: var(--tms-shadow-lift);
  padding: 12px; display: none;
}

.tms-dp--open .tms-dp__pop { display: block; }

.tms-dp__nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

.tms-dp__navbtn {
  width: 30px; height: 30px; line-height: 1;
  border: 1.5px solid var(--tms-border); background: var(--tms-field-bg);
  border-radius: var(--tms-radius-sm); cursor: pointer;
  color: var(--tms-accent-strong); font-size: 1rem;
}

.tms-dp__navbtn:hover { border-color: var(--tms-accent-light); background: var(--tms-paper); }

.tms-dp__month { font-weight: 700; color: var(--tms-ink); font-size: 0.92rem; }

.tms-dp__month--btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--tms-radius-sm);
}

.tms-dp__month--btn:hover { background: var(--tms-fill); }

/* Year-picker grid (click the month/year title to reach it). */

.tms-dp__years { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

.tms-dp__year {
  border: 1px solid var(--tms-border);
  background: var(--tms-paper);
  color: var(--tms-ink);
  border-radius: var(--tms-radius-sm);
  padding: 10px 0;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

.tms-dp__year:hover { border-color: var(--tms-accent-light); }

.tms-dp__year--selected { background: var(--tms-accent-grad); color: #fff; border: none; }

.tms-dp__grid { display: grid; grid-template-columns: repeat(7, 34px); gap: 3px; }

.tms-dp__dow {
  text-align: center; font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; color: var(--tms-text-muted); padding-bottom: 4px;
}

.tms-dp__day {
  height: 34px; border: none; background: transparent;
  border-radius: 8px; cursor: pointer; font-size: 0.85rem;
  color: var(--tms-text); font-family: inherit;
}

.tms-dp__day--empty { visibility: hidden; }

.tms-dp__day:hover:not(.tms-dp__day--disabled):not(.tms-dp__day--selected) { background: var(--tms-fill); }

.tms-dp__day--today { border: 1.5px solid var(--tms-accent-soft); }

.tms-dp__day--selected { background: var(--tms-accent-grad); color: #fff; font-weight: 700; }

.tms-dp__day--disabled { color: var(--tms-text-muted); opacity: 0.4; cursor: not-allowed; }

/* ------------------------------------------------------------------ *
 *  Wheel picker (PIN-lock style roller over <select data-wheel>)
 *  Row height 40px, 5 rows visible; the middle row is the selection.
 * ------------------------------------------------------------------ */

.tms-wheel { position: relative; width: 100%; max-width: 260px; }

.tms-wheel__native {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); border: 0;
}

.tms-wheel__viewport {
  height: 200px;               /* 5 * 40 */
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  border: 1.5px solid var(--tms-border);
  border-radius: var(--tms-radius);
  background: var(--tms-field-bg);
  -ms-overflow-style: none;
  scrollbar-width: none;
  /* Fade the top and bottom rows so the centre reads as the focus. */
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 34%, #000 66%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 34%, #000 66%, transparent);
}

.tms-wheel__viewport::-webkit-scrollbar { display: none; }

.tms-wheel__pad { height: 80px; }

/* 2 * 40, lets first/last centre */

.tms-wheel__item {
  height: 40px;
  scroll-snap-align: center;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem; color: var(--tms-text-muted);
  cursor: pointer;
  transition: color 0.12s ease, transform 0.12s ease;
  white-space: nowrap;
}

.tms-wheel__item--active {
  color: var(--tms-ink);
  font-weight: 700;
  font-size: 1.05rem;
}

/* The selection band across the centre row. */

.tms-wheel__band {
  position: absolute;
  left: 0; right: 0;
  top: 80px; height: 40px;      /* centre row */
  border-top: 1.5px solid var(--tms-accent);
  border-bottom: 1.5px solid var(--tms-accent);
  background: rgba(15, 107, 94, 0.08);
  pointer-events: none;
  z-index: 1;
}

/* Two equal columns that stack on a phone — used by the financial statement's
   income/expense breakdown. */

.tms-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 720px) {
  .tms-two-col { grid-template-columns: 1fr; }
}

/* Student Pay Fees: the UPI QR block. */

.tms-pay { text-align: center; }

.tms-pay__qr {
  width: 220px;
  max-width: 70vw;
  margin: 4px auto 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--tms-border);
  border-radius: var(--tms-radius);
}

.tms-pay__qr svg { width: 100%; height: auto; display: block; }

.tms-pay__open { margin-top: 14px; display: inline-flex; align-items: center; justify-content: center; }

/* ================================================================== *
 *  App shell
 * ================================================================== */

.tms-shell { display: flex; min-height: 100vh; overflow-x: clip; }
.tms-main { flex: 1; min-width: 0; width: 100%; display: flex; flex-direction: column; }
.tms-content {
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  padding: 26px 30px 64px;
  overflow-wrap: break-word;
  word-break: normal;
}

.tms-sidebar {
  width: var(--tms-sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  z-index: 40;
  color: var(--tms-on-pine);
  background:
    radial-gradient(420px 260px at 0% 0%, rgba(56, 160, 143, 0.20), transparent 70%),
    linear-gradient(180deg, var(--tms-pine-900) 0%, var(--tms-pine-950) 100%);
  view-transition-name: tms-sidebar;
}

.tms-sidebar__brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 14px; }
.tms-logo { width: 38px; height: 38px; flex-shrink: 0; display: block; }
.tms-sidebar__brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.tms-sidebar__brand-name { font-family: var(--tms-font-display); font-size: 1.12rem; color: #fff; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tms-sidebar__brand-sub { font-size: 0.68rem; color: var(--tms-brass-light); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 3px; font-weight: 600; }

.tms-sidebar__nav { flex: 1; overflow-y: auto; padding: 4px 12px 16px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.14) transparent; }
.tms-sidebar__nav::-webkit-scrollbar { width: 6px; }
.tms-sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 6px; }

.tms-navgroup { margin-top: 4px; }
.tms-navgroup__label {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 9px 10px 6px;
  border-radius: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--tms-on-pine-muted);
  transition: color var(--tms-fast) ease;
}
.tms-navgroup__label::-webkit-details-marker { display: none; }
.tms-navgroup__label:hover { color: #fff; }
.tms-navgroup__chev { margin-left: auto; width: 13px; height: 13px; transition: transform var(--tms-med) var(--tms-ease); opacity: 0.7; }
.tms-navgroup[open] .tms-navgroup__chev { transform: rotate(90deg); }
/* A collapsed section still shows when something inside needs attention. */
.tms-navgroup__dot { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--tms-brass-light); }
.tms-navgroup:not([open]):has(.tms-navlink__badge) .tms-navgroup__dot { display: block; }
.tms-navgroup::details-content {
  block-size: 0;
  overflow: clip;
  transition: block-size var(--tms-med) var(--tms-ease), content-visibility var(--tms-med) allow-discrete;
}
.tms-navgroup[open]::details-content { block-size: auto; }
.tms-navgroup__items { display: flex; flex-direction: column; gap: 3px; padding-bottom: 4px; }

.tms-navlink {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--tms-radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(232, 241, 238, 0.76);
  transition: background var(--tms-fast) ease, color var(--tms-fast) ease, transform var(--tms-fast) var(--tms-ease);
}
.tms-navlink .tms-icon { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.72; transition: opacity var(--tms-fast) ease; }
.tms-navlink:hover { background: rgba(255, 255, 255, 0.07); color: #fff; transform: translateX(2px); }
.tms-navlink:hover .tms-icon { opacity: 1; }
.tms-navlink--active, .tms-navlink[aria-current="page"] {
  background: rgba(56, 160, 143, 0.20);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(120, 205, 190, 0.20);
}
.tms-navlink--active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--tms-brass-light);
}
.tms-navlink--active .tms-icon { opacity: 1; color: var(--tms-brass-light); }
.tms-navlink__badge {
  margin-left: auto;
  min-width: 20px;
  text-align: center;
  background: var(--tms-brass-light);
  color: var(--tms-pine-950);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  animation: tms-pop 0.4s var(--tms-ease) backwards;
}

.tms-sidebar__user {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.tms-sidebar__user-info { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; padding: 6px; border-radius: 10px; transition: background var(--tms-fast) ease; }
.tms-sidebar__user-info:hover { background: rgba(255, 255, 255, 0.07); }
.tms-sidebar__user-text { display: flex; flex-direction: column; min-width: 0; }
.tms-sidebar__user-name { font-size: 0.85rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tms-sidebar__user-role { font-size: 0.7rem; color: var(--tms-on-pine-muted); }
.tms-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex-shrink: 0; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; color: var(--tms-pine-950); background: linear-gradient(135deg, var(--tms-brass-light), var(--tms-brass)); }
.tms-sidebar__logout { color: var(--tms-on-pine-muted); padding: 8px; border-radius: 9px; display: flex; transition: background var(--tms-fast) ease, color var(--tms-fast) ease; }
.tms-sidebar__logout:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.tms-sidebar__logout-form { margin: 0; display: flex; }
button.tms-sidebar__logout { background: none; border: 0; cursor: pointer; font: inherit; }

/* Topbar */
.tms-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--tms-topbar-height);
  padding: 0 30px;
  background: rgba(244, 243, 238, 0.78);
  backdrop-filter: saturate(1.5) blur(14px);
  -webkit-backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 1px solid rgba(229, 227, 218, 0.8);
  view-transition-name: tms-topbar;
}
.tms-topbar__heading { display: flex; flex-direction: column; min-width: 0; }
.tms-topbar__crumb { font-size: 0.68rem; color: var(--tms-text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.tms-topbar__title { font-family: var(--tms-font-display); font-size: 1.3rem; line-height: 1.2; color: var(--tms-ink); letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tms-topbar__spacer { flex: 1; }
.tms-topbar__meta { display: flex; align-items: center; gap: 10px; }
.tms-topbar__clock { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 500; color: var(--tms-text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tms-topbar__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--tms-success); animation: tms-pulse 2.6s ease-out infinite; }
.tms-topbar__icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: var(--tms-ink);
  background: var(--tms-paper);
  border: 1px solid var(--tms-border);
  cursor: pointer;
  transition: border-color var(--tms-fast) ease, transform var(--tms-fast) var(--tms-ease), box-shadow var(--tms-fast) ease;
}
.tms-topbar__icon:hover { border-color: var(--tms-accent-light); transform: translateY(-1px); box-shadow: var(--tms-shadow); }
.tms-topbar__icon-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--tms-danger);
  color: #fff;
  font-size: 0.64rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--tms-bg);
  animation: tms-pop 0.4s var(--tms-ease) backwards;
}
.tms-searchtrigger {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 260px;
  height: 38px;
  padding: 0 8px 0 12px;
  border-radius: 11px;
  border: 1px solid var(--tms-border);
  background: var(--tms-paper);
  color: var(--tms-text-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color var(--tms-fast) ease, box-shadow var(--tms-fast) ease;
}
.tms-searchtrigger:hover { border-color: var(--tms-accent-light); box-shadow: var(--tms-shadow); }
.tms-searchtrigger .tms-icon { width: 16px; height: 16px; }
.tms-kbd { margin-left: auto; font-size: 0.68rem; font-weight: 600; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--tms-border); background: var(--tms-fill); color: var(--tms-text-muted); }

.tms-menu-toggle { display: none; align-items: center; justify-content: center; background: var(--tms-paper); color: var(--tms-ink); border: 1px solid var(--tms-border); border-radius: 11px; width: 38px; height: 38px; cursor: pointer; }
.tms-sidebar-backdrop { display: none; }
.tms-bottomnav { display: none; }

/* Slim bar across the top while the next page loads. */
.tms-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2.5px;
  width: 100%;
  z-index: 120;
  transform-origin: left;
  transform: scaleX(0);
  opacity: 0;
  background: linear-gradient(90deg, var(--tms-accent-light), var(--tms-brass-light));
  pointer-events: none;
}
.tms-progress--run { opacity: 1; animation: tms-progress 8s cubic-bezier(0.1, 0.8, 0.2, 1) forwards; }

@media (max-width: 880px) {
  .tms-menu-toggle { display: none; }
  .tms-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-104%);
    transition: transform var(--tms-med) var(--tms-ease);
    box-shadow: var(--tms-shadow-lift);
    view-transition-name: none;
  }
  .tms-sidebar--open { transform: translateX(0); }
  .tms-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(8, 28, 25, 0.5);
    backdrop-filter: blur(2px);
    z-index: 30;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--tms-med) ease;
  }
  .tms-sidebar-backdrop--visible { opacity: 1; pointer-events: auto; }
  .tms-topbar { padding: 0 16px; gap: 10px; height: 58px; }
  .tms-topbar__title { font-size: 1.1rem; }
  .tms-topbar__clock, .tms-searchtrigger { display: none; }
  .tms-content { padding: 16px 14px calc(var(--tms-bottomnav-height) + 34px + env(safe-area-inset-bottom)); }

  .tms-bottomnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(248, 243, 232, 0.95);
    backdrop-filter: saturate(1.5) blur(14px);
    -webkit-backdrop-filter: saturate(1.5) blur(14px);
    border-top: 1px solid var(--tms-border);
    view-transition-name: tms-bottomnav;
  }
  .tms-bottomnav__item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: var(--tms-bottomnav-height);
    border: none;
    background: none;
    font: inherit;
    font-size: 0.66rem;
    font-weight: 600;
    color: var(--tms-text-muted);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--tms-fast) ease;
  }
  .tms-bottomnav__item .tms-icon { width: 21px; height: 21px; transition: transform var(--tms-fast) var(--tms-ease); }
  .tms-bottomnav__item:active .tms-icon { transform: scale(0.86); }
  .tms-bottomnav__item--active { color: var(--tms-accent); }
  .tms-bottomnav__item .tms-topbar__icon-badge { top: 7px; right: calc(50% - 21px); border-color: #fff; }
}

/* Page search (Ctrl/Cmd+K) */
.tms-palette { position: fixed; inset: 0; z-index: 110; display: none; align-items: flex-start; justify-content: center; padding: 11vh 16px 16px; background: rgba(8, 28, 25, 0.45); backdrop-filter: blur(4px); }
.tms-palette--open { display: flex; animation: tms-fade 0.16s ease; }
.tms-palette__box { width: 100%; max-width: 560px; background: var(--tms-paper); border-radius: var(--tms-radius-lg); box-shadow: var(--tms-shadow-lift); overflow: hidden; animation: tms-rise 0.24s var(--tms-ease); }
.tms-palette__head { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--tms-border); color: var(--tms-text-muted); }
.tms-palette__input { flex: 1; height: 54px; border: none; outline: none; font: inherit; font-size: 1rem; background: none; color: var(--tms-text); min-width: 0; }
.tms-palette__list { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow-y: auto; }
.tms-palette__item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; color: var(--tms-text); font-size: 0.92rem; font-weight: 500; }
.tms-palette__item .tms-icon { width: 17px; height: 17px; color: var(--tms-text-muted); flex-shrink: 0; }
.tms-palette__group { margin-left: auto; font-size: 0.74rem; color: var(--tms-text-muted); font-weight: 400; }
.tms-palette__item--active { background: var(--tms-tint); color: var(--tms-accent-strong); }
.tms-palette__item--active .tms-icon { color: var(--tms-accent); }
.tms-palette__empty { padding: 26px; text-align: center; color: var(--tms-text-muted); font-size: 0.9rem; }

/* ================================================================== *
 *  Dashboard hero
 * ================================================================== */

.tms-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 26px 30px;
  margin-bottom: 18px;
  border-radius: var(--tms-radius-xl);
  color: var(--tms-on-pine);
  background:
    radial-gradient(520px 260px at 92% -20%, rgba(224, 192, 136, 0.24), transparent 70%),
    radial-gradient(460px 300px at 8% 130%, rgba(56, 160, 143, 0.34), transparent 70%),
    var(--tms-pine-grad);
  box-shadow: var(--tms-shadow);
}
.tms-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.1;
  background-image: var(--tms-lattice);
  background-size: 72px 72px;
  -webkit-mask-image: linear-gradient(100deg, transparent 25%, #000 90%);
          mask-image: linear-gradient(100deg, transparent 25%, #000 90%);
  animation: tms-drift 60s linear infinite;
  pointer-events: none;
}
.tms-hero > * { position: relative; }
.tms-hero__eyebrow { margin: 0 0 4px; font-size: 0.74rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--tms-brass-light); }
.tms-hero__title { margin: 0; font-family: var(--tms-font-display); font-weight: 500; font-size: 1.85rem; line-height: 1.25; color: #fff; letter-spacing: 0; }
.tms-hero__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tms-hero__action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: background var(--tms-fast) ease, transform var(--tms-fast) var(--tms-ease);
}
.tms-hero__action .tms-icon { width: 15px; height: 15px; }
.tms-hero__action:hover { background: rgba(255, 255, 255, 0.17); transform: translateY(-1px); }
@media (max-width: 720px) {
  .tms-hero { padding: 20px; border-radius: var(--tms-radius-lg); }
  .tms-hero__title { font-size: 1.45rem; }
}

/* Main column + side column on wide screens. */
.tms-dash { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
.tms-dash > .tms-card { margin-bottom: 0; }
@media (min-width: 1180px) { .tms-dash { grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr); } }

.tms-dash .tms-statcards { grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); gap: 12px; }
/* The short-staffed table lives in the narrow side column here: stack each row
   so its Assign button is never pushed out of view. */
@media (min-width: 1180px) {
  .tms-dash .tms-staffing__table, .tms-dash .tms-staffing__table tbody, .tms-dash .tms-staffing__table tr, .tms-dash .tms-staffing__table td { display: block; width: auto; }
  .tms-dash .tms-staffing__table thead { display: none; }
  .tms-dash .tms-staffing__table tr { background: var(--tms-paper); border: 1px solid rgba(178, 63, 45, 0.14); border-radius: 10px; padding: 4px 12px 8px; margin-bottom: 8px; }
  .tms-dash .tms-staffing__table td { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border: none; background: transparent !important; }
  .tms-dash .tms-staffing__table td[data-label]::before { content: attr(data-label); font-size: 0.72rem; color: var(--tms-text-muted); font-weight: 600; }
}
/* ================================================================== *
 *  Cards & type
 * ================================================================== */

.tms-card {
  position: relative;
  background: var(--tms-surface);
  border: 1px solid var(--tms-border);
  border-radius: var(--tms-radius-lg);
  box-shadow: var(--tms-shadow-sm);
  padding: 26px 28px;
  margin-bottom: 20px;
  overflow-wrap: break-word;
  word-break: normal;
  min-width: 0;
}
.tms-card h2 { margin: 0 0 14px; color: var(--tms-ink); font-size: 1.06rem; font-weight: 650; }
.tms-card h2:only-child { margin-bottom: 0; }
.tms-card h3 { color: var(--tms-ink); font-weight: 650; }
.tms-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tms-card__head h2 { margin-bottom: 0; }
.tms-card__action { font-size: 0.82rem; font-weight: 600; color: var(--tms-accent); white-space: nowrap; }
.tms-card__action:hover { color: var(--tms-accent-strong); }
.tms-muted { color: var(--tms-text-muted); }
.tms-section-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--tms-text-muted); margin: 6px 0 0; }

.tms-note { padding: 12px 14px; border: 1px solid var(--tms-accent-soft); border-radius: var(--tms-radius); background: var(--tms-tint); font-size: 0.9rem; color: var(--tms-ink); }

/* ================================================================== *
 *  Buttons
 * ================================================================== */

.tms-btn-link, .tms-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--tms-accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.87rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--tms-fast) ease, box-shadow var(--tms-fast) ease, transform var(--tms-fast) var(--tms-ease), border-color var(--tms-fast) ease, color var(--tms-fast) ease;
}
.tms-btn-link:hover, .tms-btn:hover { background: var(--tms-accent-strong); box-shadow: var(--tms-glow); transform: translateY(-1px); }
.tms-btn-link:active, .tms-btn:active { transform: translateY(0) scale(0.98); box-shadow: none; }
.tms-btn { width: 100%; padding: 12px 18px; font-size: 0.92rem; }
.tms-btn--auth { border-radius: 12px; padding: 14px 18px; margin-top: 8px; }
.tms-btn--auth .tms-icon { width: 16px; height: 16px; transition: transform var(--tms-fast) var(--tms-ease); }
.tms-btn--auth:hover .tms-icon { transform: translateX(3px); }

.tms-btn-link--muted { background: var(--tms-paper); color: var(--tms-ink); border-color: var(--tms-border); }
.tms-btn-link--muted:hover { background: var(--tms-fill); border-color: var(--tms-fill-strong); box-shadow: none; }
.tms-btn-link--danger { background: var(--tms-danger-soft); color: var(--tms-danger); border-color: rgba(178, 63, 45, 0.18); }
.tms-btn-link--danger:hover { background: var(--tms-danger); color: #fff; box-shadow: 0 8px 20px rgba(178, 63, 45, 0.24); }
.tms-btn-link--sm { padding: 7px 12px; font-size: 0.79rem; border-radius: 8px; }
.tms-btn-link--lg { font-size: 1.02rem; padding: 15px 30px; border-radius: var(--tms-radius); width: 100%; max-width: 320px; }
.tms-btn-link[disabled], .tms-btn-link:disabled { background: var(--tms-fill); border-color: var(--tms-border); color: var(--tms-text-muted); box-shadow: none; cursor: not-allowed; transform: none; }

/* ================================================================== *
 *  Forms
 * ================================================================== */

.tms-field { margin-bottom: 20px; }
.tms-field label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--tms-ink); margin-bottom: 6px; }
.tms-field-errors { color: var(--tms-danger); font-size: 0.8rem; margin-top: 5px; font-weight: 500; }
.tms-input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--tms-fill-strong);
  border-radius: 10px;
  font-size: 0.94rem;
  font-family: inherit;
  line-height: 1.35;
  background-color: var(--tms-field-bg);
  color: var(--tms-text);
  transition: border-color var(--tms-fast) ease, box-shadow var(--tms-fast) ease;
}
.tms-input:hover { border-color: #cfccc0; }
.tms-input:focus { outline: none; border-color: var(--tms-accent); box-shadow: 0 0 0 3px rgba(15, 107, 94, 0.15); }
.tms-input::placeholder { color: #98a19d; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--tms-accent); width: 16px; height: 16px; }
.tms-inputgroup { position: relative; display: flex; align-items: center; }
.tms-inputgroup .tms-icon { position: absolute; left: 13px; width: 16px; height: 16px; color: var(--tms-text-muted); pointer-events: none; transition: color var(--tms-fast) ease; }
.tms-inputgroup .tms-input { padding-left: 39px; }
.tms-inputgroup:focus-within .tms-icon { color: var(--tms-accent); }
.tms-auth-help { margin: 7px 0 0; font-size: 0.78rem; color: var(--tms-text-muted); text-align: right; }

.tms-error { background: var(--tms-danger-soft); border: 1px solid rgba(178, 63, 45, 0.24); color: var(--tms-danger); padding: 10px 14px; border-radius: 10px; font-size: 0.88rem; margin-bottom: 18px; }

/* Messages stay on screen: some carry a one-time PIN that must not vanish. */
.tms-messages { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.tms-message {
  position: relative;
  padding: 12px 15px 12px 40px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid var(--tms-border);
  background: var(--tms-paper);
  animation: tms-rise 0.4s var(--tms-ease) backwards;
}
.tms-message::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 16px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 16%, transparent);
}
.tms-message--success { background: var(--tms-success-soft); border-color: rgba(27, 122, 82, 0.2); color: #13583b; }
.tms-message--error { background: var(--tms-danger-soft); border-color: rgba(178, 63, 45, 0.22); color: var(--tms-danger); }
.tms-message--warning { background: var(--tms-warn-soft); border-color: rgba(143, 93, 14, 0.2); color: var(--tms-warn); }
.tms-message--info { background: var(--tms-tint); border-color: var(--tms-accent-soft); color: var(--tms-accent-strong); }

/* ================================================================== *
 *  Tables, badges, chips
 * ================================================================== */

.tms-table { font-size: 0.885rem; border-collapse: separate; border-spacing: 0; }
.tms-table th, .tms-table td { padding: 14px 16px; border-bottom: 1px solid var(--tms-border); }
.tms-table th {
  color: var(--tms-text-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--tms-surface-raised);
  border-top: 1px solid var(--tms-border);
  border-bottom: 1px solid var(--tms-border);
}
.tms-table th:first-child { border-left: 1px solid var(--tms-border); border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
.tms-table th:last-child { border-right: 1px solid var(--tms-border); border-top-right-radius: 10px; border-bottom-right-radius: 10px; }
.tms-table tfoot th { border-radius: 0; border-left: none; border-right: none; background: transparent; font-size: 0.85rem; color: var(--tms-ink); text-transform: none; letter-spacing: 0; border-bottom: none; }
.tms-table tr:hover td { background: var(--tms-tint); }
.tms-table tbody tr:hover td:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.tms-table tbody tr:hover td:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
.tms-table tr.tms-table__group th { background: var(--tms-tint); color: var(--tms-ink); }

.tms-badge {
  max-width: 100%;
  white-space: nowrap;
  overflow-wrap: normal;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.tms-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.tms-badge--active { background: var(--tms-success-soft); color: var(--tms-success); }
.tms-badge--inactive { background: var(--tms-fill); color: var(--tms-text-muted); }
.tms-badge--assigned { background: var(--tms-danger-soft); color: var(--tms-danger); }
.tms-badge--warn { background: var(--tms-warn-soft); color: var(--tms-warn); }

.tms-chip { display: inline-block; max-width: 100%; overflow-wrap: anywhere; padding: 2px 9px; border-radius: 999px; font-size: 0.73rem; font-weight: 600; color: var(--tms-accent-strong); background: var(--tms-tint); border: 1px solid var(--tms-accent-soft); white-space: nowrap; }
.tms-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.tms-chips__none { color: var(--tms-text-muted); font-size: 0.8rem; }

.tms-detail-row { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--tms-border); font-size: 0.91rem; overflow-wrap: break-word; word-break: normal; }
.tms-detail-row:last-of-type { border-bottom: none; }
.tms-detail-row > span:first-child { color: var(--tms-text-muted); flex: 0 0 auto; }
.tms-detail-row > span:last-child { font-weight: 600; color: var(--tms-text); min-width: 0; text-align: right; overflow-wrap: break-word; }

/* Sliding-pill section tabs. */
.tms-subtabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; padding: 4px; width: fit-content; max-width: 100%; background: var(--tms-fill); border-radius: 12px; }
.tms-subtab { padding: 7px 13px; border-radius: 9px; font-size: 0.84rem; font-weight: 600; color: var(--tms-text-muted); text-decoration: none; transition: background var(--tms-fast) ease, color var(--tms-fast) ease, box-shadow var(--tms-fast) ease; }
.tms-subtab:hover { color: var(--tms-ink); }
.tms-subtab--active { color: var(--tms-accent-strong); background: var(--tms-paper); box-shadow: var(--tms-shadow-sm), 0 0 0 1px rgba(13, 42, 38, 0.04); }

/* ================================================================== *
 *  Stat cards
 * ================================================================== */

.tms-statcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 12px 0 24px; }
@media (max-width: 560px) {
  .tms-statcards, .tms-dash .tms-statcards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tms-statcard { padding: 12px 13px; }
  .tms-statcard__value { font-size: 1.45rem; }
}
.tms-statcard {
  --tms-stat: var(--tms-accent-light);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 18px 18px 16px;
  background: var(--tms-surface-raised);
  border: 1px solid var(--tms-border);
  border-radius: var(--tms-radius);
  overflow: hidden;
  transition: transform var(--tms-fast) var(--tms-ease), box-shadow var(--tms-fast) ease, border-color var(--tms-fast) ease;
}
.tms-statcard:hover { transform: translateY(-2px); box-shadow: var(--tms-shadow-lift); border-color: color-mix(in srgb, var(--tms-stat) 45%, var(--tms-border)); }
.tms-statcard--good { --tms-stat: var(--tms-success); }
.tms-statcard--warn { --tms-stat: var(--tms-brass); }
.tms-statcard--bad { --tms-stat: var(--tms-danger); }
.tms-statcard__label { display: flex; align-items: center; gap: 7px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.01em; color: var(--tms-text-muted); }
.tms-statcard__label::before { content: ""; flex-shrink: 0; width: 7px; height: 7px; border-radius: 2.5px; background: var(--tms-stat); transform: rotate(45deg); }
.tms-statcard__value { font-size: 1.75rem; font-weight: 650; line-height: 1.15; color: var(--tms-ink); font-variant-numeric: tabular-nums; }
.tms-statcard__value small { font-size: 0.55em; font-weight: 500; color: var(--tms-text-muted); }
.tms-statcard__meta { font-size: 0.75rem; color: var(--tms-text-muted); }
.tms-meter { display: block; height: 4px; margin-top: 8px; background: var(--tms-fill-strong); border-radius: 4px; overflow: hidden; }
.tms-meter > span { display: block; height: 100%; border-radius: 4px; background: var(--tms-stat); transform-origin: left; animation: tms-grow-x 0.9s var(--tms-ease) 0.2s backwards; }

.tms-stat { background: var(--tms-surface-raised); border: 1px solid var(--tms-border); border-radius: var(--tms-radius); padding: 15px 17px; }
.tms-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tms-stat__value { font-size: 1.55rem; font-weight: 650; color: var(--tms-ink); }
.tms-stat__label { font-size: 0.74rem; color: var(--tms-text-muted); }

/* ================================================================== *
 *  Alerts, tasks, clock
 * ================================================================== */

.tms-alert { border: 1px solid var(--tms-border); border-radius: var(--tms-radius); background: var(--tms-surface-raised); padding: 14px 16px; margin-bottom: 12px; transition: box-shadow var(--tms-fast) ease; }
.tms-alert:hover { box-shadow: var(--tms-shadow); }
.tms-alert:last-child { margin-bottom: 0; }
.tms-alert--warn { background: var(--tms-warn-soft); border-color: rgba(143, 93, 14, 0.16); }
.tms-alert--bad { background: var(--tms-danger-soft); border-color: rgba(178, 63, 45, 0.16); }
.tms-alert__title { font-weight: 650; color: var(--tms-ink); font-size: 0.92rem; }
.tms-alert__body { margin: 3px 0 8px; font-size: 0.83rem; color: var(--tms-text-muted); }
.tms-alert__list { margin: 0 0 10px; padding-left: 18px; font-size: 0.85rem; }
.tms-alert__list li { margin-bottom: 3px; }

.tms-tasklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.tms-task { border: 1px solid var(--tms-border); border-radius: var(--tms-radius); background: var(--tms-surface-raised); padding: 18px 20px; transition: transform var(--tms-fast) var(--tms-ease), box-shadow var(--tms-fast) ease, border-color var(--tms-fast) ease; }
.tms-task:hover { transform: translateY(-2px); box-shadow: var(--tms-shadow-lift); border-color: var(--tms-accent-soft); }
.tms-task__name { font-weight: 650; color: var(--tms-ink); }
.tms-task__meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.tms-task__action { display: inline-flex; align-items: center; justify-content: center; margin: 10px 6px 0 0; }
@media (max-width: 480px) { .tms-tasklist { grid-template-columns: minmax(0, 1fr); } }

.tms-clock { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; margin: 4px 0 14px; border-radius: var(--tms-radius); color: var(--tms-on-pine); background: var(--tms-pine-grad); }
.tms-clock__label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; color: var(--tms-brass-light); }
.tms-clock__timer { font-size: 2.2rem; font-weight: 600; line-height: 1.1; color: #fff; font-variant-numeric: tabular-nums; }
.tms-clock__meta { font-size: 0.76rem; color: var(--tms-on-pine-muted); }
.tms-clock__btn { width: 50%; min-width: 150px; max-width: 230px; display: inline-flex; align-items: center; justify-content: center; text-align: center; }

.tms-daynav .tms-dp { width: 170px; flex: 0 0 auto; }
.tms-pager__link { border-width: 1px; border-radius: 9px; background: var(--tms-paper); color: var(--tms-accent); }
.tms-cal__day { border-color: var(--tms-border); border-radius: 11px; }
.tms-cal__day--today { background: var(--tms-tint); border-color: var(--tms-accent-light); }
.tms-cal__day--today .tms-cal__daynum { color: var(--tms-accent); }
.tms-cal__day--selected { background: var(--tms-accent-soft); }
.tms-cal__chip--primary { background: var(--tms-pine-800); border-color: var(--tms-pine-800); color: #fff; }
.tms-cal__chip--substitute { background: var(--tms-brass); border-color: var(--tms-brass); color: #fff; }
.tms-wheel__viewport, .tms-combo__control, .tms-dp__control, .tms-combo__search { border-width: 1px; border-color: var(--tms-fill-strong); border-radius: 10px; }
.tms-wheel__band { border-width: 1px; border-color: var(--tms-accent-light); background: rgba(15, 107, 94, 0.07); }
.tms-combo__panel, .tms-dp__pop { border: 1px solid var(--tms-border); animation: tms-rise 0.18s var(--tms-ease); }
.tms-combo__control { padding: 10px 13px; font-size: 0.94rem; }
.tms-dp__control { padding: 10px 13px; font-size: 0.94rem; }
.tms-dp__navbtn { border-width: 1px; }
.tms-statpop__body, .tms-hovercard__pop, .tms-filter__panel { box-shadow: var(--tms-shadow-lift); border-radius: var(--tms-radius); animation: tms-rise 0.18s var(--tms-ease); }
.tms-statpop > summary:hover .tms-statcard { transform: translateY(-2px); }
.tms-trend-bar { background: var(--tms-accent-light); }
.tms-trend-col--current .tms-trend-bar { background: var(--tms-brass); }
.tms-bar-fill { background: linear-gradient(90deg, var(--tms-accent), var(--tms-accent-light)); }
.tms-staffing { border-color: rgba(178, 63, 45, 0.16); border-left-width: 1px; }

/* Charts grow in. */
.tms-trend-bar, .tms-attn-seg { transform-origin: bottom; animation: tms-grow-y 0.7s var(--tms-ease) backwards; }
.tms-bar-fill { transform-origin: left; animation: tms-grow-x 0.8s var(--tms-ease) backwards; }

/* ================================================================== *
 *  Sign-in and public pages
 * ================================================================== */

.tms-login__grid { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1.15fr 1fr; }
.tms-login__hero {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px 54px;
  color: var(--tms-on-pine);
  background: var(--tms-pine-950);
  isolation: isolate;
}
.tms-login__hero::before, .tms-login__hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  z-index: -1;
  animation: tms-float 16s ease-in-out infinite alternate;
}
.tms-login__hero::before { width: 560px; height: 560px; left: -140px; bottom: -180px; background: rgba(32, 138, 120, 0.55); }
.tms-login__hero::after { width: 460px; height: 460px; right: -120px; top: -140px; background: rgba(185, 138, 62, 0.34); animation-duration: 21s; animation-direction: alternate-reverse; }
.tms-login__hero-pattern {
  position: absolute;
  inset: -80px;
  z-index: -1;
  opacity: 0.13;
  background-image: var(--tms-lattice);
  background-size: 92px 92px;
  animation: tms-drift 70s linear infinite;
  -webkit-mask-image: radial-gradient(circle at 60% 40%, #000 15%, transparent 72%);
          mask-image: radial-gradient(circle at 60% 40%, #000 15%, transparent 72%);
}
.tms-login__hero-top { display: flex; align-items: center; gap: 12px; }
.tms-login__brand { font-family: var(--tms-font-display); font-weight: 500; font-size: 1.2rem; color: #fff; }
.tms-login__eyebrow { margin: 0 0 18px; font-size: 0.74rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--tms-brass-light); animation: tms-rise 0.7s var(--tms-ease) 0.05s backwards; }
.tms-login__headline { font-family: var(--tms-font-display); font-weight: 400; font-size: clamp(2.4rem, 4vw, 3.7rem); line-height: 1.16; margin: 0 0 30px; color: #fff; animation: tms-rise 0.8s var(--tms-ease) 0.14s backwards; }
.tms-login__shine {
  font-style: italic;
  background: linear-gradient(100deg, var(--tms-brass-light) 0%, #fff3da 45%, var(--tms-brass-light) 90%);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--tms-brass-light);
  animation: tms-shine 5s linear infinite;
  padding-right: 0.06em;
}
.tms-login__headline-line2 { color: rgba(232, 241, 238, 0.86); }
.tms-login__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0 0 26px; animation: tms-rise 0.8s var(--tms-ease) 0.24s backwards; }
.tms-login__stats--two { grid-template-columns: repeat(2, 1fr); max-width: 330px; }
.tms-login__stat { padding: 15px 16px; border-radius: var(--tms-radius); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.11); backdrop-filter: blur(8px); }
.tms-login__stat-num { display: block; font-size: 2.05rem; font-weight: 600; line-height: 1; color: #fff; }
.tms-login__stat-label { display: block; font-size: 0.76rem; margin-top: 7px; color: var(--tms-on-pine-muted); }
.tms-login__join {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 12px 22px;
  border-radius: 12px;
  background: #fff;
  color: var(--tms-pine-900);
  font-weight: 650;
  font-size: 0.92rem;
  transition: transform var(--tms-fast) var(--tms-ease), box-shadow var(--tms-fast) ease;
  animation: tms-rise 0.8s var(--tms-ease) 0.32s backwards;
}
.tms-login__join:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3); }
.tms-login__hero-foot { font-size: 0.82rem; color: var(--tms-on-pine-muted); }

.tms-login__panel { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 28px; background: var(--tms-bg); }
.tms-login__card { width: 100%; max-width: 408px; animation: tms-rise 0.7s var(--tms-ease) 0.1s backwards; }
.tms-login__crest { display: none; }
.tms-login__rule { display: none; }
.tms-login__title { font-family: var(--tms-font-display); font-weight: 500; font-size: 1.9rem; line-height: 1.2; color: var(--tms-ink); margin: 0 0 6px; }
.tms-login__caption { margin: 0 0 24px; color: var(--tms-text-muted); font-size: 0.94rem; }
.tms-login__foot { margin: 28px 0 0; font-size: 0.76rem; color: var(--tms-text-muted); }

.tms-authtabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 4px; margin-bottom: 24px; background: var(--tms-fill-strong); border-radius: 13px; }
.tms-authtab { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 6px; border-radius: 10px; font-size: 0.85rem; font-weight: 600; color: var(--tms-text-muted); transition: background var(--tms-fast) ease, color var(--tms-fast) ease; }
.tms-authtab .tms-icon { width: 15px; height: 15px; }
.tms-authtab:hover { color: var(--tms-ink); }
.tms-authtab--active { background: var(--tms-paper); color: var(--tms-accent-strong); box-shadow: var(--tms-shadow); }
.tms-login__card .tms-input { padding-top: 12px; padding-bottom: 12px; }

@media (max-width: 860px) {
  .tms-login__grid { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .tms-login__hero { padding: 22px 22px 26px; gap: 22px; justify-content: flex-start; }
  .tms-login__headline { font-size: 1.85rem; margin-bottom: 18px; }
  .tms-login__eyebrow { margin-bottom: 10px; font-size: 0.68rem; }
  .tms-login__stats { margin-bottom: 18px; }
  .tms-login__hero-foot { display: none; }
  .tms-login__panel { padding: 26px 20px 36px; justify-content: flex-start; }
  .tms-login__title { font-size: 1.6rem; }
}

.tms-public { max-width: 640px; margin: 0 auto; padding: 36px 20px 60px; animation: tms-rise 0.5s var(--tms-ease) backwards; }
.tms-public__head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.tms-public__mark { width: 40px; height: 40px; border-radius: 12px; background: var(--tms-pine-grad); color: var(--tms-brass-light); display: flex; align-items: center; justify-content: center; font-family: var(--tms-font-display); font-size: 1.4rem; }
.tms-public__brand { font-family: var(--tms-font-display); font-weight: 500; font-size: 1.15rem; color: var(--tms-ink); }
.tms-public__signin { margin-left: auto; font-size: 0.86rem; color: var(--tms-accent); font-weight: 600; }

/* ================================================================== *
 *  Motion
 * ================================================================== */

:root {
  --tms-lattice: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 80' fill='none' stroke='%23e0c088' stroke-width='1'%3E%3Crect x='20' y='20' width='40' height='40'/%3E%3Cpath d='M40 11.7 68.3 40 40 68.3 11.7 40Z'/%3E%3Cpath d='M0 0l20 20M80 0 60 20M0 80l20-20M80 80 60 60M40 0v11.7M40 80V68.3M0 40h11.7M80 40H68.3'/%3E%3C/svg%3E");
}

@keyframes tms-rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes tms-fade { from { opacity: 0; } }
@keyframes tms-pop { from { opacity: 0; transform: scale(0.5); } }
@keyframes tms-grow-x { from { transform: scaleX(0); } }
@keyframes tms-grow-y { from { transform: scaleY(0); } }
@keyframes tms-shine { to { background-position: -220% center; } }
@keyframes tms-pulse { 0% { box-shadow: 0 0 0 0 rgba(27, 122, 82, 0.45); } 70%, 100% { box-shadow: 0 0 0 8px rgba(27, 122, 82, 0); } }
@keyframes tms-drift { to { background-position: 184px 184px; } }
@keyframes tms-float { to { transform: translate(60px, -46px) scale(1.14); } }
@keyframes tms-progress { 0% { transform: scaleX(0); } 100% { transform: scaleX(0.92); } }

/* Page content settles in, top to bottom. `backwards` only: a fill that lasted
   past the end would leave each card a stacking context and trap its dropdowns
   beneath the next card. */
.tms-content > * { animation: tms-rise 0.46s var(--tms-ease) backwards; }
.tms-content > *:nth-child(2) { animation-delay: 0.05s; }
.tms-content > *:nth-child(3) { animation-delay: 0.1s; }
.tms-content > *:nth-child(4) { animation-delay: 0.15s; }
.tms-content > *:nth-child(n+5) { animation-delay: 0.2s; }
.tms-statcards > * { animation: tms-rise 0.46s var(--tms-ease) backwards; }
.tms-statcards > *:nth-child(2) { animation-delay: 0.05s; }
.tms-statcards > *:nth-child(3) { animation-delay: 0.1s; }
.tms-statcards > *:nth-child(n+4) { animation-delay: 0.15s; }

::view-transition-old(root) { animation: 0.14s ease both tms-vt-out; }
::view-transition-new(root) { animation: 0.2s ease both tms-vt-in; }
@keyframes tms-vt-out { to { opacity: 0; } }
@keyframes tms-vt-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

/* ================================================================== *
 *  Print
 * ================================================================== */

.tms-print-only { display: none; }
@media print {
  *, *::before, *::after { animation: none !important; }
  .tms-sidebar, .tms-topbar, .tms-sidebar-backdrop, .tms-bottomnav, .tms-palette, .tms-progress, .tms-hero, .tms-noprint { display: none !important; }
  .tms-print-only { display: block !important; }
  .tms-main, .tms-content { margin: 0 !important; padding: 0 !important; max-width: none; }
  .tms-card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  body { background: #fff; }
}

.tms-topbar__title, .tms-sidebar__brand-name, .tms-login__headline, .tms-hero__title, .tms-login__title, .tms-login__brand, .tms-public__brand { font-weight: 700; }

/* ================================================================== *
 *  Page system: the dashboard's look carried to every page.
 *  Works from the markup every template already shares, so a new page
 *  picks it up without extra classes.
 * ================================================================== */

.tms-card { --tms-pad-x: 28px; padding-left: var(--tms-pad-x); padding-right: var(--tms-pad-x); }
@media (max-width: 560px) { .tms-card { --tms-pad-x: 18px; padding-top: 20px; padding-bottom: 20px; } }

/* Section headings carry the brand's diamond. */
.tms-card > h2::before, .tms-card__head > h2::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 10px;
  border-radius: 2.5px;
  vertical-align: 0.08em;
  background: linear-gradient(135deg, var(--tms-brass-light), var(--tms-brass));
  transform: rotate(45deg);
}

/* The first card on a page opens with a banner, like the dashboard hero. */
:is(.tms-content > .tms-card:first-child, .tms-content > .tms-messages + .tms-card, .tms-content > .tms-subtabs + .tms-card, .tms-lead):has(> h2:first-child, > .tms-card__head:first-child) { padding-top: 0; }
:is(.tms-content > .tms-card:first-child, .tms-content > .tms-messages + .tms-card, .tms-content > .tms-subtabs + .tms-card, .tms-lead) > :is(h2:first-child, .tms-card__head:first-child) {
  position: relative;
  margin: -1px calc(var(--tms-pad-x) * -1 - 1px) 22px;
  padding: 22px var(--tms-pad-x);
  border-radius: var(--tms-radius-lg) var(--tms-radius-lg) 0 0;
  color: #fff;
  background:
    radial-gradient(420px 200px at 94% -30%, rgba(224, 192, 136, 0.26), transparent 70%),
    radial-gradient(420px 240px at 4% 140%, rgba(56, 160, 143, 0.36), transparent 70%),
    var(--tms-pine-grad);
}
:is(.tms-content > .tms-card:first-child, .tms-content > .tms-messages + .tms-card, .tms-content > .tms-subtabs + .tms-card, .tms-lead) > :is(h2:first-child, .tms-card__head:first-child)::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0.16;
  background-image: var(--tms-lattice);
  background-size: 64px 64px;
  -webkit-mask-image: linear-gradient(100deg, transparent 30%, #000 95%);
          mask-image: linear-gradient(100deg, transparent 30%, #000 95%);
  pointer-events: none;
}
:is(.tms-content > .tms-card:first-child, .tms-content > .tms-messages + .tms-card, .tms-content > .tms-subtabs + .tms-card, .tms-lead) > h2:first-child,
:is(.tms-content > .tms-card:first-child, .tms-content > .tms-messages + .tms-card, .tms-content > .tms-subtabs + .tms-card, .tms-lead) > .tms-card__head:first-child h2 { color: #fff; font-size: 1.25rem; font-weight: 700; margin-bottom: 0; }
:is(.tms-content > .tms-card:first-child, .tms-content > .tms-messages + .tms-card, .tms-content > .tms-subtabs + .tms-card, .tms-lead) > :is(h2:first-child, .tms-card__head:first-child) .tms-muted { color: var(--tms-on-pine-muted); }
.tms-card__head:first-child > * { position: relative; z-index: 1; }
.tms-content > .tms-card:first-child > .tms-card__head:first-child .tms-btn-link,
.tms-content > .tms-messages + .tms-card > .tms-card__head:first-child .tms-btn-link {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}
.tms-content > .tms-card:first-child > .tms-card__head:first-child .tms-btn-link:hover,
.tms-content > .tms-messages + .tms-card > .tms-card__head:first-child .tms-btn-link:hover { background: rgba(255, 255, 255, 0.2); box-shadow: none; }

/* Tables become rows of floating cards. */
.tms-card:has(> .tms-tablewrap) { background: var(--tms-surface-raised); }
.tms-tablewrap { padding-bottom: 2px; }
@media (min-width: 721px) {
  .tms-table:not(.tms-staffing__table) { border-spacing: 0 8px; }
  .tms-table th, .tms-table th:first-child, .tms-table th:last-child { background: transparent; border: none; border-radius: 0; padding: 6px 16px 0; }
  .tms-table:not(.tms-staffing__table) tbody td { background: var(--tms-paper); border-top: 1px solid var(--tms-border); border-bottom: 1px solid var(--tms-border); }
  .tms-table:not(.tms-staffing__table) tbody td:first-child { border-left: 1px solid var(--tms-border); border-radius: 12px 0 0 12px; }
  .tms-table:not(.tms-staffing__table) tbody td:last-child { border-right: 1px solid var(--tms-border); border-radius: 0 12px 12px 0; }
  .tms-table tbody tr { transition: transform var(--tms-fast) var(--tms-ease), filter var(--tms-fast) ease; }
  .tms-table tbody tr:hover { transform: translateY(-2px); filter: drop-shadow(0 8px 14px rgba(13, 42, 38, 0.1)); }
  .tms-table tbody tr:hover td { background: var(--tms-paper); border-color: var(--tms-accent-soft); }
}
.tms-table tbody tr { animation: tms-rise 0.4s var(--tms-ease) backwards; }
.tms-table tbody tr:nth-child(2) { animation-delay: 0.04s; }
.tms-table tbody tr:nth-child(3) { animation-delay: 0.08s; }
.tms-table tbody tr:nth-child(4) { animation-delay: 0.12s; }
.tms-table tbody tr:nth-child(5) { animation-delay: 0.16s; }
.tms-table tbody tr:nth-child(n+6) { animation-delay: 0.2s; }
/* A list of solid buttons is loud; in rows they are soft until needed. */
.tms-table .tms-btn-link:not(.tms-btn-link--muted):not(.tms-btn-link--danger) { background: var(--tms-accent-soft); color: var(--tms-accent-strong); }
.tms-table .tms-btn-link:not(.tms-btn-link--muted):not(.tms-btn-link--danger):hover { background: var(--tms-accent); color: #fff; }
@media (max-width: 720px) {
  .tms-table:not(.tms-staffing__table) tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 14px; border-radius: 14px; box-shadow: var(--tms-shadow-sm); padding: 12px 14px; }
  .tms-table:not(.tms-staffing__table) td { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 1px; padding: 6px 0; border: none; text-align: left; min-width: 0; }
  .tms-table:not(.tms-staffing__table) td:first-child,
  .tms-table:not(.tms-staffing__table) td:has(form, .tms-btn-link, input, select, textarea, button) { grid-column: 1 / -1; }
  .tms-table:not(.tms-staffing__table) td:has(form, .tms-btn-link, input, select, textarea, button) > * { max-width: 100%; }
}

/* Person cells: initials beside the name. */
.tms-person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.tms-person__avatar { flex-shrink: 0; width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; font-weight: 700; font-size: 0.8rem; }
.tms-person__name { min-width: 0; }
.tms-person__avatar::before { content: attr(data-i); }
.tms-person__avatar[data-c="0"] { background: #dcefe9; color: #0f6b5e; }
.tms-person__avatar[data-c="1"] { background: #f4e8d3; color: #8a6424; }
.tms-person__avatar[data-c="2"] { background: #e2e9f3; color: #3a5a86; }
.tms-person__avatar[data-c="3"] { background: #f3e2e0; color: #9a4438; }
.tms-person__avatar[data-c="4"] { background: #e8e4f2; color: #5c4c8c; }

/* Detail pages: label-and-value tiles instead of rows. */
.tms-card:has(> .tms-detail-row) { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; align-items: stretch; }
.tms-card:has(> .tms-detail-row) > :not(.tms-detail-row) { grid-column: 1 / -1; margin-bottom: 0; }
.tms-card:has(> .tms-detail-row) > .tms-detail-row {
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 3px;
  padding: 13px 15px;
  border: 1px solid var(--tms-border);
  border-radius: var(--tms-radius);
  background: var(--tms-surface-raised);
  transition: border-color var(--tms-fast) ease, transform var(--tms-fast) var(--tms-ease);
}
.tms-card:has(> .tms-detail-row) > .tms-detail-row:hover { border-color: var(--tms-accent-soft); transform: translateY(-1px); }
.tms-card:has(> .tms-detail-row) > .tms-detail-row > span:first-child { font-size: 0.78rem; font-weight: 500; }
.tms-card:has(> .tms-detail-row) > .tms-detail-row > span:last-child { text-align: left; justify-content: flex-start !important; }

/* Forms sit in two columns where there is room. */
.tms-card > form[method="post"]:not([style]):has(> .tms-field) { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 0 22px; align-items: start; }
.tms-card > form[method="post"]:not([style]):has(> .tms-field) > :not(.tms-field) { grid-column: 1 / -1; justify-self: start; }
.tms-card > form[method="post"]:not([style]):has(> .tms-field) > .tms-field:has(textarea, label > input[type="checkbox"], label > input[type="radio"]) { grid-column: 1 / -1; }

/* Choice lists from Django render as pill tiles. */
.tms-field > div:has(> div > label > input[type="checkbox"]),
.tms-field > div:has(> label > input[type="checkbox"]) { display: flex; flex-wrap: wrap; gap: 8px; }
.tms-field label:has(> input[type="checkbox"]), .tms-field label:has(> input[type="radio"]) {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  margin: 0;
  border: 1px solid var(--tms-border);
  border-radius: 10px;
  background: var(--tms-paper);
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--tms-fast) ease, background var(--tms-fast) ease;
}
.tms-field label:has(> input:checked) { border-color: var(--tms-accent); background: var(--tms-tint); color: var(--tms-accent-strong); }

/* ---- Sign-in: one composition across the whole page ---- */
.tms-login { background: var(--tms-pine-950); }
.tms-login__grid {
  position: relative;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 470px);
  align-items: center;
  gap: 40px;
  padding: 0 clamp(24px, 6vw, 96px);
  overflow: clip;
  background: var(--tms-pine-950);
  isolation: isolate;
}
.tms-login__panel, .tms-login__hero > * { position: relative; z-index: 1; }
.tms-login__hero { background: transparent; overflow: visible; padding: 92px 0 56px; align-self: stretch; justify-content: center; position: static; isolation: auto; }
.tms-login__hero > .tms-login__hero-top { position: absolute; top: 30px; left: clamp(24px, 6vw, 96px); }
.tms-login__hero > .tms-login__hero-foot { position: absolute; bottom: 26px; left: clamp(24px, 6vw, 96px); }
.tms-login__panel { background: transparent; padding: 92px 0 56px; }
.tms-login__card {
  max-width: none;
  padding: 36px 34px 32px;
  background: var(--tms-paper);
  border-radius: var(--tms-radius-xl);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.tms-login__foot { color: var(--tms-on-pine-muted); }
.tms-login__headline { font-size: clamp(2.2rem, 3.7vw, 3.4rem); line-height: 1.14; font-weight: 700; }
.tms-login__headline-line2 { font-weight: 500; }
.tms-login__stats--two { display: flex; gap: 34px; max-width: none; }
.tms-login__stat { padding: 0 0 0 16px; background: none; border: none; border-left: 2px solid var(--tms-brass-light); border-radius: 0; backdrop-filter: none; }
.tms-login__title { font-size: 1.6rem; }
.tms-sidebar__brand-name { font-size: 1rem; }
.tms-topbar__title { font-size: 1.18rem; }
.tms-hero__title { font-size: 1.7rem; }
@media (max-width: 860px) {
  .tms-login__grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; gap: 0; padding: 0 18px; }
  .tms-login__hero { padding: 84px 4px 24px; gap: 0; }
  .tms-login__hero > .tms-login__hero-top { top: 22px; left: 22px; }
  .tms-login__hero > .tms-login__hero-foot { display: none; }
  .tms-login__headline { font-size: 1.75rem; }
  .tms-login__panel { padding: 0 0 34px; }
  .tms-login__card { padding: 26px 22px; }
  .tms-hero__title { font-size: 1.3rem; }
  .tms-topbar__title { font-size: 1rem; }
}

@media print {
  .tms-card:has(> .tms-detail-row), .tms-card > form[method="post"] { display: block; }
  :is(.tms-content > .tms-card:first-child, .tms-content > .tms-messages + .tms-card, .tms-content > .tms-subtabs + .tms-card, .tms-lead) > :is(h2:first-child, .tms-card__head:first-child) { background: none; color: #000; margin: 0 0 12px; padding: 0; }
  :is(.tms-content > .tms-card:first-child, .tms-content > .tms-messages + .tms-card, .tms-content > .tms-subtabs + .tms-card, .tms-lead) > :is(h2:first-child, .tms-card__head:first-child) h2,
  :is(.tms-content > .tms-card:first-child, .tms-content > .tms-messages + .tms-card, .tms-content > .tms-subtabs + .tms-card, .tms-lead) > h2:first-child { color: #000; }
  .tms-card > h2::before, .tms-card__head > h2::before, .tms-person__avatar { display: none; }
  .tms-table { border-spacing: 0; }
  .tms-table tbody td { border-radius: 0 !important; }
}

.tms-statcard__value { white-space: nowrap; }

/* Rows keep their full outline, including the last one. */
@media (min-width: 721px) {
  .tms-table:not(.tms-staffing__table) tbody tr:last-child td { border-bottom: 1px solid var(--tms-border); }
  .tms-table:not(.tms-staffing__table) tbody tr:last-child:hover td { border-color: var(--tms-accent-soft); }
}
@media (max-width: 720px) {
  .tms-table:not(.tms-staffing__table) td:has(.tms-btn-link) { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  .tms-table:not(.tms-staffing__table) td:has(.tms-btn-link)[data-label]:not([data-label=""])::before { flex-basis: 100%; }
}

/* Profile pages open with the same banner as the rest of the site. */
.tms-card:has(> .tms-profile-banner:first-child) { padding-top: 0; }
.tms-profile-banner {
  grid-column: 1 / -1;
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin: -1px calc(var(--tms-pad-x) * -1 - 1px) 22px;
  padding: 24px var(--tms-pad-x);
  border-radius: var(--tms-radius-lg) var(--tms-radius-lg) 0 0;
  background:
    radial-gradient(420px 200px at 94% -30%, rgba(224, 192, 136, 0.26), transparent 70%),
    radial-gradient(420px 240px at 4% 140%, rgba(56, 160, 143, 0.36), transparent 70%),
    var(--tms-pine-grad);
}
.tms-profile-banner h2 { color: #fff; font-size: 1.3rem; font-weight: 700; margin: 0; }
.tms-profile-banner h2::before { display: none; }
.tms-profile-banner .tms-muted { color: var(--tms-on-pine-muted); }
.tms-profile-banner img, .tms-profile-banner > span:first-child { border: 2px solid rgba(224, 192, 136, 0.7) !important; }
.tms-profile-banner > span:first-child { background: rgba(255, 255, 255, 0.12) !important; color: #fff; }
@media print {
  .tms-profile-banner { background: none; margin: 0 0 12px; padding: 0; }
  .tms-profile-banner h2 { color: #000; }
}

/* ================================================================== *
 *  Page layouts
 * ================================================================== */
.tms-card__actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.tms-narrow { max-width: 760px; margin-left: auto; margin-right: auto; }
.tms-narrow--sm { max-width: 560px; }

/* Banner buttons: the page's main action is brass. */
:is(.tms-content > .tms-card:first-child, .tms-content > .tms-messages + .tms-card, .tms-content > .tms-subtabs + .tms-card, .tms-lead) > .tms-card__head:first-child .tms-btn-link {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}
:is(.tms-content > .tms-card:first-child, .tms-content > .tms-messages + .tms-card, .tms-content > .tms-subtabs + .tms-card, .tms-lead) > .tms-card__head:first-child .tms-btn-link:not(.tms-btn-link--muted):not(.tms-btn-link--danger) {
  background: linear-gradient(135deg, var(--tms-brass-light), var(--tms-brass));
  border-color: transparent;
  color: var(--tms-pine-950);
}

/* Side-by-side: main work on the left, a rail on the right. */
.tms-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
.tms-split > .tms-card { margin-bottom: 0; }
.tms-split + * { margin-top: 18px; }
@media (min-width: 1280px) {
  .tms-split:has(> .tms-split__rail) { grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); }
  .tms-split > :not(.tms-split__rail) { grid-column: 1; }
  .tms-split > .tms-split__rail { grid-column: 2; grid-row: 1 / span 12; position: sticky; top: calc(var(--tms-topbar-height) + 16px); max-height: calc(100vh - var(--tms-topbar-height) - 32px); overflow-y: auto; }
}

/* Profile: identity rail and grouped details. */
.tms-profile { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
.tms-profile__main { display: grid; gap: 18px; min-width: 0; }
.tms-profile__main > .tms-card, .tms-profile__rail > .tms-card { margin-bottom: 0; }
.tms-profile__card { position: relative; padding-top: 0; overflow: hidden; }
.tms-profile__cover {
  height: 96px;
  margin: 0 calc(var(--tms-pad-x) * -1);
  background:
    radial-gradient(240px 140px at 90% -20%, rgba(224, 192, 136, 0.32), transparent 70%),
    radial-gradient(260px 160px at 0% 130%, rgba(56, 160, 143, 0.4), transparent 70%),
    var(--tms-pine-grad);
}
.tms-profile__id { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; margin-top: -48px; margin-bottom: 18px; position: relative; }
.tms-profile__id img, .tms-profile__id > span:first-child {
  width: 96px !important;
  height: 96px !important;
  border: 4px solid var(--tms-paper) !important;
  box-shadow: var(--tms-shadow);
  font-size: 2rem !important;
  background: var(--tms-accent-grad) !important;
  color: #fff;
}
.tms-profile__id img { background: var(--tms-paper) !important; }
.tms-profile__id h2 { font-size: 1.2rem; line-height: 1.3; }
.tms-profile__id h2 .tms-muted { display: block; margin-top: 2px; font-size: 0.86rem; font-weight: 500; }
.tms-profile__actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 0; }
.tms-profile__actions > * { width: 100%; margin: 0; }
.tms-profile__actions .tms-btn-link { width: 100%; justify-content: center; text-align: center; padding-left: 8px; padding-right: 8px; }
.tms-profile__actions form { display: block !important; }
.tms-profile__photo { margin-top: 14px; font-size: 0.86rem; }
.tms-profile__photo summary { cursor: pointer; color: var(--tms-text-muted); font-weight: 600; }
.tms-profile__photo form { margin-top: 10px; }
.tms-profile__photo .tms-field { width: 100%; }
.tms-profile__photo input[type="file"] { max-width: 100%; }
@media (min-width: 1000px) {
  .tms-profile { grid-template-columns: 300px minmax(0, 1fr); }
  .tms-profile__rail { position: sticky; top: calc(var(--tms-topbar-height) + 16px); }
}

/* Sectioned forms: what a group is on the left, its fields on the right. */
.tms-formsec { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px 28px; padding: 22px 0; border-top: 1px solid var(--tms-border); }
.tms-formsec:first-of-type { border-top: none; padding-top: 4px; }
.tms-formsec__head h3 { margin: 0 0 4px; font-size: 1rem; color: var(--tms-ink); }
.tms-formsec__head p { margin: 0; font-size: 0.84rem; color: var(--tms-text-muted); }
.tms-formsec__fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 20px; min-width: 0; }
.tms-formsec__fields > .tms-field:has(textarea, label > input[type="checkbox"], label > input[type="radio"]) { grid-column: 1 / -1; }
@media (min-width: 900px) { .tms-formsec { grid-template-columns: 220px minmax(0, 1fr); } }

/* The save action stays in reach on long forms. */
.tms-savebar {
  position: sticky;
  bottom: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 0;
  padding: 12px 16px;
  border: 1px solid var(--tms-border);
  border-radius: var(--tms-radius-lg);
  background: var(--tms-paper);
  box-shadow: var(--tms-shadow-lift);
}
@media (max-width: 860px) { .tms-savebar { bottom: calc(var(--tms-bottomnav-height) + 12px); } }

/* Section navigator. */
.tms-sections { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
.tms-sections__body { min-width: 0; }
.tms-sections__body [id^="sec-"] { scroll-margin-top: calc(var(--tms-topbar-height) + 16px); }
.tms-sections__nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; position: sticky; top: var(--tms-topbar-height); z-index: 15; margin: -8px -4px 0; padding: 8px 4px; background: var(--tms-bg); }
.tms-sections__nav a { flex-shrink: 0; padding: 9px 13px; border-radius: 10px; font-size: 0.88rem; font-weight: 600; color: var(--tms-text-muted); text-decoration: none; transition: background var(--tms-fast) ease, color var(--tms-fast) ease; }
.tms-sections__nav a:hover { background: var(--tms-fill-strong); color: var(--tms-ink); }
.tms-sections__nav a.is-active { background: var(--tms-accent); color: #fff; }
@media (min-width: 1400px) {
  .tms-sections { grid-template-columns: 220px minmax(0, 1fr); }
  .tms-sections__nav { flex-direction: column; overflow: visible; top: calc(var(--tms-topbar-height) + 16px); margin: 0; padding: 0; background: none; }
}

/* Finance: money grouped by direction, shortcuts as tiles. */
.tms-fingroups { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px 22px; }
.tms-fingroup .tms-section-label { margin-top: 0; }
.tms-fingroup .tms-statcards { margin-bottom: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (min-width: 1100px) {
  .tms-fingroups { grid-template-columns: 2fr 3fr; }
  .tms-fingroup--wide { grid-column: 1 / -1; }
}
.tms-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tms-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 92px;
  padding: 13px;
  border: 1px solid var(--tms-border);
  border-radius: var(--tms-radius);
  background: var(--tms-paper);
  color: var(--tms-ink);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  transition: transform var(--tms-fast) var(--tms-ease), border-color var(--tms-fast) ease, box-shadow var(--tms-fast) ease;
}
.tms-tile svg { width: 20px; height: 20px; color: var(--tms-accent); }
.tms-tile:hover { transform: translateY(-2px); border-color: var(--tms-accent); box-shadow: var(--tms-shadow); text-decoration: none; }

/* Documents lead with the figure that matters. */
.tms-card:has(> .tms-detail-row) > .tms-detail-row--total {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-color: transparent;
  background: var(--tms-tint);
}
.tms-card:has(> .tms-detail-row) > .tms-detail-row--total > span:first-child { font-size: 0.9rem; font-weight: 600; color: var(--tms-accent-strong); }
.tms-card:has(> .tms-detail-row) > .tms-detail-row--total > span:last-child { font-size: 1.7rem; font-weight: 700; color: var(--tms-ink); }
.tms-doc { max-width: 960px; margin-left: auto; margin-right: auto; }
.tms-doc + .tms-card { max-width: 960px; margin-left: auto; margin-right: auto; }

@media print {
  .tms-split, .tms-profile, .tms-sections, .tms-fingroups { display: block; }
  .tms-split > .tms-split__rail, .tms-profile__rail { position: static; max-height: none; overflow: visible; }
  .tms-savebar, .tms-sections__nav, .tms-tile svg, .tms-profile__cover, .tms-profile__photo { display: none; }
  .tms-profile__id { margin-top: 0; }
}

/* Tables in narrower columns tighten up instead of clipping. */
.tms-split .tms-table th, .tms-split .tms-table td,
.tms-sections__body .tms-table th, .tms-sections__body .tms-table td { padding-left: 10px; padding-right: 10px; }
.tms-sections__body .tms-table .tms-input, .tms-sections__body .tms-table input:not([type="checkbox"]) { min-width: 0; width: 100%; padding-left: 10px; padding-right: 8px; }
@media (min-width: 721px) {
  .tms-sections__body .tms-table { table-layout: auto; width: 100%; }
  .tms-sections__body .tms-table td[data-label="Name"] { min-width: 150px; }
  .tms-sections__body .tms-table td[data-label="Start"], .tms-sections__body .tms-table td[data-label="End"] { min-width: 128px; }
  .tms-sections__body .tms-table td[data-label="Teachers needed"] { width: 74px; }
}

fieldset { min-width: 0; }

/* On narrow screens the rail (form or shortcuts) comes first. */
.tms-split > .tms-split__rail { order: -1; }

/* ---- Maintenance page ---- */
.tms-closed {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  color: #fff;
  background:
    radial-gradient(560px 420px at 8% 100%, rgba(32, 138, 120, 0.45), transparent 70%),
    radial-gradient(480px 380px at 96% 0%, rgba(185, 138, 62, 0.3), transparent 70%),
    var(--tms-pine-950);
}
.tms-closed::before {
  content: "";
  position: fixed;
  inset: 0;
  opacity: 0.07;
  background-image: var(--tms-lattice);
  background-size: 72px 72px;
  pointer-events: none;
}
.tms-closed__card { position: relative; max-width: 520px; text-align: center; animation: tms-rise 0.6s var(--tms-ease) backwards; }
.tms-closed__brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.05rem; }
.tms-closed__brand .tms-logo { width: 44px; height: 44px; }
.tms-closed__eyebrow { margin: 40px 0 10px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--tms-brass-light); }
.tms-closed__title { margin: 0; font-size: clamp(1.7rem, 5vw, 2.4rem); line-height: 1.2; font-weight: 700; color: #fff; }
.tms-closed__text { margin: 16px auto 0; max-width: 420px; color: var(--tms-on-pine-muted); line-height: 1.65; }
.tms-closed__foot { margin-top: 34px; font-size: 0.85rem; color: var(--tms-on-pine-muted); }
.tms-closed__foot a { color: var(--tms-brass-light); }
.tms-closed__signout { display: inline; margin: 0; }
.tms-closed__signout button { background: none; border: 0; padding: 0; font: inherit; color: var(--tms-brass-light); text-decoration: underline; cursor: pointer; }

.tms-public__brand .tms-logo, .tms-public__head .tms-logo { width: 38px; height: 38px; flex-shrink: 0; }
.tms-login .tms-public__brand { color: #fff; }
.tms-login .tms-public__signin { color: var(--tms-brass-light); }

/* Last Jadeed under a student's name. */
.tms-task__jadeed { margin-top: 8px; padding: 7px 11px; border-radius: 9px; background: var(--tms-tint); font-size: 0.86rem; color: var(--tms-ink); }
.tms-task__jadeed-label { display: block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--tms-accent-strong); }

/* The net sits behind the sign-in page's content, across the whole page. */
.tms-login__hero > .tms-login__hero-pattern { position: absolute; inset: 0; z-index: 0; opacity: 0.2; -webkit-mask-image: linear-gradient(115deg, #000 35%, rgba(0, 0, 0, 0.35) 100%); mask-image: linear-gradient(115deg, #000 35%, rgba(0, 0, 0, 0.35) 100%); }
.tms-hero::before { opacity: 0.16; }
.tms-profile__cover { position: relative; }
.tms-profile__cover::after { content: ""; position: absolute; inset: 0; opacity: 0.16; background-image: var(--tms-lattice); background-size: 64px 64px; pointer-events: none; }

/* Payment screenshot on a receipt: a preview that opens the full image. */
.tms-card:has(> .tms-detail-row) > .tms-detail-row--proof { grid-row: span 2; }
.tms-proof { display: block; max-width: 100%; max-height: 260px; margin-top: 4px; border: 1px solid var(--tms-border); border-radius: 10px; background: var(--tms-paper); }
@media print { .tms-proof { max-height: 420px; } }

/* A form in the rail can be long: it scrolls with the page, not inside itself. */
.tms-split > .tms-split__rail.tms-lead { position: static; max-height: none; overflow: visible; }

/* Statement: pick the date the download is sorted by. */
.tms-stmt-sort { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 0.82rem; font-weight: 600; color: var(--tms-on-pine-muted); }
.tms-stmt-sort .tms-input { width: auto; padding: 6px 30px 6px 10px; font-size: 0.85rem; }

/* Pick students to invoice. */
.tms-pickbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin: 6px 0 12px; padding: 10px 14px; border: 1px solid var(--tms-border); border-radius: var(--tms-radius); background: var(--tms-paper); }
.tms-pick { display: inline-flex; align-items: center; gap: 10px; margin: 0; font-weight: 600; cursor: pointer; }
.tms-pick input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--tms-accent); flex-shrink: 0; }

/* A student card's buttons sit in one even row. */
.tms-task__actions { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin-top: 12px; }
.tms-task__actions:not(:has(a, button, .tms-clock)) { display: none; }
.tms-task__actions > .tms-task__action { margin: 0; }
.tms-task__actions > form.tms-task__action { display: flex; }
.tms-task__actions > .tms-clock { flex-basis: 100%; margin: 0 0 4px !important; }
.tms-task__actions .tms-btn-link { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; margin: 0; line-height: 1.2; }
.tms-task__actions .tms-btn-link svg { width: 16px; height: 16px; flex-shrink: 0; }
