:root {
  --bg: #f5f7fb;
  --card-bg: #ffffff;
  --accent: #1f6fff;
  --accent-soft: rgba(31, 111, 255, 0.12);
  --text-main: #111827;
  --text-muted: #6b7280;
  --border-subtle: #e5e7eb;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --shadow-soft: 0 22px 45px rgba(15, 23, 42, 0.08);
  --shadow-input: 0 10px 30px rgba(15, 23, 42, 0.07);
  --transition-fast: 180ms ease-out;
  /* Background parallax variables */
  --bg-x: 0px;
  --bg-y: 0px;
  --bg-scroll: 0px;
  /* Mouse reveal effect variables */
  --mouse-x: 50%;
  --mouse-y: 50%;
  --reveal-opacity: 0;
  --reveal-size: 200px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100vh;
  max-height: 100vh;
  width: 100vw;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Helvetica Neue", Arial, sans-serif;
  color: var(--text-main);
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: auto; /* Enable pull-to-refresh on mobile */
  background-color: transparent; /* Ensure no white background shows through */
}

body {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

/* Parallax Background Layer - Grayscale/Washed Out */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: url('/archback.webp');
  /* Fill the page while maintaining aspect ratio */
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  z-index: -2;
  will-change: transform, filter;
  transform: translate(
    calc(var(--bg-x, 0px) * 0.6),
    calc(var(--bg-y, 0px) * 0.6 + var(--bg-scroll, 0px))
  );
  filter: grayscale(100%) brightness(0.4) contrast(0.8);
  opacity: 0.6;
  transition: filter 0.3s ease-out, opacity 0.3s ease-out;
}

/* Reveal Layer - Original Color at Mouse Position with Trail */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: url('/archback.webp');
  /* Fill the page while maintaining aspect ratio */
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  z-index: -1;
  will-change: transform, opacity, mask;
  transform: translate(
    calc(var(--bg-x, 0px) * 0.6),
    calc(var(--bg-y, 0px) * 0.6 + var(--bg-scroll, 0px))
  );
  opacity: var(--reveal-opacity, 0);
  mask: var(--reveal-mask, radial-gradient(
    circle var(--reveal-size, 200px) at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 0.8) 30%,
    rgba(0, 0, 0, 0.4) 50%,
    rgba(0, 0, 0, 0) 100%
  ));
  -webkit-mask: var(--reveal-mask, radial-gradient(
    circle var(--reveal-size, 200px) at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 0.8) 30%,
    rgba(0, 0, 0, 0.4) 50%,
    rgba(0, 0, 0, 0) 100%
  ));
  transition: opacity 0.2s ease-out;
  pointer-events: none;
}

/* Mobile: gyroscope + scroll parallax */
@media (max-width: 768px) {
  body::before,
  body::after {
    transform: translate(
      calc(var(--bg-x, 0px) * 0.6),
      calc(var(--bg-y, 0px) * 0.6 + var(--bg-scroll, 0px))
    );
  }
}

/* Desktop: mouse move + scroll parallax */
@media (min-width: 769px) {
  body::before,
  body::after {
    transform: translate(
      calc(var(--bg-x, 0px) * 0.6),
      calc(var(--bg-y, 0px) * 0.6 + var(--bg-scroll, 0px))
    );
  }
}

