:root {
  color-scheme: light;
  --background: #fafcff;
  --foreground: #020b1b;
  --card: #ffffff;
  --card-foreground: #020b1b;
  --primary: #0066cc;
  --primary-foreground: #fafcff;
  --secondary: #ebf3fc;
  --secondary-foreground: #0b223e;
  --muted: #edf2f9;
  --muted-foreground: #4a5666;
  --accent: #d8e6f9;
  --accent-foreground: #000b1f;
  --destructive: #c53637;
  --border: #d5dfeb;
  --input: #d5dfeb;
  --ring: #0066cc;
  --success: #008138;
  --warning: #a36100;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  overflow-x: hidden;
}

html {
  background: #ffffff;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  height: env(safe-area-inset-top, 0px);
  background: #ffffff;
  pointer-events: none;
}

body {
  margin: 0;
  min-width: 320px;
  background: #ffffff;
  color: var(--foreground);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.container {
  width: min(100% - 32px, 1280px);
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  backdrop-filter: blur(8px);
  padding-top: env(safe-area-inset-top, 0px);
}

.site-header::before {
  display: none;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-block: 24px;
}

h1,
h2,
p {
  margin: 0;
}

.header-inner h1 {
  color: var(--foreground);
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
}

.header-inner p,
.card-header p,
.update-note,
.latest-upload,
.site-footer {
  color: var(--muted-foreground);
  font-size: 14px;
}

.main-content {
  flex: 1;
  background: var(--background);
  padding-block: 32px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: 0 10px 18px rgba(15, 35, 60, 0.08);
}

.search-card {
  margin-bottom: 32px;
}

.card-header {
  display: grid;
  gap: 8px;
  padding: 24px 24px 0;
}

.card-header h2 {
  font-size: 16px;
  line-height: 1.1;
  font-weight: 600;
}

.card-body {
  padding: 24px;
}

.search-stack {
  display: grid;
  gap: 12px;
}

.input-wrap {
  position: relative;
}

.input-wrap input,
.password-input {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--input);
  border-radius: 6px;
  background: transparent;
  color: var(--foreground);
  outline: none;
  padding: 6px 12px 6px 40px;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(2, 11, 27, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-wrap input:focus,
.password-input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.18);
}

.password-input {
  height: 48px;
  padding-left: 12px;
  text-align: center;
  font-size: 18px;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  pointer-events: none;
}

.action-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.2);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover:not(:disabled) {
  background: #005bb8;
}

.btn-outline {
  border-color: var(--border);
  background: var(--background);
  color: var(--foreground);
}

.btn-outline:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-foreground);
}

.btn-danger {
  border-color: var(--destructive);
  background: var(--destructive);
  color: #fff;
}

.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-lg {
  width: 32px;
  height: 32px;
}

.text-primary {
  color: var(--primary);
}

.autocomplete {
  position: relative;
}

.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 14px 28px rgba(15, 35, 60, 0.15);
}

.suggestion-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--foreground);
  padding: 12px 16px;
  text-align: left;
}

.suggestion-item:last-child {
  border-bottom: 0;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: rgba(0, 102, 204, 0.08);
}

.suggestion-title {
  min-width: 0;
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.suggestion-meta {
  margin-top: 2px;
  color: var(--muted-foreground);
  font-size: 12px;
}

.badge,
.suggestion-type,
.in-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--secondary-foreground);
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.listening {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(0, 102, 204, 0.2);
  border-radius: var(--radius);
  background: rgba(0, 102, 204, 0.05);
  color: var(--primary);
  padding: 12px;
  font-size: 14px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
  animation: pulse 1.2s ease-in-out infinite;
}

.alert {
  border: 1px solid rgba(197, 54, 55, 0.2);
  border-radius: var(--radius);
  background: rgba(197, 54, 55, 0.1);
  color: var(--destructive);
  padding: 12px;
  font-size: 14px;
}

.alert.info {
  border-color: rgba(0, 102, 204, 0.2);
  background: rgba(0, 102, 204, 0.06);
  color: var(--primary);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 980px;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted-foreground);
  font-weight: 600;
}

tbody tr:hover {
  background: rgba(237, 242, 249, 0.5);
}

.col-customer {
  width: 150px;
}

.col-product {
  width: 310px;
}

