:root {
  --bg: #F4F1FA;
  --ink: #332F3A;
  --muted: #635F69;
  --panel: rgba(255, 255, 255, 0.74);
  --line: rgba(124, 58, 237, 0.12);
  --accent: #7C3AED;
  --accent-2: #DB2777;
  --clay-canvas: #F4F1FA;
  --clay-surface: rgba(255, 255, 255, 0.72);
  --clay-surface-strong: rgba(255, 255, 255, 0.86);
  --clay-input: #EFEBF5;
  --clay-outline: rgba(124, 58, 237, 0.18);
  --clay-blue: #0EA5E9;
  --clay-green: #10B981;
  --clay-amber: #F59E0B;
  --shadow: 16px 16px 32px rgba(160, 150, 180, 0.20), -10px -10px 24px rgba(255,255,255,0.92), inset 6px 6px 12px rgba(139, 92, 246, 0.04), inset -6px -6px 12px rgba(255,255,255,0.95);
  --shadow-deep: 30px 30px 60px rgba(205, 198, 217, 0.82), -30px -30px 60px rgba(255,255,255,0.95), inset 10px 10px 20px rgba(139, 92, 246, 0.05), inset -10px -10px 20px rgba(255,255,255,0.9);
  --shadow-button: 12px 12px 24px rgba(124, 58, 237, 0.28), -8px -8px 16px rgba(255,255,255,0.48), inset 4px 4px 8px rgba(255,255,255,0.32), inset -4px -4px 8px rgba(0,0,0,0.10);
  --shadow-pressed: inset 10px 10px 20px rgba(212, 206, 226, 0.92), inset -10px -10px 20px rgba(255,255,255,0.98);
  --shadow-hover: 18px 18px 36px rgba(139, 92, 246, 0.22), -12px -12px 24px rgba(255,255,255,0.95), inset 6px 6px 12px rgba(255,255,255,0.28), inset -6px -6px 12px rgba(0,0,0,0.08);
}

body {
  position: relative;
  overflow-x: hidden;
  isolation: isolate;
  font-family: "DM Sans", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: transparent;
}

body,
input,
textarea,
button,
.muted,
.status-text,
.api-status,
.history-meta,
.history-time,
.lookup-notice-text,
.auto-entry-meta,
.auto-entry-value,
.validation-row,
.criteria-list,
.storage-progress-status,
.storage-progress-percent,
.kv-v,
.attempt-item,
.popup-card,
.dialog-card,
.auth-card {
  font-family: "DM Sans", "Segoe UI", Arial, sans-serif;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -2;
  width: 52vw;
  height: 52vw;
  min-width: 22rem;
  min-height: 22rem;
  border-radius: 999px;
  filter: blur(64px);
  opacity: 0.9;
  pointer-events: none;
  animation: clay-float 10s ease-in-out infinite;
}

body::before {
  top: -10rem;
  left: -12rem;
  background: rgba(var(--theme-rgb), 0.14);
}

body::after {
  right: -10rem;
  top: 8rem;
  background: rgba(var(--theme-secondary-rgb), 0.12);
  animation: clay-float-delayed 12s ease-in-out infinite;
}

.wrap {
  position: relative;
  z-index: 1;
}

.wrap::before,
.wrap::after {
  content: "";
  position: fixed;
  z-index: -1;
  width: 28rem;
  height: 28rem;
  border-radius: 999px;
  filter: blur(56px);
  pointer-events: none;
  opacity: 0.72;
}

.wrap::before {
  left: -8rem;
  bottom: 8rem;
  background: rgba(14, 165, 233, 0.10);
  animation: clay-float-slow 14s ease-in-out infinite;
}

.wrap::after {
  right: -6rem;
  bottom: -4rem;
  background: rgba(245, 158, 11, 0.10);
  animation: clay-breathe 8s ease-in-out infinite;
}

h1,
.scanner-title,
.storage-spotlight-id,
.storage-spotlight-latest-value,
.auth-brand-title,
.auth-brand-subtitle,
.auth-login-btn,
.card h3,
.auto-panel-title,
.dialog-title,
.history-head strong,
.popup-card,
.auth-error,
.history-title strong,
.status-bar .pill,
.auto-panel-title,
#modeLabel {
  font-family: "Nunito", sans-serif;
  font-weight: 800;
}

label,
.warehouse-switcher-label,
.attempt-label,
.kv-k,
.auto-entry-label,
.storage-spotlight-latest-label,
.storage-progress-label,
.lookup-notice-badge,
.pill-tab,
.print-label-btn,
.api-btn,
.history-btn {
  font-family: "Nunito", sans-serif;
  letter-spacing: 0.06em;
  font-weight: 800;
}

