html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

body {
  background-color: #f8f9fa;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ── The shell ──────────────────────────────────────────────────────────────
   A sidebar beside the content, which below the lg breakpoint becomes a drawer
   (Bootstrap's offcanvas-lg) with a slim bar to open it. */

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  background: #fff;
  border-bottom: 1px solid #dee2e6;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.app-menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.app-topbar-brand {
  font-weight: 600;
  color: #212529;
  text-decoration: none;
}

.app-sidebar {
  background: #fff;
  border-right: 1px solid #dee2e6;
}

.app-sidebar-body {
  display: flex;
  flex-direction: column;
}

.app-brand {
  display: block;
  font-size: 1.05rem;
  font-weight: 600;
  color: #212529;
  text-decoration: none;
  padding: .35rem .75rem 1rem;
}

.app-org {
  padding: 0 .75rem .75rem;
  margin-bottom: .25rem;
  border-bottom: 1px solid #e9ecef;
}

.app-org-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6c757d;
  margin-bottom: .2rem;
}

.app-org-name {
  font-weight: 600;
  font-size: .9rem;
  color: #212529;
}

.app-nav-link {
  color: #343a40;
  border-radius: .375rem;
  padding: .45rem .75rem;
  /* The sign-out control is a button so it can post; make it match the links beside it. */
  background: none;
  border: 0;
  width: 100%;
  text-align: left;
}

.app-nav-link:hover,
.app-nav-link:focus {
  background-color: #eef1f4;
  color: #0d6efd;
}

.app-nav-link.active {
  background-color: #e7f1ff;
  color: #0d6efd;
  font-weight: 600;
}

.app-nav-divider {
  border-top: 1px solid #e9ecef;
  margin: .5rem .25rem;
}

.app-sidebar-footer {
  border-top: 1px solid #e9ecef;
  padding-top: .5rem;
  margin-top: 1rem;
}

.app-user {
  padding: .25rem .75rem .35rem;
}

.app-user-name {
  font-size: .85rem;
  color: #6c757d;
}

.app-content {
  display: flex;
  flex-direction: column;
  /* Without this a wide table stretches the flex item instead of scrolling inside it,
     and the whole page ends up scrolling sideways. */
  min-width: 0;
  flex: 1 1 auto;
}

.app-main {
  flex: 1 1 auto;
  padding: 1.25rem 1rem 2rem;
  /* Same reason as above: this is a flex child too. */
  min-width: 0;
}

.app-footer {
  border-top: 1px solid #dee2e6;
  padding: .75rem 1rem;
  font-size: .85rem;
}

/* Signed out: no navigation to show, so the page simply centres itself. */
.app-main-plain {
  padding: 3rem 1rem;
}

@media (min-width: 992px) {
  .app-shell {
    flex-direction: row;
  }

  .app-sidebar {
    flex: 0 0 240px;
    width: 240px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }

  .app-sidebar-body {
    /* Pushes the account block to the bottom of a tall sidebar. */
    height: 100%;
  }

  .app-sidebar-footer {
    margin-top: auto;
  }

  .app-main {
    padding: 1.5rem 1.75rem 2.5rem;
  }
}

/* ── Phone sizing ───────────────────────────────────────────────────────────
   Bootstrap handles most of this. What it does not do is stop a table from
   forcing the page sideways, or keep a row of tiles readable once each is a
   sixth of a phone wide. */

@media (max-width: 575.98px) {
  .app-main h1 {
    font-size: 1.5rem;
  }

  /* Tiles and ageing buckets are laid out with .row > .col, which keeps dividing
     the width no matter how narrow it gets. Two per row reads; six does not. */
  .row-tiles > .col {
    flex: 0 0 50%;
    max-width: 50%;
  }

  /* A right-aligned button next to a heading wraps under it rather than
     squeezing the heading to one word per line. */
  .app-main .d-flex.justify-content-between {
    flex-wrap: wrap;
    gap: .5rem;
  }

  .table {
    font-size: .875rem;
  }

  /* Left to itself a table squeezes its columns to fit, turning "01 Aug 2026" into three
     stacked lines. Giving it a floor makes the wrapper scroll instead, which keeps every
     row readable — the page still does not move sideways, only the table box does. */
  .table-responsive > .table {
    min-width: 34rem;
  }
}

/* Any table wide enough to need it scrolls within its own box. The page itself
   must never scroll sideways. */
.table-responsive {
  -webkit-overflow-scrolling: touch;
}
