/* =========================================================
   Animal Welfare (AW) — shell extensions on Excelloite theme
   Reuses --k-* tokens. Does not redefine the design system.
   ========================================================= */

:root {
  --k-purple: #0072a3;
  --k-purple-deep: #005b82;
  --k-blue: #0072a3;
}

/* Nested nav groups (no section titles) — match Dashboard column width */
.k-nav-group {
  margin-bottom: 4px;
  padding: 0 10px;
  box-sizing: border-box;
}

.k-nav + .k-nav-group,
.k-nav-group + .k-nav-group {
  margin-top: 4px;
}

/* Section labels removed from shell — keep rule inert if leftover markup appears */
.k-nav-section {
  display: none !important;
}

.k-nav-group__toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--k-text-2);
  font-family: var(--k-font);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  box-sizing: border-box;
}

.k-nav-group__toggle i:first-child {
  font-size: 16px;
  width: 18px;
  flex-shrink: 0;
  text-align: center;
  color: var(--k-muted);
}

.k-nav-group__toggle .k-nav-caret {
  margin-left: auto;
  font-size: 12px;
  color: var(--k-muted-2);
  transition: transform 0.15s ease;
}

.k-nav-group.is-open > .k-nav-group__toggle .k-nav-caret {
  transform: rotate(180deg);
}

.k-nav-group__toggle:hover {
  background: rgba(255, 255, 255, 0.55);
  color: var(--k-text);
}

.k-nav-group.is-active > .k-nav-group__toggle {
  color: var(--k-purple);
}

.k-nav-group.is-active > .k-nav-group__toggle i:first-child {
  color: var(--k-purple);
}

.k-nav-group__list {
  list-style: none;
  margin: 0;
  padding: 2px 0 6px 14px;
  display: none;
}

.k-nav-group.is-open > .k-nav-group__list {
  display: block;
}

/* Submenus indented under parent group */
.k-nav-group__list > li > a {
  padding: 7px 10px;
  font-size: 13px;
  box-sizing: border-box;
}

.k-nav-group__list > li > a i {
  font-size: 16px;
  width: 18px;
  flex-shrink: 0;
  text-align: center;
}

/* Modals — dialog + panel share overlay centering (dialog was unstyled) */
.k-modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10000;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.k-modal[hidden] {
  display: none !important;
}

.k-modal:not(.is-open) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.k-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.k-modal__backdrop {
  position: absolute !important;
  inset: 0 !important;
  z-index: 0;
}

.k-modal__panel,
.k-modal__dialog {
  position: relative !important;
  z-index: 1 !important;
  margin: 0 auto;
  max-height: min(92vh, 720px);
  overflow: hidden;
}

/* Header popovers — same surface language as k-card / k-modal */
.k-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 280px;
  max-width: 360px;
  background: var(--k-surface);
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-lg);
  z-index: 80;
  display: none;
  overflow: hidden;
}

.k-popover.is-open {
  display: block;
}

.k-popover--center {
  min-width: 260px;
  right: auto;
  left: 0;
}

.k-popover__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--k-border);
}

.k-popover__head strong {
  font-size: 13px;
}

.k-popover__body {
  max-height: 320px;
  overflow-y: auto;
}

.k-popover__item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  font-family: var(--k-font);
  color: var(--k-text);
  cursor: pointer;
  text-decoration: none;
}

.k-popover__item:hover {
  background: var(--k-bg);
}

.k-popover__item.is-active {
  background: var(--k-purple-soft);
}

.k-popover__item .title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.k-popover__item .sub {
  font-size: 12px;
  color: var(--k-muted);
  margin-top: 2px;
}

.k-popover__foot {
  padding: 10px 14px;
  border-top: 1px solid var(--k-border);
  text-align: center;
}

.k-topbar__right {
  position: relative;
}

/* Header surface — pinned while page content scrolls */
body.k-app {
  height: 100%;
  overflow: hidden;
}

html {
  height: 100%;
}

body.k-app .k-shell {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

body.k-app .k-main {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  min-width: 0;
}

body.k-app .k-topbar {
  background: #f6f5f2;
  position: sticky;
  top: 0;
  z-index: 40;
  flex-shrink: 0;
}

body.k-app .k-content {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.k-app .k-topbar .k-search input,
body.k-app .k-topbar .k-search input:focus {
  background: #fff;
}

body.k-app .k-env {
  background: #fff;
}

.k-topbar-dd {
  position: relative;
}

.k-center-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 240px;
  padding: 6px 10px;
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius-sm);
  background: var(--k-surface);
  color: var(--k-text);
  font-family: var(--k-font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.k-center-btn:hover {
  border-color: var(--k-border-strong);
}

.k-center-btn i.ph-buildings {
  color: var(--k-purple);
}

.k-center-btn .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.k-center-btn .ph-caret-down {
  margin-left: auto;
  color: var(--k-muted);
  font-size: 12px;
}

.k-notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--k-red);
  border: 1.5px solid var(--k-surface);
}

.k-notif-row {
  position: relative;
}

.k-notif-row .k-popover__item {
  padding-right: 36px;
}

.k-notif-row.is-read .title {
  font-weight: 500;
  color: var(--k-muted);
}

.k-notif-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--k-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.k-notif-dismiss:hover {
  background: var(--k-bg);
  color: var(--k-text);
}

.k-icon-btn {
  position: relative;
}

.k-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px 2px 2px;
  border: 1px solid transparent;
  border-radius: var(--k-radius-pill);
  background: transparent;
  cursor: pointer;
  font-family: var(--k-font);
  color: var(--k-text);
}

.k-profile-btn:hover {
  background: rgba(0, 0, 0, 0.04);
}

.k-profile-btn .meta {
  text-align: left;
  line-height: 1.2;
}

.k-profile-btn .meta strong {
  display: block;
  font-size: 12px;
}

.k-profile-btn .meta span {
  font-size: 11px;
  color: var(--k-muted);
}

/* UI state blocks */
.k-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  min-height: 220px;
  color: var(--k-muted);
}

