/* app shell */
[hidden] { display: none !important; }

/* ===== App shell / drawer nav / scan / dark theme ===== */
html[data-theme="dark"] body,
body[data-theme="dark"] {
  --app-bg: #0b1622;
  --app-surface: #132233;
  --app-surface-strong: #16293d;
  --app-border: rgba(160, 181, 205, 0.28);
  --app-text: #f4f8fc;
  --app-text-soft: #c6d5e4;
  --app-brand: #12304d;
  --app-brand-2: #f2a65a;
  --app-shadow: 0 20px 44px rgba(0, 0, 0, 0.34);
  --docs-summary-value: #f2b36f;
  --docs-summary-label: #dbe7f3;
}

html[data-theme="light"] body,
body[data-theme="light"],
body:not([data-theme]) {
  --app-bg: #f2f4f7;
  --app-surface: rgba(255,255,255,0.97);
  --app-surface-strong: #ffffff;
  --app-border: rgba(222, 227, 232, 0.98);
  --app-text: #101828;
  --app-text-soft: #667085;
  --app-brand: #0b3a66;
  --app-brand-2: #e87722;
  --app-shadow: 0 16px 40px rgba(16, 24, 40, 0.10);
  --docs-summary-value: #123a66;
  --docs-summary-label: #000000;
}

.card,
.asideBox,
.docsStatCard,
.docsControlsCard,
.docsTableWrap,
.drawer,
.attDialog,
.scanHero,
.scanShell,
.scanResultCard,
.qrDocCard,
.offlineCard {
  background: var(--app-surface);
  border-color: var(--app-border);
  box-shadow: var(--app-shadow);
}

.search,
.select,
.date,
textarea,
input,
.docsToolbarSearch,
.docsToolbarFilters,
#forwardModeWrap,
.latestRemarkCell.hasRemark,
.fileInput,
.modalCard,
.attachList,
.branchMeta,
.inlineBranchBlock,
.ackSummary,
.tGroup,
.tLine,
.tContent,
.aTag {
  background: var(--app-surface-strong);
  border-color: var(--app-border);
  color: var(--app-text);
}

.search::placeholder,
textarea::placeholder,
input::placeholder {
  color: color-mix(in srgb, var(--app-text-soft) 82%, transparent);
}