.muted,
.status-text,
.api-status,
.history-meta,
.history-time,
.lookup-notice-text,
.auto-entry-meta,
.validation-row,
.criteria-list,
.scanner-subtitle,
.scanner-status {
  color: var(--muted);
}

input,
textarea {
  border: 0;
  color: var(--ink);
  background: var(--clay-input);
  box-shadow: var(--shadow-pressed);
  transition: all .25s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.9;
}

input:focus,
textarea:focus,
.auth-card input:focus,
.dialog-card input:focus {
  outline: none;
  background: rgba(255,255,255,0.96);
  box-shadow: var(--shadow), 0 0 0 4px rgba(var(--theme-rgb), 0.14);
  border-color: transparent;
}

.dialog-card input:focus {
  color: #111827;
  caret-color: var(--accent);
  -webkit-text-fill-color: #111827;
}

.dialog-card input:focus::selection {
  background: rgba(var(--theme-rgb), 0.22);
  color: #111827;
}

button,
.warehouse-btn,
.pill-tab,
.history-btn,
.api-btn {
  border-radius: 20px;
  border: 0;
  font-family: "DM Sans", sans-serif;
  font-weight: 700;
  background: var(--theme-soft-gradient);
  box-shadow: var(--shadow-button);
  transform: translateY(0);
  transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}

button:hover,
.warehouse-btn:hover,
.pill-tab:hover,
.history-btn:hover,
.api-btn:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  filter: saturate(1.04);
}

button:active,
.warehouse-btn:active,
.pill-tab:active,
.history-btn:active,
.api-btn:active {
  transform: scale(0.92);
  box-shadow: var(--shadow-pressed);
}

#clearBtn,
#revertBtn,
#clearAutoBtn,
.warehouse-btn,
#sendBackUspsBtn,
#sendBackWaBtn,
#sendBackOorBtn,
.dialog-actions .secondary {
  color: var(--ink);
  background: rgba(255,255,255,0.82);
  box-shadow: var(--shadow);
}

#sendBackMilitaryBtn,
#googleOpenBtn,
#googleOpenNameAddrBtn,
.history-btn,
.api-btn,
.warehouse-btn.active,
#runBtn,
#sendBackBtn.ready,
.auth-login-btn {
  color: #ffffff;
  background: var(--theme-gradient);
  box-shadow: var(--shadow-button);
}

#sendBackUspsBtn {
  background: linear-gradient(135deg, rgba(255,255,255,0.96) 0%, rgba(232, 245, 255, 0.95) 100%);
  border: 1px solid rgba(14, 165, 233, 0.18);
}

#sendBackUspsBtn::before {
  border: 0;
  box-shadow: 4px 4px 8px rgba(0, 75, 135, 0.12), -2px -2px 6px rgba(255,255,255,0.92);
}

#sendBackMilitaryBtn {
  background: linear-gradient(135deg, #34D399 0%, #10B981 58%, #0F766E 100%);
}

#sendBackWaBtn {
  background: linear-gradient(135deg, rgba(255,255,255,0.96) 0%, rgba(255, 237, 244, 0.96) 100%);
  border: 1px solid rgba(var(--theme-secondary-rgb), 0.16);
  color: #8A1E58;
}

#sendBackOorBtn {
  background: linear-gradient(135deg, rgba(255,255,255,0.96) 0%, rgba(255, 243, 224, 0.96) 100%);
  border: 1px solid rgba(245, 158, 11, 0.22);
  color: #9A3412;
}
#sendBackCustomBtn {
  background: linear-gradient(135deg, rgba(255,255,255,0.96) 0%, rgba(224, 247, 250, 0.96) 100%);
  border: 1px solid rgba(34, 211, 238, 0.24);
  color: #155E75;
}

#sendBackBtn.dimmed {
  background: rgba(255,255,255,0.52);
  color: var(--muted);
  box-shadow: var(--shadow-pressed);
}

