/* ==========================================================================
   Rentee fluid - one layout and one set of controls for every screen.

   Loaded last by every shell (surface.php, dashboard.php, the owner portal,
   the sign-in page), so it settles what the older stylesheets disagree on:

     1  one surface and one gutter: the page fills the width beside the
        sidebar, in a single background colour, from 360px to 2560px
     2  the sidebar: open from 1280px, collapsible from 1024px (remembered),
        an off-canvas drawer below that
     3  fluid content: forms, figure strips, tables and dialogs reflow by the
        space they have; prose keeps a readable measure
     4  type: 16px input text on phones (no iOS zoom), nothing under 12px
     Controls (buttons, fields, selects, filter bars) are not styled here: they
     keep the original design in rentee-list.css (v5 restored it).

   assets/css/app.css is the compiled template and is never edited; these
   rules are unlayered, so they win over its @layer rules without !important.
   Prints, exports and e-mails keep their fixed sizes - they are not screens.
   ========================================================================== */

:root {
  --page-gutter: clamp(16px, 2.2vw, 40px);
  --main-sidebar-width: 15rem;
  /* the v2 tokens, global so pages outside .rx share them */
  --ui-sheet: #FFFFFF; --ui-ink: #14262C; --ui-ink-2: #4E636B; --ui-mute: #81959C;
  --ui-line: #DFE7EA; --ui-teal: #0B6E7C; --ui-teal-ink: #FFFFFF; --ui-teal-wash: #E6F2F4;
  --ui-crit: #B23A2E; --ui-r: 6px;
}
html.dark {
  --ui-sheet: #15252A; --ui-ink: #E4EDEF; --ui-ink-2: #A9BCC2; --ui-mute: #7A9198;
  --ui-line: #26393F; --ui-teal: #4FB3C1; --ui-teal-ink: #06171C; --ui-teal-wash: #173B42; --ui-crit: #F08A7E;
}

/* ---------------------------------------------------------------- 1 surface */
html, body { max-width: 100%; overflow-x: clip; }
#root main.main-content {
  padding-left: calc(var(--page-gutter) + env(safe-area-inset-left, 0px));
  padding-right: calc(var(--page-gutter) + env(safe-area-inset-right, 0px));
  /* a flex item of #root: it takes all the room the sidebar leaves */
  flex: 1 1 0%;
  min-width: 0;
}
/* page wrappers: no box of their own, the main area's background shows through */
#root main.main-content :is(.rx-page, .rl, .rl-page, .rd-page, .rf-page, .rk-page, .sl-page, .rx-list) {
  max-width: none;
  padding-left: 0; padding-right: 0;
  margin-left: 0; margin-right: 0;
  background: transparent;
}
#root main.main-content .rx.rx-page { padding-top: 24px; padding-bottom: 24px; }
#root main.main-content > .rx.rx-list { padding-top: 0; }
/* Tailwind boxes inside pages */
#root main.main-content :is(.container, [class*="max-w-screen"], .max-w-7xl, .max-w-6xl, .max-w-5xl) { max-width: none; width: 100%; }