.k-state__icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 14px;
  background: var(--k-bg);
  color: var(--k-muted);
}

.k-state__icon--warn {
  background: var(--k-amber-soft);
  color: var(--k-amber);
}

.k-state__icon--danger {
  background: var(--k-red-soft);
  color: var(--k-red);
}

.k-state__icon--ok {
  background: var(--k-green-soft);
  color: var(--k-green);
}

.k-state__icon--purple {
  background: var(--k-purple-soft);
  color: var(--k-purple);
}

.k-state h3 {
  margin: 0 0 6px;
  font-size: 16px;
  color: var(--k-text);
  font-weight: 600;
}

.k-state p {
  margin: 0 0 16px;
  font-size: 13px;
  max-width: 360px;
  line-height: 1.5;
}

.k-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--k-border);
  border-top-color: var(--k-purple);
  border-radius: 50%;
  animation: aw-spin 0.7s linear infinite;
  margin-bottom: 12px;
}

@keyframes aw-spin {
  to {
    transform: rotate(360deg);
  }
}

.k-input.is-invalid,
.k-select.is-invalid {
  border-color: var(--k-red);
  box-shadow: 0 0 0 3px var(--k-red-soft);
}

.k-required {
  color: var(--k-red, #c0392b);
  font-weight: 700;
  margin-inline-start: 0.15em;
}

.k-field-error {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--k-red);
}

.k-field-error[hidden] {
  display: none;
}

.k-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--k-radius);
  border: 1px solid var(--k-border);
  background: var(--k-surface);
  font-size: 13px;
  margin-bottom: 12px;
}

.k-alert i {
  font-size: 18px;
  margin-top: 1px;
}

.k-alert--success {
  background: var(--k-green-soft);
  border-color: #bbf7d0;
  color: #166534;
}

.k-alert--warning {
  background: var(--k-amber-soft);
  border-color: #fde68a;
  color: #92400e;
}

.k-alert--danger {
  background: var(--k-red-soft);
  border-color: #fecaca;
  color: #991b1b;
}

.k-alert--info {
  background: var(--k-purple-soft);
  border-color: #c5e8f7;
  color: var(--k-purple-deep);
}

.k-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.k-stat-grid--dense {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.k-stat-grid--dense .k-stat__value {
  font-size: 20px;
}

.k-stat-grid--6 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.k-stat-grid--6 .k-stat {
  min-width: 0;
  padding: 12px 12px 10px;
}

.k-stat-grid--6 .k-stat__value {
  font-size: 22px;
}

.k-stat-grid--6 .k-stat__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10px;
}

.k-stat-grid--6 .k-stat__hint {
  font-size: 11px;
}

@media (max-width: 900px) {
  .k-stat-grid--6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .k-stat-grid--6 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Supervisor critical list */
.aw-supervisor-critical .k-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.aw-critical-list {
  display: flex;
  flex-direction: column;
  margin: 0 -4px;
}

.aw-critical-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 10px;
  border-bottom: 1px solid var(--k-border);
  text-decoration: none;
  color: inherit;
  border-left: 3px solid transparent;
  transition: background 0.15s ease;
}

.aw-critical-row:last-child {
  border-bottom: 0;
}

.aw-critical-row:hover {
  background: var(--k-bg);
}

.aw-critical-row.is-urgent {
  border-left-color: #dc2626;
}

.aw-critical-row.is-watch {
  border-left-color: #d97706;
}

.aw-critical-row__time {
  font-size: 12px;
  font-weight: 700;
  color: var(--k-purple);
  font-variant-numeric: tabular-nums;
}

.aw-critical-row__title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.aw-critical-row__meta {
  font-size: 12px;
  color: var(--k-muted);
  margin-top: 2px;
}

.aw-critical-row__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .aw-critical-row {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .aw-critical-row__tags {
    grid-column: 2;
    justify-content: flex-start;
  }
}

.k-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--k-muted);
  margin: 18px 0 10px;
}

.k-alert-panel .k-popover__item {
  border-bottom: 1px solid var(--k-border);
}

.k-alert-panel .k-popover__item:last-child {
  border-bottom: 0;
}

/* Dashboard — Alerts fills full KPI column height with usable content */
.aw-dash-kpis {
  align-items: stretch;
}

.aw-dash-kpis > .aw-dash-kpis__main {
  min-width: 0;
}

.aw-dash-kpis > .k-alert-panel {
  align-self: stretch;
  height: auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.k-alert-panel__body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow: visible;
}

.k-alert-panel__section {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.k-alert-panel__section .k-section-label {
  flex: 0 0 auto;
}

.k-alert-panel__list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.aw-dash-alert {
  flex: 1 1 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 64px;
  padding: 12px 12px;
  border: 1px solid var(--k-border);
  border-radius: 10px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.aw-dash-alert:hover {
  border-color: #b8dced;
  background: var(--k-purple-soft);
}

.aw-dash-alert > i {
  flex: 0 0 auto;
  margin-top: 2px;
  font-size: 16px;
  color: var(--k-muted);
}

.aw-dash-alert--urgent > i {
  color: var(--k-red, #c0392b);
}

.aw-dash-alert--warning > i {
  color: var(--k-amber, #c47d0e);
}

.aw-dash-alert .title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.aw-dash-alert .sub {
  font-size: 12px;
  color: var(--k-muted);
  margin-top: 4px;
  line-height: 1.35;
  white-space: normal;
}

.k-master-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - 260px);
  overflow-x: hidden;
  overflow-y: auto;
}

.k-master-nav button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  font-family: var(--k-font);
  font-size: 13px;
  color: var(--k-text-2);
  cursor: pointer;
}

.k-master-nav button > span:not(.k-badge) {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.k-master-nav button > .k-badge {
  flex: 0 0 auto;
  margin-left: auto;
}

.k-master-nav button > i:first-child {
  flex: 0 0 auto;
  width: 18px;
  text-align: center;
}

.k-master-nav button:hover {
  background: var(--k-bg);
}

.k-master-nav button.active {
  background: var(--k-purple-soft);
  color: var(--k-purple);
  border-color: #c5e8f7;
}

/* Masters page — fixed catalog rail + flexible content */
.aw-masters-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.aw-masters-nav-panel {
  width: 280px;
  max-width: 280px;
  min-width: 280px;
  position: sticky;
  top: 12px;
  overflow: hidden;
}

.aw-masters-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.k-table button.k-pill {
  cursor: pointer;
  font-family: inherit;
}

@media (max-width: 992px) {
  .aw-masters-layout {
    grid-template-columns: 1fr;
  }

  .aw-masters-nav-panel {
    width: 100%;
    max-width: none;
    min-width: 0;
    position: static;
  }

  .k-master-nav {
    max-height: 240px;
  }
}

.k-detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 12px;
  font-size: 13px;
}

.k-detail-grid dt {
  color: var(--k-muted);
}

.k-detail-grid dd {
  margin: 0;
  font-weight: 500;
}

@media (max-width: 1100px) {
  .k-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .k-stat-grid {
    grid-template-columns: 1fr;
  }

  .k-profile-btn .meta {
    display: none;
  }

  .k-center-btn {
    max-width: 160px;
  }
}

.k-stat {
  background: var(--k-surface);
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  padding: 14px 16px;
  box-shadow: var(--k-shadow);
}

.k-stat__label {
  font-size: 12px;
  color: var(--k-muted);
  margin-bottom: 6px;
}

.k-stat__value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.k-stat__hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--k-muted);
}

