/* Kestrelay overrides on the purchased admin theme.
   Kept in one file so a theme update can be dropped in without
   losing our changes, and so every deviation is visible in one place
   rather than buried in a 1MB stylesheet. */

/* Sign-in, before the shell exists. */
.gate {
  min-height: 100vh; display: grid; place-items: center;
  background: #f4f7f6; padding: 24px;
}
.gate-card {
  width: 100%; max-width: 24rem; background: #fff;
  border-radius: 14px; padding: 34px 32px;
  box-shadow: 0 12px 40px rgba(20, 40, 34, .08);
}
.gate-brand {
  display: flex; align-items: center; gap: 11px;
  font-size: 19px; font-weight: 500; color: #1e2b26;
}
.gate-brand b { font-weight: 700; }
.gate-sub { margin: 6px 0 26px; color: #7b8a84; font-size: 13.5px; }
.gate-foot { margin: 18px 0 0; font-size: 12px; color: #98a6ad;
  text-align: center; }

/* The theme's sidebar carries a profile block with follower counts.
   This is a control plane, so the space goes to navigation. */
.main-nav .sidebar-user { display: none; }
.main-nav .nav-menu { padding-top: 18px; }

.hdr-who { color: #7b8a84; font-size: 13px; }
.hdr-who b { color: #1e2b26; font-weight: 600; }

/* Counts sit beside the nav label, so an unhandled enquiry is
   visible without opening the section. */
.nav-count {
  margin-left: auto; background: #0F6E56; color: #fff;
  border-radius: 20px; padding: 1px 8px;
  font-size: 11px; font-weight: 600; line-height: 1.6;
}
.nav-count.zero { display: none; }
.nav-menu li a { display: flex; align-items: center; }

/* Numbers are read down a column and compared, so they are tabular
   and right aligned. Proportional digits make that harder than it
   needs to be. */
.num, td.num, th.num {
  font-variant-numeric: tabular-nums; text-align: right;
  white-space: nowrap;
}
.sub { display: block; color: #98a6ad; font-size: 12px; }
.empty { color: #98a6ad; padding: 26px 0; text-align: center; }
.card .card-header { padding: 22px 26px; }
.card .card-header h5 { font-size: 16px; }
.table td, .table th { vertical-align: middle; }
.state {
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; padding: 3px 9px; border-radius: 20px;
}
.state.ok { background: #e4f1ec; color: #0F6E56; }
.state.warn { background: #fdf1e0; color: #ba7517; }
.state.bad { background: #fbeceb; color: #d22d3d; }

/* Sidebar items.
   The theme draws the active item as a full-bleed filled block with
   no gap, so two adjacent items touch and a hover on the neighbour
   reads as one merged shape. Each item gets its own inset pill. */
.main-nav .nav-menu > li.dropdown {
  margin: 3px 14px;
}
.main-nav .nav-menu > li.dropdown > a.nav-link {
  border-radius: 9px;
  padding: 11px 14px;
  margin: 0;
  transition: background .15s ease, color .15s ease;
}
.main-nav .nav-menu > li.dropdown > a.nav-link:hover {
  background: #eef4f2;
  color: #0F6E56;
}
.main-nav .nav-menu > li.dropdown.active > a.nav-link,
.main-nav .nav-menu > li.dropdown > a.nav-link.active {
  background: #0F6E56;
  color: #fff;
}
.main-nav .nav-menu > li.dropdown > a.nav-link svg {
  width: 17px; height: 17px; margin-right: 11px;
}
.main-nav .nav-menu > li.dropdown.active > a.nav-link svg,
.main-nav .nav-menu > li.dropdown > a.nav-link.active svg {
  stroke: #fff;
}
.main-nav .sidebar-main-title h6 {
  color: #0F6E56; font-size: 12px; letter-spacing: .08em;
  text-transform: uppercase; margin: 0;
}
.main-nav .sidebar-main-title > div {
  padding: 4px 14px 12px; border-bottom: 1px solid #eef1f0;
  margin: 0 14px 10px;
}

/* Collapsed sidebar: icons only, still clickable.
   Hiding the sidebar entirely wastes the toggle, because the whole
   point is to keep navigation reachable while giving a wide table
   room to breathe. */
.page-wrapper.compact-wrapper.nav-rail .page-body-wrapper header.main-nav { width: 78px; }
.page-wrapper.compact-wrapper.nav-rail .page-body-wrapper .page-body,
.page-wrapper.compact-wrapper.nav-rail .page-body-wrapper .footer { margin-left: 78px; }

.page-wrapper.compact-wrapper.nav-rail .page-body-wrapper header.main-nav .nav-menu > li.dropdown { margin: 3px 12px; }
.page-wrapper.compact-wrapper.nav-rail .page-body-wrapper header.main-nav .nav-menu > li.dropdown > a.nav-link {
  padding: 12px 0;
  justify-content: center;
}
.page-wrapper.compact-wrapper.nav-rail .page-body-wrapper header.main-nav .nav-menu > li.dropdown > a.nav-link svg {
  margin-right: 0;
}
.page-wrapper.compact-wrapper.nav-rail .page-body-wrapper header.main-nav .nav-menu > li.dropdown > a.nav-link span {
  display: none;
}
.page-wrapper.compact-wrapper.nav-rail .page-body-wrapper header.main-nav .sidebar-main-title { display: none; }
/* The unread badge still has to be visible on the rail, so it moves
   onto the icon rather than sitting beside a label that is gone. */
.page-wrapper.compact-wrapper.nav-rail .page-body-wrapper header.main-nav .nav-count {
  position: absolute; top: 4px; right: 10px;
  margin: 0; padding: 0 5px; font-size: 10px;
}
.page-wrapper.compact-wrapper.nav-rail .page-body-wrapper header.main-nav .nav-menu > li.dropdown { position: relative; }
@media (max-width: 991px) {
  .page-wrapper.compact-wrapper.nav-rail .page-body-wrapper .page-body,
  .page-wrapper.compact-wrapper.nav-rail .page-body-wrapper .footer { margin-left: 0; }
}

/* The toggle is an icon in a div, so it needs to look and behave like
   a control rather than decoration. */
.toggle-sidebar {
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  transition: background .15s ease;
}
.toggle-sidebar:hover { background: #eef4f2; }
.toggle-sidebar svg { stroke: #0F6E56; width: 20px; height: 20px; }

/* The header's logo block matches the sidebar width, so it narrows
   with the rail. Swapping to the mark rather than squeezing the
   wordmark, which just distorts it. */
.logo-mark { display: none; }
.page-wrapper.compact-wrapper.nav-rail .page-main-header
  .main-header-right .main-header-left { width: auto; gap: 14px; }
.page-wrapper.compact-wrapper.nav-rail .logo-full { display: none; }
.page-wrapper.compact-wrapper.nav-rail .logo-mark { display: block; }

/* ---- Mobile ----
   The theme narrows the sidebar to 120px below 992px but leaves the
   page body offset by 290px, which is why content sat off-screen and
   the page had to be dragged sideways.
   Below 992px the sidebar becomes a drawer over the content and the
   body takes the full width. */
@media (max-width: 991px) {
  .page-wrapper.compact-wrapper .page-body-wrapper header.main-nav {
    width: 260px !important;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 12;
  }
  .page-wrapper.nav-open .page-body-wrapper header.main-nav {
    transform: translateX(0);
  }
  .page-wrapper.compact-wrapper .page-body-wrapper .page-body,
  .page-wrapper.compact-wrapper .page-body-wrapper .footer {
    margin-left: 0 !important;
  }
}

@media (max-width: 991px) {
  /* The rail is a desktop idea: a 78px strip permanently eating a
     phone screen helps nobody, and carrying the desktop preference
     over would leave the drawer stuck at rail width. */
  .page-wrapper.compact-wrapper.nav-rail .page-body-wrapper
    header.main-nav { width: 260px !important; }
  .page-wrapper.compact-wrapper.nav-rail .page-body-wrapper
    header.main-nav .nav-menu > li.dropdown > a.nav-link {
    padding: 11px 14px;
    justify-content: flex-start;
  }
  .page-wrapper.compact-wrapper.nav-rail .page-body-wrapper
    header.main-nav .nav-menu > li.dropdown > a.nav-link span {
    display: inline;
  }
  .page-wrapper.compact-wrapper.nav-rail .page-body-wrapper
    header.main-nav .nav-menu > li.dropdown > a.nav-link svg {
    margin-right: 11px;
  }
  .page-wrapper.compact-wrapper.nav-rail .page-body-wrapper
    header.main-nav .sidebar-main-title { display: block; }
  .page-wrapper.compact-wrapper.nav-rail .logo-full { display: block; }
  .page-wrapper.compact-wrapper.nav-rail .logo-mark { display: none; }
}

@media (max-width: 991px) {
  /* The header block is sized for a 290px sidebar that is no longer
     beside it, so it takes only the room the logo needs. */
  .page-main-header .main-header-right .main-header-left {
    width: auto !important;
    gap: 14px;
  }
  .nav-scrim {
    position: fixed; inset: 65px 0 0;
    background: rgba(12, 24, 20, .4);
    z-index: 11; opacity: 0; pointer-events: none;
    transition: opacity .25s ease;
  }
  .page-wrapper.nav-open .nav-scrim {
    opacity: 1; pointer-events: auto;
  }
}

/* A wide table scrolls inside its own container rather than moving
   the whole page. */
html, body { overflow-x: hidden; }

/* ---- Tables on a phone ----
   An eight column table cannot be read by dragging it sideways, so
   below 768px each row restacks as a labelled block. The column name
   comes from data-label, set where the row is built. */
@media (max-width: 767px) {
  .table.stacked thead { display: none; }
  .table.stacked tbody tr {
    display: block;
    padding: 14px 4px;
    border-bottom: 1px solid #eef1f0;
  }
  .table.stacked tbody tr:last-child { border-bottom: 0; }
  .table.stacked tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    width: 100%;
    border: 0 !important;
    padding: 4px 0 !important;
    text-align: right;
  }
}

@media (max-width: 767px) {
  .table.stacked tbody td::before {
    content: attr(data-label);
    color: #98a6ad;
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    flex: none;
  }
  /* The first cell is the row's identity, so it reads as a heading
     rather than as another label and value pair. */
  .table.stacked tbody td:first-child {
    display: block;
    text-align: left;
    margin-bottom: 6px;
  }
  .table.stacked tbody td:first-child::before { display: none; }
  .table.stacked tbody td .progress {
    flex: 1;
    max-width: 120px;
    margin-left: 12px;
  }
}

/* A hidden badge stays hidden whatever a layout rule does to it. */
.nav-count[hidden] { display: none !important; }

@media (max-width: 991px) {
  /* On a phone the drawer always shows labels, so the badge sits
     beside the label as normal rather than pinned to an icon it is
     no longer sharing space with. */
  .page-wrapper.compact-wrapper.nav-rail .page-body-wrapper
    header.main-nav .nav-count {
    position: static;
    margin-left: auto;
    padding: 1px 8px;
    font-size: 11px;
  }
}

/* The body sits inside a 290px left margin, so any child wider than
   the remaining space pushes the whole page sideways and takes the
   fixed header with it. Clipping here means a wide table scrolls in
   its own container, which is what table-responsive is for. */
.page-wrapper .page-body-wrapper .page-body { overflow-x: hidden; }
.page-body .container-fluid { max-width: 100%; }

/* Back is a navigation control, not a warning. The theme's secondary
   outline renders tan, which reads as caution next to a red action. */
.btn-outline-secondary {
  border-color: #d7dcda;
  color: #57605c;
}
.btn-outline-secondary:hover {
  background: #f2f5f4;
  border-color: #b9c2be;
  color: #1e2b26;
}

/* A row that opens something should say so before it is clicked. */
.table tbody tr[style*="cursor"] { transition: background .12s ease; }
.table tbody tr[style*="cursor"]:hover { background: #f4f8f6; }

/* Header controls. */
.hdr-icon {
  background: none; border: 0; padding: 8px; border-radius: 8px;
  color: #57605c; display: inline-flex; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.hdr-icon:hover { background: #eef4f2; color: #0F6E56; }
.hdr-icon svg { width: 18px; height: 18px; }
body.dark-only .hdr-icon { color: #b8c1bd; }
body.dark-only .hdr-icon:hover { background: rgba(255,255,255,.06); }

/* Search overlay. */
.finder {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(12,24,20,.45);
  display: flex; justify-content: center;
  padding: 12vh 20px 20px;
}
.finder-box {
  width: 100%; max-width: 40rem; background: #fff;
  border-radius: 12px; padding: 20px;
  box-shadow: 0 20px 60px rgba(12,24,20,.28);
  max-height: 70vh; overflow: auto;
}
body.dark-only .finder-box { background: #232c37; }
.find-row {
  display: flex; gap: 12px; align-items: center;
  padding: 11px 8px; border-radius: 8px; cursor: pointer;
}
.find-row:hover { background: #f2f6f4; }
body.dark-only .find-row:hover { background: rgba(255,255,255,.05); }
.find-row .kind {
  font-size: 11px; color: #8b938e; margin-left: auto;
}

/* ---- Dark mode repairs ----
   The sections set a few colours inline, which cannot respond to a
   theme class. These become variables so one definition covers both
   modes instead of every call site guessing. */
:root {
  --kr-hair: #eef1f0;
  --kr-tint: #f5f8f7;
  --kr-tint2: #f8faf9;
  --kr-edge: #e1e9e6;
}
body.dark-only {
  --kr-hair: rgba(255, 255, 255, .09);
  --kr-tint: rgba(255, 255, 255, .04);
  --kr-tint2: rgba(255, 255, 255, .03);
  --kr-edge: rgba(255, 255, 255, .10);
}

body.dark-only .gate { background: #1d2531; }
body.dark-only .gate-card { background: #232c37; }
body.dark-only .gate-brand { color: #e6ebe9; }

/* The header identity was set for a light bar and disappears on a
   dark one. */
body.dark-only .hdr-who { color: #98a6ad; }
body.dark-only .hdr-who b { color: #e6ebe9; }

body.dark-only .main-nav .sidebar-main-title > div,
body.dark-only .table.stacked tbody tr {
  border-color: var(--kr-hair);
}

/* Settings and client forms use tinted callouts, which were built
   for the light theme only. */
body.dark-only .field-group {
  background: var(--kr-tint);
  border-left-color: #2FA07C;
}
body.dark-only .field-group h4 { color: #e6ebe9; }
body.dark-only .group-note,
body.dark-only .sub { color: #98a6ad; }
body.dark-only .empty { color: #8b938e; }
body.dark-only .state.ok { background: rgba(47,160,124,.16); }
body.dark-only .state.warn { background: rgba(186,117,23,.18); }
body.dark-only .state.bad { background: rgba(210,45,61,.18); }

/* The wordmark is dark ink on a light bar, so it vanishes in dark
   mode. Two files rather than a CSS filter: a filter would tint the
   teal tile along with the text. */
.logo-full-dark { display: none; }
body.dark-only .logo-full { display: none; }
body.dark-only .logo-full-dark { display: block; }

/* The theme hides .logo-wrapper wholesale in dark mode and expects a
   separate .dark-logo-wrapper element. We swap the image instead, so
   that rule has to be reversed or the header is simply empty. */
body.dark-only .page-main-header .main-header-right .main-header-left
  .logo-wrapper {
  display: block;
}
/* On the rail only the mark shows, in either mode. */
.page-wrapper.compact-wrapper.nav-rail .logo-full-dark {
  display: none !important;
}

/* The collapse control sits on the same bar as the logo. */
body.dark-only .toggle-sidebar:hover {
  background: rgba(255, 255, 255, .07);
}
body.dark-only .toggle-sidebar svg { stroke: #2FA07C; }
