/* Apple-like visual layer — IDs, forms, and business controls unchanged. */
:root {
  --bg: #f5f5f7;
  --bg-deep: #fbfbfd;
  --surface: #ffffff;
  --surface-soft: #f5f5f7;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.14);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;
  --accent-dark: #0077ed;
  --accent-soft: rgba(0, 113, 227, 0.08);
  --amber: #b25000;
  --amber-soft: #fff4e5;
  --danger: #de071c;
  --danger-soft: #fff2f2;
  --success: #248a3d;
  --success-soft: #eaf8ee;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 12px 32px rgba(0, 0, 0, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

@keyframes ui-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

html { color-scheme: light; }

body,
body.customer-page {
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47059;
  letter-spacing: -0.022em;
  font-weight: 400;
  background:
    radial-gradient(1200px 420px at 50% -8%, rgba(0, 113, 227, 0.06), transparent 55%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 28%, #eef0f3 100%);
  background-attachment: fixed;
}

body::before,
body::after {
  display: none;
}

.app-shell,
.auth-shell,
.customer-login-shell,
.customer-portal-shell {
  position: relative;
  z-index: 1;
}

.app-shell,
.customer-portal-shell {
  width: min(1440px, calc(100vw - 48px));
  padding: 28px 0 96px;
  animation: ui-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

h1, h2, h3, p { margin: 0; }

h1, h2, h3 {
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(28px, 2.4vw, 40px);
  line-height: 1.1;
  font-weight: 700;
}

h2 {
  font-size: 24px;
  line-height: 1.16667;
}

h3 {
  font-size: 19px;
  line-height: 1.21053;
}

.brand p,
.panel-head p,
.customer-login-copy,
#customerPortalWelcome,
.muted {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.42859;
  letter-spacing: -0.016em;
}

.topbar,
.customer-portal-topbar {
  position: sticky;
  top: 14px;
  z-index: 40;
  gap: 18px;
  margin-bottom: 28px;
  padding: 14px 22px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04), 0 8px 28px rgba(0, 0, 0, 0.06);
}

.brand {
  gap: 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: #1d1d1f;
  box-shadow: none;
}

.brand-mark svg {
  stroke: #f5f5f7;
  stroke-width: 2.4;
}

.tabs {
  gap: 4px;
  padding: 4px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  box-shadow: none;
}

.tab-button {
  min-height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.016em;
  text-transform: none;
}

.tab-button:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

.tab-button.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.session-user {
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-shadow: none;
}

.auth-shell,
.customer-login-shell {
  min-height: 100vh;
}

.auth-card,
.customer-login-card,
.customer-login-intro,
.customer-portal-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  clip-path: none;
}

.auth-card,
.customer-login-card {
  padding: 40px 36px;
}

.customer-login-intro {
  background: linear-gradient(180deg, #ffffff 0%, #f5f5f7 100%);
}

.customer-portal-eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: none;
}

.customer-intro-point,
.customer-session-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfbfd;
  box-shadow: none;
}

.customer-session-card strong {
  color: var(--text);
  font-family: var(--font);
  text-shadow: none;
}

.parser-panel,
.order-panel,
.single-grid .panel,
.customer-portal-panel {
  padding: 28px;
}

.panel-head {
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.total-pill,
.metric {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fbfbfd;
  box-shadow: none;
}

.total-pill {
  min-width: 168px;
  padding: 14px 16px;
  text-align: right;
}

.metric {
  padding: 18px 16px 16px;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease;
}

.metric.is-emphasis {
  border-color: rgba(0, 113, 227, 0.28);
  background: #f3f8ff;
  box-shadow: 0 8px 24px rgba(0, 113, 227, 0.08);
}

.metric span,
.total-pill span,
.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-transform: none;
}

.metric strong,
.total-pill strong {
  color: var(--text);
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-shadow: none;
}

.total-pill strong {
  font-size: 28px;
  color: var(--text);
}

.metric strong { font-size: 26px; }

.field span {
  margin-bottom: 8px;
}

input,
textarea,
select {
  min-height: 44px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  caret-color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input::placeholder,
textarea::placeholder {
  color: #86868b;
}

input:hover,
textarea:hover,
select:hover {
  border-color: rgba(0, 0, 0, 0.28);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.16);
}

option {
  background: #fff;
  color: var(--text);
}

textarea { min-height: 180px; }

button {
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
}

.primary-button,
.ghost-button,
.icon-text-button,
.icon-button,
.mini-button,
.danger-button {
  border-radius: 980px;
  font-weight: 500;
  letter-spacing: -0.016em;
  text-transform: none;
}

.primary-button {
  border: 0;
  background: var(--accent);
  color: #fff;
  box-shadow: none;
  animation: none;
  padding: 0 20px;
}

.primary-button:hover:not(:disabled) {
  background: #0077ed;
  filter: none;
}

.primary-button:active:not(:disabled) {
  background: #006edb;
  transform: scale(0.98);
}

.ghost-button,
.icon-text-button {
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  color: var(--text);
}

.ghost-button:hover:not(:disabled),
.icon-text-button:hover:not(:disabled) {
  border-color: rgba(0, 0, 0, 0.18);
  color: var(--text);
  background: #f5f5f7;
  box-shadow: none;
  filter: none;
}

