/**
 * Livestock & Poultry module shell — extends Keystone theme tokens.
 */

html.theme-keystone .module-shell {
  display: flex;
  min-height: 100vh;
}

html.theme-keystone .module-rail {
  width: var(--sidebar-width, 280px);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-right: 1px solid var(--border);
}

html.theme-keystone .rail-brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.25;
  color: var(--text-light);
}

html.theme-keystone .module-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
}

html.theme-keystone .module-nav-link {
  text-decoration: none;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

html.theme-keystone .module-nav-link:hover {
  background: rgba(67, 97, 238, 0.12);
  color: var(--text-light);
}

html.theme-keystone .module-nav-link--active {
  background: rgba(67, 97, 238, 0.22);
  border-left: 3px solid var(--primary-light);
  margin-left: -2px;
  padding-left: 9px;
  color: #fff;
}

html.theme-keystone .nav-ico {
  display: inline-flex;
  font-style: normal;
  min-width: 1.45rem;
  justify-content: center;
}

html.theme-keystone .module-main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--dark);
}

html.theme-keystone .module-bar {
  padding: 14px 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 14px;
  background: rgba(15, 23, 42, 0.92);
  border-bottom: 1px solid var(--border);
}

html.theme-keystone .seg-strong {
  color: var(--text-muted);
  margin-right: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

html.theme-keystone .seg-bar {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
}

html.theme-keystone .seg-bar a {
  font-size: 0.86rem;
  color: var(--text-light);
  background: rgba(67, 97, 238, 0.18);
  border-radius: 999px;
  padding: 7px 16px;
  text-decoration: none;
  border: 1px solid rgba(148, 163, 184, 0.35);
  line-height: 1.2;
  transition: border-color 0.15s, box-shadow 0.15s;
}

html.theme-keystone .seg-bar a:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.15);
}

html.theme-keystone .module-main {
  padding: 22px 24px 48px;
  color: var(--text-dark);
}

html.theme-keystone .module-main h1,
html.theme-keystone .module-main h2,
html.theme-keystone .module-main h3 {
  color: var(--text-light);
}

html.theme-keystone .module-main p,
html.theme-keystone .module-main li,
html.theme-keystone .module-main td,
html.theme-keystone .module-main dd {
  color: var(--text-dark);
}

html.theme-keystone .module-bar .seg-strong {
  color: #e2e8f0;
}

html.theme-keystone .lang-switch {
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--text-muted);
}

html.theme-keystone .lang-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

html.theme-keystone .lang-switch a:hover {
  text-decoration: underline;
}

/* Flash alerts */
html.theme-keystone .flash {
  padding: 14px 22px;
  margin: 0 22px 0;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
}

html.theme-keystone .flash-success {
  background: rgba(67, 170, 139, 0.14);
  border: 1px solid rgba(67, 170, 139, 0.45);
  color: #bbf7d0;
}

html.theme-keystone .flash-danger {
  background: rgba(249, 65, 68, 0.12);
  border: 1px solid rgba(249, 65, 68, 0.4);
  color: #fecaca;
}

/* KPI dashboard grid */
.ls-kpi-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.ls-kpi-card {
  background: var(--card-bg);
  border: var(--border-light);
  border-radius: var(--radius);
  padding: 16px 18px;
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-sm);
}

.ls-kpi-card.ls-kpi-accent-warn {
  border-left-color: var(--warning);
}

.ls-kpi-card.ls-kpi-accent-danger {
  border-left-color: var(--danger);
}

.ls-kpi-card.ls-kpi-accent-info {
  border-left-color: var(--info);
}

.ls-kpi-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}