/* ---------------------------------------------------------------- 2 sidebar */
#root nav.header { width: calc(100% - var(--main-sidebar-width)); }
#root main.main-content { margin-left: var(--main-sidebar-width); }
#root .main-sidebar { translate: 0 0; }
.rx-side-backdrop { display: none; }
/* the toggle only exists where the sidebar can be put away */
@media (min-width: 1280px) { #customToggleMenue { display: none; } nav.header .header-container > div > .size-7:first-child { width: 0; overflow: hidden; } }
@media (min-width: 1024px) and (max-width: 1279.98px) {
  html.rx-side-collapsed #root .main-sidebar { translate: -100% 0; }
  html.rx-side-collapsed #root main.main-content { margin-left: 0; }
  html.rx-side-collapsed #root nav.header { width: 100%; }
}
@media (max-width: 1023.98px) {
  #root .main-sidebar { translate: -100% 0; z-index: 70; transition: translate .2s ease; }
  body.is-sidebar-open #root .main-sidebar { translate: 0 0; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  #root main.main-content { margin-left: 0; }
  #root nav.header { width: 100%; }
  .rx-side-backdrop { position: fixed; inset: 0; z-index: 65; background: rgba(20, 38, 44, .42); }
  body.is-sidebar-open .rx-side-backdrop { display: block; }
}
@media (prefers-reduced-motion: reduce) { #root .main-sidebar, #root main.main-content, #root nav.header { transition: none; } }
/* the header stays one line */
nav.header .header-container, nav.header .header-container > div { flex-wrap: nowrap; min-width: 0; }
nav.header .header-container .tb-actions { flex-wrap: nowrap; }
#customToggleMenue .menu-toggle { width: 40px; height: 40px; margin-left: -6px; }
nav.header .header-container > div > .size-7:first-child { width: 40px; height: 40px; }

/* ---------------------------------------------------------------- 3 content */
/* text never pushes a layout wider */
#root main.main-content :where(div, section, article, aside, form, li, dd, dt, label, fieldset, header, nav, figure, td, th) { min-width: 0; }
#root main.main-content :where(p, dd, li, h1, h2, h3, h4, .tn-sub, .rx-sub, .rd-meta, .rx-head-meta) { overflow-wrap: anywhere; }
#root main.main-content td { overflow-wrap: break-word; }
/* prose keeps a readable measure */
#root main.main-content :where(.rx-head-purpose, .rx-sec-hint, .rx-empty, .rd-panel-note, .rf-card-head p, .rl-empty, .rd-empty, .tn-empty, .rk-desc) { max-width: 75ch; }
/* images and charts */
#root main.main-content img { max-width: 100%; }
#root main.main-content img:not([class*="size-"]):not([class*="h-"]):not([height]):not(.tn-av):not(.rd-thumb img) { height: auto; }
#root main.main-content canvas { max-width: 100%; }
/* forms fill the width: 1 column on phones, 2 on laptops, 3-4 on big screens. The card grid
   (.rf-grid) keeps its two cards a row - the fields inside each card reflow. */
#root main.main-content :is(.rf-card-body.rf-cols-2, .rf-card-body.rf-cols-3, .sl-grid, .rx-form) {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 16px;
}
#root main.main-content :is(.rf-card-body, .rx-form, .sl-grid) :is(.rf-wide, .is-wide, .sl-wide, .rf-full) { grid-column: 1 / -1; }
.rx-drawer .rx-form { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
/* figure strips */
#root main.main-content :is(.rd-metrics, .rl-stats, .rx-figs, .rk-stats, .stat-grid) { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
/* the deal start: a two-column form and an aside from 1024px, stacked below */
#root main.main-content .sl-wizard { max-width: none; }
@media (min-width: 1024px) { .rx-wizard { grid-template-columns: minmax(0, 1fr) clamp(280px, 24vw, 380px); } }
/* record pages: rail 232px, content, aside; the aside drops below 1200px, the rail becomes a bar below 900px */
@media (min-width: 900px) and (max-width: 1199.98px) { .rd-body { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 899.98px) {
  .rx-record { grid-template-columns: 1fr; }
  .rx-rail { display: none; }
  .rx-progress { display: flex; flex-direction: column; gap: 8px; background: var(--rx-sheet); border: 1px solid var(--rx-line); border-radius: var(--rx-R); padding: 12px 16px; }
  .rx-progress-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
  .rx-progress .rx-bar { flex: none; width: 100%; }
}
/* dashboards: main chart and Needs attention side by side from 1100px */
@media (min-width: 1920px) { .rx-dash-body, .rx-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* tables: only the table scrolls, with a shadow at the edge that has more */
.rx-tscroll, #root main.main-content :is(.tn-scroll, .rk-scroll, .rx-table-wrap, .table-responsive, .is-scrollbar-hidden.min-w-full, .overflow-x-auto) {
  overflow-x: auto; max-width: 100%;
  background:
    linear-gradient(to right, var(--ui-sheet) 30%, transparent) left / 24px 100% no-repeat local,
    linear-gradient(to left, var(--ui-sheet) 30%, transparent) right / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(20, 38, 44, .14), transparent) left / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(20, 38, 44, .14), transparent) right / 10px 100% no-repeat scroll;
}
#root main.main-content table { width: 100%; }

/* list tables stack below 640px: the first column is the heading of each row */
@media (max-width: 639.98px) {
  #root main.main-content table.tn-table, #root main.main-content table.tn-table > tbody,
  #root main.main-content table.tn-table > tbody > tr, #root main.main-content table.tn-table > tbody > tr > td { display: block; width: 100%; }
  #root main.main-content table.tn-table > thead { display: none; }
  #root main.main-content table.tn-table > tbody > tr { padding: 10px 16px; border-bottom: 1px solid var(--ui-line); }
  #root main.main-content table.tn-table > tbody > tr > td { border: 0 !important; padding: 3px 0 !important; height: auto !important; text-align: left !important; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 0; white-space: normal; }
  #root main.main-content table.tn-table > tbody > tr > td[data-l]:not(:first-child)::before { content: attr(data-l); color: var(--ui-mute); font-size: 12px; font-weight: 500; flex: none; max-width: 45%; }
  #root main.main-content table.tn-table > tbody > tr > td:first-child { padding-bottom: 6px !important; }
  #root main.main-content table.tn-table > tbody > tr > td:empty, #root main.main-content table.tn-table > tbody > tr > td[data-empty] { display: none; }
  #root main.main-content table.tn-table > tbody > tr > td[colspan] { display: block; }
  #root main.main-content .tn-scroll { max-height: none; overflow: visible; background: none; }
  .rx-list .tn-table td:first-child { min-width: 0; }
}

/* filter bars wrap; on phones they fold behind a Filters button */
#root main.main-content :is(.tn-bar, .rk-gfilters, .rx-toolbar) { flex-wrap: wrap; }
.rx-filters-btn { display: none; }
@media (max-width: 639.98px) {
  .tn-bar .tn-search { flex: 1 1 100%; }
  .tn-bar .rx-filters-btn { display: inline-flex; }
  .tn-bar:not(.is-filters-open) > :is(.tn-field, .tn-range, .tn-apply, .tn-clear):not(.rx-filters-btn) { display: none; }
  .tn-bar.is-filters-open { background: var(--ui-sheet); box-shadow: 0 8px 24px rgba(20, 38, 44, .12); }
  .tn-bar.is-filters-open > :is(.tn-field, .tn-range) { flex: 1 1 100%; }
  .tn-bar.is-filters-open .tn-field select, .tn-bar.is-filters-open .tn-range input { width: 100%; }
}

/* dialogs and drawers fit the screen; full screen on phones */
:is(.rd-modal, .modal-content, .swal-modal, .rx-drawer) { max-width: calc(100vw - 32px); }
@media (max-width: 639.98px) {
  :is(.rd-modal, .rd-modal-wide) { width: 100vw; max-width: 100vw; min-height: 100dvh; border-radius: 0; margin: 0; }
  .rd-modal-wrap { padding: 0; align-items: stretch; }
  .rx-drawer { width: 100vw; max-width: 100vw; }
}

/* ---------------------------------------------------------------- 4 touch and type */
@media (max-width: 767.98px) {
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px !important; }
}