.k-stat__hint.up {
  color: var(--k-green);
}

.k-stat__hint.down {
  color: var(--k-red);
}

.k-center-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--k-radius-pill);
  background: var(--k-purple-soft);
  color: var(--k-purple);
  font-size: 12px;
  font-weight: 600;
}

.aw-module-ready {
  border: 1px dashed var(--k-border-strong);
  border-radius: var(--k-radius);
  padding: 28px;
  background: var(--k-surface);
}

/* Global search results (Chunk 9) */
.aw-global-search-wrap {
  position: relative;
}
.aw-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 320px;
  max-height: 360px;
  overflow: auto;
  background: var(--k-surface);
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  z-index: 80;
  padding: 6px;
}
.aw-search-item {
  display: grid;
  grid-template-columns: 110px 1fr;
  grid-template-rows: auto auto;
  gap: 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}
.aw-search-item:hover,
.aw-search-item:focus {
  background: var(--k-purple-soft);
}
.aw-search-item__type {
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--k-purple);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.aw-search-item__label {
  font-size: 13px;
  font-weight: 600;
}
.aw-search-item__sub {
  font-size: 12px;
  color: var(--k-muted);
}
.aw-search-empty {
  padding: 14px 12px;
  font-size: 13px;
  color: var(--k-muted);
}

.k-state__icon--success {
  color: var(--k-success, #0f9f6e);
  background: rgba(15, 159, 110, 0.1);
}

@media (max-width: 900px) {
  .k-topbar .k-search {
    display: none;
  }
}

/* Hub: 4 product cards (Animal Care + existing 3) */
.k-hub-cards {
  grid-template-columns: repeat(2, minmax(220px, 280px));
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Sidebar user card stays pinned while nav scrolls */
body.k-app .k-sidebar {
  display: flex !important;
  flex-direction: column !important;
  height: 100vh !important;
  max-height: 100vh !important;
  overflow: hidden !important;
}

body.k-app .k-sidebar > .k-brand {
  flex: 0 0 auto;
}

body.k-app .k-sidebar-scroll {
  flex: 1 1 0% !important;
  min-height: 0 !important;
  max-height: none;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  overscroll-behavior: contain;
}

body.k-app .k-sidebar-foot {
  flex: 0 0 auto !important;
  margin-top: 0 !important;
  position: relative;
  z-index: 2;
  box-shadow: 0 -6px 16px rgba(16, 24, 40, 0.04);
}

/* ---------- Animal module (Chunk 3) ---------- */
.aw-animal-photo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--k-text);
  flex-shrink: 0;
  overflow: hidden;
  background: #e8f4fb;
}

.aw-animal-photo--lg {
  width: 88px;
  height: 88px;
  border-radius: 18px;
  font-size: 22px;
}

.aw-animal-photo--img {
  padding: 0;
  border: 1px solid var(--k-border);
}

.aw-animal-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.aw-profile-photo-btn {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 18px;
  line-height: 0;
}

.aw-profile-photo-btn:hover .aw-animal-photo {
  box-shadow: 0 0 0 2px rgba(0, 149, 218, 0.35);
}

.aw-filter-panel {
  background: var(--k-surface);
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--k-shadow);
}

/* Filter inputs — single row + horizontal scroll */
.aw-filter-grid {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.aw-filter-grid > .k-field,
.aw-filter-grid > label.k-field {
  flex: 0 0 auto;
  width: 160px;
  min-width: 140px;
  margin: 0;
}

.aw-filter-grid > .k-field:first-child,
.aw-filter-grid > .k-search,
.aw-filter-grid > .k-field .k-search {
  width: 200px;
  min-width: 180px;
}

.aw-filter-grid .k-input,
.aw-filter-grid .k-select {
  min-width: 0;
  width: 100%;
}

/* Table toolbars — single row + horizontal scroll */
.k-table-toolbar {
  display: flex;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 10px;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.k-table-toolbar > * {
  flex: 0 0 auto;
}

.k-table-toolbar .k-search {
  width: 220px;
  min-width: 180px;
}

.k-table-toolbar .k-select.k-input,
.k-table-toolbar select.k-select,
.k-table-toolbar select.k-input {
  min-width: 130px;
}

.aw-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-top: 1px solid var(--k-border);
}

.aw-pagination__pages {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.aw-pagination__pages button.active {
  background: var(--k-purple-soft);
  color: var(--k-purple);
  border-color: #c5e8f7;
}

.aw-profile-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.aw-profile-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.aw-metric {
  background: var(--k-bg);
  border-radius: var(--k-radius-sm);
  padding: 10px 12px;
}

.aw-metric__label {
  font-size: 11px;
  color: var(--k-muted);
  margin-bottom: 4px;
}

.aw-metric__value {
  font-size: 14px;
  font-weight: 600;
}

.aw-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--k-border);
}

