:root {
  color-scheme: light;
  --ink: #181818;
  --muted: #70706b;
  --muted-2: #979790;
  --canvas: #f4f4f1;
  --panel: #ffffff;
  --surface: #f8f8f6;
  --surface-strong: #eeeeea;
  --line: #ddddD7;
  --line-strong: #c6c6be;
  --success: #168358;
  --success-soft: #ebf8f1;
  --warning: #a66c00;
  --warning-soft: #fff7e5;
  --danger: #b42318;
  --danger-soft: #fff1ef;
  --shadow: 0 18px 50px rgba(24, 24, 24, .06);
  --ease: cubic-bezier(.16, 1, .3, 1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--canvas);
  scroll-behavior: smooth;
}

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

button, input, select { font: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
.upload-card:focus-within {
  outline: 3px solid rgba(24, 24, 24, .16);
  outline-offset: 3px;
}

.app-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(28px, calc((100vw - 1880px) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--ink);
  font: 700 12px ui-monospace, "Cascadia Code", monospace;
}

.brand strong { font-size: 17px; letter-spacing: -.02em; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.export-script-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
  background: var(--panel);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: transform .2s var(--ease), background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}

.export-script-button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.export-script-button:hover { border-color: #92928b; background: var(--surface); transform: translateY(-1px); }
.export-script-button:active { transform: scale(.97); }
.export-script-button:disabled { cursor: wait; opacity: .7; transform: none; }
.export-script-button.copied { color: var(--success); border-color: #a8d5bd; background: var(--success-soft); }

.logout-button {
  min-height: 36px;
  padding: 0 11px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.logout-button:hover { color: var(--ink); background: var(--surface); }

.version {
  color: var(--muted);
  font: 13px ui-monospace, "Cascadia Code", monospace;
}

.toast {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: 24px;
  max-width: min(440px, calc(100vw - 28px));
  padding: 12px 16px;
  border: 1px solid #a8d5bd;
  border-radius: 10px;
  color: #315d47;
  background: var(--success-soft);
  box-shadow: 0 16px 42px rgba(24, 24, 24, .14);
  font-size: 13px;
  font-weight: 650;
  transform: translateX(-50%);
  animation: toast-in .25s var(--ease) both;
}

.toast.error { color: var(--danger); border-color: #edc0ba; background: var(--danger-soft); }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.workflow {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .84);
}

.workflow ol {
  width: min(760px, calc(100% - 40px));
  min-height: 88px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.workflow li {
  position: relative;
  z-index: 0;
  display: grid;
  grid-template-columns: 38px auto;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted-2);
  font-size: 14px;
  font-weight: 600;
}

.workflow li:not(:last-child)::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: 50%;
  left: calc(50% + 58px);
  width: calc(100% - 116px);
  height: 1px;
  background: var(--line-strong);
}

.step-number {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel);
  font: 600 14px ui-monospace, "Cascadia Code", monospace;
  transition: color .25s var(--ease), background .25s var(--ease), border-color .25s var(--ease), transform .25s var(--ease);
}

.workflow li.active { color: var(--ink); }
.workflow li.active .step-number { color: #fff; border-color: var(--ink); background: var(--ink); transform: scale(1.06); }
.workflow li.complete { color: var(--success); }
.workflow li.complete .step-number { color: var(--success); border-color: #a8d5bd; background: var(--success-soft); }
.workflow li.complete:not(:last-child)::after { background: #a8d5bd; }

.app-main {
  width: min(1880px, 100%);
  margin: 0 auto;
  padding: 26px 28px 52px;
}

.screen { animation: screen-in .3s var(--ease) both; }

@keyframes screen-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.screen-heading {
  margin-bottom: 22px;
}

.screen-heading h1,
.card-heading h1,
.success-banner h1 {
  margin: 0;
  font-size: clamp(24px, 2.4vw, 34px);
  line-height: 1.12;
  letter-spacing: -.035em;
}

.screen-heading p:not(.eyebrow),
.success-banner p:not(.eyebrow) {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.project-name-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.project-name-field span,
.project-name-field strong,
.project-name-field small { display: block; }
.project-name-field strong { font-size: 15px; }
.project-name-field small { margin-top: 4px; color: var(--muted); font-size: 13px; }
.project-name-field input {
  width: min(620px, 55%);
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
}
.project-name-field input::placeholder { color: var(--muted-2); }
.project-name-field input:hover { border-color: #a7a79f; }

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.upload-card {
  min-width: 0;
  display: block;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .25s var(--ease), transform .25s var(--ease), box-shadow .25s var(--ease);
}

.upload-card:hover,
.upload-card.dragging {
  border-color: #a7a79f;
  box-shadow: 0 24px 54px rgba(24, 24, 24, .09);
  transform: translateY(-2px);
}

.upload-card.has-file { border-color: #a8d5bd; }
.upload-card input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.upload-card-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.upload-card-heading > span:last-child,
.upload-card-heading strong,
.upload-card-heading small { display: block; }

.upload-card-heading strong { font-size: 20px; letter-spacing: -.025em; }
.upload-card-heading small { margin-top: 4px; color: var(--muted); font-size: 14px; }

.type-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface);
  font: 700 12px ui-monospace, "Cascadia Code", monospace;
}

.drop-area {
  min-height: 310px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  background: var(--surface);
  text-align: center;
  transition: background .25s var(--ease), border-color .25s var(--ease);
}

.dragging .drop-area { border-color: #92928b; background: #f1f1ee; }
.has-file .drop-area { border-color: #a8d5bd; background: var(--success-soft); }

.file-icon {
  width: 62px;
  height: 62px;
  margin-bottom: 22px;
  fill: none;
  stroke: #777771;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.has-file .file-icon { stroke: var(--success); }

.choose-button {
  min-width: 188px;
  min-height: 46px;
  display: inline-grid;
  place-items: center;
  padding: 0 20px;
  border-radius: 10px;
  color: #fff;
  background: var(--ink);
  font-size: 14px;
  font-weight: 700;
  transition: transform .2s var(--ease), background .2s var(--ease);
}

.upload-card:hover .choose-button { background: #30302e; transform: scale(1.02); }

.drop-hint { margin-top: 16px; color: var(--muted); font-size: 14px; }
.file-state { margin-top: 14px; color: var(--muted-2); font-size: 13px; }
.has-file .file-state { color: var(--success); font-weight: 650; }

.selected-files {
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}

.selected-files:empty { display: none; }

.selected-file {
  max-width: 220px;
  overflow: hidden;
  padding: 5px 8px;
  border: 1px solid #cbe4d7;
  border-radius: 999px;
  color: #315d47;
  background: rgba(255, 255, 255, .86);
  font: 12px ui-monospace, "Cascadia Code", monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-file.more { color: var(--muted); border-color: var(--line); }

.upload-actions,
.review-actions,
.result-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 26px;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 0 18px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: transform .2s var(--ease), background .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.primary-button {
  min-width: 224px;
  border: 1px solid var(--ink);
  color: #fff;
  background: var(--ink);
  box-shadow: 0 8px 18px rgba(24, 24, 24, .13);
}

.primary-button:hover { background: #30302e; box-shadow: 0 12px 24px rgba(24, 24, 24, .17); transform: translateY(-1px); }
.primary-button:active, .secondary-button:active { transform: scale(.96); }
.primary-button:disabled { opacity: .56; cursor: wait; transform: none; }
.primary-button.loading .button-arrow { animation: spin .8s linear infinite; }

.secondary-button {
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: var(--panel);
}

.secondary-button:hover { border-color: #92928b; background: var(--surface); transform: translateY(-1px); }
.secondary-button.large { min-height: 50px; padding-inline: 24px; }
.secondary-button.compact-button { min-height: 38px; padding-inline: 14px; white-space: nowrap; }
.download-button { min-height: 50px; background: var(--success); border-color: var(--success); }
.download-button:hover { background: #126c48; }

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

.error-banner,
.warning-list {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid #edc0ba;
  border-radius: 10px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 14px;
  line-height: 1.5;
}

.warning-list { color: var(--warning); border-color: #ead6a4; background: var(--warning-soft); }
.warning-list p { margin: 4px 0; }

.recent-projects { margin-top: 28px; }
.recent-project-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.recent-project {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .2s var(--ease);
}
.recent-project:hover { border-color: #a7a79f; background: var(--panel); transform: translateY(-1px); }
.recent-project-open {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 94px;
  padding: 17px 82px 17px 15px;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.recent-project-open > span:first-child { min-width: 0; }
.recent-project strong,
.recent-project small { display: block; }
.recent-project strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.recent-project small { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.recent-project-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 5px;
}
.project-action {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  cursor: pointer;
  transition: color .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease), transform .2s var(--ease);
}
.project-action svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.project-action:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface); transform: translateY(-1px); }
.project-action.delete:hover { color: var(--danger); border-color: #edc0ba; background: var(--danger-soft); }
.recent-project-state { grid-column: 1 / -1; margin: 0; padding: 18px 4px; color: var(--muted); font-size: 13px; }
.recent-project-state.error { color: var(--danger); }

.project-dialog {
  width: min(500px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 28px 90px rgba(24, 24, 24, .22);
}
.project-dialog::backdrop { background: rgba(24, 24, 24, .32); backdrop-filter: blur(2px); }
.project-dialog form { padding: 22px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.dialog-heading h2 { margin: 0; font-size: 22px; letter-spacing: -.025em; }
.dialog-close {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.dialog-close:hover { color: var(--ink); border-color: var(--line-strong); }
.dialog-field { display: block; margin-top: 22px; }
.dialog-field span { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.dialog-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
  background: var(--surface);
}
.dialog-description { margin: 20px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.dialog-description strong { color: var(--ink); }
.script-export-dialog { width: min(560px, calc(100% - 28px)); }
.script-instructions {
  display: grid;
  gap: 12px;
  margin: 20px 0 0;
  padding: 16px 18px 16px 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.5;
}
.script-instructions li::marker { color: var(--muted); font-weight: 700; }
#copy-dialog-script.copied { color: #fff; border-color: var(--success); background: var(--success); }
.dialog-error { margin: 14px 0 0; color: var(--danger); font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.dialog-actions .secondary-button,
.dialog-actions .dialog-primary,
.danger-button { min-width: 0; min-height: 42px; }
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  color: #fff;
  background: var(--danger);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}
.danger-button:hover { background: #942017; }
.danger-button:disabled,
.dialog-primary:disabled { opacity: .55; cursor: wait; }

.review-screen {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 14px;
}

.uploaded-sidebar,
.content-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.uploaded-sidebar {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 112px);
  align-self: start;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-heading {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 16px;
  border-bottom: 1px solid var(--line);
}

.sidebar-heading h2 {
  margin: 0;
  font-size: 16px;
}

.sidebar-heading span { color: var(--muted); font-size: 13px; }

.sidebar-tools {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.sidebar-tools label { min-width: 0; }
.sidebar-search { position: relative; }
.sidebar-search svg { position: absolute; top: 50%; left: 11px; width: 17px; height: 17px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.7; }
.sidebar-tools input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  font-size: 13px;
}
.sidebar-tools input { padding: 0 10px 0 36px; }
.sidebar-tools input::placeholder { color: var(--muted-2); }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell { width: min(100%, 420px); }
.auth-brand { justify-content: center; margin-bottom: 22px; }
.auth-card {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0; font-size: 26px; letter-spacing: -.025em; }
.auth-card > p { margin: 8px 0 24px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.auth-form { display: grid; gap: 16px; }
.auth-field { display: grid; gap: 7px; }
.auth-field span { font-size: 13px; font-weight: 700; }
.auth-field input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
  background: var(--panel);
}
.auth-submit { width: 100%; justify-content: center; margin-top: 2px; }
.auth-error { margin: 0 !important; color: var(--danger) !important; font-size: 13px !important; }

.uploaded-sidebar details { border-bottom: 1px solid var(--line); }
.uploaded-sidebar details:last-child { border-bottom: 0; }

.uploaded-sidebar summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  list-style: none;
}

.uploaded-sidebar summary::-webkit-details-marker { display: none; }
.uploaded-sidebar summary::after { content: "⌄"; color: var(--muted); }
.uploaded-sidebar details[open] summary::after { transform: rotate(180deg); }
.uploaded-sidebar summary span { margin-left: auto; margin-right: 10px; color: var(--muted); font-weight: 500; }

.sidebar-files { min-height: 0; overflow: auto; padding: 8px; }
.sidebar-empty { margin: 0; padding: 24px 16px; color: var(--muted); font-size: 13px; text-align: center; }

.sidebar-file {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 10px 8px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

button.sidebar-file { cursor: pointer; }
button.sidebar-file:hover { background: var(--surface); }
.sidebar-file.active { background: var(--surface-strong); }
.file-check { width: 19px; height: 19px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--success); font-size: 11px; }
.file-check.attention { background: var(--warning); }
.file-check.error { background: var(--danger); }
.file-check.unchanged { color: var(--muted); background: var(--surface-strong); }
.sidebar-file strong, .sidebar-file small { display: block; white-space: normal; overflow-wrap: anywhere; }
.sidebar-file strong { font-size: 13px; font-weight: 600; line-height: 1.4; }
.sidebar-file small { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.review-content { min-width: 0; display: grid; gap: 14px; }
.content-card { min-width: 0; padding: 18px; }

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.card-heading.compact { margin-bottom: 13px; }
.card-heading h2 { margin: 0; font-size: 16px; letter-spacing: -.015em; }
.card-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.shown-count { color: var(--muted); font-size: 13px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.metric {
  min-width: 0;
  min-height: 86px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.metric > span:last-child { min-width: 0; }
.metric small, .metric strong { display: block; }
.metric small { margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.metric strong { font: 700 22px ui-monospace, "Cascadia Code", monospace; }

.metric-symbol {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background: var(--surface-strong);
  font: 700 11px ui-monospace, "Cascadia Code", monospace;
}

.metric-symbol.success { color: #fff; background: var(--success); }
.metric-symbol.warning { color: #fff; background: var(--warning); }
.metric.success .metric-symbol { color: #fff; background: var(--success); }
.metric.warning .metric-symbol { color: #fff; background: var(--warning); }
.metric.danger .metric-symbol { color: #fff; background: var(--danger); }

.split-metric { justify-content: space-around; gap: 8px; }
.split-metric > div { min-width: 0; display: flex; align-items: center; gap: 9px; }
.split-metric > div + div { padding-left: 12px; border-left: 1px solid var(--line); }
.split-metric .metric-symbol { width: 30px; height: 30px; }

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 180px auto;
  gap: 9px;
  margin-bottom: 12px;
}

.search-field { position: relative; }
.search-field svg { position: absolute; top: 50%; left: 13px; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.7; }

.filters input,
.filters select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  font-size: 13px;
}

.filters input { padding: 0 12px 0 40px; }
.filters select { padding: 0 32px 0 12px; }
.filters input::placeholder { color: var(--muted-2); }
.filters input:hover, .filters select:hover { border-color: var(--line-strong); }
.filters .secondary-button { min-height: 42px; white-space: nowrap; }

.reference-table-wrap,
.output-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.reference-table-wrap { max-height: 360px; }
.output-table-wrap { max-height: 430px; }

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }

th {
  position: sticky;
  z-index: 1;
  top: 0;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

td {
  max-width: 310px;
  padding: 10px 12px;
  overflow: hidden;
  border-bottom: 1px solid #ecece8;
  color: #3e3e3a;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

tr:last-child td { border-bottom: 0; }
.reference-row { cursor: pointer; }
.reference-row:hover td { background: var(--surface); }
.reference-row.selected td { background: #eeeeea; }
td:nth-child(2), td:nth-child(5) { font-family: ui-monospace, "Cascadia Code", monospace; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status-pill i { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.status-ready { color: var(--success); }
.status-not_found { color: var(--danger); font-weight: 700; }
.status-ambiguous { color: var(--warning); }
.status-already_long_id, .status-dynamic { color: var(--muted); }
.empty-state { margin: 0; padding: 28px; color: var(--muted); text-align: center; font-size: 13px; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.page-size-label { display: flex; align-items: center; gap: 8px; }
.page-size-label select { height: 36px; padding: 0 28px 0 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--panel); }
.page-controls { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.page-button { min-height: 36px; padding: 0 12px; }
.page-button:disabled { opacity: .42; cursor: default; transform: none; }

.diff-card {
  scroll-margin-top: 18px;
  transition: inset .28s var(--ease), border-radius .28s var(--ease), box-shadow .28s var(--ease);
}

.code-modal-open { overflow: hidden; }

.diff-card.code-expanded {
  position: fixed;
  z-index: 50;
  inset: 16px;
  display: flex;
  flex-direction: column;
  padding: 20px;
  border-color: var(--line-strong);
  border-radius: 16px;
  box-shadow: 0 30px 90px rgba(24, 24, 24, .2);
}

.diff-card.code-expanded::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  background: rgba(24, 24, 24, .28);
}

.diff-card.code-expanded .code-grid { flex: 1; min-height: 0; }
.diff-card.code-expanded pre { height: calc(100vh - 112px); }

.code-grid { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; }
.code-pane { min-width: 0; background: #fafaf8; }
.code-pane + .code-pane { border-left: 1px solid var(--line); }
.code-pane.converted { background: #f2faf5; }

.code-label {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.converted .code-label { color: var(--success); background: var(--success-soft); }
.copy-button { padding: 4px 0; border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; text-transform: none; }
.copy-button:hover { color: var(--ink); }

pre {
  height: 420px;
  margin: 0;
  overflow: auto;
  padding: 8px 0;
  color: #444440;
  font: 12px/1.65 "Cascadia Code", Consolas, monospace;
  tab-size: 4;
  white-space: normal;
}

.converted pre { color: #315d47; }

.code-line {
  min-height: 21px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: start;
  padding-right: 12px;
}

.line-number {
  padding-right: 12px;
  color: var(--muted-2);
  text-align: right;
  user-select: none;
}

.code-line code {
  min-width: 0;
  color: inherit;
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.original .code-line.changed { color: #8f2f27; background: #fff0ee; }
.converted .code-line.changed { color: #17633f; background: #dff5e8; }
.code-line.changed .line-number { color: currentColor; }
.code-line.object-not-found,
.original .code-line.object-not-found,
.converted .code-line.object-not-found {
  color: #8f2f27;
  background: #ffe8e5;
  box-shadow: inset 3px 0 var(--danger);
}
.code-line.object-not-found .line-number { color: var(--danger); font-weight: 700; }
.missing-token {
  padding: 1px 2px;
  border: 1px solid #e39a91;
  border-radius: 3px;
  color: #7b211a;
  background: #ffc9c3;
  font: inherit;
}
.code-line.object-not-found code::after {
  content: "Объект не найден";
  display: inline-block;
  margin-left: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  color: #fff;
  background: var(--danger);
  font: 700 10px/1.5 Inter, system-ui, sans-serif;
  white-space: nowrap;
}
.code-line.focused { box-shadow: inset 3px 0 var(--ink); }

.success-banner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 28px;
  border: 1px solid #a8d5bd;
  border-radius: 14px;
  background: var(--success-soft);
}

.success-icon {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 2px solid var(--success);
  border-radius: 50%;
  color: var(--success);
  font-size: 32px;
  font-weight: 600;
}

.result-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 20px;
}

.result-metric {
  min-height: 124px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.result-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface-strong);
  font: 700 13px ui-monospace, "Cascadia Code", monospace;
}

.result-metric.good .result-icon { color: var(--success); background: var(--success-soft); }
.result-metric.warn .result-icon { color: var(--warning); background: var(--warning-soft); }
.result-metric.error .result-icon { color: var(--danger); background: var(--danger-soft); }
.result-metric small, .result-metric strong { display: block; }
.result-metric small { margin-bottom: 7px; color: var(--muted); font-size: 14px; }
.result-metric strong { font: 700 30px ui-monospace, "Cascadia Code", monospace; }

.output-card { margin-top: 20px; }
.output-name { min-width: 0; display: inline-flex; align-items: center; gap: 10px; }
.output-name i { width: 34px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--surface); font: normal 9px ui-monospace, monospace; }
.output-status { color: var(--success); }
.more-row td { color: var(--muted); background: var(--surface); text-align: center; }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 1180px) {
  .recent-project-list { grid-template-columns: 1fr 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .result-metrics { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: minmax(220px, 1fr) 160px 160px; }
  .filters .secondary-button { grid-column: 1 / -1; justify-self: end; }
}

@media (max-width: 900px) {
  .upload-grid { grid-template-columns: 1fr; }
  .drop-area { min-height: 260px; }
  .review-screen { grid-template-columns: 1fr; }
  .uploaded-sidebar { position: static; max-height: none; }
  .sidebar-files { max-height: 190px; }
  .result-metrics { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-header { padding-inline: 16px; }
  .header-actions { gap: 7px; }
  .version { display: none; }
  .app-main { padding: 18px 14px 40px; }
  .workflow ol { width: calc(100% - 20px); min-height: 76px; }
  .workflow li { grid-template-columns: 32px; gap: 3px; text-align: center; }
  .workflow li:not(:last-child)::after { left: calc(50% + 30px); width: calc(100% - 60px); }
  .step-number { width: 32px; height: 32px; justify-self: center; }
  .step-label { font-size: 12px; }
  .upload-card { padding: 17px; }
  .project-name-field { align-items: stretch; flex-direction: column; gap: 12px; }
  .project-name-field input { width: 100%; }
  .recent-project-list { grid-template-columns: 1fr; }
  .drop-area { min-height: 235px; padding: 20px; }
  .card-heading { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .filters .secondary-button { grid-column: auto; width: 100%; }
  .pagination { align-items: stretch; flex-direction: column; }
  .page-controls { justify-content: space-between; }
  .code-grid { grid-template-columns: 1fr; }
  .code-pane + .code-pane { border-top: 1px solid var(--line); border-left: 0; }
  .diff-card.code-expanded { inset: 8px; overflow: auto; padding: 12px; }
  .diff-card.code-expanded .code-grid { display: block; overflow: visible; }
  .diff-card.code-expanded pre { height: 38vh; }
  .success-banner { align-items: flex-start; padding: 22px; }
  .success-icon { width: 50px; height: 50px; font-size: 25px; }
  .review-actions, .result-actions { flex-direction: column; }
  .review-actions .primary-button, .result-actions .primary-button, .result-actions .secondary-button { width: 100%; }
}

@media (max-width: 440px) {
  .brand { display: none; }
  .header-actions { width: 100%; justify-content: flex-end; }
  .export-script-button { gap: 6px; padding-inline: 8px; font-size: 11px; }
  .export-script-button svg { display: none; }
  .workflow li:not(:last-child)::after { display: none; }
  .upload-card-heading strong { font-size: 18px; }
  .success-banner { flex-direction: column; }
}