.page-wrapper {
  width: 100%;
  max-width: 1100px;
  height: calc(100vh - 48px);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* Page entry animations */
.page-wrapper.entering {
  animation: slideDownBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

body.entering::before {
  opacity: 0 !important;
  animation: fadeInBackgroundBase 0.6s ease-out 0.2s forwards;
}

body.entering::after {
  opacity: 0 !important;
}

@keyframes fadeInBackgroundBase {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 0.6;
  }
}

@keyframes slideDownBounce {
  0% {
    transform: translateY(-50px);
    opacity: 0;
  }
  60% {
    transform: translateY(10px);
    opacity: 0.9;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fadeInBackground {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Detail view: allow page scrolling */
html.detail-view-active,
body.detail-view-active {
  height: auto !important;
  max-height: none !important;
  overflow: auto !important;
  overflow-x: hidden !important;
}

body.detail-view-active {
  align-items: flex-start !important;
  padding-bottom: 40px !important;
}

body.detail-view-active .page-wrapper {
  height: auto !important;
}

body.detail-view-active .shell {
  height: auto !important;
  overflow: visible !important;
}

/* Custom scrollbar for page-wrapper */
.page-wrapper::-webkit-scrollbar {
  width: 6px;
}

.page-wrapper::-webkit-scrollbar-thumb {
  background: #d1d1d6;
  border-radius: 999px;
}

.shell {
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  /* Beautiful diagonal gradient greenish glass effect */
  background: linear-gradient(
    135deg,
    rgba(180, 220, 200, 0.25) 0%,
    rgba(160, 210, 180, 0.3) 25%,
    rgba(140, 200, 160, 0.28) 50%,
    rgba(150, 215, 175, 0.3) 75%,
    rgba(170, 225, 190, 0.25) 100%
  );
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-radius: 32px;
  border: 1px solid rgba(120, 180, 140, 0.4);
  /* Drop shadow and bevel effect */
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.2),
    0 8px 24px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(150, 200, 170, 0.5) inset,
    0 2px 4px rgba(255, 255, 255, 0.3) inset,
    0 -2px 8px rgba(0, 0, 0, 0.1) inset,
    0 0 60px rgba(120, 200, 150, 0.1);
  padding: 40px 32px 36px;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  transition: box-shadow 0.3s ease-out;
  display: flex;
  flex-direction: column;
}

/* When search results are shown, shell expands to fill available space */
.shell:has(#list-view:not(.hidden)) {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}


/* Subtle glow on hover */
.shell:hover {
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.2),
    0 8px 24px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(150, 200, 170, 0.5) inset,
    0 2px 4px rgba(255, 255, 255, 0.3) inset,
    0 -2px 8px rgba(0, 0, 0, 0.1) inset,
    0 0 80px rgba(120, 220, 160, 0.25),
    0 0 120px rgba(100, 200, 140, 0.15);
}

/* Edge distortion layer for glass refraction effect */
.shell::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(180, 220, 200, 0.2) 0%,
    rgba(160, 210, 180, 0.25) 25%,
    rgba(140, 200, 160, 0.22) 50%,
    rgba(150, 215, 175, 0.25) 75%,
    rgba(170, 225, 190, 0.2) 100%
  );
  border-radius: 32px;
  z-index: -1;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0.8;
  pointer-events: none;
  /* Edge distortion/refraction - stronger at edges for glass effect */
  mask: 
    radial-gradient(ellipse 200% 100% at 0% 50%, transparent 0%, rgba(0, 0, 0, 0.2) 5%, rgba(0, 0, 0, 0.8) 10%, rgba(0, 0, 0, 1) 15%, rgba(0, 0, 0, 1) 85%, rgba(0, 0, 0, 0.8) 90%, rgba(0, 0, 0, 0.2) 95%, transparent 100%),
    radial-gradient(ellipse 100% 200% at 50% 0%, transparent 0%, rgba(0, 0, 0, 0.2) 5%, rgba(0, 0, 0, 0.8) 10%, rgba(0, 0, 0, 1) 15%, rgba(0, 0, 0, 1) 85%, rgba(0, 0, 0, 0.8) 90%, rgba(0, 0, 0, 0.2) 95%, transparent 100%);
  -webkit-mask: 
    radial-gradient(ellipse 200% 100% at 0% 50%, transparent 0%, rgba(0, 0, 0, 0.2) 5%, rgba(0, 0, 0, 0.8) 10%, rgba(0, 0, 0, 1) 15%, rgba(0, 0, 0, 1) 85%, rgba(0, 0, 0, 0.8) 90%, rgba(0, 0, 0, 0.2) 95%, transparent 100%),
    radial-gradient(ellipse 100% 200% at 50% 0%, transparent 0%, rgba(0, 0, 0, 0.2) 5%, rgba(0, 0, 0, 0.8) 10%, rgba(0, 0, 0, 1) 15%, rgba(0, 0, 0, 1) 85%, rgba(0, 0, 0, 0.8) 90%, rgba(0, 0, 0, 0.2) 95%, transparent 100%);
  mask-composite: intersect;
  -webkit-mask-composite: source-in;
}

/* Subtle light accent blobs */
.shell::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: 999px;
  filter: blur(40px);
  opacity: 0.4;
  z-index: -1;
  width: 300px;
  height: 300px;
  background: radial-gradient(
    circle,
    rgba(120, 200, 150, 0.2) 0%,
    rgba(100, 180, 130, 0.15) 40%,
    transparent 70%
  );
  top: -150px;
  left: -100px;
}