.aw-timeline li {
  position: relative;
  padding: 0 0 18px 18px;
}

.aw-timeline li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--k-purple);
  border: 2px solid var(--k-surface);
}

.aw-timeline__date {
  font-size: 12px;
  font-weight: 600;
  color: var(--k-purple);
}

.aw-timeline__activity {
  font-size: 14px;
  font-weight: 600;
  margin: 2px 0;
}

/* Animal / profile tabs — keep headers on one scrollable row */
.aw-profile-tabs.k-tabs {
  flex-wrap: nowrap;
  gap: 0 4px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 0;
}

.aw-profile-tabs .k-tab {
  flex: 0 0 auto;
  padding: 8px 10px 10px;
  font-size: 12.5px;
}

.aw-timeline__meta {
  font-size: 12px;
  color: var(--k-muted);
}

.aw-upload-box {
  border: 1px dashed var(--k-border-strong);
  border-radius: var(--k-radius);
  padding: 28px;
  text-align: center;
  background: var(--k-bg);
  cursor: pointer;
}

.aw-upload-box:hover {
  border-color: var(--k-purple);
  background: var(--k-purple-soft);
}

.aw-steps {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.aw-step {
  flex: 1;
  min-width: 110px;
  padding: 10px 12px;
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius-sm);
  background: var(--k-surface);
  font-size: 12px;
  color: var(--k-muted);
}

.aw-step.is-active {
  border-color: #7ec8e8;
  background: var(--k-purple-soft);
  color: var(--k-purple);
  font-weight: 600;
}

.aw-step.is-done {
  border-color: #bbf7d0;
  background: var(--k-green-soft);
  color: #166534;
}

.aw-form-section {
  margin-bottom: 18px;
}

.aw-form-section__title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--k-muted);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--k-border);
}

.aw-tab-panel[hidden] {
  display: none !important;
}

.aw-alert-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.aw-alert-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  background: var(--k-surface);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.aw-alert-item:hover {
  border-color: #7ec8e8;
  background: var(--k-purple-soft);
}

.aw-alert-item--red {
  border-left: 3px solid #dc2626;
}

.aw-alert-item--orange {
  border-left: 3px solid #d97706;
}

.aw-alert-item__title {
  font-weight: 600;
  font-size: 13px;
}

.aw-alert-item__detail {
  font-size: 12px;
  color: var(--k-muted);
  margin-top: 2px;
}

.aw-meal-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.aw-meal-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px;
  padding: 8px 10px;
  background: var(--k-bg);
  border-radius: var(--k-radius-sm);
  font-size: 13px;
}

.aw-meal-row strong {
  color: var(--k-muted);
  font-weight: 600;
}

/* Volunteer certificate preview (theme tokens only) */
.aw-certificate {
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  background: linear-gradient(160deg, #f5fafc 0%, #fff 45%, #e8f6fc 100%);
  padding: 8px;
}

.aw-certificate.is-generated {
  box-shadow: 0 0 0 2px rgba(0, 149, 218, 0.18);
}

.aw-certificate__inner {
  position: relative;
  border: 2px solid var(--k-purple);
  border-radius: calc(var(--k-radius) - 2px);
  padding: 28px 24px 32px;
  text-align: center;
  min-height: 420px;
  background:
    linear-gradient(var(--k-bg), var(--k-bg)) padding-box,
    linear-gradient(135deg, rgba(0, 149, 218, 0.15), transparent 40%) border-box;
}

.aw-certificate__brand {
  font-family: Outfit, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--k-purple);
}

.aw-certificate__eyebrow {
  margin-top: 18px;
  font-size: 22px;
  font-weight: 600;
  color: var(--k-text);
}

.aw-certificate__body {
  margin: 14px auto 0;
  max-width: 420px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--k-muted);
}

.aw-certificate__name {
  margin: 16px 0 8px;
  font-size: 28px;
  font-weight: 700;
  color: var(--k-purple);
}

.aw-certificate__footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 40px;
  padding: 0 12px;
}

.aw-certificate__sign {
  font-weight: 600;
  font-size: 14px;
  border-top: 1px solid var(--k-border);
  padding-top: 8px;
  min-width: 140px;
}

.aw-certificate__sign-label {
  font-size: 11px;
  color: var(--k-muted);
  margin-top: 4px;
}

.aw-certificate__seal {
  position: absolute;
  right: 22px;
  bottom: 88px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 2px dashed var(--k-purple);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--k-purple);
  opacity: 0.85;
}

@media print {
  body.k-app .k-sidebar,
  body.k-app .k-topbar,
  body.k-app .k-title-row,
  body.k-app .k-page-actions,
  #form-cert,
  #cert-list,
  #btn-print,
  #gen-status {
    display: none !important;
  }

  .aw-certificate {
    box-shadow: none;
    border: none;
    background: #fff;
  }

  .k-grid.k-grid-2 {
    display: block !important;
  }
}

/* Global table single-line + horizontal scroll */
.k-card[style*="overflow:hidden"],
.k-card[style*="overflow: hidden"] {
  overflow-x: auto !important;
  overflow-y: visible;
}

/* Fill the card/container; scroll horizontally when columns exceed width */
.k-table-scroll {
  width: 100%;
  max-width: 100%;
}

table.k-table,
.aw-perm-table {
  width: 100% !important;
}

table.k-table th,
table.k-table td,
.aw-perm-table th,
.aw-perm-table td {
  white-space: nowrap !important;
}

/* Table action column — icon-only, horizontal */
.k-table-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.k-table td .k-row {
  flex-wrap: nowrap !important;
}

.k-btn.k-btn--icon {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.k-btn.k-btn--icon i {
  font-size: 15px;
  line-height: 1;
  margin: 0;
}

.k-btn.k-btn--icon.k-btn--primary {
  color: #fff;
}

/* Permission matrix (admin) */
.aw-perm-scroll {
  overflow: auto;
  max-height: 520px;
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
}

.aw-perm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 920px;
}