.pill,
.auto-status,
.lookup-notice-badge {
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,0.78);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.ok,
.auto-status.ok {
  background: linear-gradient(135deg, #6EE7B7 0%, #10B981 100%);
  color: #ffffff;
}

.bad,
.auto-status.bad {
  background: linear-gradient(135deg, #F9A8D4 0%, #DB2777 100%);
  color: #ffffff;
}

.auto-status.warn {
  background: linear-gradient(135deg, #FCD34D 0%, #F59E0B 100%);
  color: #ffffff;
}

.auto-status.live {
  background: linear-gradient(135deg, #7DD3FC 0%, #0EA5E9 100%);
  color: #ffffff;
}

.kv,
.attempt-bar,
.card,
.storage-card,
.auto-panel,
.auto-entry,
.validation-panel,
.history-panel,
.storage-spotlight,
.lookup-notice,
.mode-toggle,
.queue-mini,
.auto-empty,
.detail-banner {
  border: 1px solid rgba(255,255,255,0.54);
  background: var(--clay-surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.card,
.storage-card,
.auto-entry,
.validation-panel,
.history-panel,
.storage-spotlight {
  border-radius: 32px;
}

.attempt-bar,
.kv,
.auto-panel,
.mode-toggle,
.lookup-notice,
.queue-mini,
.detail-banner {
  border-radius: 24px;
}

.card:hover,
.auto-entry.clickable:hover,
.history-panel:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
}

.storage-card:hover,
.validation-panel:hover,
.storage-card:focus-within,
.storage-card:focus-within:hover,
.validation-panel:focus-within,
.validation-panel:focus-within:hover {
  transform: none;
  box-shadow: var(--shadow);
}

.storage-card.eligible {
  background: rgba(240, 253, 248, 0.88);
  border-color: rgba(16, 185, 129, 0.16);
}

.storage-card.not-eligible,
.detail-banner {
  background: rgba(255, 245, 250, 0.90);
  border-color: rgba(var(--theme-secondary-rgb), 0.16);
}

.lookup-notice {
  background: rgba(255,255,255,0.84);
}

.storage-spotlight.highlight .storage-spotlight-id,
.red {
  color: var(--accent);
}

.storage-progress-track {
  background: rgba(255,255,255,0.6);
  box-shadow: var(--shadow-pressed);
  border: 0;
}

.storage-progress-fill {
  border-radius: 999px;
  background: var(--theme-gradient);
  box-shadow: inset 2px 2px 6px rgba(255,255,255,0.28);
}

.storage-progress.error .storage-progress-fill {
  background: linear-gradient(135deg, #F9A8D4 0%, #DB2777 100%);
}

.storage-progress-status.error,
.validation-row.bad strong,
.lookup-notice-title,
.lookup-notice-text {
  color: #8A1E58;
}

.validation-row.ok strong {
  color: #0F9A68;
}

.scanner-card,
.dialog-card {
  background: var(--theme-dialog-gradient);
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: 18px 18px 42px rgba(var(--theme-rgb), 0.28), -8px -8px 20px rgba(255,255,255,0.08), inset 6px 6px 12px rgba(255,255,255,0.04), inset -8px -8px 14px rgba(0,0,0,0.18);
}

.scanner-modal,
.modal {
  background: rgba(var(--theme-rgb), 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.dialog-card input {
  background: rgba(255,255,255,0.14);
  box-shadow: inset 8px 8px 16px rgba(var(--theme-rgb), 0.18), inset -8px -8px 16px rgba(255,255,255,0.06);
  border: 0;
}

.dialog-actions .secondary {
  color: #ffffff;
  background: rgba(255,255,255,0.16);
}

.auth-card {
  border: 0;
  border-radius: 48px;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.88) 0%, rgba(255,255,255,0.72) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-deep);
}

.auth-brand-title {
  background: var(--theme-title-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-card input {
  background: var(--clay-input);
  border: 0;
  box-shadow: var(--shadow-pressed);
}

.auth-login-btn {
  border-radius: 24px;
}

.history-btn,
.api-btn,
.mode-toggle {
  border-radius: 22px;
}

.mode-toggle,
.auto-panel,
.history-head {
  background: rgba(255,255,255,0.78);
}

.history-head {
  border-radius: 24px 24px 0 0;
}

.history-panel,
.auto-panel {
  overflow: hidden;
}

.status-bar .pill {
  padding: 8px 14px;
}

body.normal-mode #detailSection {
  margin-top: 18px;
}

@keyframes clay-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(2deg); }
}

@keyframes clay-float-delayed {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-15px) rotate(-2deg); }
}

@keyframes clay-float-slow {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-28px) rotate(5deg); }
}

@keyframes clay-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 860px) {
  body::before,
  body::after,
  .wrap::before,
  .wrap::after {
    opacity: 0.54;
  }

  .auth-card {
    border-radius: 32px;
  }

  .card,
  .storage-card,
  .auto-entry,
  .validation-panel,
  .history-panel,
  .storage-spotlight {
    border-radius: 26px;
  }

  .attempt-bar,
  .kv,
  .auto-panel,
  .mode-toggle,
  .lookup-notice {
    border-radius: 20px;
  }

  .history-controls-grid {
    grid-template-columns: 1fr;
  }

  .history-toolbar {
    flex-direction: column;
  }

  .history-controls-actions {
    align-items: flex-start;
  }

  .history-search-btn,
  .history-download-btn,
  .history-copy-btn {
    width: 100%;
    min-width: 0;
  }
  .history-action-buttons {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .history-card {
    width: min(100vw - 20px, 920px);
    padding: 16px;
  }
}

/* History modal must stay flat and motionless; override later clay theme rules. */
#historyModal {
  padding: 8px;
  background: rgba(0, 0, 0, 0.56);
}
#historyModal .history-card {
  width: min(1280px, calc(100vw - 16px));
  height: calc(100vh - 16px);
  min-height: calc(100vh - 16px);
  max-height: calc(100vh - 16px);
  padding: 12px;
  border-radius: 14px;
  background: #0f172a;
  border: 0;
  box-shadow: none;
}
#historyModal .history-layout,
#historyModal .history-main,
#historyModal .history-panel,
#historyModal .history-section,
#historyModal .history-controls,
#historyModal .history-remote-results {
  min-height: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