/* checkboxes, radios and switches take the accent */
#root :is(input[type=checkbox], input[type=radio], .form-checkbox, .form-radio, .form-switch) { accent-color: var(--ui-teal); }
html, body { accent-color: var(--ui-teal); }

/* ---------------------------------------------------------------- the owner portal
   Its own shell (owner-style.css): a fixed sidebar and a .main column. The
   column may not grow past the window, its sidebar becomes a drawer below
   1024px, and its tables scroll on their own. Its colours are its own. */
body > .main { min-width: 0; max-width: 100%; }
body > .main > .content { padding-left: var(--page-gutter); padding-right: var(--page-gutter); min-width: 0; max-width: none; }
body > .main .topbar { padding-left: var(--page-gutter); padding-right: var(--page-gutter); min-width: 0; flex-wrap: nowrap; }
body > .main .topbar-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body > .main :where(.card, .stat-card, .stats-grid > *, .charts-row > *, .tables-row > *, .bottom-row > *) { min-width: 0; }
body > .main .stats-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
@media (max-width: 1023.98px) {
  body > .sidebar { transform: translateX(-100%); }
  body > .sidebar.open { transform: translateX(0); }
  body > .main { margin-left: 0; }
  body > .main .hamburger { display: flex; width: 40px; height: 40px; }
  body > .main .topbar-search { display: none; }
}
@media (max-width: 639.98px) { body > .main .topbar-title span { display: none; } }

