:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --text: #242826;
  --muted: #69716d;
  --line: #d9ddda;
  --accent: #176b55;
  --accent-dark: #105442;
  --accent-soft: #e8f2ee;
  --danger: #a33434;
  --warning: #7d5712;
  --warning-bg: #fff7e7;
  --focus: #247f68;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid rgba(36, 127, 104, .45); outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent); outline-offset: 2px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(100%, 420px); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 38px; box-shadow: 0 12px 35px rgba(27, 39, 34, .06); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.65rem, 3vw, 2.15rem); line-height: 1.15; letter-spacing: -.025em; }
h2 { margin-bottom: 16px; font-size: 1.3rem; }
.eyebrow { margin-bottom: 8px; color: var(--accent); font-weight: 750; font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; }
.muted, .heading-note { color: var(--muted); line-height: 1.5; }
label { display: block; margin: 24px 0 7px; font-weight: 700; font-size: .9rem; }
input, select { width: 100%; min-height: 44px; padding: 9px 11px; color: var(--text); background: #fff; border: 1px solid #afb6b2; border-radius: 6px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 43px; padding: 10px 18px; border: 1px solid transparent; border-radius: 6px; font-weight: 750; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, transform .05s; }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: .55; cursor: wait; }
.button.primary { color: #fff; background: var(--accent); }
.button.primary:hover { background: var(--accent-dark); }
.button.secondary { color: var(--text); background: var(--surface); border-color: #bfc5c1; }
.button.secondary:hover { border-color: #838c87; background: #fafbfa; }
.button.full { width: 100%; margin-top: 12px; }
.form-error { min-height: 1.25em; margin: 8px 0 0; color: var(--danger); font-size: .9rem; line-height: 1.4; }
.centered { text-align: center; }

.topbar { border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .96); }
.topbar-inner { width: min(100% - 40px, 1100px); min-height: 64px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { color: var(--text); font-size: .98rem; font-weight: 800; text-decoration: none; }
nav { display: flex; align-items: center; gap: 8px; }
nav a, .link-button { padding: 8px 10px; color: var(--muted); background: none; border: 0; border-radius: 5px; font-size: .9rem; text-decoration: none; cursor: pointer; }
nav a:hover, nav a.active, .link-button:hover { color: var(--accent); background: var(--accent-soft); }

.content { width: min(100% - 40px, 1100px); margin: 0 auto; padding: 48px 0 72px; }
.page-heading { min-height: 70px; margin-bottom: 28px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.heading-note { margin-top: 25px; font-size: .9rem; }

.drop-zone { min-height: 280px; padding: 40px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; color: var(--muted); background: var(--surface); border: 1.5px dashed #aeb6b1; border-radius: 8px; cursor: pointer; text-align: center; }
.drop-zone:hover, .drop-zone.dragging { color: var(--accent); border-color: var(--accent); background: #f9fcfa; }
.drop-zone strong { color: var(--text); font-size: 1.05rem; }
.upload-icon { width: 42px; height: 42px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); border-radius: 50%; font-size: 1.45rem; }
.progress-block { max-width: 680px; margin: 30px auto 0; }
.progress-head { margin-bottom: 8px; display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; }
.progress-track { width: 100%; height: 8px; overflow: hidden; appearance: none; background: #dfe3e0; border: 0; border-radius: 999px; }
.progress-track::-webkit-progress-bar { background: #dfe3e0; border-radius: 999px; }
.progress-track::-webkit-progress-value { background: var(--accent); border-radius: 999px; transition: width .25s ease; }
.progress-track::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.progress-track.large { height: 10px; margin: 20px 0; }

.analysis-grid { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(320px, .88fr); gap: 46px; }
.preview-frame { height: 540px; padding: 18px; display: grid; place-items: center; background: #e8ebe9; border: 1px solid var(--line); border-radius: 8px; }
.preview-frame img { width: 100%; height: 100%; object-fit: contain; }
.source-name { margin: 12px 0; overflow-wrap: anywhere; color: var(--muted); font-size: .9rem; }
.warnings { display: grid; gap: 7px; }
.warning { margin: 0; padding: 10px 12px; color: var(--warning); background: var(--warning-bg); border-left: 3px solid #d69b31; font-size: .88rem; line-height: 1.45; }
.parameters-column { padding-top: 3px; }
.details { margin: 0; border-top: 1px solid var(--line); }
.details > div { min-height: 42px; padding: 9px 0; display: grid; grid-template-columns: 1fr 1.15fr; gap: 12px; align-items: baseline; border-bottom: 1px solid var(--line); }
.details dt { color: var(--muted); font-size: .86rem; }
.details dd { margin: 0; text-align: right; font-weight: 680; overflow-wrap: anywhere; }
.step-control { margin: 24px 0 18px; }
.step-control label { margin-top: 0; }
.calculated dd { color: var(--accent); }
.pixel-note { margin: 16px 0 4px; padding: 11px 12px; color: #3e554d; background: var(--accent-soft); border-radius: 5px; font-size: .88rem; line-height: 1.45; }

.processing, #result-section { padding: 46px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.processing { max-width: 760px; margin: 38px auto; }
.processing p:last-child { margin-bottom: 0; color: var(--muted); font-size: .9rem; }
.result-heading { margin-bottom: 28px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.result-heading h2 { margin-bottom: 0; font-size: 1.8rem; }
.success-mark { margin-bottom: 4px; color: var(--accent); font-weight: 750; }
.result-details { margin-bottom: 24px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 36px; }

.empty-state { padding: 70px 20px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; text-align: center; }
.history-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.history-item { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.history-thumb { height: 210px; display: grid; place-items: center; background: #e7eae8; border-bottom: 1px solid var(--line); }
.history-thumb img { width: 100%; height: 100%; object-fit: contain; }
.history-body { padding: 17px; }
.history-name { margin-bottom: 6px; overflow-wrap: anywhere; font-weight: 750; }
.history-meta { margin-bottom: 13px; color: var(--muted); font-size: .84rem; line-height: 1.55; white-space: pre-line; }
.status { display: inline-block; margin-bottom: 13px; padding: 4px 8px; color: #4b5350; background: #ecefed; border-radius: 4px; font-size: .78rem; font-weight: 750; }
.status.ready { color: var(--accent-dark); background: var(--accent-soft); }
.status.failed { color: var(--danger); background: #f9eaea; }
.history-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.history-actions .button { min-height: 36px; padding: 7px 10px; font-size: .82rem; }
.delete-button { color: var(--danger); background: transparent; border: 0; cursor: pointer; font-size: .82rem; }
.delete-button:hover { text-decoration: underline; }
.more { margin: 28px auto 0; }
noscript { display: block; padding: 30px; text-align: center; }

@media (max-width: 820px) {
  .analysis-grid { grid-template-columns: 1fr; gap: 28px; }
  .preview-frame { height: 430px; }
  .history-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-details { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .login-shell { padding: 14px; }
  .login-panel { padding: 26px 22px; }
  .topbar-inner { width: min(100% - 24px, 1100px); min-height: auto; padding: 12px 0; align-items: flex-start; flex-direction: column; gap: 7px; }
  nav { width: 100%; overflow-x: auto; }
  nav a, .link-button { padding: 7px 8px; white-space: nowrap; }
  .content { width: min(100% - 24px, 1100px); padding: 30px 0 50px; }
  .page-heading { min-height: 0; margin-bottom: 20px; flex-direction: column; gap: 8px; }
  .heading-note { margin: 0 0 17px; }
  .drop-zone { min-height: 225px; padding: 28px 18px; }
  .preview-frame { height: 380px; padding: 10px; }
  .details > div { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
  .processing, #result-section { padding: 25px 20px; }
  .result-heading { align-items: stretch; flex-direction: column; }
  .result-heading .button { width: 100%; }
  .history-grid { grid-template-columns: 1fr; }
  .history-thumb { height: 260px; }
}
