/* ==========================================================================
   KHADC Unified Civic Design System (UI/UX Pro Max — Accessible & Ethical)
   Lightweight, GPU-composited micro-interactions, Apple-inspired tactile feel,
   universal mobile table-to-card reflow, unified header, and toast/confirm UI.
   ========================================================================== */

:root {
  --khadc-font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --khadc-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --khadc-navy: #102a4e;
  --khadc-navy-light: #1e3f6f;
  --khadc-blue: #1e40af;
  --khadc-gold: #d97706;
  --khadc-gold-light: #fef3c7;
  --khadc-green: #15803d;
  --khadc-green-bg: #dcfce7;
  --khadc-red: #b91c1c;
  --khadc-red-bg: #fee2e2;
  --khadc-bg: #f1f5f9;
  --khadc-surface: #ffffff;
  --khadc-text: #0f172a;
  --khadc-muted: #475569;
  --khadc-border: rgba(15, 23, 42, 0.1);
  --khadc-border-strong: #cbd5e1;
  --khadc-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --khadc-shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --khadc-shadow-md: 0 8px 20px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --khadc-shadow-lg: 0 18px 38px rgba(15, 23, 42, 0.14), 0 4px 12px rgba(15, 23, 42, 0.06);
  --khadc-radius-sm: 8px;
  --khadc-radius-md: 12px;
  --khadc-radius-lg: 14px;
  --khadc-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --khadc-apple-spring: cubic-bezier(0.16, 1, 0.3, 1);
}

@supports (animation-timing-function: linear(0, 1)) {
  :root {
    /* True Apple iOS/macOS damped spring curve (~2.8% micro-overshoot, silky settle) */
    --khadc-apple-spring: linear(
      0, 0.012, 0.048 2.2%, 0.185 4.8%, 0.785 13.5%, 0.968 18.2%,
      1.024 22.8%, 1.028 26.5%, 1.014 33%, 1.002 42%, 0.998 55%, 1
    );
  }
}

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
}

body,
button,
input,
select,
textarea {
  font-family: var(--khadc-font-sans);
}

body {
  background-color: var(--khadc-bg);
  color: var(--khadc-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: rgba(16, 42, 78, 0.08);
  overflow-x: hidden;
}

.khadc-tabular,
.kpi-value,
.metric-value,
.font-mono-num {
  font-variant-numeric: tabular-nums;
}

.khadc-mono {
  font-family: var(--khadc-font-mono);
}

.notice-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.khadc-scroll-smooth {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* --------------------------------------------------------------------------
   Accessible Focus Rings
   -------------------------------------------------------------------------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #0284c7;
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   100% Unified Civic Header (Identical across all 8 Portals)
   -------------------------------------------------------------------------- */
.khadc-header {
  background: linear-gradient(135deg, var(--khadc-navy) 0%, var(--khadc-navy-light) 100%);
  color: #ffffff;
  border-bottom: 4px solid var(--khadc-gold);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.22);
  position: sticky;
  top: 0;
  z-index: 60;
  width: 100%;
}

.khadc-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.khadc-header--full .khadc-header-inner {
  max-width: none;
  padding: 18px 28px;
}

.khadc-crest-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.khadc-crest-img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.34));
}

.khadc-crest {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--khadc-gold);
  color: var(--khadc-navy);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.28);
}

.khadc-brand-titles {
  min-width: 0;
}