.header {
  text-align: center;
  margin-bottom: 18px;
  position: relative;
  z-index: 1;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(31, 111, 255, 0.04);
  border: 1px solid rgba(31, 111, 255, 0.09);
  font-size: 12px;
  font-weight: 500;
  color: #2563eb;
  margin-bottom: 12px;
}

.eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25);
}

/* Main title: R&B Central Kashmir - Dark grey with white outline */
.title {
  font-family: 'Baumans', cursive;
  font-size: clamp(42px, 6vw, 72px);
  font-weight: 400;
  letter-spacing: 0.02em;
  margin: 0 0 8px;
  color: #333333;
  text-shadow: 
    -0.5px -0.5px 0 #fff,
    0.5px -0.5px 0 #fff,
    -0.5px 0.5px 0 #fff,
    0.5px 0.5px 0 #fff,
    -1px 0 0 #fff,
    1px 0 0 #fff,
    0 -1px 0 #fff,
    0 1px 0 #fff;
}

/* Secondary title: DPR Tracker - White with dark grey outline */
.subtitle {
  font-family: 'Bruno Ace', cursive;
  font-size: clamp(22px, 3vw, 36px);
  font-weight: 400;
  margin-top: 4px;
  letter-spacing: 0.05em;
  color: #ffffff;
  text-shadow: 
    -0.5px -0.5px 0 #333333,
    0.5px -0.5px 0 #333333,
    -0.5px 0.5px 0 #333333,
    0.5px 0.5px 0 #333333,
    -1px 0 0 #333333,
    1px 0 0 #333333,
    0 -1px 0 #333333,
    0 1px 0 #333333;
}

/* Mobile: larger title fonts */
@media (max-width: 768px) {
  .title {
    font-size: clamp(48px, 12vw, 80px);
  }
  
  .subtitle {
    font-size: clamp(32px, 8vw, 56px);
  }
}

.description {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
  text-align: center;
}

.search-bar-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 14px;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}

.search-card {
  background: var(--card-bg);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  width: 100%;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 540px;
  background: #f9fafb;
  padding: 8px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: var(--shadow-input);
  transition: box-shadow var(--transition-fast),
    transform var(--transition-fast),
    border-color var(--transition-fast),
    background-color var(--transition-fast);
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-input);
  background: #ffffff;
  transform: translateY(-1px);
}

.search-inner {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f9fafb;
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: var(--shadow-input);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.search-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  font-size: 18px;
}

.search-icon svg {
  width: 100%;
  height: 100%;
}

input[type="text"] {
  flex: 1;
  border: none;
  outline: none;
  padding: 12px 16px;
  font-size: 14px;
  background: transparent;
  color: var(--text-main);
}

input[type="text"]::placeholder {
  color: #9ca3af;
}

.search-input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: 14px;
  color: var(--text-main);
}

.search-input::placeholder {
  color: #9ca3af;
}

.search-btn {
  border: none;
  outline: none;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 24px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 15px 40px rgba(37, 99, 235, 0.55);
  transform: translateY(0);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
              background var(--transition-fast);
  white-space: nowrap;
}

.search-btn:focus-visible {
  outline: 2px solid #bfdbfe;
  outline-offset: 2px;
}

.search-btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 18px 45px rgba(37, 99, 235, 0.55);
}

.search-btn:active {
  transform: translateY(0);
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.5);
}

.search-btn.loading {
  opacity: 0.7;
  cursor: not-allowed;
  position: relative;
}

.search-btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  margin: auto;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--border-subtle);
  background: #f9fafb;
  color: #4b5563;
  cursor: default;
  white-space: nowrap;
}

#status {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  min-height: 20px;
  position: relative;
  z-index: 1;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  text-align: center;
}

.loading-text {
  position: relative;
  display: inline-block;
}

.loading-text::after {
  content: '...';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

.content-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.1fr);
  gap: 18px;
  margin-top: 16px;
  margin-bottom: 16px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
}


#list-view {
  grid-template-columns: 1fr !important;
  grid-template-rows: 1fr !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
}

#list-view .card {
  height: 100%;
}

@media (max-width: 900px) {
  .content-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  max-height: 100%;
}


.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  flex-shrink: 0; /* Don't shrink the header */
  padding: 0; /* No extra padding */
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

.card-sub {
  font-size: 14px;
  color: var(--text-muted);
}