.appTopbar.topbar {
  top: 0;
  z-index: 0;
  isolation: isolate;
  width: 100%;
  min-height: var(--app-topbar-height);
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  display: block;
  background: linear-gradient(180deg, color-mix(in srgb, var(--app-brand) 96%, #ffffff 4%), color-mix(in srgb, var(--app-brand) 88%, #06121d 12%));
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.navToggle {
  position: relative;
  z-index: 2315;
}

.appTopbarMain {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
}

.appBrandShell,
.appBrandHeaderLink {
  min-width: 0;
  flex: 1 1 auto;
}

.appBrandHeaderLink {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  overflow: hidden;
}

.appBrandLogoLink {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  flex: 0 0 48px;
}

.appBrandLogoLink img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.appBrandTextLink {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.appBrandTextLink h1 {
  margin: 0;
  color: #fff;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appBrandTextLink .brandSubtitle {
  margin-top: 2px;
  color: rgba(233, 240, 247, 0.82);
  font-size: 11.5px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbarTools {
  margin-left: 0;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.topbarToolsLeft {
  order: -1;
}

.appTopbarMain > .appBrandHeaderLink {
  justify-content: flex-start;
}

.navToggle {
  width: 46px;
  height: 46px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  color: #fff;
  box-shadow: none;
}

.navToggle:hover { background: rgba(255,255,255,0.14); cursor: pointer; }
.navToggleLine { width: 18px; height: 2px; border-radius: 999px; background: currentColor; display: block; }

.appNavBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 10, 18, 0.5);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 2400;
}

.appNavBackdrop.isOpen { opacity: 1; pointer-events: auto; }
.appNavBackdrop[hidden] { display: none !important; opacity: 0 !important; pointer-events: none !important; }

.appSideNav {
  position: fixed;
  top: 10px;
  left: 10px;
  bottom: 10px;
  width: var(--drawer-width);
  max-height: none;
  overflow-y: auto;
  padding: 18px 14px 16px;
  border-radius: 28px;
  border: 1px solid var(--app-border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--app-surface-strong) 96%, #ffffff 4%), color-mix(in srgb, var(--app-surface) 98%, #cedbeb 2%));
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.28);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2410;
  transform: translateX(calc(-100% - 20px));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform .22s ease, opacity .22s ease, visibility .22s ease;
}

.appSideNav.isOpen {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.appDrawerHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 4px 10px;
}

.appDrawerBrand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.appDrawerBrand img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: contain;
  background: rgba(11, 58, 102, 0.08);
  padding: 4px;
}

.appDrawerBrand strong,
.appDrawerBrand span { display: block; }
.appDrawerBrand span { font-size: 12px; line-height: 1.25; margin-top: 2px; }

.appDrawerClose {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--app-border);
  background: rgba(148, 163, 184, 0.1);
  color: var(--app-text);
  font-size: 18px;
}

.appDrawerSectionLabel {
  padding: 8px 8px 2px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.appDrawerNavLinks {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.appSideNav a {
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 0 14px;
  border-radius: 16px;
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 700;
  font-size: 14px;
  text-align: left;
  color: var(--app-text);
  background: transparent;
  border: 1px solid transparent;
}

.appSideNav a:hover { background: rgba(11, 58, 102, 0.08); }
.appSideNav .navActive { background: rgba(37, 99, 235, 0.12); border-color: rgba(37, 99, 235, 0.2); color: #1d4ed8; }
.appSideNav .navPlaceholder {
  color: #344054;
  opacity: 1;
}
.appSideNav .navPlaceholder:hover {
  background: rgba(11, 58, 102, 0.05);
}
.appSideNav .navLogout { margin-top: 6px; }
.navIcon { width: 18px; display: inline-flex; justify-content: center; flex: 0 0 18px; opacity: .9; }

.themePickerDrawer { display: flex; padding: 4px 8px 0; justify-content: flex-start; align-items: center; gap: 12px; }
.themeOrb {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid rgba(15, 23, 42, 0.18);
  background: linear-gradient(180deg, #ffffff, #edf2f7);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.65);
}

.themeOrb.themeOrbDark {
  border-color: rgba(255,255,255,0.22);
  background: linear-gradient(180deg, #111827, #020617);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.themeOrb.isActive {
  transform: scale(1.08);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18), inset 0 0 0 1px rgba(255,255,255,0.7);
}

.appInstallDrawerBtn {
  margin: 8px 8px 0;
  min-height: 44px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 14px;
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
  font-weight: 700;
}

.desktopRailToggle,
.themePicker:not(.themePickerDrawer),
.appQuickAction,
.appNav:not(.appSideNav) {
  display: none !important;
}

body.has-desktop-rail .page,
body.desktop-rail-collapsed .page { padding-left: 0 !important; }

.scanPage { display: flex; flex-direction: column; gap: 18px; }
.scanHero,
.scanShell,
.scanResultCard,
.qrDocCard,
.offlineCard { border-radius: 24px; padding: 18px; }
.scanTitle { margin: 0; font-size: clamp(28px, 6vw, 42px); line-height: 1.02; }
.scanLead,
.scanHint,
.scanResultMeta,
.qrSub { font-weight: 600; }

.scanVideoWrap {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  background: #08131d;
  min-height: 320px;
  border: 1px solid rgba(0,0,0,0.08);
}

#scanVideo {
  width: 100%;
  height: min(72vh, 520px);
  object-fit: cover;
  display: block;
}

.scanFrame {
  position: absolute;
  inset: 50% auto auto 50%;
  width: min(64vw, 260px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 3px solid rgba(255,255,255,0.92);
  border-radius: 22px;
  box-shadow: 0 0 0 999px rgba(0,0,0,0.22);
  pointer-events: none;
}

.scanActions,
.scanFallbackActions { display: flex; flex-wrap: wrap; gap: 10px; }
.scanTokenForm { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-top: 10px; }
.scanStatus { min-height: 22px; }
.scanResultCard[hidden] { display: none !important; }
.scanResultTracking { font-size: 22px; font-weight: 900; color: var(--app-brand); }
.qrDocGrid { display: grid; grid-template-columns: 180px 1fr; gap: 10px 14px; }
.qrKey { font-size: 13px; font-weight: 800; }
.qrValue { font-weight: 800; }

.mobileScanFab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 1040;
  min-height: 54px;
  padding: 0 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #0b3a66, #0b5ea8);
  color: #fff;
  text-decoration: none;
  font-weight: 900;
  box-shadow: 0 18px 34px rgba(11, 58, 102, 0.28);
  display: none;
  align-items: center;
}

/* dark mode fixes */
body[data-theme="dark"] .topbar,
body[data-theme="dark"] .appTopbar { background: linear-gradient(180deg, #0d2136, #08131d); }
body[data-theme="dark"] .appBrandLogoLink { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.1); }
body[data-theme="dark"] .appBrandTextLink h1 { color: #f5f9ff; }
body[data-theme="dark"] .appBrandTextLink .brandSubtitle,
body[data-theme="dark"] .appDrawerBrand span,
body[data-theme="dark"] .appDrawerSectionLabel,
body[data-theme="dark"] .appSideNav .navPlaceholder,
body[data-theme="dark"] .appSideNav .navLogout,
body[data-theme="dark"] .docsLead,
body[data-theme="dark"] .docsSectionSub,
body[data-theme="dark"] .docInfoMeta,
body[data-theme="dark"] .requesterMeta,
body[data-theme="dark"] .docStateHint,
body[data-theme="dark"] .deadlineMetaLine,
body[data-theme="dark"] .daysHintText,
body[data-theme="dark"] .latestRemarkText,
body[data-theme="dark"] .tMeta,
body[data-theme="dark"] .tMetaLeft,
body[data-theme="dark"] .tNote,
body[data-theme="dark"] .tLineMove,
body[data-theme="dark"] .tLineLeft,
body[data-theme="dark"] .aMeta,
body[data-theme="dark"] .aNote,
body[data-theme="dark"] .ackSummaryCounts,
body[data-theme="dark"] .ackSummaryEmpty,
body[data-theme="dark"] .ackSummaryPersonSection,
body[data-theme="dark"] .routeLabel,
body[data-theme="dark"] .kv .k,
body[data-theme="dark"] .mini,
body[data-theme="dark"] .muted,
body[data-theme="dark"] .docsResultsMeta,
body[data-theme="dark"] .pagerInfo { color: #bfd1e3; }

body[data-theme="dark"] .appSideNav { background: linear-gradient(180deg, #102132, #0b1723); }
body[data-theme="dark"] .appSideNav .navActive { color: #9cc9ff; background: rgba(96, 165, 250, 0.16); border-color: rgba(96, 165, 250, 0.28); }
body[data-theme="dark"] .appInstallDrawerBtn { color: #b9d7ff; background: rgba(96, 165, 250, 0.12); border-color: rgba(96, 165, 250, 0.24); }
body[data-theme="dark"] .docsTableModern th { background: linear-gradient(180deg, #173f63, #102d48); }

body[data-theme="dark"] .docsTableWrap,
body[data-theme="dark"] .docsControlsCard,
body[data-theme="dark"] .docsStatCard,
body[data-theme="dark"] .card,
body[data-theme="dark"] .asideBox,
body[data-theme="dark"] .drawer,
body[data-theme="dark"] .attDialog,
body[data-theme="dark"] .scanHero,
body[data-theme="dark"] .scanShell,
body[data-theme="dark"] .scanResultCard,
body[data-theme="dark"] .qrDocCard,
body[data-theme="dark"] .offlineCard,
body[data-theme="dark"] .docsToolbarSearch,
body[data-theme="dark"] .docsToolbarFilters,
body[data-theme="dark"] .search,
body[data-theme="dark"] .select,
body[data-theme="dark"] .date,
body[data-theme="dark"] textarea,
body[data-theme="dark"] input,
body[data-theme="dark"] .latestRemarkCell.hasRemark,
body[data-theme="dark"] .attachList,
body[data-theme="dark"] .branchMeta,
body[data-theme="dark"] .inlineBranchBlock,
body[data-theme="dark"] .ackSummary,
body[data-theme="dark"] .tGroup,
body[data-theme="dark"] .tLine,
body[data-theme="dark"] .tContent,
body[data-theme="dark"] .aTag,
body[data-theme="dark"] .docsTableModern tbody tr,
body[data-theme="dark"] .docsTableModern tbody tr td,
body[data-theme="dark"] .notice,
body[data-theme="dark"] .modalCard,
body[data-theme="dark"] .forwardDeadlineWrap,
body[data-theme="dark"] .ackSummaryPerson,
body[data-theme="dark"] .tNote,
body[data-theme="dark"] .tLineNote {
  background: var(--app-surface);
  color: var(--app-text);
  border-color: var(--app-border);
}

body[data-theme="dark"] .docsTableModern tbody tr:hover { background: rgba(23, 41, 60, 0.98); }
body[data-theme="dark"] .docsRow.rowToneIncoming { background: linear-gradient(90deg, rgba(17, 52, 93, 0.55), rgba(13,27,41,0.96)); }
body[data-theme="dark"] .docsRow.rowTonePending { background: linear-gradient(90deg, rgba(95, 24, 24, 0.45), rgba(13,27,41,0.96)); }

body[data-theme="dark"] .docsTitle,
body[data-theme="dark"] .docsSectionTitle,
body[data-theme="dark"] .docInfoTitle,
body[data-theme="dark"] .requesterName,
body[data-theme="dark"] .routeValue.strong,
body[data-theme="dark"] .routeValue,
body[data-theme="dark"] .deadlineBadge,
body[data-theme="dark"] .daysPill,
body[data-theme="dark"] .docStateText,
body[data-theme="dark"] .docMiniBadge,
body[data-theme="dark"] .tGroupTitle,
body[data-theme="dark"] .tLineTitle,
body[data-theme="dark"] .tRemark,
body[data-theme="dark"] .ackSummaryTitle,
body[data-theme="dark"] .ackSummaryPersonName,
body[data-theme="dark"] .aLink,
body[data-theme="dark"] .btnGhost,
body[data-theme="dark"] .drawerClose,
body[data-theme="dark"] .navToggle,
body[data-theme="dark"] .appDrawerClose { color: var(--app-text); }

body[data-theme="dark"] .docMiniBadge,
body[data-theme="dark"] .daysPill,
body[data-theme="dark"] .deadlineBadge,
body[data-theme="dark"] .btnGhost,
body[data-theme="dark"] .pagerBtn,
body[data-theme="dark"] .aTag,
body[data-theme="dark"] .ackSummaryTab,
body[data-theme="dark"] .branchPill {
  background: #122538;
  border-color: rgba(133, 164, 196, 0.22);
}

body[data-theme="dark"] .themeOrb.themeOrbDark {
  background: linear-gradient(180deg, #111827, #020617);
}

body[data-theme="dark"] a:not(.appSideNav a):not(.mobileScanFab):not(.docsAddBtn) { color: #9ac7ff; }

:root {
  --app-topbar-height: 72px;
}

@media (max-width: 980px) {
  :root { --drawer-width: min(320px, calc(100vw - 16px));
          --app-topbar-height: 62px; 
        }

  .content { padding: 16px 14px 80px; }
  .appTopbar.topbar { padding: calc(8px + env(safe-area-inset-top)) 10px 8px; }
  .appTopbarMain { min-height: 54px; gap: 10px; }
  .appBrandHeaderLink { gap: 10px; }
  .appBrandLogoLink { width: 42px; height: 42px; border-radius: 12px; flex-basis: 42px; }
  .appBrandLogoLink img { width: 32px; height: 32px; }

  .appSideNav {
    top: calc(8px + env(safe-area-inset-top));
    left: 8px;
    bottom: 8px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    border-radius: 24px;
  }

  .docsHero,
  .docsControlsTop,
  .docsTableTopbar,
  .scanActions,
  .scanFallbackActions,
  .docsHeroActions,
  .pager,
  .footer {
    flex-direction: column;
    align-items: stretch;
  }

  .docsControlsGrid,
  .scanTokenForm,
  .qrDocGrid { grid-template-columns: 1fr; }

  .docsToolbarSearch,
  .docsToolbarFilters { grid-template-columns: 1fr; }

  .docsControlBtn,
  .docsAddBtn,
  .docsClearFilters,
  .btnSecondary,
  .btnPrimary,
  .btnComp,
  .btnGreen,
  .btnGhost,
  .appInstallDrawerBtn { width: 100%; }

  .docsTableWrap {
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .docsTableModern,
  .docsTableModern thead,
  .docsTableModern tbody,
  .docsTableModern th,
  .docsTableModern td,
  .docsTableModern tr { display: block; }

  .docsTableModern { min-width: 0; }
  .docsTableModern thead { display: none; }
  .docsTableModern tbody { display: grid; gap: 12px; }

  .docsTableModern tbody tr {
    border-radius: 22px;
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    box-shadow: var(--app-shadow);
    padding: 6px 0;
    overflow: hidden;
  }

  .docsTableModern tbody tr td {
    border-bottom: 1px solid rgba(148,163,184,0.14);
    padding: 12px 14px;
  }

  .docsTableModern tbody tr td:last-child { border-bottom: 0; }

  .docsTableModern td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 8px;
    color: var(--app-text-soft);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .08em;
  }

  .drawer { width: 100vw; border-left: 0; }
  .drawerHeader { padding-top: calc(14px + env(safe-area-inset-top)); }
  .kv { grid-template-columns: 1fr; gap: 6px; }
  .drawerActions { justify-content: stretch; }
  .drawerActions > * { flex: 1 1 calc(50% - 8px); }
  .docsStatsGrid { grid-template-columns: 1fr 1fr; }
  .docsTitle { font-size: 30px; }
  .mobileScanFab { display: inline-flex; }
}

@media (max-width: 640px) {
  .topbar { padding-left: 14px; padding-right: 14px; }
  .logo { height: 50px; }
  .brand { gap: 10px; }
  .docsStatsGrid { grid-template-columns: 1fr; }
  .docsSummaryPill { width: 100%; justify-content: center; }
  .drawerActions > * { flex-basis: 100%; }
  .scanVideoWrap { min-height: 260px; }
  #scanVideo { height: min(64vh, 420px); }
  .mobileScanFab { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
}

@media (max-width: 1100px) {
  .appBrandHeaderLink { flex: 0 1 auto; gap: 0; }
  .appBrandTextLink { display: none !important; }
}

@media (min-width: 1101px) {
  .appBrandTextLink { display: flex !important; }
}


body[data-theme="dark"] .themeOrb {
  background: linear-gradient(180deg, #ffffff, #dfe7f1);
  border-color: rgba(191, 209, 227, 0.7);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.78);
}

body[data-theme="dark"] .themeOrb.themeOrbDark {
  background: linear-gradient(180deg, #111827, #020617);
  border-color: rgba(191, 209, 227, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

body[data-theme="light"] .themeOrb:not(.themeOrbDark),
body:not([data-theme]) .themeOrb:not(.themeOrbDark) {
  background: linear-gradient(180deg, #ffffff, #edf2f7);
}

body[data-theme="light"] .themeOrb.themeOrbDark,
body:not([data-theme]) .themeOrb.themeOrbDark {
  background: linear-gradient(180deg, #111827, #020617);
}

.drawerBackdrop {
  z-index: 1400;
}

.drawer {
  z-index: 1410;
}

@media (max-width: 980px) {
  .appTopbarMain {
    justify-content: flex-start;
  }

  .topbarToolsLeft {
    margin-right: 2px;
  }
}

.appSideNav { overscroll-behavior: contain; }
.appDrawerSectionLabel { text-align: left; }


/* ===== 2026-03-16 hotfix: drawer layering + darker theme contrast ===== */
body[data-theme="dark"]::before {
  opacity: 0.035;
  filter: grayscale(20%) blur(4px);
}

body[data-theme="dark"] {
  background:
    radial-gradient(circle at top right, rgba(242,166,90,0.08), transparent 24%),
    radial-gradient(circle at top left, rgba(43,108,176,0.10), transparent 24%),
    var(--app-bg);
}

body[data-theme="dark"] .docsHero,
body[data-theme="dark"] .docsControlsCard,
body[data-theme="dark"] .docsStatCard,
body[data-theme="dark"] .docsTableWrap,
body[data-theme="dark"] .toolbar,
body[data-theme="dark"] .docsToolbarSearch,
body[data-theme="dark"] .docsToolbarFilters,
body[data-theme="dark"] .card,
body[data-theme="dark"] .asideBox,
body[data-theme="dark"] .drawer,
body[data-theme="dark"] .modalCard,
body[data-theme="dark"] .attDialog,
body[data-theme="dark"] .scanHero,
body[data-theme="dark"] .scanShell,
body[data-theme="dark"] .scanResultCard,
body[data-theme="dark"] .qrDocCard,
body[data-theme="dark"] .offlineCard {
  background: rgba(19, 34, 51, 0.96);
  border-color: rgba(160, 181, 205, 0.24);
}

body[data-theme="dark"] .docsTableTopbar,
body[data-theme="dark"] .latestRemarkCell.hasRemark,
body[data-theme="dark"] .attachList,
body[data-theme="dark"] .branchMeta,
body[data-theme="dark"] .inlineBranchBlock,
body[data-theme="dark"] .ackSummary,
body[data-theme="dark"] .tGroup,
body[data-theme="dark"] .tContent,
body[data-theme="dark"] .tLine,
body[data-theme="dark"] .tNote,
body[data-theme="dark"] .tLineNote,
body[data-theme="dark"] .ackSummaryPerson,
body[data-theme="dark"] .forwardDeadlineWrap {
  background: rgba(22, 41, 61, 0.96);
  border-color: rgba(160, 181, 205, 0.22);
}

body[data-theme="dark"] .docsTableModern tbody tr,
body[data-theme="dark"] .docsTableModern tbody tr td {
  background: rgba(19, 34, 51, 0.94);
}

body[data-theme="dark"] .docsTableModern tbody tr:hover,
body[data-theme="dark"] .docsRow.rowToneIncoming:hover,
body[data-theme="dark"] .docsRow.rowTonePending:hover {
  background: rgba(26, 48, 71, 0.98);
}

body[data-theme="dark"] .docsRow.rowToneIncoming {
  background: linear-gradient(90deg, rgba(21, 112, 239, 0.18), rgba(19, 34, 51, 0.96));
}

body[data-theme="dark"] .docsRow.rowTonePending {
  background: linear-gradient(90deg, rgba(217, 45, 32, 0.18), rgba(19, 34, 51, 0.96));
}

body[data-theme="dark"] .docsTitle,
body[data-theme="dark"] .docsSectionTitle,
body[data-theme="dark"] .docInfoTitle,
body[data-theme="dark"] .requesterName,
body[data-theme="dark"] .routeValue,
body[data-theme="dark"] .routeValue.strong,
body[data-theme="dark"] .drawerTitle,
body[data-theme="dark"] .kv .v,
body[data-theme="dark"] .statValue,
body[data-theme="dark"] .statTitle,
body[data-theme="dark"] .drawerHeader *,
body[data-theme="dark"] .drawerActions *,
body[data-theme="dark"] .docStateText,
body[data-theme="dark"] .latestRemarkText,
body[data-theme="dark"] .deadlineBadge,
body[data-theme="dark"] .daysPill,
body[data-theme="dark"] .docMiniBadge,
body[data-theme="dark"] .btnGhost,
body[data-theme="dark"] .aLink {
  color: var(--app-text);
}

.docMiniBadge.new {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #ffffff;
  border: 1px solid rgba(21, 128, 61, 0.45);
  box-shadow:
    0 0 0 1px rgba(34, 197, 94, 0.18),
    0 6px 14px rgba(21, 128, 61, 0.28);
  font-weight: 900;
  animation: docNewPulse 1.6s ease-in-out infinite;
}

body[data-theme="dark"] .docMiniBadge.new {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #ffffff;
  border: 1px solid rgba(21, 128, 61, 0.45);
  box-shadow:
    0 0 0 1px rgba(34, 197, 94, 0.18),
    0 6px 14px rgba(21, 128, 61, 0.28);
}

body[data-theme="dark"] .docsLead,
body[data-theme="dark"] .docsSectionSub,
body[data-theme="dark"] .docInfoMeta,
body[data-theme="dark"] .requesterMeta,
body[data-theme="dark"] .docStateHint,
body[data-theme="dark"] .deadlineMetaLine,
body[data-theme="dark"] .daysHintText,
body[data-theme="dark"] .routeLabel,
body[data-theme="dark"] .mini,
body[data-theme="dark"] .muted,
body[data-theme="dark"] .docsResultsMeta,
body[data-theme="dark"] .drawerSub,
body[data-theme="dark"] .kv .k,
body[data-theme="dark"] .tMeta,
body[data-theme="dark"] .tMetaLeft,
body[data-theme="dark"] .tLineMove,
body[data-theme="dark"] .tLineLeft,
body[data-theme="dark"] .aMeta,
body[data-theme="dark"] .aNote,
body[data-theme="dark"] .ackSummaryCounts,
body[data-theme="dark"] .ackSummaryEmpty,
body[data-theme="dark"] .ackSummaryPersonSection {
  color: var(--app-text-soft);
}

body[data-theme="dark"] .search,
body[data-theme="dark"] .select,
body[data-theme="dark"] .date,
body[data-theme="dark"] textarea,
body[data-theme="dark"] input,
body[data-theme="dark"] .fileInput,
body[data-theme="dark"] .drawerActionRemarksInput {
  background: #102234;
  color: var(--app-text);
  border-color: rgba(160, 181, 205, 0.24);
}

body[data-theme="dark"] .search::placeholder,
body[data-theme="dark"] textarea::placeholder,
body[data-theme="dark"] input::placeholder {
  color: #a9bfd4;
}

body[data-theme="dark"] .chip.incoming { background: rgba(243,156,18,.18); color: #ffd18b; border-color: rgba(243,156,18,.28); }
body[data-theme="dark"] .chip.action { background: rgba(21,112,239,.18); color: #9cc9ff; border-color: rgba(21,112,239,.28); }
body[data-theme="dark"] .chip.released { background: rgba(18,183,106,.18); color: #9cf0bf; border-color: rgba(18,183,106,.28); }
body[data-theme="dark"] .chip.archived { background: rgba(148,163,184,.18); color: #d3deea; border-color: rgba(148,163,184,.26); }
body[data-theme="dark"] .chip.overdue { background: rgba(217,45,32,.18); color: #ffb4ab; border-color: rgba(217,45,32,.28); }

.drawerBackdrop {
  z-index: 2300;
}

.drawer {
  z-index: 2310;
}

.drawerHeader {
  top: 0;
  z-index: 5;
  background: inherit;
}

.drawerClose {
  position: relative;
  z-index: 6;
  color: red;
}

#d_branch_wrap {
  z-index: 1 !important;
}

@media (max-width: 980px) {
  .drawer {
    z-index: 2310;
  }

  .drawerHeader {
    padding-top: calc(14px + env(safe-area-inset-top));
  }
}


/* ===== Scan page refresh ===== */
html { scroll-behavior: smooth; }

.scanPageZoho {
  gap: 14px;
}

.scanHeroCompact,
.scanShellCompact,
.scanResultCardCompact {
  border-radius: 20px;
  padding: 14px;
}

.scanHeroCompact {
  background: linear-gradient(180deg, rgba(11,58,102,0.08), rgba(255,255,255,0.92));
}

.scanHeroTopline,
.scanHeroBody,
.scanSectionHead,
.scanResultRow,
.scanMiniStats,
.scanTabs,
.scanStatusPanel {
  display: flex;
  gap: 10px;
}

.scanHeroTopline,
.scanSectionHead,
.scanResultRow {
  align-items: center;
  justify-content: space-between;
}

.scanHeroBody {
  align-items: flex-start;
  justify-content: space-between;
}

.scanHeroPill,
.scanStatusBadge,
.scanOverlayChip,
.scanTabLink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
}

.scanHeroPill,
.scanOverlayChip {
  background: rgba(11,58,102,0.08);
  color: #0b3a66;
}

.scanStatusBadge {
  background: rgba(148,163,184,0.14);
  color: #334155;
  white-space: nowrap;
}

.scanStatusBadge[data-tone="good"] {
  background: rgba(34,197,94,0.12);
  color: #166534;
}

.scanStatusBadge[data-tone="warn"] {
  background: rgba(245,158,11,0.14);
  color: #92400e;
}

.scanStatusBadge[data-tone="bad"] {
  background: rgba(239,68,68,0.12);
  color: #991b1b;
}

.scanMiniStats {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.scanMiniStat,
.scanHelpCard,
.scanStatusPanel {
  border: 1px solid rgba(148,163,184,0.16);
  background: rgba(255,255,255,0.82);
  box-shadow: 0 10px 24px rgba(15,23,42,0.06);
}

.scanMiniStat {
  min-width: 112px;
  padding: 10px 12px;
  border-radius: 14px;
}

.scanMiniLabel,
.scanSectionSub,
.scanTinyNote,
.scanResultLabel,
.scanHelpCard p {
  color: var(--app-text-soft);
  font-size: 12px;
  line-height: 1.45;
}

.scanMiniLabel {
  display: block;
  margin-bottom: 4px;
}

.scanTabs {
  position: sticky;
  top: calc(var(--app-topbar-height) + 8px);
  z-index: 20;
  flex-wrap: wrap;
  padding: 8px;
  border: 1px solid rgba(148,163,184,0.14);
  border-radius: 18px;
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(12px);
}

.scanTabLink {
  text-decoration: none;
  color: var(--app-text-soft);
  background: rgba(148,163,184,0.12);
}

.scanTabLink:hover {
  color: var(--app-brand);
  background: rgba(11,58,102,0.08);
}

.scanPrimaryActions {
  align-items: stretch;
}

.scanFileLabel,
.scanOpenLink {
  text-decoration: none;
}

.scanVideoWrapCompact {
  min-height: 280px;
  border-radius: 18px;
}

#scanVideo {
  background: #08131d;
}

.scanOverlayTop {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: flex-start;
  pointer-events: none;
}

.scanStatusPanel {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 16px;
}

.scanStatus[data-state="error"] {
  color: #b42318;
}

.scanTokenFormCompact {
  margin-top: 0;
}

.scanResultStack {
  display: grid;
  gap: 10px;
}

.scanResultRow {
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid rgba(148,163,184,0.16);
  border-radius: 14px;
  background: rgba(255,255,255,0.82);
}

.scanResultLabel {
  min-width: 68px;
  font-weight: 800;
}

.scanResultMeta {
  overflow-wrap: anywhere;
}

.scanHelpGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.scanHelpCard {
  padding: 12px;
  border-radius: 16px;
}

.scanHelpTitle {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
}

@media (max-width: 980px) {
  .scanHeroBody,
  .scanSectionHead,
  .scanResultRow {
    flex-direction: column;
    align-items: stretch;
  }

  .scanMiniStats {
    justify-content: stretch;
  }

  .scanTabs {
    top: calc(var(--app-topbar-height) + 6px);
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .scanTabs::-webkit-scrollbar {
    display: none;
  }

  .scanTabLink {
    flex: 0 0 auto;
  }

  .scanHelpGrid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .scanTitle {
    font-size: 24px;
    line-height: 1.08;
  }

  .scanLead {
    font-size: 12px;
    line-height: 1.45;
  }

  .scanHeroCompact,
  .scanShellCompact,
  .scanResultCardCompact {
    border-radius: 18px;
    padding: 12px;
  }

  .scanVideoWrapCompact {
    min-height: 240px;
  }

  #scanVideo {
    height: min(52vh, 340px);
  }

  .scanFrame {
    width: min(68vw, 220px);
    border-radius: 18px;
  }

  .scanResultTracking {
    font-size: 18px;
  }

  .scanMiniStat,
  .scanStatusPanel,
  .scanResultRow,
  .scanHelpCard {
    box-shadow: none;
  }
}

body[data-theme="dark"] .scanHeroCompact {
  background: linear-gradient(180deg, rgba(11,58,102,0.26), rgba(8,19,29,0.96));
}

body[data-theme="dark"] .scanMiniStat,
body[data-theme="dark"] .scanHelpCard,
body[data-theme="dark"] .scanStatusPanel,
body[data-theme="dark"] .scanResultRow,
body[data-theme="dark"] .scanTabs {
  background: rgba(8,19,29,0.92);
  border-color: rgba(148,163,184,0.18);
}

body[data-theme="dark"] .scanHeroPill,
body[data-theme="dark"] .scanOverlayChip,
body[data-theme="dark"] .scanTabLink {
  background: rgba(96,165,250,0.12);
  color: #dbeafe;
}

body[data-theme="dark"] .scanStatusBadge {
  background: rgba(148,163,184,0.18);
  color: #cbd5e1;
}


/* ===== 2026-03-25 QR scan robustness + compact status layout ===== */
.scanStageGrid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, .9fr);
  gap: 12px;
  align-items: start;
}

.scanVideoWrapCompact {
  position: relative;
  overflow: hidden;
}

.scanVideoWrapCompact.isLive {
  box-shadow: inset 0 0 0 1px rgba(34,197,94,0.22);
}

#scanVideo {
  width: 100%;
  object-fit: cover;
}

.scanVideoState {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(8, 19, 29, 0.72);
  color: #e5eef7;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
}

.scanVideoState[data-tone="good"] { background: rgba(22, 101, 52, 0.84); }
.scanVideoState[data-tone="warn"] { background: rgba(146, 64, 14, 0.88); }
.scanVideoState[data-tone="bad"] { background: rgba(153, 27, 27, 0.88); }

.scanSideCard {
  border: 1px solid rgba(148,163,184,0.16);
  background: rgba(255,255,255,0.82);
  box-shadow: 0 10px 24px rgba(15,23,42,0.06);
  border-radius: 18px;
  padding: 12px;
  min-width: 0;
}

.scanSideHead {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}

.scanSideHint,
.scanPreviewEmpty {
  color: var(--app-text-soft);
  font-size: 12px;
  line-height: 1.45;
}

.scanPreviewWrap {
  border: 1px dashed rgba(148,163,184,0.24);
  border-radius: 14px;
  background: rgba(248,250,252,0.92);
  overflow: hidden;
}

.scanPreviewWrap img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  background: #eef2f6;
}

.scanPreviewEmpty {
  padding: 12px;
  border: 1px dashed rgba(148,163,184,0.22);
  border-radius: 14px;
  background: rgba(248,250,252,0.76);
}

.scanDebugList {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.scanDebugItem {
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,0.16);
  background: rgba(248,250,252,0.94);
  color: #334155;
  font-size: 11.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.scanDebugItem[data-tone="good"] {
  border-color: rgba(34,197,94,0.18);
  background: rgba(240,253,244,0.94);
  color: #166534;
}

.scanDebugItem[data-tone="warn"] {
  border-color: rgba(245,158,11,0.18);
  background: rgba(255,251,235,0.96);
  color: #92400e;
}

.scanDebugItem[data-tone="bad"] {
  border-color: rgba(239,68,68,0.18);
  background: rgba(254,242,242,0.96);
  color: #991b1b;
}

.qrPageZoho {
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.qrDocCardCompact,
.qrInfoCard,
.qrReceiveCard {
  border-radius: 20px;
  padding: 14px;
}

.qrDocCardCompact {
  background: linear-gradient(180deg, rgba(11,58,102,0.08), rgba(255,255,255,0.92));
}

.qrHeroTop,
.qrDocRow,
.qrInfoGrid {
  display: flex;
  gap: 10px;
}

.qrHeroTop,
.qrDocRow {
  align-items: flex-start;
  justify-content: space-between;
}

.qrStatusPill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(11,58,102,0.08);
  color: #0b3a66;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
}

.qrLead,
.qrDocLabel,
.qrMuted {
  color: var(--app-text-soft);
}

.qrDocGrid {
  display: grid;
  gap: 10px;
}

.qrDocRow {
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid rgba(148,163,184,0.16);
  background: rgba(255,255,255,0.82);
}

.qrDocLabel {
  min-width: 110px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.qrDocValue {
  min-width: 0;
  flex: 1 1 auto;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.qrInfoCard,
.qrReceiveCard {
  border: 1px solid rgba(148,163,184,0.16);
  background: rgba(255,255,255,0.9);
  box-shadow: 0 10px 24px rgba(15,23,42,0.06);
}

.qrActionRow {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

@media (max-width: 900px) {
  .scanStageGrid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .scanSideCard,
  .scanPreviewEmpty,
  .scanDebugItem,
  .qrDocCardCompact,
  .qrInfoCard,
  .qrReceiveCard,
  .qrDocRow {
    box-shadow: none;
  }

  .qrHeroTop,
  .qrDocRow {
    flex-direction: column;
    align-items: stretch;
  }

  .qrDocLabel { min-width: 0; }
}

body[data-theme="dark"] .scanSideCard,
body[data-theme="dark"] .scanPreviewWrap,
body[data-theme="dark"] .scanPreviewEmpty,
body[data-theme="dark"] .scanDebugItem,
body[data-theme="dark"] .qrDocCardCompact,
body[data-theme="dark"] .qrInfoCard,
body[data-theme="dark"] .qrReceiveCard,
body[data-theme="dark"] .qrDocRow {
  background: rgba(8,19,29,0.92);
  border-color: rgba(148,163,184,0.18);
}

body[data-theme="dark"] .scanPreviewWrap img { background: #0f1d2b; }
body[data-theme="dark"] .scanDebugItem { color: #dbe7f3; }
body[data-theme="dark"] .scanDebugItem[data-tone="good"] { color: #bbf7d0; }
body[data-theme="dark"] .scanDebugItem[data-tone="warn"] { color: #fde68a; }
body[data-theme="dark"] .scanDebugItem[data-tone="bad"] { color: #fecaca; }
body[data-theme="dark"] .qrDocCardCompact { background: linear-gradient(180deg, rgba(11,58,102,0.26), rgba(8,19,29,0.96)); }
body[data-theme="dark"] .qrStatusPill { background: rgba(96,165,250,0.12); color: #dbeafe; }
