/* Shared UI for every role-aware screen: the collapsing nav rail and the
   dashboard surfaces the three Home pages are built from.

   These classes are separate from the compiled Tailwind bundle: utilities
   omitted by its tree shaking would otherwise silently have no effect.
   The frontend build copies this file alongside the generated styles. */

/* Colour tokens (--ta-*) live in theme.css, which every page loads first. */
body { background: var(--ta-page); }
/* Most pages still ship their old hand-written sidebar, which shows until
   role-nav.js has asked the server what the account holds and redrawn it --
   so every navigation flashed stale links ("Admin Dashboard", "Engine
   Calibration"). Keep the space, hide the stale contents. */
aside#sidebar:not(.ta-rail) > * { visibility: hidden; }
.ta-hidden { display: none !important; }

/* ---- the rail ------------------------------------------------------ */
/* Collapsed to icons, expanding over the content on hover rather than
   pushing it, so the page does not reflow every time the pointer passes. */
.ta-rail { width: 72px; overflow-x: hidden; overflow-y: auto;
           transition: width .16s ease, box-shadow .16s ease; }
.ta-rail:hover { width: 256px; box-shadow: 0 10px 30px color-mix(in srgb, var(--ta-gray-950) 12%, transparent); }
.ta-rail .ta-lbl { display: none; white-space: nowrap; }
.ta-rail:hover .ta-lbl { display: block; }
.ta-rail-row { display: flex; align-items: center; gap: 11px; padding: 7px 0;
               justify-content: center; border-radius: 8px; font-size: 14px;
               color: var(--ta-gray-700); text-decoration: none; }
.ta-rail:hover .ta-rail-row { justify-content: flex-start; padding: 7px 8px; }
.ta-rail-row:hover { background: var(--ta-gray-100); }
.ta-rail-row--on { background: var(--ta-accent-tint); color: var(--ta-accent); font-weight: 600; }
.ta-rail-mark { width: 32px; height: 32px; flex: none; border-radius: 8px;
                background: var(--ta-gray-100); color: var(--ta-muted);
                display: flex; align-items: center; justify-content: center; }