.table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  flex: 1 1 0; /* Take remaining space */
  min-width: 0;
  min-height: 0;
  /* Make table-wrapper fill remaining space in card */
  margin: 0; /* No margin */
  padding: 0 0 16px 0; /* Add bottom padding for scrollable content */
  display: block; /* Ensure it's a block element */
}

.table-wrapper::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: #d1d1d6;
  border-radius: 999px;
}

table {
  border-collapse: collapse;
  width: 100%;
  max-width: 100%;
  table-layout: auto;
  min-width: 0;
  /* Ensure table doesn't constrain wrapper height */
  height: auto;
}

th,
td {
  padding: 10px 12px;
  font-size: 15px;
  text-align: left;
  border-bottom: 1px solid #f0f0f5;
  box-sizing: border-box;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

th {
  background: #f8f8fb;
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 600;
  white-space: nowrap;
  padding: 12px 14px;
  font-size: 16px;
}

td {
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background-color 150ms ease-out, transform 100ms ease-out;
}

tbody tr:hover {
  background: #f5f7fb;
  transform: translateY(-1px);
}

/* Add margin at bottom of table */
tbody tr:last-child td {
  padding-bottom: 20px; /* Extra padding for last row */
  border-bottom: none; /* Remove border from last row */
}

.pill-btn {
  border: none;
  outline: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  cursor: pointer;
  background: #f5f7fb;
  color: var(--text-main);
  transition: background-color 140ms ease-out,
    transform 100ms ease-out;
  white-space: nowrap;
}

.pill-btn:hover {
  background: #e5e7eb;
  transform: translateY(-0.5px);
}

.pill-btn.primary {
  background: var(--accent);
  color: #fff;
}

.pill-btn.primary:hover {
  background: #1d4ed8;
}

.pill-btn.ghost {
  background: #f5f7fb;
}

.pill-btn.view-btn {
  background: #22c55e;
  color: #ffffff;
  font-weight: 600;
  border: none;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
  transition: background-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.pill-btn.view-btn:hover {
  background: #16a34a;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
  transform: translateY(-1px);
}

.pill-btn.view-btn:active {
  background: #15803d;
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(34, 197, 94, 0.3);
}

.hidden {
  display: none !important;
}

/* DETAIL VIEW */

#detail-view {
  grid-template-columns: 1fr !important;
}

#detail-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 20px 20px 18px;
  box-shadow: var(--shadow-soft);
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  /* Allow content to determine height - no max-height restriction */
  min-height: fit-content;
}

.detail-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

#detail-card h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
}

.detail-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.detail-content-wrapper {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
  margin-bottom: 12px;
}

@media (max-width: 1024px) {
  .detail-content-wrapper {
    grid-template-columns: 1fr;
  }

  .qr-panel {
    position: static;
    display: flex;
    justify-content: center;
    margin-top: 12px;
  }

  .qr-container {
    width: 100%;
    max-width: 300px;
  }
}