.col-price,
.col-quantity,
.col-amount {
  width: 110px;
}

.col-date {
  width: 150px;
}

.col-note {
  width: 170px;
}

.th-label,
.product-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.product-cell {
  flex-wrap: wrap;
}

.price-cell {
  color: var(--primary);
  font-weight: 600;
}

.customer-cell {
  white-space: nowrap;
}

.wrap-cell {
  overflow-wrap: anywhere;
}

.upload-band {
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  padding-block: 24px;
}

.upload-inner {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.upload-panel {
  width: min(100%, 448px);
  display: grid;
  gap: 12px;
}

.upload-panel .btn {
  width: fit-content;
}

.progress {
  width: min(100%, 360px);
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--muted);
}

.progress-bar {
  width: 0;
  height: 100%;
  background: var(--primary);
  transition: width 0.2s ease;
}

.upload-status {
  margin: 0;
  width: min(100%, 520px);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
}

.upload-status.success {
  background: #f0fdf4;
  color: var(--success);
}

.upload-status.error {
  background: #fef2f2;
  color: var(--destructive);
}

.latest-upload {
  display: grid;
  gap: 4px;
}

.latest-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.latest-detail {
  display: grid;
  gap: 4px;
  padding-left: 18px;
  font-size: 12px;
}

.latest-file {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.update-note {
  flex: 1;
}

.update-note p {
  margin-bottom: 4px;
  font-weight: 500;
}

.update-note ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.68);
  padding-block: 12px;
  text-align: center;
}

.password-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  padding: 16px;
}

.password-panel {
  width: min(100%, 448px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 18px 40px rgba(2, 11, 27, 0.22);
  padding: 32px;
}

.password-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: rgba(0, 102, 204, 0.1);
  color: var(--primary);
}

.password-copy {
  display: grid;
  gap: 8px;
  text-align: center;
}

.password-copy h2 {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
}

.password-copy p {
  color: var(--muted-foreground);
  font-size: 14px;
}

.password-error {
  margin: 0;
  color: var(--destructive);
  font-size: 14px;
}

.password-submit {
  width: 100%;
  height: 48px;
  font-size: 16px;
}

.hidden {
  display: none !important;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

@media (max-width: 760px) {
  .container {
    width: min(100% - 24px, 1280px);
  }

  .header-inner {
    padding-block: 18px;
  }

  .header-inner h1 {
    font-size: 20px;
  }

  .main-content {
    flex: 0 0 auto;
    padding-block: 16px 12px;
  }

  .input-wrap input {
    height: 44px;
    font-size: 17px;
    padding-block: 8px;
  }

  .search-card {
    margin-bottom: 14px;
  }

  .card-header,
  .card-body {
    padding-inline: 14px;
  }

  .card-header {
    padding-top: 18px;
  }

  .card-body {
    padding-block: 16px;
  }

  .results-card .card-body {
    padding-inline: 8px;
  }

  table {
    min-width: 532px;
    font-size: 15px;
  }

  th,
  td {
    padding: 8px 4px;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  th {
    font-size: 16px;
    line-height: 1.25;
  }

  .col-customer {
    width: 58px;
  }

  .col-product {
    width: 128px;
  }

  .col-price,
  .col-quantity {
    width: 48px;
  }

  .col-amount {
    width: 57px;
  }

  .col-date {
    width: 92px;
  }

  .col-note {
    width: 102px;
  }

  .customer-cell {
    overflow: hidden;
    text-overflow: clip;
  }

  .col-price,
  .col-quantity,
  .col-amount,
  .price-cell,
  .quantity-cell,
  .amount-cell {
    text-align: center;
  }

  .date-cell {
    white-space: nowrap;
  }

  .th-label {
    gap: 0;
  }

  .th-label .icon {
    display: none;
  }

  .product-cell {
    display: block;
  }

  .product-cell .product-text {
    display: block;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .product-cell .in-badge {
    display: inline-block;
    margin-top: 4px;
  }

  .upload-inner {
    display: grid;
    gap: 14px;
  }

  .update-note {
    order: 1;
  }

  .upload-panel {
    order: 2;
  }

  .upload-band {
    padding-block: 16px;
  }

  .update-note ul {
    padding-left: 16px;
  }

  .upload-panel .btn {
    width: 100%;
  }
}