.ls-kpi-value {
  font-size: 1.42rem;
  font-weight: 700;
  color: var(--text-light);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.ls-kpi-sub {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* AJAX operational dashboard */
html.theme-keystone .ls-dashboard-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px 18px;
  margin-bottom: 14px;
}

html.theme-keystone .ls-dashboard-head-text h2 {
  margin: 0 0 8px;
  color: var(--text-light);
}

html.theme-keystone .ls-dashboard-status {
  margin: 6px 0 0;
  font-variant-numeric: tabular-nums;
  color: #e2e8f0;
}

html.theme-keystone .ls-dashboard-refresh {
  flex-shrink: 0;
  min-height: 44px;
  padding: 10px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-light);
  border-radius: var(--ls-radius-control, 14px);
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

html.theme-keystone .ls-dashboard-refresh:hover {
  border-color: rgba(52, 211, 153, 0.55);
  background: rgba(67, 97, 238, 0.18);
}

html.theme-keystone .ls-dashboard-error {
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: var(--ls-radius-control, 14px);
  font-size: 0.9rem;
  background: rgba(249, 65, 68, 0.12);
  border: 1px solid rgba(249, 65, 68, 0.4);
  color: #fecaca;
}

html.theme-keystone .ls-dashboard--loading .ls-kpi-value {
  opacity: 0.42;
  transition: opacity 0.2s ease;
}

/* Nested cards on dashboard — soften double border */
.ls-kpi-grid .card {
  margin-bottom: 0;
}

/* Reports & data tables */
.ls-report-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

.ls-report-wrap table,
.card table {
  font-size: 0.9rem;
}

.card table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card table tbody tr:hover {
  background: rgba(67, 97, 238, 0.06);
}

.badge,
span.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-open {
  background: rgba(39, 125, 161, 0.25);
  color: #bae6fd;
}

.badge-alert {
  background: rgba(249, 65, 68, 0.2);
  color: #fecaca;
}

.badge-ok {
  background: rgba(67, 170, 139, 0.22);
  color: #bbf7d0;
}

.mini {
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

button[type="submit"],
button {
  border-radius: var(--radius-sm);
  transition: transform 0.12s, box-shadow 0.12s;
}

button[type="submit"]:hover {
  transform: translateY(-1px);
  box-shadow: var(--glow);
}

/* Login page (Keystone auth) */
.ls-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(5, 150, 105, 0.35), transparent),
    linear-gradient(165deg, var(--darker) 0%, var(--dark) 45%, #0f172a 100%);
}

/* Data-entry forms: readable labels, no wasted horizontal stretch, mobile-friendly taps */
html.theme-keystone .ls-form {
  max-width: min(36rem, 100%);
}

html.theme-keystone .ls-form--wide {
  max-width: min(56rem, 100%);
}

html.theme-keystone .ls-form-grid {
  display: grid;
  gap: 14px 16px;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 640px) {
  html.theme-keystone .ls-form-grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

html.theme-keystone .ls-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

html.theme-keystone .ls-field--full {
  grid-column: 1 / -1;
}

html.theme-keystone .ls-field--actions {
  grid-column: 1 / -1;
  margin-top: 4px;
}

html.theme-keystone .ls-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #f8fafc;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

html.theme-keystone .ls-form .ls-input,
html.theme-keystone .ls-form input.ls-input,
html.theme-keystone .ls-form select.ls-input {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 1rem;
}

html.theme-keystone .ls-field--actions button[type='submit'],
html.theme-keystone .ls-field--actions button {
  width: 100%;
  min-height: 46px;
  padding: 12px 18px;
  font-size: 1rem;
}

@media (min-width: 640px) {
  html.theme-keystone .ls-field--actions button[type='submit'],
  html.theme-keystone .ls-field--actions button {
    width: auto;
    min-width: 11rem;
  }
}

/* Softer corners — livestock module (inputs, buttons, cards, chips) */
html.theme-keystone {
  --ls-radius-control: 14px;
}

html.theme-keystone .module-main .card {
  border-radius: 18px;
}

html.theme-keystone .module-main input:not([type='checkbox']):not([type='radio']):not([type='file']),
html.theme-keystone .module-main select,
html.theme-keystone .module-main textarea {
  border-radius: var(--ls-radius-control, 14px) !important;
}

html.theme-keystone .module-main button[type='submit'],
html.theme-keystone .module-main button:not(.module-nav-link):not(.seg-bar a),
html.theme-keystone .module-main .btn,
html.theme-keystone .module-main .badge {
  border-radius: var(--ls-radius-control, 14px);
}

html.theme-keystone .module-main table button[type='submit'],
html.theme-keystone .module-main table button {
  border-radius: var(--ls-radius-control, 14px);
}

html.theme-keystone .ls-kpi-card {
  border-radius: 18px;
}

html.theme-keystone .ls-report-wrap {
  border-radius: 14px;
}

html.theme-keystone .ls-form .ls-input,
html.theme-keystone .ls-form input.ls-input,
html.theme-keystone .ls-form select.ls-input {
  border-radius: var(--ls-radius-control, 14px) !important;
}

/* Filter / toolbar forms (reports, audit): horizontal on wide screens, wrap on narrow */
html.theme-keystone .ls-form--toolbar {
  max-width: min(52rem, 100%);
}

html.theme-keystone .ls-form--compact {
  max-width: none;
}

html.theme-keystone .ls-form-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 14px;
  align-items: flex-end;
}

html.theme-keystone .ls-form-toolbar .ls-field {
  flex: 1 1 11rem;
  min-width: 0;
}

html.theme-keystone .ls-form-toolbar .ls-field--shrink {
  flex: 0 1 10rem;
}

html.theme-keystone .ls-form-toolbar .ls-field--fit {
  flex: 0 0 auto;
}

html.theme-keystone .ls-form-toolbar .ls-field--grow {
  flex: 1 1 12rem;
  min-width: 0;
}

html.theme-keystone .ls-form-toolbar a.mini {
  align-self: center;
  padding: 10px 4px;
}

html.theme-keystone .ls-form-toolbar .ls-input,
html.theme-keystone .ls-form-toolbar input.ls-input,
html.theme-keystone .ls-form-toolbar select.ls-input {
  min-height: 44px;
}

@media (min-width: 960px) {
  html.theme-keystone .ls-form-grid--5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

html.theme-keystone .ls-sale-line {
  margin-top: 10px;
  padding: 12px 12px 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(244, 114, 182, 0.35);
  background: rgba(15, 23, 42, 0.45);
}

html.theme-keystone .ls-sale-line:first-child {
  margin-top: 0;
}

html.theme-keystone .pos-sale-lines-title {
  color: var(--text-light, #f8fafc);
}

html.theme-keystone .pos-sale-lines-add {
  margin: 10px 0 6px;
}

html.theme-keystone .pos-add-sale-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm, 10px);
  border: 1px dashed rgba(244, 114, 182, 0.45);
  background: rgba(67, 97, 238, 0.12);
  color: var(--text-light, #f8fafc);
}

html.theme-keystone .pos-add-sale-line--round {
  border-style: solid;
  border-color: rgba(244, 114, 182, 0.5);
}

html.theme-keystone .pos-add-sale-line:hover {
  border-style: solid;
  background: rgba(67, 97, 238, 0.22);
}

/* POS toolbar + dynamic lines (any theme) */
.pos-sale-lines-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 8px;
}

.pos-sale-lines-title {
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.92;
}

.pos-add-sale-line--round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  padding: 0;
  border-radius: 50%;
  font: inherit;
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.04);
  color: inherit;
}