.icon-button,
.mini-button {
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: #fff;
  color: var(--muted);
}

.icon-button:hover:not(:disabled),
.mini-button:hover:not(:disabled) {
  border-color: rgba(0, 0, 0, 0.16);
  color: var(--text);
  background: #f5f5f7;
  box-shadow: none;
}

.danger-button,
.intercept-button {
  border-color: rgba(222, 7, 28, 0.22);
  background: var(--danger-soft);
  color: var(--danger);
  box-shadow: none;
}

.restore-button {
  border-color: rgba(36, 138, 61, 0.22);
  background: var(--success-soft);
  color: var(--success);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(0, 113, 227, 0.35);
  outline-offset: 2px;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: none;
  overflow-x: auto;
}

thead th,
th {
  background: #fbfbfd;
  color: #6e6e73;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-transform: none;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

td {
  color: var(--text);
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

tbody tr:nth-child(even) { background: transparent; }
tbody tr:hover { background: #f5f5f7; }

.orders-table tr.is-intercepted td { background: var(--danger-soft); }
.orders-table tr.is-intercepted td:not(:last-child) { color: #9b1020; }

.settlement-pill,
.status-pill,
.tag {
  border-radius: 999px;
  letter-spacing: -0.01em;
  text-transform: none;
  font-weight: 500;
}

.settlement-pill.is-unsettled,
.status-pill,
.tag.warn {
  border: 0;
  background: var(--amber-soft);
  color: var(--amber);
  box-shadow: none;
}

.settlement-pill.is-settled,
.tag.good {
  border: 0;
  background: var(--success-soft);
  color: var(--success);
  box-shadow: none;
}

.parse-result {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfbfd;
  color: var(--muted);
}

.parse-result strong { color: var(--text); }

.tag {
  border: 0;
  background: #f5f5f7;
  color: var(--muted);
}

.customer-login-notice {
  border: 0;
  border-radius: 14px;
  background: var(--amber-soft);
  color: var(--amber);
}

.customer-login-env {
  border: 0;
  border-radius: 14px;
  background: #f5f5f7;
  color: var(--muted);
}

.modal-backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(16px);
}

.modal {
  border: 0;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
}

.log-item,
.detail-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfbfd;
}

#syncPanel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-width: calc(100vw - 36px);
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow);
}

#syncPanel button {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-transform: none;
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
}

#syncPanel [data-kind="pending"] {
  background: #f5a524;
  color: #1d1d1f;
}

#syncPanel [data-kind="error"],
#syncPanel #exportPending {
  background: var(--danger);
  color: #fff;
}

.toast {
  max-width: calc(100vw - 32px);
  border-radius: 16px;
  background: #1d1d1f;
  color: #f5f5f7;
  border: 0;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

body.auth-only #syncPanel { display: none; }
.tab-panel.is-active { animation: ui-rise 0.4s cubic-bezier(0.22, 1, 0.36, 1) both; }

.recent-orders-panel {
  margin-top: 18px;
}

.customer-month-hint {
  margin: 10px 0 0;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
}

.table-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.table-footer .limit-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.table-footer .limit-field select {
  min-height: 36px;
  width: auto;
}

.batch-toolbar {
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fbfbfd;
}

.batch-toolbar .batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.compact-table {
  min-width: 720px;
}

.parse-result {
  border-color: rgba(0, 0, 0, 0.08);
}

.parse-issue-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.parse-issue {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
}

.parse-issue.warn {
  background: #fff2f2;
  color: #9b1020;
  border: 1px solid rgba(222, 7, 28, 0.12);
}

.parse-issue.good {
  background: #eaf8ee;
  color: #1f6b32;
  border: 1px solid rgba(36, 138, 61, 0.12);
}

.sku-suggestion-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.sku-suggestion {
  font-size: 13px !important;
  min-height: 32px !important;
  padding: 0 12px !important;
}

.field.is-incomplete input,
.field.is-incomplete textarea,
.field.is-incomplete select {
  border-color: #de071c;
  background: #fff8f8;
  box-shadow: 0 0 0 4px rgba(222, 7, 28, 0.08);
}

.items-table tr.is-unmatched {
  background: #fff2f2;
}

.items-table tr.is-unmatched .item-sku {
  border-color: #de071c;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 99px;
}
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  .topbar,
  .customer-portal-topbar {
    position: static;
    flex-wrap: wrap;
    border-radius: 22px;
  }
  .tabs { width: 100%; order: 3; }
  .tab-button { flex: 1; }
}

@media (max-width: 640px) {
  .app-shell,
  .customer-portal-shell {
    width: calc(100vw - 24px);
    padding-top: 16px;
  }
  h1 { font-size: 28px; }
  .auth-card,
  .customer-login-card,
  .parser-panel,
  .order-panel,
  .customer-portal-panel {
    padding: 22px 18px;
    border-radius: 22px;
  }
  input, select, textarea { font-size: 16px; }
}

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

@media print {
  body, body.customer-page { background: #fff !important; }
  #syncPanel { display: none !important; }
}