.ta-rail-row--on .ta-rail-mark { background: var(--ta-accent); color: #fff; }
.ta-rail-badge { margin-left: auto; font-size: 11px; font-weight: 600;
                 white-space: nowrap; color: var(--ta-muted); }
.ta-rail-group { font-size: 10.5px; letter-spacing: .11em; font-weight: 600;
                 color: var(--ta-muted); padding: 0 8px 6px; white-space: nowrap; }
/* Below md the aside is a slide-in drawer, so it is always the wide form. */
@media (max-width: 767px) {
  .ta-rail, .ta-rail:hover { width: 100%; box-shadow: none; }
  .ta-rail .ta-lbl { display: block; }
  .ta-rail-row { justify-content: flex-start; padding: 7px 8px; }
}

/* ---- shared controls: buttons, inputs, cards -------------------------
   One look per control for every page (src/shell/ui.tsx wraps them for
   React). In Tailwind's components layer, so a page can still add layout
   utilities (w-full, mt-4, hidden sm:inline-flex) on top.

   Buttons: ta-btn plus one variant (--primary, --secondary, --ghost,
   --danger) and, when it is not the default medium, one size (--sm for
   table rows and toolbars, --lg for a page's main call to action). */
@layer components {
  .ta-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
            height: 38px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--ta-radius-control);
            font: inherit; font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap;
            text-decoration: none; cursor: pointer;
            transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
  .ta-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
  .ta-btn:disabled, .ta-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
  .ta-btn--primary { background: var(--ta-accent); border-color: var(--ta-accent); color: #fff; }
  .ta-btn--primary:hover:not(:disabled) { background: var(--ta-accent-hover); border-color: var(--ta-accent-hover); color: #fff; }
  .ta-btn--secondary { background: #fff; border-color: var(--ta-gray-300); color: var(--ta-gray-900); }
  .ta-btn--secondary:hover:not(:disabled) { background: var(--ta-gray-50); border-color: var(--ta-gray-400); }
  .ta-btn--ghost { background: transparent; color: var(--ta-gray-700); }
  .ta-btn--ghost:hover:not(:disabled) { background: var(--ta-gray-100); color: var(--ta-gray-900); }
  .ta-btn--danger { background: #fff; border-color: #fecaca; color: var(--ta-danger); }
  .ta-btn--danger:hover:not(:disabled) { background: #fef2f2; border-color: #fca5a5; }
  .ta-btn--sm { height: 30px; padding: 0 10px; gap: 6px; font-size: 12.5px; }
  .ta-btn--sm svg { width: 14px; height: 14px; }
  .ta-btn--lg { height: 46px; padding: 0 22px; font-size: 15px; }
  .ta-btn--block { width: 100%; }

  .ta-input, .ta-select, .ta-textarea { width: 100%; height: 40px; padding: 0 12px;
            border: 1px solid var(--ta-gray-300); border-radius: var(--ta-radius-control);
            background: #fff; color: var(--ta-gray-900); font: inherit; font-size: 14px; }
  .ta-textarea { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
  .ta-input--icon { padding-left: 36px; }
  .ta-input--sm, .ta-select--sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
  .ta-input--lg { height: 46px; padding: 0 16px; font-size: 15px; }
  .ta-input::placeholder, .ta-textarea::placeholder { color: var(--ta-gray-500); }
  .ta-input:focus, .ta-select:focus, .ta-textarea:focus { outline: none; border-color: var(--ta-accent);
            box-shadow: 0 0 0 3px color-mix(in srgb, var(--ta-accent) 15%, transparent); }
  .ta-input:disabled, .ta-select:disabled, .ta-textarea:disabled,
  .ta-input[readonly], .ta-textarea[readonly] { background: var(--ta-gray-50); color: var(--ta-gray-600); }

  .ta-card { background: #fff; border: 1px solid var(--ta-line); border-radius: var(--ta-radius-card); }
  .ta-card--empty { border-style: dashed; border-color: var(--ta-gray-300); }
}

/* ---- shared surfaces ----------------------------------------------- */
.ta-eyebrow { font-size: 11px; letter-spacing: .09em; font-weight: 600; color: var(--ta-accent); }
.ta-h2 { margin: 0; font-size: 12.5px; font-weight: 600; letter-spacing: .09em;
         color: var(--ta-accent); }

/* ---- stat strip ----------------------------------------------------- */
.ta-strip { display: flex; flex-wrap: wrap; overflow: hidden; }
.ta-stat { flex: 1 1 180px; min-width: 0; padding: 15px 20px;
           border-left: 1px solid var(--ta-line-soft); display: flex;
           align-items: baseline; gap: 10px; }
.ta-stat:first-child { border-left: 0; }
.ta-stat__n { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.ta-stat__n--zero { color: var(--ta-gray-400); }
.ta-stat__l { font-size: 13px; font-weight: 500; }
.ta-stat__h { font-size: 11.5px; color: var(--ta-muted); }

/* ---- body grid ------------------------------------------------------ */
.ta-body { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
           gap: 22px; align-items: start; }
@media (max-width: 1100px) { .ta-body { grid-template-columns: 1fr; } }
.ta-col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.ta-col--rail { gap: 14px; }
.ta-section { display: flex; flex-direction: column; gap: 11px; }

/* ---- rows, tiles, badges -------------------------------------------- */
.ta-row { display: flex; align-items: center; gap: 15px; padding: 15px 20px;
          border-top: 1px solid var(--ta-line-soft); }
.ta-row:first-child { border-top: 0; }
.ta-row:hover { background: var(--ta-gray-50); }
.ta-row__mark { width: 36px; height: 36px; border-radius: 9px; flex: none;
                background: var(--ta-accent-tint); color: var(--ta-accent);
                display: flex; align-items: center; justify-content: center;
                font-weight: 600; font-size: 12.5px; }
.ta-row__foot { padding: 13px 20px; border-top: 1px solid var(--ta-line-soft);
                background: var(--ta-gray-50); font-size: 12.5px; color: var(--ta-muted); }
.ta-pill { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; flex: none;
           padding: 5px 10px; border-radius: 999px; }
.ta-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 13px; }
.ta-tile { background: #fff; border: 1px solid var(--ta-line); border-radius: 12px;
           padding: 16px 17px; display: flex; flex-direction: column; gap: 5px;
           text-decoration: none; color: inherit; }
.ta-tile:hover { border-color: var(--ta-accent); box-shadow: 0 4px 14px color-mix(in srgb, var(--ta-gray-950) 6%, transparent); }
.ta-tile__t { font-weight: 600; font-size: 14.5px; }
.ta-tile__d { font-size: 13px; line-height: 1.5; color: var(--ta-muted-2); }
.ta-chip { font-size: 10px; font-weight: 600; letter-spacing: .06em; white-space: nowrap;
           padding: 3px 7px; border-radius: 999px;
           background: var(--ta-idle-bg); color: var(--ta-muted-2); }
.ta-chip--n { background: var(--ta-accent-tint); color: var(--ta-accent); }
.ta-chip--good { background: var(--ta-good-bg); color: var(--ta-good); }
.ta-chip--warn { background: var(--ta-warn-bg); color: var(--ta-warn); }

/* ---- checklist ------------------------------------------------------ */
.ta-step { display: flex; align-items: center; gap: 15px; padding: 16px 20px;
           border-top: 1px solid var(--ta-line-soft); }
.ta-step:first-child { border-top: 0; }
.ta-step__n { width: 30px; height: 30px; border-radius: 50%; flex: none;
              border: 1.5px solid var(--ta-gray-200); background: #fff; color: var(--ta-muted);
              display: flex; align-items: center; justify-content: center;
              font-weight: 600; font-size: 13px; }
.ta-step--done .ta-step__n { border-color: var(--ta-good); background: var(--ta-good-bg); color: var(--ta-good); }
.ta-step--now  .ta-step__n { border-color: var(--ta-accent); background: var(--ta-accent-tint); color: var(--ta-accent); }
.ta-step__t { font-weight: 600; font-size: 14.5px; color: var(--ta-muted); }
.ta-step--done .ta-step__t, .ta-step--now .ta-step__t { color: var(--ta-ink); }
.ta-step__d { font-size: 12.5px; color: var(--ta-muted); line-height: 1.45; }
.ta-step__cta { font-size: 13px; font-weight: 600; flex: none; color: var(--ta-muted); }
.ta-step--done .ta-step__cta { color: var(--ta-good); }
.ta-step--now .ta-step__cta { color: var(--ta-accent); }

/* ---- rail cards ----------------------------------------------------- */
.ta-panel { background: #fff; border: 1px solid var(--ta-line); border-radius: 12px;
            padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.ta-health { display: flex; align-items: baseline; justify-content: space-between;
             gap: 10px; font-size: 13px; }
.ta-health__v { font-weight: 500; }
.ta-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ta-good); }
.ta-dot--warn { background: #E0A42B; }
.ta-event { display: flex; flex-direction: column; gap: 2px; padding-left: 13px;
            border-left: 2px solid var(--ta-line); }
.ta-event__t { font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.ta-event__w { font-size: 11.5px; color: var(--ta-muted); }
.ta-promo { background: var(--ta-accent); border-radius: 12px; padding: 18px; color: #fff;
            display: flex; flex-direction: column; gap: 9px; }
.ta-promo__h { font-weight: 600; font-size: 17px; line-height: 1.3; }
.ta-promo__d { font-size: 13px; line-height: 1.5; color: #E2E6FD; }
.ta-promo .ta-btn { background: #fff; color: var(--ta-accent); align-self: flex-start;
                    padding: 9px 16px; font-size: 13px; margin-top: 4px; box-shadow: none; }
.ta-promo .ta-btn:hover { background: var(--ta-gray-100); }

/* ---- pinned rail ------------------------------------------------------ */
/* "Always expanded": the rail keeps its full width and stops reacting to
   hover. Selectors are one class deeper than the collapsed ones so they win
   without !important. */
html.ta-rail-pinned .ta-rail,
html.ta-rail-pinned .ta-rail:hover { width: 256px; box-shadow: none; }
html.ta-rail-pinned .ta-rail .ta-lbl { display: block; }
html.ta-rail-pinned .ta-rail-row { justify-content: flex-start; padding: 7px 8px; }
html.ta-rail-pinned.ta-rail-injected body,
html.ta-rail-pinned.ta-rail-injected:has(.ta-rail:hover) body { padding-left: 256px; }

/* The control, at the foot of the rail. It is a rail row, so it centres in
   the collapsed rail and lines up with the links when the rail is wide. */
.ta-rail-foot { position: sticky; bottom: 0; background: #fff;
                padding: 8px 12px 12px; border-top: 1px solid var(--ta-line); }
.ta-rail-toggle { width: 100%; border: 0; background: none; font: inherit;
                  color: var(--ta-muted); cursor: pointer; }
.ta-rail-toggle:hover .ta-rail-mark { color: var(--ta-accent); }
.ta-rail-toggle[aria-pressed="true"] .ta-rail-mark {
  background: var(--ta-accent-tint);
  color: var(--ta-accent);
}
/* Below md the rail is a drawer the menu button already controls, so pinning
   would mean nothing. */
@media (max-width: 767px) { .ta-rail-foot { display: none; } }

/* ---- injected rail ---------------------------------------------------- */
/* For the shell that has no sidebar of its own: the Opportunity Workspace and
   the Email Log, which use a 52px sticky topbar. The rail is fixed below it
   and the body reserves only its collapsed width, because it expands over the
   content rather than pushing it. */
.ta-rail--floating {
  position: fixed;
  left: 0;
  z-index: 40;
}
/* Offset by whichever header the page has: a 52px sticky topbar, or the
   64px fixed one. */
html.ta-rail-topbar .ta-rail--floating { top: 52px; height: calc(100vh - 52px); }
html.ta-rail-header .ta-rail--floating { top: 64px; height: calc(100vh - 64px); }

/* The body reserves the rail's width, and widens with it on hover so the rail
   pushes the content across rather than covering it — which is what the
   pages with a real sidebar do, and what this looked wrong against. */
html.ta-rail-injected body {
  padding-left: 72px;
  transition: padding-left .16s ease;
}

/* The sticky topbar is inside the body, so the rail offset pushes it across
   too. Pull it back to the window edge: the rail hangs BELOW this bar, so its
   logo belongs at the far left like every other header, not indented past a
   rail that is not beside it. A React page's topbar sits in #root rather than
   directly in the body, so each rule names both. */
html.ta-rail-injected body > header.topbar,
html.ta-rail-injected #root > header.topbar {
  margin-left: -72px;
  padding-left: 20px;
  transition: margin-left .16s ease;
}
html.ta-rail-injected:has(.ta-rail:hover) body > header.topbar,
html.ta-rail-injected:has(.ta-rail:hover) #root > header.topbar,
html.ta-rail-pinned.ta-rail-injected body > header.topbar,
html.ta-rail-pinned.ta-rail-injected #root > header.topbar {
  margin-left: -256px;
}
html.ta-rail-injected:has(.ta-rail:hover) body { padding-left: 256px; }

@media (max-width: 767px) {
  html.ta-rail-injected body,
  html.ta-rail-injected:has(.ta-rail:hover) body { padding-left: 0; }
  html.ta-rail-injected body > header.topbar,
  html.ta-rail-injected #root > header.topbar,
  html.ta-rail-injected:has(.ta-rail:hover) body > header.topbar,
  html.ta-rail-injected:has(.ta-rail:hover) #root > header.topbar,
  html.ta-rail-pinned.ta-rail-injected body > header.topbar,
  html.ta-rail-pinned.ta-rail-injected #root > header.topbar { margin-left: 0; padding-left: 0; }
  .ta-rail--floating { position: static; height: auto; }
}

/* ---- the data grid ------------------------------------------------- */
/* The table library is a CDN bundle that ships its own blue (#1570EF) for the
   toolbar buttons it injects, so its Export button sat a shade off every other
   primary button on the page. Point its utility classes at the app accent from
   here rather than forking the vendor file; !important is needed because they
   are the library's own utilities, not ours. */
.tiram-dg-bg-grid-primary { background-color: var(--ta-accent) !important; }
.hover\:tiram-dg-bg-grid-primary-hover:hover { background-color: var(--ta-accent-hover) !important; }
.tiram-dg-text-grid-primary { color: var(--ta-accent) !important; }
.tiram-dg-border-grid-primary { border-color: var(--ta-accent) !important; }

/* ---- pagination ---------------------------------------------------- */
/* One pager for every list, drawn the way opportunity_list.html draws its
   own: filled accent "‹ Prev" / "Next ›" buttons and a plain select. Pages
   with a hand-written pager use the .ta-pager classes; the grid library's
   pager is restyled onto the same look by its buttons' titles, which are the
   only stable hooks it renders. First/Last are hidden to match. */
.ta-pager { display: flex; align-items: center; justify-content: space-between;
            gap: 16px; flex-wrap: wrap; padding: 12px 4px; }
/* Pages toggle their pager with Tailwind's .hidden, which .ta-pager would
   otherwise beat by loading later. */
.ta-pager.hidden { display: none; }
.ta-pager__info { font-size: 12px; color: var(--ta-gray-600); }
.ta-pager__controls { display: flex; align-items: center; gap: 8px; }
.ta-pager__btn,
.tiram-dg-btn[title="Previous page"],
.tiram-dg-btn[title="Next page"] {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 100px; padding: 8px 16px; border-radius: 6px;
  font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.25;
  border: 1.5px solid var(--ta-accent) !important;
  background: var(--ta-accent) !important; color: #fff !important;
  cursor: pointer; transition: all 120ms ease;
}
.ta-pager__btn:not(:disabled):hover,
.tiram-dg-btn[title="Previous page"]:not(:disabled):hover,
.tiram-dg-btn[title="Next page"]:not(:disabled):hover {
  border-color: var(--ta-accent-hover) !important;
  background: var(--ta-accent-hover) !important;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--ta-accent) 30%, transparent);
}
.ta-pager__btn:disabled,
.tiram-dg-btn[title="Previous page"]:disabled,
.tiram-dg-btn[title="Next page"]:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.tiram-dg-btn[title="Previous page"] svg,
.tiram-dg-btn[title="Next page"] svg,
.tiram-dg-btn[title="First page"],
.tiram-dg-btn[title="Last page"] { display: none !important; }
.tiram-dg-btn[title="Previous page"]::before { content: "\2039  Prev"; white-space: pre; }
.tiram-dg-btn[title="Next page"]::after { content: "Next \203A"; }
.ta-pager__select {
  padding: 6px 12px !important; font-family: inherit; font-size: 14px; font-weight: 500;
  color: var(--ta-gray-900) !important; background: #fff !important;
  border: 1.5px solid var(--ta-gray-300) !important; border-radius: 6px !important;
  cursor: pointer; transition: all 120ms ease; height: auto !important;
}
.ta-pager__select:hover { border-color: var(--ta-accent) !important; color: var(--ta-accent) !important;
                          background: var(--ta-accent-tint) !important; }
.ta-pager__select:focus-visible { outline: 2px solid var(--ta-accent-tint); outline-offset: 1px;
                                  border-color: var(--ta-accent) !important; }
/* "Display per page" sits top right, as .rows-per-page does on
   opportunity_list.html. On grid pages scripts/grid-page-size.js puts it in
   the toolbar and drives the library's footer select, hidden here. */
.ta-page-size { margin-left: auto; display: inline-flex; align-items: center; gap: 12px;
                font-size: 14px; font-weight: 500; color: var(--ta-gray-900); white-space: nowrap;
                padding-left: 24px; border-left: 2px solid var(--ta-gray-300); }
.tiram-dg-grid > .tiram-dg-border-t > div:has(> select) { display: none !important; }

/* ==== Phones, tablets and every browser ================================ */
/* Everything below was added so the same pages hold up outside desktop
   Chrome. Plain CSS, no new Tailwind classes: the bundle is precompiled, so a
   utility that is not already in it does nothing. */

/* ---- the rail on a phone: an off-canvas drawer, on every shell ------- */
/* The pinned rules above are one class deeper than the mobile ones earlier in
   this file, so on a phone they still won: the body kept 256px of padding and
   left about 130px for the page. These repeat those selectors, later in the
   file and inside the query, so they win at equal specificity. */
@media (max-width: 767px) {
  html.ta-rail-injected body,
  html.ta-rail-pinned.ta-rail-injected body,
  html.ta-rail-injected:has(.ta-rail:hover) body,
  html.ta-rail-pinned.ta-rail-injected:has(.ta-rail:hover) body { padding-left: 0; }

  .ta-rail, .ta-rail:hover,
  html.ta-rail-pinned .ta-rail,
  html.ta-rail-pinned .ta-rail:hover { width: min(288px, 86vw); }

  /* The injected rail is the drawer itself. The Admin Portal shells slide
     their own sidebar with a translate class, so only the height is ours. */
  html.ta-rail-injected .ta-rail--floating {
    position: fixed; left: 0; bottom: 0; height: auto; z-index: 70;
    transform: translateX(-105%); visibility: hidden;
    transition: transform .2s ease, visibility 0s linear .2s;
    box-shadow: 0 10px 30px color-mix(in srgb, var(--ta-gray-950) 18%, transparent);
  }
  html.ta-rail-injected.ta-nav-open .ta-rail--floating {
    transform: none; visibility: visible; transition: transform .2s ease;
  }
  html.ta-rail-topbar .ta-rail--floating { top: 52px; }
  html.ta-rail-header .ta-rail--floating { top: 64px; }
  aside#sidebar.ta-rail:not(.ta-rail--floating) { height: auto; bottom: 0; overflow-y: auto; }
  .ta-rail nav { padding-bottom: 24px; }
}
.ta-nav-btn { display: none; }
.ta-nav-scrim { display: none; }
@media (max-width: 767px) {
  .ta-nav-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; margin-right: 8px; flex: none; border: 0;
    border-radius: 8px; background: none; color: var(--ta-ink); cursor: pointer;
  }
  .ta-nav-btn:hover { background: var(--ta-gray-100); }
  html.ta-nav-open .ta-nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 65;
    background: color-mix(in srgb, var(--ta-gray-950) 45%, transparent);
  }
  html.ta-nav-open, html.ta-nav-open body { overflow: hidden; }
}

/* ---- the rail on a touch tablet -------------------------------------- */
/* Hover does not exist on a touchscreen: a tap leaves the rail "hovered",
   expanded over the page and pushing it sideways until the next tap
   elsewhere. Where the device cannot hover, the collapsed rail stays
   collapsed; pinning it open still works. */
@media (min-width: 768px) and (hover: none) {
  html:not(.ta-rail-pinned) .ta-rail:hover { width: 72px; box-shadow: none; }
  html:not(.ta-rail-pinned) .ta-rail:hover .ta-lbl { display: none; }
  html:not(.ta-rail-pinned) .ta-rail:hover .ta-rail-row { justify-content: center; padding: 7px 0; }
  html.ta-rail-injected:not(.ta-rail-pinned):has(.ta-rail:hover) body { padding-left: 72px; }
  html.ta-rail-injected:not(.ta-rail-pinned):has(.ta-rail:hover) body > header.topbar,
  html.ta-rail-injected:not(.ta-rail-pinned):has(.ta-rail:hover) #root > header.topbar { margin-left: -72px; }
}

/* ---- viewport height ------------------------------------------------- */
/* 100vh is the height with the mobile toolbar hidden, so anything sized to it
   ends up partly behind the toolbar on iOS Safari and Android Chrome. dvh is
   the height actually visible; browsers without it keep the vh rule. */
@supports (height: 100dvh) {
  html.ta-rail-topbar .ta-rail--floating { height: calc(100dvh - 52px); }
  html.ta-rail-header .ta-rail--floating { height: calc(100dvh - 64px); }
  .min-h-screen { min-height: 100dvh; }
  .h-\[calc\(100vh-4rem\)\] { height: calc(100dvh - 4rem); }
  .min-h-\[calc\(100vh-4rem\)\] { min-height: calc(100dvh - 4rem); }
  .max-h-\[90vh\] { max-height: 90dvh; }
  .max-h-\[85vh\] { max-height: 85dvh; }
}
@media (max-width: 767px) {
  @supports (height: 100dvh) {
    html.ta-rail-injected .ta-rail--floating { height: auto; }
  }
}

/* ---- form fields ----------------------------------------------------- */
/* iOS zooms the page into any field whose text is under 16px, and most of
   ours are 13-14px. Touch devices get 16px; desktop keeps its sizes. */
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
  select, textarea { font-size: 16px !important; }
}

/* ---- tables ---------------------------------------------------------- */
/* Several admin tables sit in an overflow-hidden card, which clips columns
   off a narrow screen with no way to reach them. Let those cards scroll
   sideways instead; the rounded corners still clip. A flex child also has
   to be allowed to shrink below its content or it widens the whole page. */
main, .flex-1 { min-width: 0; }
@media (max-width: 1023px) {
  div:has(> table), div:has(> .tiramai-grid), div:has(> [class*="tiram-dg"]) {
    overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%;
  }
}
/* On a phone a table squeezed to the screen breaks every word into letters;
   past a readable width it scrolls sideways in its card instead. */
@media (max-width: 767px) {
  div:has(> table) > table { min-width: 560px; }
  /* Long ids and keys in <code> have no break points and widened the page. */
  code { overflow-wrap: anywhere; }
}

/* ---- dialogs --------------------------------------------------------- */
/* The admin dialogs are fixed full-screen overlays with a height-capped
   panel. On a phone, keep the panel inside the visible screen with a small
   margin and let its body scroll, so the footer buttons stay reachable. */
@media (max-width: 767px) {
  .fixed.inset-0 > .max-w-md, .fixed.inset-0 > .max-w-lg, .fixed.inset-0 > .max-w-xl,
  .fixed.inset-0 > .max-w-2xl, .fixed.inset-0 > .max-w-3xl, .fixed.inset-0 > .max-w-4xl {
    width: calc(100vw - 24px); max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px); overflow-y: auto;
  }
  @supports (height: 100dvh) {
    .fixed.inset-0 > .max-w-md, .fixed.inset-0 > .max-w-lg, .fixed.inset-0 > .max-w-xl,
    .fixed.inset-0 > .max-w-2xl, .fixed.inset-0 > .max-w-3xl, .fixed.inset-0 > .max-w-4xl {
      max-height: calc(100dvh - 24px);
    }
  }
}

/* ---- keyboard focus -------------------------------------------------- */
/* Most controls remove the outline and draw focus with a box-shadow, which
   Windows High Contrast mode strips, leaving no focus mark at all. A real
   outline shows for keyboard focus only, so mouse and touch look the same. */
a:focus-visible, button:focus-visible, [role="button"]:focus-visible,
[role="tab"]:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--ta-accent); outline-offset: 2px;
}
@media (forced-colors: active) {
  :focus-visible { outline: 2px solid CanvasText !important; outline-offset: 2px; }
}

/* ---- motion ---------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

/* ---- moving between screens --------------------------------------- */
/* Every screen is its own page. Cross-fade from one to the next instead of
   flashing white, and keep the rail still across the swap, since it is the
   same on both sides. Browsers without cross-document transitions ignore it. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
aside#sidebar.ta-rail { view-transition-name: ta-rail; }

/* Inside the React app a rail link swaps the page without a document load, so
   the transition above does not run. While the new page mounts (RoleNav adds
   this class for a moment) the rail and the space kept for it land at their
   final size at once, and the page's content slides in from behind the rail
   instead: the same entrance on every page, with the rail and header still. */
html.ta-route-settling body,
html.ta-route-settling #sidebar,
html.ta-route-settling .ta-rail,
html.ta-route-settling #root > header.topbar { transition: none !important; }
@keyframes ta-page-in { from { transform: translateX(-160px); } to { transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  html.ta-route-settling #root main { animation: ta-page-in .2s ease-out; }
}
