:root {
  --ink: #181d26;
  --ink-active: #0d1218;
  --body: #333840;
  --muted: #41454d;
  --hairline: #dddddd;
  --border-strong: #9297a0;
  --canvas: #ffffff;
  --surface-soft: #f8fafc;
  --surface-strong: #e0e2e6;
  --cream: #f5e9d4;
  --peach: #fcab79;
  --mint: #a8d8c4;
  --yellow: #f4d35e;
  --forest: #0a2e0e;
  --link: #1b61c9;
  --focus: #458fff;
  --success: #006400;
  --danger: #aa2d00;
  --warning: #8a5300;
  --radius-input: 6px;
  --radius-card: 10px;
  --radius-large: 12px;
  --content-width: 1280px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--body);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--link);
  text-decoration: none;
}

button {
  border: 0;
}

[hidden] {
  display: none !important;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 64px;
  border-bottom: 1px solid var(--hairline);
  background: #fff;
}

.nav-inner {
  width: min(100%, var(--content-width));
  height: 64px;
  margin: 0 auto;
  padding: 0 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-input);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
}

.nav-context {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}

.nav-context strong {
  color: var(--ink);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.account-email {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-shell {
  width: min(100%, var(--content-width));
  margin: 0 auto;
  padding: 44px 48px 56px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

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

h1,
h2,
h3 {
  color: var(--ink);
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(30px, 4vw, 40px);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h2 {
  margin-bottom: 6px;
  font-size: 24px;
  font-weight: 400;
  line-height: 1.35;
}

.lead {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
}

.button {
  min-height: 48px;
  padding: 12px 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-large);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  transition: none;
}

.button:focus-visible,
.tab-button:focus-visible,
.file-picker:focus-within,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.button-primary {
  background: var(--ink);
  color: #fff;
}

.button-primary:active {
  background: var(--ink-active);
}

.button-secondary {
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--ink);
}

.button-text {
  min-height: 40px;
  padding: 8px 10px;
  background: transparent;
  color: var(--ink);
}

.button[disabled] {
  border-color: var(--surface-strong);
  background: var(--surface-strong);
  color: #737780;
  cursor: not-allowed;
}

.field {
  display: grid;
  gap: 8px;
}

.field label,
.field-label {
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-input);
  background: var(--canvas);
  color: var(--ink);
}

.field input::placeholder {
  color: #8d929b;
}

.field input:focus {
  border-color: var(--focus);
  outline: 2px solid rgba(69, 143, 255, 0.2);
}

.field-wide {
  grid-column: 1 / -1;
}

.optional-mark {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.asin-list,
.competitor-rows {
  display: grid;
  gap: 10px;
}

.asin-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
}

.asin-row-own {
  grid-template-columns: 64px minmax(0, 1fr) 72px;
}

.asin-row-own::after {
  content: "";
}

.asin-role {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-input);
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
}

.asin-row-own .asin-role {
  background: var(--ink);
  color: #fff;
}

.button-compact {
  min-height: 40px;
  justify-self: start;
  padding: 8px 14px;
  font-size: 13px;
}

.remove-competitor {
  width: 100%;
  min-height: 40px;
  min-width: 0;
  padding: 8px 10px;
}

.field-hint {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.field-error {
  color: var(--danger);
}

.notice {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-input);
  background: var(--surface-soft);
  color: var(--body);
}

.notice-success {
  border-color: #9ecaa2;
  background: #f3faf3;
  color: var(--success);
}

.notice-error {
  border-color: #d9a18e;
  background: #fff7f4;
  color: var(--danger);
}