.pos-sale-lines .pos-line-remove-wrap {
  display: none;
}

.pos-sale-lines--multiple .pos-line-remove-wrap {
  display: block;
}

html.theme-keystone .pos-remove-sale-line {
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  padding: 4px 0;
  border: none;
  background: none;
  color: rgba(248, 113, 113, 0.95);
  text-decoration: underline;
}

html.theme-keystone .pos-line-remove-wrap {
  margin-top: 4px;
}

/* ------------------------------------------------------------------------- */
/* App shell — cream panel nav on dark chrome (mobile bottom bar + drawer)   */
/* ------------------------------------------------------------------------- */
html.theme-keystone {
  --ls-cream: #fdf8e9;
  --ls-cream-deep: #f5ecd8;
  --ls-navy: #0f172a;
  --ls-nav-pill: #1e293b;
  --ls-section-blue: #4361ee;
}

html.theme-keystone.ls-no-scroll {
  overflow: hidden;
}

html.theme-keystone body.ls-no-scroll {
  overflow: hidden;
}

html.theme-keystone .ls-shell.module-shell {
  position: relative;
  min-height: 100vh;
}

/* Mobile: stack top bar + main under each other (row default would squeeze content sideways). */
@media (max-width: 960px) {
  html.theme-keystone .ls-shell.module-shell {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
}

/* Section labels (Overview / Farm …) */
html.theme-keystone .ls-nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ls-section-blue);
  margin: 16px 0 8px 4px;
  padding-left: 12px;
  border-left: 3px solid var(--ls-section-blue);
  line-height: 1.2;
}