#historyModal .history-layout,
#historyModal .history-main,
#historyModal .history-panel,
#historyModal .history-section {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}
#historyModal .history-panel,
#historyModal .history-panel:hover,
#historyModal .history-section,
#historyModal .history-section:hover,
#historyModal .history-mode-toggle,
#historyModal .history-mode-toggle:hover,
#historyModal .history-search-btn,
#historyModal .history-search-btn:hover,
#historyModal .history-search-btn:active,
#historyModal .history-mode-btn,
#historyModal .history-mode-btn:hover,
#historyModal .history-mode-btn:active,
#historyModal #historyCloseBtn,
#historyModal #historyCloseBtn:hover,
#historyModal #historyCloseBtn:active {
  transform: none !important;
  box-shadow: none !important;
  filter: none !important;
}
#historyModal .history-controls {
  position: relative;
  flex: 0 0 auto;
  padding: 8px 92px 10px 8px;
  overflow: visible;
  background: #0f172a;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  z-index: 2;
}
#historyModal .history-mode-toggle {
  background: #111827;
  border: 1px solid rgba(255,255,255,0.08);
}
#historyModal .history-field input,
#historyModal .history-field select {
  background: #1f2937;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: none;
}
#historyModal .history-controls-actions {
  min-height: 18px;
  padding: 0 2px;
}
#historyModal .history-remote-results {
  flex: 1 1 0%;
  min-height: 0;
  padding: 8px;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
#historyModal .history-remote-results .multi-search-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: #111827;
  box-shadow: none;
}
#historyModal .history-empty {
  border-radius: 12px;
  background: #111827;
  box-shadow: none;
}
#historyModal #historyCloseBtn {
  top: 8px;
  right: 8px;
  background: #1f2937;
  color: #f9fafb;
  border: 1px solid rgba(255,255,255,0.12);
}
#historyModal .history-search-btn {
  background: #2563eb;
  color: #eff6ff;
  border: 0;
}
#historyModal .history-download-btn,
#historyModal .history-copy-btn {
  background: #1f2937;
  color: #eff6ff;
  border: 1px solid rgba(255,255,255,0.12);
}
#historyModal .history-mode-btn {
  background: transparent;
  color: #cbd5e1;
  border: 0;
}
#historyModal .history-mode-btn.active {
  background: #2563eb;
  color: #eff6ff;
}
#historyModal .history-browse-status,
#historyModal .history-browse-status.ok,
#historyModal .history-browse-status.bad {
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
  padding: 0 !important;
}

/* Flatten global control glow/shadow across the tool. */
button,
button:hover,
button:active,
.warehouse-btn,
.warehouse-btn:hover,
.warehouse-btn:active,
.pill-tab,
.pill-tab:hover,
.pill-tab:active,
.history-btn,
.history-btn:hover,
.history-btn:active,
.api-btn,
.api-btn:hover,
.api-btn:active,
.auth-login-btn,
.auth-login-btn:hover,
.auth-login-btn:active,
.tool-settings-btn,
.tool-settings-btn:hover,
.tool-settings-btn:active,
.warehouse-menu-btn,
.warehouse-menu-btn:hover,
.warehouse-menu-btn:active {
  box-shadow: none !important;
  filter: none !important;
  transform: none !important;
}
.card,
.storage-card,
.auto-entry,
.validation-panel,
.history-panel,
.storage-spotlight,
.lookup-notice,
.attempt-bar,
.kv,
.auto-panel,
.mode-toggle,
.queue-mini,
.auto-empty,
.detail-banner,
.pill,
.auto-status,
.lookup-notice-badge {
  box-shadow: none !important;
}
input,
textarea,
input:focus,
textarea:focus,
.dialog-card input:focus,
.auth-card input,
.auth-card input:focus {
  box-shadow: none !important;
}
.auth-card label {
  color: #5b6475;
}
.tno-scan-btn,
.tno-scan-btn:hover,
.tno-scan-btn:active {
  transform: translateY(-50%) !important;
  box-shadow: none !important;
  filter: none !important;
}