.khadc-brand-titles h1 {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #ffffff;
  margin: 0;
  line-height: 1.2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

.khadc-brand-titles p {
  font-size: 13.5px;
  color: #e2e8f0;
  margin: 4px 0 0;
  line-height: 1.35;
  font-weight: 500;
}

.khadc-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.khadc-user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.khadc-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  min-height: 40px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 9999px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.khadc-user-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.khadc-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  background: rgba(217, 119, 6, 0.24);
  border: 1px solid rgba(251, 191, 36, 0.5);
  color: #fde68a;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.khadc-btn-signout {
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(248, 113, 113, 0.72);
  background: rgba(220, 38, 38, 0.24);
  color: #fef2f2;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: transform 90ms ease, background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

@media (hover: hover) {
  .khadc-btn-signout:hover {
    background: #dc2626;
    border-color: #ef4444;
    color: #ffffff;
  }
}

.khadc-btn-signout:active {
  transform: translateY(1px) scale(0.975);
}

/* Mobile-only hamburger trigger & right-side slide-over drawer (for all portals) */
.khadc-mobile-menu-btn {
  display: none;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
}

.khadc-mobile-drawer-overlay {
  display: none;
}

.khadc-mobile-drawer {
  display: none;
}

/* --------------------------------------------------------------------------
   Unified Top Menu Bar (Trader + All 6 Officer Portals; Zero Sidebars)
   -------------------------------------------------------------------------- */
.khadc-topbar,
.nav-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  padding: 6px;
  border-radius: var(--khadc-radius-md);
  border: 1px solid var(--khadc-border);
  box-shadow: var(--khadc-shadow-xs);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.khadc-topbar::-webkit-scrollbar,
.nav-bar::-webkit-scrollbar {
  display: none;
}

.khadc-topbar-item,
.nav-bar .nav-item {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  background: transparent;
  color: var(--khadc-muted);
  border-radius: var(--khadc-radius-sm);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  flex-shrink: 0;
  transition: transform 90ms ease, background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

@media (hover: hover) {
  .khadc-topbar-item:hover:not(.active),
  .nav-bar .nav-item:hover:not(.active) {
    background: #f1f5f9;
    color: var(--khadc-navy);
  }
}

.khadc-topbar-item.active,
.nav-bar .nav-item.active {
  background: var(--khadc-navy);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(16, 42, 78, 0.22);
}

.khadc-topbar-item:active,
.nav-bar .nav-item:active {
  transform: translateY(1px) scale(0.975);
}

/* --------------------------------------------------------------------------
   Apple-Inspired Tactile Button Physics & Lightweight GPU Motion
   -------------------------------------------------------------------------- */
.btn,
.btn-primary,
.btn-secondary,
.btn-outline,
.btn-gold,
.btn-danger,
.btn-success,
.filter-pill,
.admin-sidebar .nav-item,
.sidebar-nav-item,
.mobile-menu-btn,
.sidebar-close-btn {
  cursor: pointer;
  transition: transform 90ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

@media (hover: hover) {
  .btn:not(:disabled):hover,
  .btn-primary:not(:disabled):hover,
  .btn-secondary:not(:disabled):hover,
  .btn-outline:not(:disabled):hover,
  .btn-gold:not(:disabled):hover,
  .btn-danger:not(:disabled):hover,
  .btn-success:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
  }
}

.btn:not(:disabled):active,
.btn-primary:not(:disabled):active,
.btn-secondary:not(:disabled):active,
.btn-outline:not(:disabled):active,
.btn-gold:not(:disabled):active,
.btn-danger:not(:disabled):active,
.btn-success:not(:disabled):active,
.filter-pill:active,
.admin-sidebar .nav-item:active,
.sidebar-nav-item:active,
.mobile-menu-btn:active {
  transform: translateY(1px) scale(0.975);
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.16);
}

.card,
.metric-card,
.kpi-card,
.table-container,
.license-card {
  border: 1px solid var(--khadc-border);
  border-radius: var(--khadc-radius-md);
  box-shadow: var(--khadc-shadow-sm);
}

/* --------------------------------------------------------------------------
   Apple iOS/macOS App-Launch Spring Choreography (GPU transform + opacity)
   -------------------------------------------------------------------------- */
@keyframes khadcPageEnter {
  0% {
    opacity: 0;
    transform: scale(0.965) translateY(14px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes khadcAppleCardIn {
  0% {
    opacity: 0;
    transform: scale(0.955) translateY(18px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes khadcAppleRowIn {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes khadcModalIn {
  0% {
    opacity: 0;
    transform: scale(0.93) translateY(16px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes khadcToastIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes khadcToastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }
}

/* Every Screen Container Opens with Apple App-Launch Spring */
.khadc-page-enter,
.container > div[x-show],
.officer-container > div[x-show],
.officer-container > section[x-show],
.admin-content > section[x-show],
.auth-card {
  animation: khadcPageEnter 420ms var(--khadc-apple-spring) both;
  transform-origin: center top;
  will-change: transform, opacity;
}

/* Modals & Sheets Pop with Crisp Spring Scale */
.modal-box,
.modal-card {
  animation: khadcModalIn 380ms var(--khadc-apple-spring) both;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* Every Direct Section, Card, Banner, Grid & Form Block Cascades In */
.container > div[x-show] > *,
.officer-container > div[x-show] > *,
.officer-container > section[x-show] > *,
.admin-content > section[x-show] > *,
.khadc-stagger > *,
.wizard-step-panel[x-show],
.card[x-show] {
  animation: khadcAppleCardIn 460ms var(--khadc-apple-spring) both;
}

.container > div[x-show] > *:nth-child(2),
.officer-container > div[x-show] > *:nth-child(2),
.officer-container > section[x-show] > *:nth-child(2),
.admin-content > section[x-show] > *:nth-child(2),
.khadc-stagger > *:nth-child(2) { animation-delay: 45ms; }

.container > div[x-show] > *:nth-child(3),
.officer-container > div[x-show] > *:nth-child(3),
.officer-container > section[x-show] > *:nth-child(3),
.admin-content > section[x-show] > *:nth-child(3),
.khadc-stagger > *:nth-child(3) { animation-delay: 90ms; }

.container > div[x-show] > *:nth-child(4),
.officer-container > div[x-show] > *:nth-child(4),
.officer-container > section[x-show] > *:nth-child(4),
.admin-content > section[x-show] > *:nth-child(4),
.khadc-stagger > *:nth-child(4) { animation-delay: 135ms; }

.container > div[x-show] > *:nth-child(5),
.officer-container > div[x-show] > *:nth-child(5),
.officer-container > section[x-show] > *:nth-child(5),
.admin-content > section[x-show] > *:nth-child(5),
.khadc-stagger > *:nth-child(5) { animation-delay: 180ms; }

.container > div[x-show] > *:nth-child(n+6),
.officer-container > div[x-show] > *:nth-child(n+6),
.officer-container > section[x-show] > *:nth-child(n+6),
.admin-content > section[x-show] > *:nth-child(n+6),
.khadc-stagger > *:nth-child(n+6) { animation-delay: 220ms; }

/* KPI & Metric Cards */
.kpi-grid .kpi-card,
.metrics-grid .metric-card {
  animation: khadcAppleCardIn 460ms var(--khadc-apple-spring) both;
}

.kpi-grid .kpi-card:nth-child(2),
.metrics-grid .metric-card:nth-child(2) { animation-delay: 45ms; }

.kpi-grid .kpi-card:nth-child(3),
.metrics-grid .metric-card:nth-child(3) { animation-delay: 90ms; }

.kpi-grid .kpi-card:nth-child(4),
.metrics-grid .metric-card:nth-child(4) { animation-delay: 135ms; }

/* Auth Card Inner Elements Cascade */
.auth-card > * {
  animation: khadcAppleCardIn 420ms var(--khadc-apple-spring) both;
}
.auth-card > *:nth-child(2) { animation-delay: 40ms; }
.auth-card > *:nth-child(3) { animation-delay: 80ms; }
.auth-card > *:nth-child(4) { animation-delay: 120ms; }
.auth-card > *:nth-child(n+5) { animation-delay: 160ms; }

/* Every Table Row, Mobile Card & License Card Springs In Sequentially */
.data-table tbody tr,
table.khadc-mobile-cards tbody tr,
.license-card {
  animation: khadcAppleRowIn 400ms var(--khadc-apple-spring) both;
}

.data-table tbody tr:nth-child(2),
table.khadc-mobile-cards tbody tr:nth-child(2),
.license-card:nth-child(2) { animation-delay: 35ms; }

.data-table tbody tr:nth-child(3),
table.khadc-mobile-cards tbody tr:nth-child(3),
.license-card:nth-child(3) { animation-delay: 70ms; }

.data-table tbody tr:nth-child(4),
table.khadc-mobile-cards tbody tr:nth-child(4),
.license-card:nth-child(4) { animation-delay: 105ms; }

.data-table tbody tr:nth-child(5),
table.khadc-mobile-cards tbody tr:nth-child(5),
.license-card:nth-child(5) { animation-delay: 140ms; }

.data-table tbody tr:nth-child(6),
table.khadc-mobile-cards tbody tr:nth-child(6),
.license-card:nth-child(6) { animation-delay: 175ms; }

.data-table tbody tr:nth-child(n+7),
table.khadc-mobile-cards tbody tr:nth-child(n+7),
.license-card:nth-child(n+7) { animation-delay: 210ms; }

/* --------------------------------------------------------------------------
   Accessible Civic Toast Notifications (Replaces alert())
   -------------------------------------------------------------------------- */
.khadc-toast-stack {
  position: fixed;
  top: 82px;
  right: 18px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(410px, calc(100vw - 24px));
  pointer-events: none;
}

.khadc-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border-radius: var(--khadc-radius-md);
  background: #ffffff;
  color: var(--khadc-text);
  border: 1px solid var(--khadc-border-strong);
  border-left-width: 5px;
  box-shadow: var(--khadc-shadow-lg);
  animation: khadcToastIn 220ms var(--khadc-ease-out) both;
}

.khadc-toast.is-leaving {
  animation: khadcToastOut 160ms ease-in forwards;
}

.khadc-toast--success {
  border-left-color: var(--khadc-green);
}

.khadc-toast--error {
  border-left-color: var(--khadc-red);
}

.khadc-toast--warning {
  border-left-color: var(--khadc-gold);
}

.khadc-toast--info {
  border-left-color: var(--khadc-blue);
}

.khadc-toast-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 1px;
}

.khadc-toast--success .khadc-toast-icon { color: var(--khadc-green); }
.khadc-toast--error .khadc-toast-icon { color: var(--khadc-red); }
.khadc-toast--warning .khadc-toast-icon { color: var(--khadc-gold); }
.khadc-toast--info .khadc-toast-icon { color: var(--khadc-blue); }

.khadc-toast-body {
  flex: 1;
  min-width: 0;
}

.khadc-toast-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--khadc-text);
  margin-bottom: 2px;
}

.khadc-toast-msg {
  font-size: 13.5px;
  line-height: 1.45;
  color: #334155;
  word-break: break-word;
}

.khadc-toast-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 120ms ease, color 120ms ease, transform 80ms ease;
}

.khadc-toast-close:hover {
  background: #f1f5f9;
  color: var(--khadc-text);
}

.khadc-toast-close:active {
  transform: scale(0.92);
}

/* --------------------------------------------------------------------------
   Accessible Civic Confirmation Dialog (Replaces confirm())
   -------------------------------------------------------------------------- */
.khadc-confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.56);
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.khadc-confirm-card {
  background: #ffffff;
  border-radius: var(--khadc-radius-lg);
  border: 1px solid var(--khadc-border-strong);
  box-shadow: var(--khadc-shadow-lg);
  width: min(440px, 100%);
  padding: 22px;
  animation: khadcModalIn 190ms var(--khadc-ease-out) both;
}

.khadc-confirm-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--khadc-navy);
  margin: 0 0 8px;
}

.khadc-confirm-msg {
  font-size: 14px;
  line-height: 1.55;
  color: #334155;
  margin: 0 0 20px;
}

.khadc-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.khadc-confirm-btn {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--khadc-border-strong);
  transition: transform 90ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.khadc-confirm-btn:active {
  transform: translateY(1px) scale(0.975);
}

.khadc-confirm-btn--cancel {
  background: #ffffff;
  color: #334155;
}

.khadc-confirm-btn--cancel:hover {
  background: #f8fafc;
}

.khadc-confirm-btn--primary {
  background: var(--khadc-navy);
  border-color: var(--khadc-navy);
  color: #ffffff;
}

.khadc-confirm-btn--danger {
  background: var(--khadc-red);
  border-color: var(--khadc-red);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Universal Mobile Responsiveness (<= 768px):
   - Every table turns into clean stacked mobile cards (data-label)
   - Desktop single-row cards, hero rows, and grids split cleanly on mobile
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .khadc-header-inner,
  .khadc-header--full .khadc-header-inner {
    padding: 16px 16px;
    gap: 10px 12px;
    flex-wrap: wrap;
  }

  .khadc-crest-wrap {
    flex: 1 1 0%;
    min-width: 0;
    gap: 12px;
  }

  .khadc-header-right {
    margin-left: auto;
  }

  .khadc-crest-img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 3px 7px rgba(0, 0, 0, 0.32));
  }

  .khadc-crest {
    width: 54px;
    height: 54px;
    font-size: 12px;
  }

  .khadc-brand-titles h1 {
    font-size: clamp(15px, 4.1vw, 17.5px);
    font-weight: 800;
    line-height: 1.22;
    letter-spacing: 0.02em;
  }

  .khadc-brand-titles p {
    font-size: 12.5px;
    margin-top: 3px;
    line-height: 1.3;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  .khadc-user-chip {
    padding: 4px 9px;
    min-height: 36px;
    font-size: 11.5px;
    gap: 5px;
  }

  .khadc-user-name {
    max-width: 115px;
  }

  .khadc-role-badge {
    font-size: 9.5px;
    padding: 2px 6px;
  }

  .khadc-btn-signout {
    min-height: 36px;
    min-width: auto;
    padding: 0 9px;
    font-size: 11px;
    gap: 4px;
    border-radius: 8px;
  }

  .khadc-btn-signout svg {
    width: 14px;
    height: 14px;
  }

  .khadc-mobile-menu-btn {
    display: inline-flex;
    min-height: 36px;
    min-width: 40px;
    padding: 0 8px;
  }

  /* Collapse topbar on mobile into right-side drawer */
  .khadc-topbar {
    display: none !important;
  }

  .khadc-mobile-drawer-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.52);
    z-index: 140;
  }

  .khadc-mobile-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(300px, 84vw);
    background: #ffffff;
    z-index: 150;
    box-shadow: -8px 0 28px rgba(15, 23, 42, 0.22);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  .khadc-mobile-drawer-head {
    background: linear-gradient(135deg, var(--khadc-navy) 0%, var(--khadc-navy-light) 100%);
    color: #ffffff;
    padding: 16px;
    border-bottom: 3px solid var(--khadc-gold);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .khadc-mobile-drawer-nav {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .khadc-mobile-drawer-item {
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--khadc-text);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
  }

  .khadc-mobile-drawer-item.active {
    background: var(--khadc-navy);
    color: #ffffff;
  }

  .khadc-toast-stack {
    top: auto;
    bottom: 16px;
    right: 12px;
    left: 12px;
    width: auto;
  }

  /* Universal Table-to-Card Transformation */
  table.khadc-mobile-cards,
  table.mobile-cards {
    border: 0;
  }

  table.khadc-mobile-cards thead,
  table.mobile-cards thead {
    display: none;
  }

  table.khadc-mobile-cards tbody,
  table.mobile-cards tbody {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  table.khadc-mobile-cards tr,
  table.mobile-cards tr {
    display: block;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  }

  table.khadc-mobile-cards tbody tr:hover,
  table.mobile-cards tbody tr:hover {
    background: #ffffff;
  }

  table.khadc-mobile-cards td,
  table.mobile-cards td,
  table.data-table.khadc-mobile-cards td,
  table.data-table.mobile-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 10px 0;
    border: none;
    border-bottom: 1px solid #f1f5f9;
    background: transparent;
    font-size: 13.5px;
    text-align: right;
    white-space: normal !important;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
  }

  table.khadc-mobile-cards td:first-child,
  table.mobile-cards td:first-child {
    padding-top: 2px;
  }

  table.khadc-mobile-cards td > *,
  table.mobile-cards td > * {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  table.khadc-mobile-cards td:last-child,
  table.mobile-cards td:last-child {
    border-bottom: none;
    padding-bottom: 2px;
  }

  table.khadc-mobile-cards td[data-label]::before,
  table.mobile-cards td[data-label]::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--khadc-muted);
    text-align: left;
    flex: 0 0 auto;
    max-width: 44%;
  }

  table.khadc-mobile-cards td.action-cell,
  table.mobile-cards td.action-cell,
  table.khadc-mobile-cards td[data-label="Action"],
  table.mobile-cards td[data-label="Action"],
  table.data-table.khadc-mobile-cards td.action-cell,
  table.data-table.khadc-mobile-cards td[data-label="Action"] {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    padding-top: 12px;
    margin-top: 2px;
    gap: 8px;
    border-bottom: none;
  }

  table.khadc-mobile-cards td.action-cell::before,
  table.mobile-cards td.action-cell::before,
  table.khadc-mobile-cards td[data-label="Action"]::before,
  table.mobile-cards td[data-label="Action"]::before {
    display: none;
  }

  table.khadc-mobile-cards td[colspan] {
    display: block;
    text-align: center;
    border-bottom: none;
  }

  table.khadc-mobile-cards td[colspan]::before {
    display: none;
  }

  /* Split Desktop Single-Row Cards & Action Rows Cleanly on Mobile */
  .khadc-mobile-stack {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .khadc-mobile-stack > * {
    flex: 0 0 auto !important;
    width: 100% !important;
    text-align: left !important;
  }

  .khadc-mobile-stack > .badge,
  .khadc-mobile-stack > .status-pill {
    width: auto !important;
    align-self: flex-start !important;
  }

  .khadc-mobile-grid-1 {
    grid-template-columns: 1fr !important;
  }

  .khadc-confirm-actions {
    flex-direction: column-reverse;
  }

  .khadc-confirm-btn {
    width: 100%;
  }
}

/* --------------------------------------------------------------------------
   Reduced Motion Respect (Accessibility)
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
