:root {
  color-scheme: light;
  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface-soft: #faf9f6;
  --text: #242322;
  --muted: #6e6a64;
  --line: #ded9d1;
  --accent: #8b5d2e;
  --accent-dark: #55391f;
  --warning-bg: #fff5d9;
  --warning-text: #6a4a10;
  --error-bg: #fff0ed;
  --error-text: #97372b;
  --shadow: 0 18px 50px rgba(42, 38, 32, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 32px 18px;
}

.login-shell {
  width: min(940px, 100%);
  display: grid;
  grid-template-columns: 1fr minmax(320px, 430px);
  gap: 56px;
  align-items: center;
}

.brand-mark,
.wordmark {
  color: var(--text);
  font-size: 30px;
  font-weight: 760;
  letter-spacing: 0;
  text-decoration: none;
}

.login-panel,
.work-section {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  padding: 42px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 760;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 14px;
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1.05;
  font-weight: 780;
}

h2 {
  margin-bottom: 6px;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 760;
}

.login-copy,
.section-heading p,
.page-heading p {
  color: var(--muted);
  line-height: 1.7;
}

.form-stack,
.coordinate-panel {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 14px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(139, 93, 46, 0.14);
}

.primary-button,
.ghost-button {
  min-height: 46px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0 20px;
  font-weight: 760;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

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

.primary-button:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.ghost-button {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.ghost-button:hover {
  color: var(--text);
  border-color: #bdb6ab;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--error-text);
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px clamp(18px, 4vw, 56px);
}

.workspace {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 14px 0 64px;
}

.page-heading {
  margin-bottom: 34px;
}

.page-heading h1 {
  margin-bottom: 8px;
}

.work-section {
  padding: clamp(22px, 4vw, 34px);
  margin-bottom: 28px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}

.step-index {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  font-weight: 760;
  flex: 0 0 auto;
}

.dropzone {
  min-height: 260px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  border: 2px dashed #bdb6ab;
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
  outline: none;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.dropzone:hover,
.dropzone:focus,
.dropzone.is-dragging {
  border-color: var(--accent);
  background: #fffaf1;
  transform: translateY(-1px);
}

.dropzone strong {
  font-size: 22px;
}

.dropzone span {
  color: var(--muted);
}

.upload-icon {
  width: 48px;
  height: 48px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  position: relative;
}

.upload-icon::before,
.upload-icon::after {
  content: "";
  position: absolute;
  background: var(--accent);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.upload-icon::before {
  width: 2px;
  height: 22px;
}

.upload-icon::after {
  width: 22px;
  height: 2px;
}

.inline-status {
  min-height: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  color: var(--muted);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #d8d1c7;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

.preview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: 28px;
  align-items: start;
}

.preview-pane {
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.preview-pane img {
  width: 100%;
  height: 100%;
  max-height: 620px;
  object-fit: contain;
  display: block;
}

.coordinate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.result-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  overflow: hidden;
}

.empty-state {
  min-height: 150px;
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 26px;
}

.total-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 20px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.total-line span {
  color: var(--muted);
  font-weight: 700;
}

.total-line strong {
  font-size: 30px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

td:last-child,
th:last-child {
  text-align: right;
}

.warning-bar,
.feedback {
  padding: 14px 16px;
  border-radius: 7px;
  line-height: 1.6;
}

.warning-bar {
  margin: 18px;
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid #efd99c;
}

.feedback {
  position: sticky;
  bottom: 18px;
  margin-top: 18px;
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid #f0c7c0;
  box-shadow: var(--shadow);
}

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

@media (max-width: 820px) {
  .login-shell,
  .preview-grid {
    grid-template-columns: 1fr;
  }

  .brand-mark {
    font-size: 28px;
  }

  .login-panel {
    padding: 28px;
  }

  .coordinate-grid {
    grid-template-columns: 1fr;
  }

  .preview-pane {
    min-height: 300px;
  }
}
