:root {
  color: #171717;
  background: #fafafa;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --blue: #111111;
  --blue-dark: #000000;
  --blue-soft: #f2f2f2;
  --green: #187044;
  --green-soft: #e8f5ed;
  --red: #a12622;
  --red-soft: #fff0ef;
  --amber: #765300;
  --amber-soft: #fff4d7;
  --line: #dedede;
  --muted: #777777;
  --surface: #ffffff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.035);
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input { font: inherit; }
button, input[type="file"] { cursor: pointer; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid #6d5ce7; outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 10;
  top: 12px;
  left: 12px;
  transform: translateY(-150%);
  padding: 10px 14px;
  border-radius: 8px;
  color: white;
  background: var(--blue-dark);
}
.skip-link:focus { transform: translateY(0); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header {
  background: rgba(255, 255, 255, .96);
  color: #171717;
  min-height: 64px;
  border-bottom: 1px solid #ececec;
}
.header-inner {
  width: min(1180px, calc(100% - 40px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.header-actions-only { justify-content: flex-end; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-actions button { color: #171717; border-color: #d7d7d7; }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 30px auto 64px; }
.card {
  background: var(--surface);
  border: 1px solid #dedede;
  border-radius: 12px;
  box-shadow: var(--shadow);
}
h1, h2, h3 { color: #171717; line-height: 1.22; }
h1 { margin: 20px 0 10px; font-size: clamp(27px, 3vw, 36px); }
h2 { margin: 0 0 10px; font-size: clamp(23px, 2.5vw, 29px); }
h3 { font-size: 18px; }
.lead { color: var(--muted); line-height: 1.55; margin: 0 0 28px; max-width: 760px; }

.field { margin-top: 20px; }
.field label, .field-label { display: block; margin-bottom: 8px; font-weight: 700; }
.field input:not([type="file"]) {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #b8b8b8;
  border-radius: 7px;
  background: white;
}
.field-hint { display: block; margin-top: 7px; color: var(--muted); font-size: 14px; line-height: 1.4; }

.button {
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--blue);
  border-radius: 7px;
  color: var(--blue);
  background: white;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.button:hover { background: #f1f1f1; }
.button-primary { color: white; background: var(--blue); }
.button-primary:hover { background: var(--blue-dark); }
.button:disabled { cursor: not-allowed; color: #929292; border-color: #d7d7d7; background: #eeeeee; }
.button-block { width: 100%; margin-top: 26px; }

.policy-note {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f7f7;
}
.policy-note .field-label { margin-bottom: 4px; }

.alert {
  display: flex;
  gap: 12px;
  margin: 20px 0;
  padding: 14px 16px;
  border-radius: 10px;
  border-left: 5px solid;
  line-height: 1.48;
}
.alert-error { color: #701a17; border-color: var(--red); background: var(--red-soft); }
.alert-warning { color: #5f4100; border-color: #ba8100; background: var(--amber-soft); }
.alert-info { color: #173d65; border-color: var(--blue); background: var(--blue-soft); }
.alert-success { color: #145c38; border-color: var(--green); background: var(--green-soft); }
.alert strong { display: block; margin-bottom: 2px; }

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}
.steps li { position: relative; display: flex; align-items: center; gap: 9px; color: var(--muted); font-weight: 650; }
.steps li:not(:last-child)::after { content: ""; height: 1px; flex: 1; margin: 0 12px; background: var(--line); }
.step-number { width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: white; }
.steps .active { color: var(--blue-dark); }
.steps .active .step-number, .steps .done .step-number { border-color: var(--blue); }
.steps .active .step-number { color: white; background: var(--blue); }
.steps .done .step-number { color: var(--blue); background: var(--blue-soft); }

.workspace { padding: clamp(24px, 4vw, 42px); }
.actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; padding-top: 24px; border-top: 1px solid #e1e6eb; }
.actions-end { justify-content: flex-end; }

.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 25px; }
.upload-card { position: relative; min-height: 190px; padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.upload-card.has-file { border-color: #79a88f; background: #f8fcfa; }
.upload-card.has-error { border-color: #d37d79; background: #fffafa; }
.upload-card h3 { margin: 0 0 6px; }
.upload-card p { min-height: 40px; margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.42; }
.file-input { max-width: 100%; color: #555; }
.file-input::file-selector-button { margin-right: 10px; padding: 8px 11px; border: 1px solid var(--blue); border-radius: 7px; color: var(--blue); background: white; font-weight: 650; }
.file-meta { display: grid; gap: 4px; margin-top: 13px; }
.file-name { overflow-wrap: anywhere; font-weight: 700; }
.status-ok { color: var(--green); font-size: 14px; font-weight: 700; }
.error-text { color: var(--red); font-size: 14px; line-height: 1.4; }
.remove-file { margin-top: 8px; padding: 6px 0; border: 0; color: var(--blue); background: transparent; text-decoration: underline; }

.summary { margin: 24px 0 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.summary li { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(0, 1.4fr) auto; gap: 18px; align-items: center; padding: 15px 18px; }
.summary li + li { border-top: 1px solid #e3e8ec; }
.summary-label { font-weight: 700; }
.summary-value { overflow-wrap: anywhere; color: #555; }
.badge { display: inline-flex; width: fit-content; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 13px; font-weight: 750; white-space: nowrap; }
.badge-success { color: #145c38; background: var(--green-soft); }
.badge-fail { color: #701a17; background: var(--red-soft); }
.badge-running { color: #173d65; background: var(--blue-soft); }
.badge-queued { color: #5f4100; background: var(--amber-soft); }

.job-card { padding: clamp(24px, 4vw, 42px); }
.job-id { margin: 0 0 8px; color: var(--muted); font-size: 14px; font-weight: 700; letter-spacing: .03em; }
.progress-track { overflow: hidden; width: 100%; height: 10px; margin: 20px 0 8px; border-radius: 999px; background: #e8e8e8; }
.progress-bar { height: 100%; border-radius: inherit; background: var(--blue); transition: width .25s ease; }
.progress-label { color: var(--muted); font-size: 14px; }
.result-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .8fr); gap: 22px; margin-top: 24px; }
.result-panel { padding: 22px; border: 1px solid var(--line); border-radius: 12px; }
.result-panel h3 { margin-top: 0; }
.hash-list { display: grid; gap: 16px; }
.hash-row span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 13px; font-weight: 700; }
code.hash { display: block; overflow-wrap: anywhere; padding: 9px; border-radius: 7px; background: #f2f2f2; color: #333; font-size: 12px; line-height: 1.45; }
.download-stack { display: grid; gap: 10px; }

.history-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 20px; }
.table-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 16px; border-bottom: 1px solid #e2e7eb; text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: #555; background: #f7f7f7; font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
.empty-state { padding: 52px 24px; text-align: center; }
.empty-state h2 { margin-top: 0; }

@media (max-width: 720px) {
  .header-inner { width: min(100% - 28px, 1120px); min-height: 64px; }
  .page-shell { width: min(100% - 24px, 1120px); margin-top: 22px; }
  .top-user { display: none; }
  .steps { grid-template-columns: 1fr; gap: 10px; }
  .steps li:not(:last-child)::after { display: none; }
  .upload-grid, .result-grid { grid-template-columns: 1fr; }
  .summary li { grid-template-columns: 1fr; gap: 5px; }
  .actions { flex-direction: column-reverse; }
  .actions .button { width: 100%; }
  .history-head { align-items: stretch; flex-direction: column; }
}

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