html.theme-keystone .ls-nav-section:first-of-type .ls-nav-section-label {
  margin-top: 6px;
}

html.theme-keystone .ls-nav-section {
  margin-bottom: 4px;
}

/* ---- Desktop: inset cream rail ------------------------------------------------ */
@media (min-width: 961px) {
  html.theme-keystone .ls-top-bar,
  html.theme-keystone .ls-bottom-nav,
  html.theme-keystone .ls-fab {
    display: none !important;
  }

  html.theme-keystone .ls-drawer-backdrop {
    display: none !important;
  }

  html.theme-keystone .module-rail.ls-rail {
    background: var(--ls-cream);
    border-right: none;
    border-radius: 0 22px 22px 0;
    margin: 14px 0 14px 14px;
    padding: 22px 14px 18px;
    box-shadow: 6px 4px 28px rgba(15, 23, 42, 0.18);
    width: min(var(--sidebar-width, 280px), 92vw);
    align-self: stretch;
    max-height: calc(100vh - 28px);
    overflow: auto;
  }

  html.theme-keystone .rail-brand.ls-rail-brand {
    color: var(--ls-navy);
    font-size: 1.02rem;
    padding-bottom: 0;
    margin-bottom: 0;
    border-bottom: none;
  }

  html.theme-keystone .ls-rail .module-nav-link {
    color: #334155;
    border-radius: 14px;
    padding: 11px 14px;
    border-left: none !important;
    margin-left: 0 !important;
  }

  html.theme-keystone .ls-rail .module-nav-link:hover {
    background: rgba(67, 97, 238, 0.12);
    color: var(--ls-navy);
  }

  html.theme-keystone .ls-rail .module-nav-link--active {
    background: var(--ls-nav-pill);
    color: #fff !important;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.28);
  }

  html.theme-keystone .ls-rail-footer {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(30, 41, 59, 0.12);
    font-size: 0.84rem;
    color: #64748b;
  }

  html.theme-keystone .ls-rail-lang a,
  html.theme-keystone .ls-rail-logout {
    color: #475569;
  }

  html.theme-keystone .ls-rail .lang-switch {
    color: #64748b;
  }

  html.theme-keystone .ls-sheet-handle {
    display: none;
  }

  html.theme-keystone .ls-rail-brand-block {
    margin-bottom: 4px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(30, 41, 59, 0.1);
  }

  html.theme-keystone .ls-rail-tagline {
    font-size: 0.82rem;
    color: #64748b;
    margin: 6px 0 0;
    line-height: 1.4;
    font-weight: 500;
  }
}