.aw-perm-table th,
.aw-perm-table td {
  border-bottom: 1px solid var(--k-border);
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
}

.aw-perm-table th {
  position: sticky;
  top: 0;
  background: var(--k-bg);
  z-index: 1;
  font-weight: 600;
  color: var(--k-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.aw-perm-table td.mod {
  text-align: left;
  font-weight: 600;
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 1;
}

.aw-perm-check {
  color: #16a34a;
  font-weight: 700;
}

.aw-perm-x {
  color: var(--k-muted);
}

.aw-center-access {
  display: grid;
  gap: 8px;
}

.aw-center-access label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius-sm);
  font-size: 13px;
  cursor: pointer;
}

.aw-settings-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.aw-report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.aw-report-card {
  display: block;
  padding: 14px;
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  text-decoration: none;
  color: inherit;
  background: #fff;
  transition: border-color 0.15s ease;
}

.aw-report-card:hover {
  border-color: var(--k-purple);
}

.aw-report-card strong {
  display: block;
  margin-bottom: 4px;
}

.aw-report-card span {
  font-size: 12px;
  color: var(--k-muted);
}

/* ---------- Responsive polish (theme-aligned) ---------- */

.k-shell,
.k-main,
.k-content {
  min-width: 0;
  max-width: 100%;
}

.k-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.k-card > .k-table-scroll,
.k-card .k-table-scroll {
  display: block;
}

@media (max-width: 1024px) {
  .k-profile-btn .meta {
    display: none;
  }

  .k-center-btn {
    max-width: min(220px, 42vw);
  }

  .k-center-btn .label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 900px) {
  .k-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .k-page-actions {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    gap: 8px;
  }

  .k-page-actions .k-btn {
    flex: 0 1 auto;
  }

  .k-table-toolbar {
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  .k-table-toolbar .k-search {
    width: 200px !important;
    min-width: 160px;
    max-width: none;
    flex: 0 0 auto;
  }

  /* Dashboard / dense toolbars with date inputs */
  #dash-date-bar.k-table-toolbar,
  .k-table-toolbar:has(input[type="date"]) {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  #dash-date-bar .k-input[type="date"],
  .k-table-toolbar input[type="date"].k-input {
    width: min(160px, 42vw) !important;
    min-width: 132px;
    flex: 0 1 auto;
  }

  #dash-date-bar .k-card__sub {
    margin-left: 0 !important;
    width: 100%;
  }

  .k-modal__panel,
  .k-modal__dialog {
    max-width: calc(100vw - 24px) !important;
    margin: 12px auto;
  }

  .k-modal__panel--xl,
  .k-modal__dialog--xl {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }

  .k-modal__body {
    max-height: min(70vh, 560px);
    overflow: auto;
  }

  .k-grid.k-grid-2,
  .k-grid.k-grid-23,
  .k-grid.k-grid-32 {
    grid-template-columns: 1fr;
  }

  .k-detail-grid {
    grid-template-columns: 110px 1fr;
  }

  .aw-profile-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .aw-profile-head {
    flex-direction: column;
  }

  .aw-filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
    align-items: end;
  }

  .aw-filter-grid > .k-field,
  .aw-filter-grid > label.k-field,
  .aw-filter-grid > .k-field:first-child,
  .aw-filter-grid > .k-search,
  .aw-filter-grid > .k-field .k-search {
    width: 100%;
    min-width: 0;
    flex: none;
  }

  .aw-report-cards {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

@media (max-width: 640px) {
  .k-content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .k-title.sans {
    font-size: 22px;
  }

  .k-page-actions .k-btn {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
  }

  .k-page-actions .k-btn--primary {
    flex: 1 1 100%;
  }

  .k-table th,
  .k-table td {
    white-space: nowrap;
  }

  .aw-chart-wrap,
  .k-card canvas {
    max-width: 100%;
    overflow-x: auto;
  }

  .k-center-btn {
    max-width: min(148px, 38vw);
  }

  .k-env {
    display: none;
  }

  .k-crumbs {
    display: none;
  }

  .aw-profile-metrics {
    grid-template-columns: 1fr;
  }

  .k-detail-grid {
    grid-template-columns: 1fr;
  }

  .k-detail-grid dt {
    margin-top: 6px;
  }

  .aw-filter-grid {
    grid-template-columns: 1fr;
  }

  .aw-filter-grid > .k-field,
  .aw-filter-grid > label.k-field {
    min-width: 0;
    width: 100%;
  }

  .aw-pagination {
    flex-wrap: wrap;
    gap: 8px;
  }

  .k-stat-grid--dense .k-stat__value {
    font-size: 20px;
  }
}

/* Large form modals (add/edit stay on page) */
.k-modal__panel--xl,
.k-modal__dialog--xl {
  max-width: 920px;
  width: calc(100vw - 32px);
}

.k-modal__body--scroll {
  max-height: min(62vh, 640px);
  overflow: auto;
  padding-top: 8px;
}

.k-modal__panel--xl .aw-form-section {
  margin-bottom: 14px;
  padding-bottom: 12px;
}

.k-modal__panel--xl .aw-form-section__title {
  font-size: 13px;
  margin-bottom: 10px;
}

/* ---------- Floating quick actions ---------- */
.aw-fab-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.aw-fab,
.aw-fab-panel {
  pointer-events: auto;
}

.aw-fab {
  position: relative;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: #0072a3;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 149, 218, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.15s ease;
}

.aw-fab:hover {
  background: #007fba;
  box-shadow: 0 10px 28px rgba(0, 149, 218, 0.42);
}

.aw-fab:focus-visible {
  outline: 2px solid #0072a3;
  outline-offset: 3px;
}

.aw-fab i {
  font-size: 22px;
  line-height: 1;
  position: absolute;
  transition: opacity 0.15s ease, transform 0.18s ease;
}

.aw-fab__close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

.aw-fab.is-open .aw-fab__plus {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

.aw-fab.is-open .aw-fab__close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

.aw-fab-panel {
  width: min(300px, calc(100vw - 32px));
  background: var(--k-surface);
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-lg, 0 16px 40px rgba(16, 24, 40, 0.16));
  overflow: hidden;
  display: none;
  transform-origin: bottom right;
}

.aw-fab-panel.is-open {
  display: block;
  animation: aw-fab-in 0.16s ease;
}

@keyframes aw-fab-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.aw-fab-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 10px 14px;
  border-bottom: 1px solid var(--k-border);
}

.aw-fab-panel__head strong { font-size: 13px; }

.aw-fab-panel__body {
  max-height: min(58vh, 420px);
  overflow-y: auto;
  padding: 4px 0;
}

.aw-fab-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  text-decoration: none;
  color: inherit;
}