.detail-table-wrapper {
  border-radius: 12px;
  border: 1px solid #f0f0f5;
  overflow-x: auto;
  overflow-y: visible;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.qr-panel {
  position: sticky;
  top: 20px;
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid #f0f0f5;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.detail-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.detail-table th,
.detail-table td {
  font-size: 15px;
  padding: 10px 12px;
  border-bottom: 1px solid #f3f3f7;
  box-sizing: border-box;
}

.detail-table th {
  min-width: 140px;
  max-width: 35%;
  background: #fafafa;
  text-align: left;
  font-weight: 600;
  color: #3a3a3c;
  white-space: nowrap;
  font-size: 16px;
}

.detail-table td {
  word-wrap: break-word;
  word-break: break-word;
  max-width: 65%;
}

.detail-table tr:nth-child(even) td {
  background: #f9f9fb;
}

.file-download-row {
  border-top: 2px solid var(--accent) !important;
}

.file-download-row td {
  background: #f9f9fb !important;
  text-align: center;
  padding: 16px !important;
}

.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.qr-container img {
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  padding: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.06);
  background: #ffffff;
  width: 200px;
  height: 200px;
  object-fit: contain;
  display: block;
}

.small-text {
  font-size: 14px;
  color: var(--text-muted);
}

.tracking-link {
  font-size: 15px;
  word-break: break-all;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  body {
    padding: 16px;
  }

  .page-wrapper {
    padding: 0;
  }

  .shell {
    padding: 26px 18px 22px;
    border-radius: 24px;
  }

  .search-card {
    flex-direction: column;
    align-items: stretch;
  }

  .search-button {
    width: 100%;
    justify-content: center;
  }

  .title {
    font-size: 28px;
  }

  .subtitle {
    font-size: 15px;
  }

  .description {
    font-size: 13px;
  }

  .search-bar {
    max-width: 100%;
  }

  .detail-content-wrapper {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .qr-panel {
    position: static;
    display: flex;
    justify-content: center;
  }

  .qr-container {
    width: 100%;
    max-width: 300px;
  }

  .detail-table-wrapper {
    margin-bottom: 0;
  }

  .detail-table {
    font-size: 13px;
  }

  .detail-table th {
    min-width: 80px;
    max-width: 35%;
    font-size: 12px;
    padding: 8px 10px;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
  }

  .detail-table td {
    max-width: 65%;
    font-size: 12px;
    padding: 8px 10px;
    line-height: 1.4;
  }
}

/* PDF Export styles - comprehensive A4 layout */
body.pdf-export {
  background: #ffffff !important;
  padding: 0 !important;
  margin: 0 !important;
  font-size: 10px !important;
}

body.pdf-export .page-wrapper,
body.pdf-export .shell {
  padding: 0 !important;
  margin: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  background: #ffffff !important;
  box-shadow: none !important;
  border: none !important;
}

body.pdf-export .header,
body.pdf-export .search-bar-wrapper,
body.pdf-export #status,
body.pdf-export #list-view,
body.pdf-export .detail-topbar {
  display: none !important;
}

body.pdf-export #detail-card {
  padding: 5mm !important;
  margin: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

body.pdf-export #detail-card h2 {
  font-size: 24px !important;
  margin: 0 0 3mm 0 !important;
  padding: 0 !important;
}

body.pdf-export .detail-subtitle {
  font-size: 16.5px !important;
  margin: 0 0 5mm 0 !important;
  padding: 0 !important;
}

body.pdf-export .detail-content-wrapper {
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
}

body.pdf-export .detail-table-wrapper {
  margin: 0 0 5mm 0 !important;
  padding: 0 !important;
  border: 1px solid #ccc !important;
  overflow: visible !important;
}

body.pdf-export .detail-table {
  font-size: 15px !important;
  width: 100% !important;
  border-collapse: collapse !important;
  line-height: 1.3 !important;
}

body.pdf-export .detail-table th {
  font-size: 15px !important;
  padding: 3mm 3.5mm !important;
  width: 35% !important;
  background: #f0f0f0 !important;
  font-weight: 600 !important;
  border: 1px solid #ddd !important;
  vertical-align: top !important;
}

body.pdf-export .detail-table td {
  font-size: 15px !important;
  padding: 3mm 3.5mm !important;
  width: 65% !important;
  border: 1px solid #ddd !important;
  vertical-align: top !important;
  word-break: break-word !important;
}

body.pdf-export .qr-panel {
  margin: 5mm 0 0 0 !important;
  padding: 0 !important;
  width: 100% !important;
}

body.pdf-export .qr-container {
  display: flex !important;
  flex-direction: row !important;
  gap: 8mm !important;
  align-items: center !important;
  justify-content: center !important;
}

body.pdf-export .qr-container img {
  width: 50mm !important;
  height: 50mm !important;
  max-width: 50mm !important;
  max-height: 50mm !important;
  border: 1px solid #ccc !important;
  padding: 2mm !important;
}

body.pdf-export .small-text {
  font-size: 12px !important;
  margin: 2mm 0 !important;
}

body.pdf-export .tracking-link {
  font-size: 10.5px !important;
  word-break: break-all !important;
}

body.pdf-export .print-footer {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  padding: 3mm 5mm !important;
  text-align: center !important;
  font-size: 12px !important;
  color: #666 !important;
  border-top: 1px solid #ddd !important;
  background: #ffffff !important;
}

/* Print: A4-optimized layout - completely transforms the page */
@media print {
  @page {
    size: A4;
    margin: 5mm;
  }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  html, body {
    width: 210mm !important;
    height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    background-image: none !important;
    font-size: 10px !important;
    overflow: visible !important;
  }

  /* Remove all background images */
  body::before,
  body::after {
    display: none !important;
    background: none !important;
    background-image: none !important;
  }

  .page-wrapper {
    width: 200mm !important;
    max-width: 200mm !important;
    padding: 0 !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
    background: #ffffff !important;
    background-image: none !important;
  }

  .shell {
    width: 200mm !important;
    max-width: 200mm !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    background-image: none !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
  }

  .shell::before,
  .shell::after {
    display: none !important;
  }

  .header,
  .search-bar-wrapper,
  #status,
  #list-view,
  .detail-topbar,
  .detail-topbar .back-btn,
  .detail-actions {
    display: none !important;
  }

  #detail-view {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  #detail-card {
    display: block !important;
    width: 200mm !important;
    max-width: 200mm !important;
    padding: 5mm !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    background: #ffffff !important;
    background-image: none !important;
    box-shadow: none !important;
    border: none !important;
    page-break-inside: avoid !important;
  }

  #detail-card h2 {
    font-size: 24px !important;
    font-weight: 700 !important;
    margin: 0 0 3mm 0 !important;
    padding: 0 !important;
    line-height: 1.2 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
  }

  .detail-subtitle {
    font-size: 16.5px !important;
    margin: 0 0 5mm 0 !important;
    padding: 0 !important;
    color: #000 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
  }

  .detail-content-wrapper {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .detail-table-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 5mm 0 !important;
    padding: 0 !important;
    border: 1px solid #ccc !important;
    overflow: visible !important;
    box-sizing: border-box !important;
    page-break-inside: avoid !important;
  }

  .detail-table {
    font-size: 15px !important;
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 0 !important;
    line-height: 1.3 !important;
    table-layout: fixed !important;
    border: 1px solid #999 !important;
  }

  .detail-table th,
  .detail-table td {
    font-size: 15px !important;
    padding: 3mm 3.5mm !important;
    border: 1px solid #999 !important;
    border-top: 1px solid #999 !important;
    border-right: 1px solid #999 !important;
    border-bottom: 1px solid #999 !important;
    border-left: 1px solid #999 !important;
    vertical-align: top !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
  }

  .detail-table th {
    width: 35% !important;
    background: #f0f0f0 !important;
    font-weight: 600 !important;
    color: #000 !important;
  }

  .detail-table td {
    width: 65% !important;
    word-break: break-word !important;
  }

  .detail-table tr:nth-child(even) td {
    background: #fafafa !important;
  }

  .qr-panel {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 5mm 0 0 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    page-break-inside: avoid !important;
    box-sizing: border-box !important;
  }

  .qr-container {
    display: flex !important;
    flex-direction: row !important;
    gap: 8mm !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }

  .qr-container > div {
    text-align: center !important;
  }

  .qr-container > div:first-child {
    flex-shrink: 0 !important;
  }

  .qr-container img {
    width: 50mm !important;
    height: 50mm !important;
    max-width: 50mm !important;
    max-height: 50mm !important;
    border: 1px solid #ccc !important;
    padding: 2mm !important;
    background: #ffffff !important;
    display: block !important;
    margin: 0 auto !important;
  }

  .small-text {
    font-size: 12px !important;
    color: #333 !important;
    margin: 2mm 0 !important;
    line-height: 1.3 !important;
  }

  .tracking-link {
    font-size: 10.5px !important;
    word-break: break-all !important;
    color: #0066cc !important;
    text-decoration: underline !important;
    display: block !important;
    margin: 2mm 0 !important;
    line-height: 1.3 !important;
  }

  /* Footer with timestamp */
  .print-footer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 200mm !important;
    padding: 3mm 5mm !important;
    text-align: center !important;
    font-size: 12px !important;
    color: #666 !important;
    border-top: 1px solid #ddd !important;
    background: #ffffff !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }

  .file-download-row {
    page-break-inside: avoid !important;
  }

  .file-download-row td {
    padding: 2mm !important;
    text-align: center !important;
    background: #f9f9f9 !important;
  }

  .file-download-row .pill-btn {
    font-size: 14px !important;
    padding: 2mm 4mm !important;
    display: inline-block !important;
  }

  /* Footer with timestamp - show in print */
  .print-footer {
    display: block !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 200mm !important;
    padding: 3mm 5mm !important;
    text-align: center !important;
    font-size: 12px !important;
    color: #666 !important;
    border-top: 1px solid #ddd !important;
    background: #ffffff !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }

  /* Ensure footer appears on print */
  @page {
    margin-bottom: 15mm !important;
  }
}