.auth-loading {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
  color: var(--muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--surface-strong);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.login-main {
  width: min(100%, var(--content-width));
  min-height: calc(100vh - 64px - 74px);
  margin: 0 auto;
  padding: 72px 48px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
  align-items: center;
  gap: 72px;
}

.login-copy {
  max-width: 700px;
}

.login-copy h1 {
  max-width: 620px;
  margin-bottom: 20px;
  font-size: clamp(42px, 5vw, 64px);
  font-weight: 400;
  line-height: 1.08;
}

.login-copy .lead {
  max-width: 560px;
  font-size: 17px;
  line-height: 1.65;
}

.current-tool {
  margin-top: 36px;
  padding: 24px;
  border-radius: var(--radius-large);
  background: var(--forest);
  color: #fff;
}

.current-tool span {
  display: block;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.current-tool strong {
  display: block;
  font-size: 22px;
  font-weight: 400;
}

.current-tool p {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.78);
}

.auth-card {
  padding: 32px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-large);
  background: var(--surface-soft);
}

.auth-card h2 {
  margin-bottom: 18px;
}

.auth-access-note {
  margin: -6px 0 24px;
  color: var(--muted);
  line-height: 1.7;
}

.auth-tabs {
  margin-bottom: 24px;
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--hairline);
}

.tab-button {
  min-height: 44px;
  padding: 0 2px;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 500;
}

.tab-button[aria-selected="true"] {
  border-bottom-color: var(--ink);
  color: var(--ink);
}

.auth-form {
  display: grid;
  gap: 18px;
}

.auth-form .button {
  width: 100%;
  margin-top: 4px;
}

.site-footer {
  min-height: 74px;
  border-top: 1px solid var(--hairline);
  background: var(--canvas);
}

.footer-inner {
  width: min(100%, var(--content-width));
  min-height: 74px;
  margin: 0 auto;
  padding: 16px 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--muted);
  font-size: 13px;
}

.task-card {
  margin-bottom: 32px;
  padding: 28px;
  border: 1px solid rgba(24, 29, 38, 0.08);
  border-radius: var(--radius-large);
  background: var(--cream);
}

.system-alerts {
  margin-bottom: 24px;
  display: grid;
  gap: 10px;
}

.system-alert {
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-left-width: 4px;
  border-radius: var(--radius-input);
}

.system-alert strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  font-weight: 600;
}

.system-alert p {
  margin: 0;
}

.system-alert-warning {
  border-color: #d7b668;
  background: #fff9e8;
  color: var(--warning);
}

.system-alert-critical {
  border-color: #d9a18e;
  background: #fff7f4;
  color: var(--danger);
}

.task-card h2 {
  margin-bottom: 18px;
}

.task-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) 128px;
  align-items: start;
  column-gap: 16px;
  row-gap: 20px;
}

.file-picker {
  min-height: 72px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid rgba(24, 29, 38, 0.25);
  border-radius: var(--radius-input);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
}

.file-picker.is-dragging {
  border-color: var(--focus);
  outline: 2px solid rgba(69, 143, 255, 0.2);
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.file-copy {
  min-width: 0;
}

.file-copy strong,
.file-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-copy strong {
  color: var(--ink);
  font-weight: 500;
}

.file-copy span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.file-action {
  flex: 0 0 auto;
  color: var(--link);
  font-weight: 500;
}

.task-form > #task-submit {
  min-height: 72px;
  min-width: 128px;
  margin-top: 29px;
}

.section {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-large);
  overflow: hidden;
  background: var(--canvas);
}

.section-head {
  min-height: 76px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--hairline);
}

.section-head h2 {
  margin-bottom: 2px;
  font-size: 20px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.refresh-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.table-scroller {
  max-height: 590px;
  overflow: auto;
}

.task-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.task-table th,
.task-table td {
  padding: 15px 20px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  vertical-align: top;
}

.task-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.task-table tr:last-child td {
  border-bottom: 0;
}

.task-table .col-time {
  width: 190px;
}

.task-table .col-asin {
  width: 170px;
}

.task-table .col-status {
  width: 250px;
}

.task-table .col-action {
  width: 130px;
}

.asin-code {
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  font-weight: 500;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--body);
  font-weight: 500;
}

.status::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  content: "";
}

.status-pending::before {
  background: var(--border-strong);
}

.status-running::before {
  background: var(--link);
}

.status-completed::before {
  background: var(--success);
}