.aw-fab-item:hover { background: var(--k-bg); }

.aw-fab-item__icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(0, 149, 218, 0.1);
  color: #0072a3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.aw-fab-item__icon i { font-size: 16px; }

.aw-fab-item .title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}

.aw-fab-item .sub {
  display: block;
  font-size: 12px;
  color: var(--k-muted);
  margin-top: 2px;
}

@media (max-width: 640px) {
  .aw-fab-root { right: 14px; bottom: 14px; }
  .aw-fab { width: 48px; height: 48px; }
}

/* ---------- Photo gallery + lightbox ---------- */
.aw-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}

.aw-gallery__tile {
  position: relative;
  aspect-ratio: 1;
}

.aw-gallery__item,
.aw-gallery__more {
  appearance: none;
  border: 1px solid var(--k-border);
  border-radius: 12px;
  padding: 0;
  margin: 0;
  background: var(--k-bg);
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 1;
  position: relative;
}

.aw-gallery__tile .aw-gallery__item {
  width: 100%;
  height: 100%;
}

.aw-gallery__item:hover,
.aw-gallery__more:hover {
  border-color: #0072a3;
  box-shadow: 0 0 0 2px rgba(0, 149, 218, 0.18);
}

.aw-gallery__delete {
  appearance: none;
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(8, 15, 28, 0.78);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.aw-gallery__delete:hover {
  background: #b42318;
}

.aw-gallery__item img,
.aw-gallery__item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.aw-gallery__play {
  position: absolute;
  inset: auto auto 10px 10px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: rgba(8, 15, 28, 0.72);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.aw-gallery__more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--k-muted);
}

.aw-photo-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.aw-photo-previews:empty {
  display: none;
}

.aw-photo-preview {
  position: relative;
  border: 1px solid var(--k-border);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--k-bg);
}

.aw-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.aw-photo-preview__remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.aw-photo-preview__remove:hover {
  background: rgba(185, 28, 28, 0.92);
}

.aw-photo-preview__remove i {
  font-size: 14px;
}

.aw-lightbox {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.aw-lightbox[hidden] {
  display: none !important;
}

.aw-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 15, 28, 0.82);
  backdrop-filter: blur(4px);
}