/* ---- Mobile chrome ----------------------------------------------------------- */
@media (max-width: 960px) {
  html.theme-keystone .ls-top-bar {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: nowrap;
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    background: rgba(15, 23, 42, 0.97);
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
    position: sticky;
    top: 0;
    z-index: 90;
    min-height: 56px;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
  }

  html.theme-keystone .ls-top-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(30, 41, 59, 0.65);
    color: #f8fafc;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  html.theme-keystone .ls-top-center {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  html.theme-keystone .ls-top-brand {
    font-weight: 700;
    font-size: 0.82rem;
    color: #f1f5f9;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  html.theme-keystone .ls-top-user-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }

  html.theme-keystone .ls-role-pill {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #94a3b8;
  }

  html.theme-keystone .ls-user-pill {
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(67, 97, 238, 0.42);
    border: 1px solid rgba(129, 140, 248, 0.55);
    color: #e0e7ff;
    font-weight: 600;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html.theme-keystone .ls-top-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
  }

  html.theme-keystone .ls-theme-dots {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 5px;
    max-width: 120px;
  }

  html.theme-keystone .ls-theme-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    background: var(--dot, #64748b);
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
  }

  html.theme-keystone .ls-theme-dot:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  html.theme-keystone .ls-top-lang {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 600;
  }

  html.theme-keystone .ls-top-lang a {
    color: #94a3b8;
    text-decoration: none;
    padding: 4px 6px;
    border-radius: 8px;
  }

  html.theme-keystone .ls-top-lang a.is-active {
    color: #f8fafc;
    background: rgba(67, 97, 238, 0.35);
  }

  html.theme-keystone .ls-top-lang-sep {
    opacity: 0.45;
    color: #64748b;
  }

  html.theme-keystone .ls-top-logout {
    color: #94a3b8;
    text-decoration: none;
    font-size: 1.1rem;
    padding: 6px;
    border-radius: 10px;
    line-height: 1;
  }

  html.theme-keystone .ls-rail-brand-block {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
  }

  html.theme-keystone .ls-rail-tagline {
    font-size: 0.78rem;
    color: #64748b;
    margin: 4px 0 0;
  }

  html.theme-keystone .ls-sheet-handle {
    width: 40px;
    height: 5px;
    border-radius: 999px;
    background: rgba(30, 41, 59, 0.22);
    margin: 0 auto 12px;
    flex-shrink: 0;
  }

  html.theme-keystone .module-rail.ls-rail {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: 100% !important;
    max-height: min(88vh, 720px);
    z-index: 200;
    transform: translate3d(0, 110%, 0);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--ls-cream);
    border-radius: 24px 24px 0 0;
    padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    margin: 0;
    box-shadow: 0 -16px 56px rgba(0, 0, 0, 0.38);
    display: flex;
    flex-direction: column;
    overflow: auto;
    border-right: none;
  }

  html.theme-keystone .ls-shell.drawer-open .module-rail.ls-rail {
    transform: translate3d(0, 0, 0);
  }

  html.theme-keystone .ls-shell.drawer-open .ls-fab {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
    transition: opacity 0.2s, transform 0.2s;
  }

  html.theme-keystone .module-rail.ls-rail .rail-brand.ls-rail-brand {
    color: var(--ls-navy);
    padding-bottom: 0;
    margin-bottom: 0;
    border-bottom: none;
  }

  html.theme-keystone .module-rail.ls-rail .module-nav-link {
    color: #334155;
    border-radius: 14px;
    border-left: none !important;
    margin-left: 0 !important;
    padding: 11px 14px;
  }

  html.theme-keystone .module-rail.ls-rail .module-nav-link:hover {
    background: rgba(67, 97, 238, 0.1);
    color: var(--ls-navy);
  }

  html.theme-keystone .module-rail.ls-rail .module-nav-link--active {
    background: var(--ls-nav-pill);
    color: #fff !important;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.25);
  }

  html.theme-keystone .ls-rail-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(30, 41, 59, 0.12);
    color: #64748b;
    font-size: 0.84rem;
  }

  html.theme-keystone .ls-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(15, 23, 42, 0.52);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    appearance: none;
  }

  html.theme-keystone .ls-fab {
    position: fixed;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    left: max(16px, env(safe-area-inset-left, 0px));
    z-index: 88;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  html.theme-keystone .ls-fab .ls-hamburger {
    color: #fff;
  }

  html.theme-keystone .ls-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 85;
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 4px;
    padding: 8px 8px calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--ls-cream);
    border-top: 1px solid rgba(30, 41, 59, 0.12);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.14);
  }

  html.theme-keystone .ls-bn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 52px;
    padding: 6px 4px;
    border: none;
    background: transparent;
    border-radius: 16px;
    font: inherit;
    color: #475569;
    text-decoration: none;
    cursor: pointer;
    min-width: 0;
  }

  html.theme-keystone .ls-bn-ico {
    font-size: 1.25rem;
    line-height: 1;
  }

  html.theme-keystone .ls-bn-text {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: capitalize;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  html.theme-keystone .ls-bn-item.is-active {
    background: rgba(67, 97, 238, 0.14);
    color: var(--ls-navy);
  }

  html.theme-keystone .ls-bn-more.ls-bn-item {
    color: #64748b;
  }

  /* Let the page grow with content; avoid a tall empty flex slab below short pages. */
  html.theme-keystone .module-main-wrap.ls-main-wrap {
    flex: 0 1 auto;
    min-height: 0;
    width: 100%;
    background: transparent;
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }

  html.theme-keystone .module-main {
    padding: 16px 16px 28px;
  }

  html.theme-keystone body.ls-app-body {
    background: linear-gradient(180deg, #151c2e 0%, #0f172a 38%, #0d1526 100%);
  }
}

/* Hamburger icon */
html.theme-keystone .ls-hamburger {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  box-shadow: 0 7px 0 currentColor, 0 14px 0 currentColor;
}

/* Dashboard KPI tiles (reference: dark card, cream pill CTA, icon) */
html.theme-keystone .ls-kpi-grid--tiles {
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  html.theme-keystone .ls-kpi-grid--tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  html.theme-keystone .ls-kpi-grid--tiles {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

html.theme-keystone .ls-kpi-card--tile {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 14px;
  padding: 18px 16px;
  min-height: 118px;
  background: linear-gradient(155deg, rgba(30, 41, 59, 0.98) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 20px;
  border-left-width: 4px;
  border-left-color: var(--primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

html.theme-keystone .ls-kpi-card--tile.ls-kpi-accent-warn {
  border-left-color: var(--warning);
}

html.theme-keystone .ls-kpi-card--tile.ls-kpi-accent-danger {
  border-left-color: var(--danger);
}

html.theme-keystone .ls-kpi-card--tile.ls-kpi-accent-info {
  border-left-color: var(--info);
}

html.theme-keystone .ls-kpi-tile-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

html.theme-keystone .ls-kpi-card--tile .ls-kpi-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.15;
  order: 0;
}

html.theme-keystone .ls-kpi-card--tile .ls-kpi-label {
  order: 1;
  font-size: 0.82rem;
  color: #e2e8f0;
  margin-bottom: 6px;
  text-transform: none;
  letter-spacing: 0.02em;
}

html.theme-keystone .ls-kpi-pill {
  order: 2;
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ls-cream);
  color: var(--ls-navy);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(30, 41, 59, 0.12);
  transition: transform 0.12s, box-shadow 0.12s;
}

html.theme-keystone .ls-kpi-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

html.theme-keystone .ls-kpi-tile-ico {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  align-self: center;
}

html.theme-keystone .ls-dash-page.card {
  background: rgba(30, 41, 59, 0.35);
  border-radius: 22px;
}

/* Cream fields: WebKit often keeps light inherited/autofill text without explicit fill color */
html.theme-keystone .module-main input:not([type='checkbox']):not([type='radio']):not([type='file']):not([type='reset']):not([type='button']):not([type='submit']),
html.theme-keystone .module-main select,
html.theme-keystone .module-main textarea,
html.theme-keystone .ls-form input:not([type='checkbox']):not([type='radio']):not([type='file']):not([type='reset']):not([type='button']):not([type='submit']),
html.theme-keystone .ls-form select,
html.theme-keystone .ls-form textarea {
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
  caret-color: #0f172a !important;
}

html.theme-keystone .module-main input:disabled,
html.theme-keystone .module-main select:disabled,
html.theme-keystone .module-main textarea:disabled,
html.theme-keystone .ls-form input:disabled,
html.theme-keystone .ls-form select:disabled,
html.theme-keystone .ls-form textarea:disabled {
  color: #334155 !important;
  -webkit-text-fill-color: #334155 !important;
  opacity: 1;
}

/* Field evidence thumbnails in data tables */
.ls-evidence-thumb-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  line-height: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.06);
}

.ls-evidence-thumb-link:hover {
  border-color: rgba(59, 130, 246, 0.55);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.ls-evidence-thumb {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: cover;
}

.ls-evidence-file-link {
  word-break: break-all;
}

table td .ls-evidence-empty {
  opacity: 0.65;
}