/* ---------------------------------------------------------------- sign-in page */
.lg-split > * { min-width: 0; }

/* ---------------------------------------------------------------- touch, everywhere
   On a phone or tablet every control and every link that stands on its own
   is at least 40px tall; a link inside a sentence is exempt. */
@media (max-width: 768px) {
  #root main.main-content :is(.tn-name, .rd-more, .rd-crumbs a, .rx-crumbs a, .rd-contact a, .rx-dash-meta a, .rx-seg a, .rx-seg button, .rd-facts dd > a, .rd-facts dd span > a, .rk-grp-btn, .tn-pager > *) {
    display: inline-flex; align-items: center; min-height: 40px;
  }
  #root main.main-content .rx-seg { overflow-x: auto; max-width: 100%; }
}
/* nothing smaller than 12px */
/* nothing smaller than 12px: the small-print classes that went below it */
:is(.rd-cap, .rf-hint, .rk-grp-txt span, .text-tiny, .text-tiny-plus, .tagline, .stat-label, .filter-label, .lg-wordmark span, .lg-foot, .lg-foot span, .lg-note, .badge, .tn-sub, .rx-sub) { font-size: 12px !important; }

/* ---------------------------------------------------------------- odds and ends found by the audit */
#root main.main-content :is(iframe, video, embed, object) { max-width: 100%; }
/* sortable headings show their whole word; the table scrolls instead */
#root main.main-content th { white-space: nowrap; }
#root main.main-content th .tn-sort > span { overflow: visible; text-overflow: clip; }
/* a wrapped line of blocker links: separate items, not one long inline run */
.rx-blockers-inline { display: flex; flex-wrap: wrap; gap: 2px 10px; }
@media (max-width: 768px) {
  /* a link standing on its own (in a list, a cell, a tile foot) is a 40px target */
  #root main.main-content :is(li, td, dd, .rx-tile-foot, .rx-sec-head, .rs-chips) > a[href]:not(:has(div, p, img, h1, h2, h3, h4, table)),
  #root main.main-content :is(.rx-sec-link, .rs-chip, .tn-sort, .gridjs-sort) { display: inline-flex; align-items: center; min-height: 40px; min-width: 24px; }
  #root main.main-content .gridjs-sort { min-width: 40px; }
  /* checkboxes and radios: 24px, the WCAG minimum for a target inside a row */
  #root :is(main, .rd-modal, .rx-drawer) :is(input[type=checkbox], input[type=radio]) { width: 24px; height: 24px; }
}
/* main is a grid: a child centred with auto margins would shrink to its content */
#root main.main-content > :where(div, section, form, article) { width: 100%; justify-self: stretch; }
@media (max-width: 768px) {
  #root main.main-content :is(.rd-meta a, .rx-blockers a, .rx-blockers-inline a) { display: inline-flex; align-items: center; min-height: 40px; }
}
/* on a phone two figures share a row, so a strip is not a long column */
@media (max-width: 639.98px) {
  #root main.main-content :is(.rd-metrics, .rl-stats, .rx-figs, .rk-stats, .stat-grid) { grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
}
@media (max-width: 899.98px) { #root main.main-content .rf-grid { grid-template-columns: minmax(0, 1fr); } #root main.main-content .rf-grid > .rf-half { grid-column: 1 / -1; } }

/* ---------------------------------------------------------------- the Portfolio dashboard (Overview)
   _admin_dash.php is the Overview again (v4): its own page box gives way to
   the one surface and gutter, like every other page. */
#root main.main-content #dashRoot { background: transparent; max-width: none; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
@media (max-width: 768px) { #dashRoot .bx-more { display: inline-flex; align-items: center; min-height: 40px; } }

/* v4: a link that is a paragraph on its own (Help troubleshooting, the sign-in
   page's help links) is a tap target in its own right on a phone */
@media (max-width: 768px) {
  .hc-body p > a:only-child, .hc-card p > a:only-child, main p > a:only-child, .lg-note > a { display: inline-flex; align-items: center; min-height: 40px; }
}