.aw-lightbox__figure {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: min(92vw, 960px);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.aw-lightbox__img,
.aw-lightbox__video {
  max-width: 100%;
  max-height: calc(86vh - 36px);
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  background: #0b1220;
}

.aw-lightbox__caption {
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  font-weight: 500;
}

.aw-lightbox__close,
.aw-lightbox__nav {
  position: absolute;
  z-index: 2;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}

.aw-lightbox__close:hover,
.aw-lightbox__nav:hover {
  background: rgba(255, 255, 255, 0.22);
}

.aw-lightbox__close {
  top: 18px;
  right: 18px;
}

.aw-lightbox__nav--prev {
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.aw-lightbox__nav--next {
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.aw-lightbox__close i,
.aw-lightbox__nav i {
  font-size: 20px;
}

body.aw-lightbox-open {
  overflow: hidden;
}

/* Overlay modal — Tailwind-compatible utilities (Minex layout does not load Vite/Tailwind) */
.aw-overlay.fixed {
  position: fixed;
}

.aw-overlay.inset-0 {
  inset: 0;
}

.aw-overlay.z-50 {
  z-index: 10000;
}

.aw-overlay.flex {
  display: flex;
}

.aw-overlay.items-center {
  align-items: center;
}

.aw-overlay.justify-center {
  justify-content: center;
}

.aw-overlay.p-4 {
  padding: 1rem;
}

.aw-overlay.bg-black\/50,
.aw-overlay[class*="bg-black/50"] {
  background-color: rgb(0 0 0 / 0.5);
}

.aw-overlay.hidden,
.aw-overlay[hidden] {
  display: none !important;
}

.aw-overlay.is-open {
  display: flex !important;
}

.aw-overlay__backdrop.absolute {
  position: absolute;
}

.aw-overlay__backdrop.inset-0 {
  inset: 0;
}

.aw-overlay__card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 48rem;
  max-height: 90vh;
  overflow: hidden;
  background: #fff;
  border-radius: 0.75rem;
  box-shadow: 0 24px 48px rgb(15 23 42 / 0.18);
}

.aw-overlay__card.overflow-visible {
  overflow: visible;
}

.aw-overlay__card.max-w-5xl {
  max-width: 64rem;
}

.aw-overlay__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--k-border, #e6e8ee);
}

.aw-overlay__title {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  color: var(--k-ink, #111827);
}

.aw-overlay__lede {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--k-muted, #6b7280);
}

.aw-overlay__close {
  border: 0;
  background: transparent;
  color: var(--k-muted, #6b7280);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.aw-overlay__close:hover {
  background: rgb(15 23 42 / 0.06);
  color: var(--k-ink, #111827);
}

.aw-overlay__body {
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

.aw-overlay__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--k-border, #e6e8ee);
}

.aw-overlay .k-grid.k-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 720px) {
  .aw-overlay .k-grid.k-grid-2 {
    grid-template-columns: 1fr;
  }
}

.k-autosuggest {
  position: relative;
  z-index: 2;
}

.k-autosuggest__list {
  position: absolute;
  z-index: 80;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 220px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

.k-autosuggest__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: 0;
  background: #fff;
  color: var(--k-text);
  cursor: pointer;
  font-size: 13px;
}

.k-autosuggest__item:hover,
.k-autosuggest__item:focus {
  background: var(--k-surface-2, #f4f7fb);
}

.k-autosuggest__empty {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--k-muted);
}

.k-autosuggest__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.k-autosuggest__chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--k-surface-2, #f4f7fb);
  font-size: 12px;
}

.k-autosuggest__chip-remove {
  border: 0;
  background: transparent;
  color: var(--k-muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
}

@media (max-width: 640px) {
  .aw-gallery {
    grid-template-columns: repeat(3, 1fr);
  }

  .aw-lightbox {
    padding: 12px;
  }

  .aw-lightbox__nav--prev {
    left: 8px;
  }

  .aw-lightbox__nav--next {
    right: 8px;
  }
}

/* Add Animal overlay form — Tailwind-named utilities (Vite Tailwind is not loaded on this layout) */
.aw-overlay .space-y-5 > * + * {
  margin-top: 1.25rem;
}

.aw-overlay .w-full {
  width: 100%;
}

.aw-overlay .text-sm {
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.aw-overlay .font-semibold {
  font-weight: 600;
}

.aw-overlay .uppercase {
  text-transform: uppercase;
}

.aw-overlay .tracking-wide {
  letter-spacing: 0.05em;
}

.aw-overlay .text-gray-500 {
  color: #6b7280;
}

.aw-overlay .text-center {
  text-align: center;
}

.aw-overlay .cursor-pointer {
  cursor: pointer;
}

.aw-overlay .px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.aw-overlay .py-8 {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.aw-overlay .border {
  border-width: 1px;
  border-style: solid;
}

.aw-overlay .border-2 {
  border-width: 2px;
}

.aw-overlay .border-dashed {
  border-style: dashed;
}

.aw-overlay .border-gray-300 {
  border-color: #d1d5db;
}

.aw-overlay .rounded-md {
  border-radius: 0.375rem;
}

.aw-overlay .shadow-sm {
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.aw-overlay .bg-white {
  background-color: #fff;
}

.aw-overlay .bg-gray-50 {
  background-color: #f9fafb;
}

.aw-overlay .bg-blue-600 {
  background-color: #2563eb;
  border-color: #1d4ed8;
  color: #fff;
}

.aw-overlay .col-span-2 {
  grid-column: 1 / -1;
}

.aw-overlay .k-input.border-gray-300,
.aw-overlay .k-select.border-gray-300,
.aw-overlay .k-textarea.border-gray-300 {
  border: 1px solid #d1d5db;
}

.aw-overlay .focus\:ring:focus,
.aw-overlay .k-input.focus\:ring:focus,
.aw-overlay .k-select.focus\:ring:focus,
.aw-overlay .k-textarea.focus\:ring:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.35);
  border-color: #3b82f6;
}

.aw-overlay .focus\:border-blue-500:focus {
  border-color: #3b82f6;
}

.aw-upload-box.is-dragover {
  border-color: #3b82f6;
  background: #eff6ff;
}

#modal-animal-register .k-btn--primary.bg-blue-600:hover {
  background-color: #1d4ed8;
  border-color: #1e40af;
  color: #fff;
}

/* ---------- Field PWA: My Tasks ---------- */
body.k-app--field .k-search,
body.k-app--field .k-env,
body.k-app--field .k-crumbs,
body.k-app--field #aw-center-dd,
body.k-app--field .aw-fab-root {
  display: none !important;
}

.aw-my-tasks {
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

.aw-my-tasks .k-title.sans {
  font-size: 28px;
  letter-spacing: -0.03em;
}

.aw-my-tasks__section {
  margin-bottom: 18px;
}

.aw-my-tasks__section h2 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--k-muted);
}

.aw-my-tasks__card {
  background: #fff;
  border: 1px solid var(--k-line, #e4eaf0);
  border-radius: 16px;
  margin-bottom: 10px;
  overflow: hidden;
}

.aw-my-tasks__card.is-overdue {
  border-color: #f1c4c4;
}

.aw-my-tasks__hit {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 14px 16px;
  border: 0;
  background: #fff;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.aw-my-tasks__hit-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.aw-my-tasks__hit-main strong {
  font-size: 16px;
  line-height: 1.3;
}

.aw-my-tasks__meta {
  font-size: 13px;
  color: var(--k-muted);
}

.aw-my-tasks__body {
  border-top: 1px solid var(--k-line, #e4eaf0);
  padding: 8px 10px 12px;
  background: #f7fafc;
}

.aw-my-tasks__checks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.aw-my-tasks__check {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 12px;
  border: 1px solid var(--k-line, #e4eaf0);
  border-radius: 12px;
  background: #fff;
  text-align: left;
  font-size: 16px;
  line-height: 1.3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.aw-my-tasks__check.is-done {
  color: var(--k-muted);
  text-decoration: line-through;
}

.aw-my-tasks__box {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px solid #0072a3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: #fff;
}

.aw-my-tasks__check.is-done .aw-my-tasks__box {
  background: #0072a3;
}

.aw-my-tasks__empty,
.aw-my-tasks__loading {
  padding: 8px 0;
}

.aw-my-tasks__empty-check {
  margin: 8px 4px;
}

@media (max-width: 640px) {
  body.k-app--field .k-content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .aw-my-tasks .k-title.sans {
    font-size: 26px;
  }
}

/* ---------- Field PWA: My Animals ---------- */
.aw-my-animals {
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

.aw-my-animals .k-title.sans {
  font-size: 28px;
  letter-spacing: -0.03em;
}

.aw-my-animals__card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 72px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--k-line, #e4eaf0);
  border-radius: 16px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.aw-my-animals__card .aw-animal-photo {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  font-size: 16px;
}

.aw-my-animals__hit-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.aw-my-animals__hit-main strong {
  font-size: 16px;
  line-height: 1.3;
}

.aw-my-animals__meta {
  font-size: 13px;
  color: var(--k-muted);
}

.aw-my-animals__empty,
.aw-my-animals__loading {
  padding: 8px 0;
}

.aw-my-animal__back {
  margin: 0 0 12px;
}

.aw-my-animal__head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.aw-my-animal__card {
  background: #fff;
  border: 1px solid var(--k-line, #e4eaf0);
  border-radius: 16px;
  padding: 14px 16px 16px;
  margin-bottom: 12px;
}

.aw-my-animal__card h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.aw-my-animal__card h3 {
  margin: 14px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--k-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.aw-my-animal__status {
  margin: 0;
}

.aw-my-animal__form .k-input {
  width: 100%;
  min-height: 88px;
  resize: vertical;
}

.aw-my-animal__submit {
  margin-top: 10px;
  width: 100%;
  min-height: 44px;
}

.aw-my-animal__notes {
  margin-top: 12px;
}

.aw-my-animal__actions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.aw-my-animal__actions li {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--k-line, #e4eaf0);
  border-radius: 12px;
  background: #f7fafc;
}

.aw-my-animal__actions .k-btn {
  flex: 0 0 auto;
  min-height: 40px;
}

@media (max-width: 640px) {
  .aw-my-animals .k-title.sans {
    font-size: 26px;
  }
}

.aw-offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4000;
  padding: 10px 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  background: #fff6e5;
  color: #7a4b00;
  border-bottom: 1px solid #f0d9a8;
}

.aw-offline-banner[hidden] {
  display: none !important;
}

/* Overlay / modal open — hide FAB so Save/Cancel stay tappable (css.md) */
body:has(.aw-overlay.is-open) .aw-fab-root,
body:has(.k-modal.is-open) .aw-fab-root {
  display: none !important;
}

/* Keep last fields and table rows clear of the floating quick-action button */
body.k-app:not(.k-app--field) .k-content {
  padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  scroll-padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 1024px) {
  .k-topbar .k-icon-btn,
  .k-icon-btn.k-nav-toggle,
  #aw-notif-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }

  .k-center-btn {
    min-height: 40px;
  }

  .k-page-actions .k-btn {
    min-height: 40px;
    height: auto;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  /* Theme clips cards at tablet; only cards with history/list tables should unclip */
  .k-card:has(.k-table-scroll),
  .k-card--flush:has(.k-table-scroll) {
    overflow: visible;
  }

  .k-table-scroll {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }

  .aw-profile-tabs .k-tab {
    min-height: 40px;
    padding: 10px 12px;
    display: inline-flex;
    align-items: center;
  }

  .k-autosuggest__item {
    min-height: 40px;
    padding: 10px 12px;
    box-sizing: border-box;
  }
}

@media (max-width: 640px) {
  .k-topbar {
    padding: 0 10px;
    gap: 6px;
  }

  .k-topbar__left,
  .k-topbar__right {
    gap: 6px;
  }

  .k-topbar .k-brand__mark {
    display: none;
  }

  .aw-overlay {
    padding: 8px;
    align-items: stretch;
  }

  .aw-overlay__card {
    max-height: calc(100dvh - 16px);
    height: auto;
    margin: auto 0;
  }

  .aw-overlay__foot .k-btn {
    min-height: 40px;
  }
}

@media (max-width: 480px) {
  .k-btn {
    height: auto;
    min-height: 40px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .k-btn.k-btn--icon {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
  }
}

@media (max-width: 900px) {
  .aw-dash-kpis > .k-alert-panel {
    min-height: 0;
    height: auto;
  }

  .aw-dash-kpis .k-alert-panel__body,
  .aw-dash-kpis .k-alert-panel__section,
  .aw-dash-kpis .k-alert-panel__list {
    flex: 0 1 auto;
    min-height: auto;
    overflow: visible;
  }

  .aw-dash-kpis .aw-dash-alert {
    flex: 0 0 auto;
  }
}

/* Pinned list tables: ID/name stay put horizontally, headers stay put vertically.
   Scoped with .k-table-scroll--pinned so other screens keep the plain scroller. */
.k-table-scroll--pinned {
  overflow: auto;
  max-height: min(520px, calc(100vh - 240px));
  -webkit-overflow-scrolling: touch;
}

.k-table-scroll--pinned > .k-table {
  border-collapse: separate;
  border-spacing: 0;
}

.k-table-scroll--pinned .k-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f5f8fb;
}

.k-table-scroll--pinned .k-table .k-col-pin {
  position: sticky;
  z-index: 1;
  background: #fff;
}

.k-table-scroll--pinned .k-table thead th.k-col-pin {
  z-index: 4;
  background: #f5f8fb;
}

.k-table-scroll--pinned .k-table tr:hover td.k-col-pin {
  background: #f5f8fb;
}

.k-table-scroll--pinned .k-table .k-col-pin--edge {
  border-right: 1px solid var(--k-border);
  box-shadow: 8px 0 8px -8px rgba(16, 24, 40, 0.45);
}

/* Filter arrows sit outside the scrolling row and stick while the page scrolls. */
.aw-filter-panel--sticky {
  position: sticky;
  top: 0;
  z-index: 6;
}

.aw-filter-scroll {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.aw-filter-scroll > .aw-filter-grid {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}

.aw-filter-scroll__btn {
  position: sticky;
  top: 8px;
  z-index: 2;
  flex: 0 0 auto;
  align-self: center;
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--k-border);
  border-radius: 8px;
  background: #fff;
  color: var(--k-text);
  cursor: pointer;
}

.aw-filter-scroll__btn--prev {
  left: 0;
}

.aw-filter-scroll__btn--next {
  right: 0;
}

.aw-filter-scroll__btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.k-table td.aw-receipt-cell {
  white-space: normal;
  vertical-align: top;
  min-width: 12rem;
}

.aw-receipt-note {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
  white-space: normal;
}

.aw-receipt-cell .k-btn {
  margin-top: 8px;
}

@media (max-width: 900px) {
  .aw-filter-scroll__btn {
    display: none;
  }
}