.status-failed::before {
  background: var(--danger);
}

.failure-reason {
  margin: 6px 0 0 15px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.45;
}

.report-link {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  color: var(--link);
  font-weight: 500;
}

.empty-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 500;
}

.mobile-task-list {
  display: none;
}

.mobile-task {
  padding: 18px;
  border-bottom: 1px solid var(--hairline);
}

.mobile-task:last-child {
  border-bottom: 0;
}

.mobile-task-head,
.mobile-task-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.mobile-task-time {
  margin: 10px 0;
  color: var(--muted);
  font-size: 12px;
}

.mobile-task-head .status {
  flex: 0 0 auto;
}

.mobile-failure-reason {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--danger);
  background: #fff7f4;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.55;
}

.report-shell {
  width: min(100%, 1540px);
  margin: 0 auto;
  padding: 32px 28px 48px;
}

.report-head {
  margin-bottom: 20px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.report-head h1 {
  margin-bottom: 6px;
  font-size: clamp(28px, 4vw, 38px);
}

.report-meta {
  color: var(--muted);
}

.report-frame-wrap {
  min-height: 560px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-large);
  overflow: hidden;
  background: var(--canvas);
}

.report-frame {
  display: block;
  width: 100%;
  min-height: 720px;
  border: 0;
  background: #fff;
}

.report-message {
  min-height: 560px;
  padding: 48px 24px;
  display: grid;
  place-items: center;
  text-align: center;
}

.report-message-inner {
  max-width: 520px;
}

.report-message h2 {
  margin-bottom: 8px;
}

.report-message p {
  color: var(--muted);
}

.local-preview {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 5px 8px;
  border-radius: var(--radius-input);
  background: var(--cream);
  color: var(--warning);
  font-size: 12px;
  font-weight: 500;
}

@media (max-width: 1024px) {
  .nav-inner,
  .page-shell,
  .footer-inner {
    padding-left: 24px;
    padding-right: 24px;
  }

  .login-main {
    padding: 56px 24px;
    grid-template-columns: 1fr 380px;
    gap: 40px;
  }

  .task-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .task-form > #task-submit {
    grid-column: 1 / -1;
    justify-self: end;
    min-height: 48px;
    margin-top: 0;
  }

  .account-email {
    max-width: 150px;
  }
}

@media (max-width: 767px) {
  .site-header,
  .nav-inner {
    height: 60px;
  }

  .nav-inner {
    padding: 0 16px;
    gap: 12px;
  }

  .brand-text {
    display: none;
  }

  .nav-context {
    font-size: 13px;
  }

  .account-email {
    display: none;
  }

  .button-text {
    min-height: 44px;
    padding: 8px;
  }

  .login-main {
    min-height: auto;
    padding: 48px 16px;
    display: block;
  }

  .login-copy h1 {
    font-size: 40px;
  }

  .login-copy .lead {
    font-size: 15px;
  }

  .current-tool {
    margin: 28px 0 24px;
  }

  .auth-card {
    padding: 24px 20px;
  }

  .footer-inner {
    padding: 16px;
    display: block;
    text-align: center;
  }

  .footer-inner span {
    display: block;
    margin-top: 4px;
  }

  .page-shell {
    padding: 32px 16px;
  }

  .page-heading {
    align-items: flex-start;
  }

  .task-card {
    padding: 22px 16px;
  }

  .task-form {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .asin-row,
  .asin-row-own {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .asin-row-own::after {
    display: none;
  }

  .remove-competitor {
    grid-column: 2;
    justify-self: end;
  }

  .task-form > #task-submit {
    grid-column: auto;
    width: 100%;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .refresh-meta {
    width: 100%;
    justify-content: space-between;
  }

  .table-scroller {
    display: none;
  }

  .mobile-task-list {
    display: block;
  }

  .report-shell {
    padding: 24px 12px 36px;
  }

  .report-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .report-frame-wrap {
    border-radius: var(--radius-card);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 1.8s;
  }
}
