*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --pf-brand-900: #002C22;
  --pf-brand-800: #004F3B;
  --pf-brand-700: #166534;
  --pf-brand-600: #059669;
  --pf-brand-100: #ECFDF5;
  --pf-warm-700:  #962305;
  --pf-warm-100:  #FBE9E7;
  --pf-ink:       #111827;
  --pf-ink-2:     #4B5563;
  --pf-ink-3:     #6B7280;
  --pf-ink-4:     #9CA3AF;
  --pf-line:      #E5E7EB;
  --pf-line-2:    #D1D5DB;
  --pf-surface:   #FFFFFF;
  --pf-surface-muted: #F9FAFB;
  --pf-bg:        #F5F7F6;
  --pf-bg-tint:   #ECFDF5;
  --pf-border:    var(--pf-line);
  --pf-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --pf-shadow-focus: 0 0 0 3px rgba(5, 150, 105, 0.2);
  --pf-font-sans: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --pf-font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --pf-dur-fast:  150ms;
  --pf-ease:      cubic-bezier(.4, 0, .2, 1);
}

body {
  background: var(--pf-bg);
  font-family: var(--pf-font-sans);
  color: var(--pf-ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Login ──────────────────────────────────────────────────────────── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--pf-surface);
  border: 1px solid var(--pf-border);
  border-radius: 8px;
  box-shadow: var(--pf-shadow-sm);
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--pf-ink);
  margin-bottom: 28px;
  justify-content: center;
}

.login-logo img { width: 26px; height: 26px; }
.login-logo-accent { color: var(--pf-brand-600); }

.login-card .field { margin-bottom: 16px; }
.login-card .field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--pf-ink-2);
  margin-bottom: 6px;
}

.login-card input[type="password"] {
  width: 100%;
  background: var(--pf-surface);
  border: 1px solid var(--pf-border);
  border-radius: 6px;
  color: var(--pf-ink);
  font-size: 14px;
  font-family: var(--pf-font-sans);
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--pf-dur-fast) var(--pf-ease), box-shadow var(--pf-dur-fast) var(--pf-ease);
}
.login-card input[type="password"]:focus {
  border-color: var(--pf-brand-600);
  box-shadow: var(--pf-shadow-focus);
}

/* ── Header ─────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 52px;
  background: var(--pf-surface);
  border-bottom: 1px solid var(--pf-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--pf-ink);
  text-decoration: none;
}

.logo img { width: 20px; height: 20px; }
.logo-accent { color: var(--pf-brand-600); }

/* ── Main ───────────────────────────────────────────────────────────── */
.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 24px 56px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}

/* ── Card ───────────────────────────────────────────────────────────── */
.card {
  background: var(--pf-surface);
  border: 1px solid var(--pf-border);
  border-radius: 8px;
  box-shadow: var(--pf-shadow-sm);
  overflow: hidden;
}

.card-hd {
  padding: 13px 20px;
  border-bottom: 1px solid var(--pf-border);
  background: var(--pf-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-hd-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--pf-ink);
}

.card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Eyebrow ────────────────────────────────────────────────────────── */
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--pf-ink-3);
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--pf-border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--pf-font-sans);
  cursor: pointer;
  background: var(--pf-surface);
  color: var(--pf-ink);
  transition: background var(--pf-dur-fast) var(--pf-ease), border-color var(--pf-dur-fast) var(--pf-ease);
  text-decoration: none;
}
.btn:hover { background: var(--pf-bg); }
.btn:focus-visible { outline: none; box-shadow: var(--pf-shadow-focus); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-primary {
  background: var(--pf-brand-600);
  color: #fff;
  border-color: var(--pf-brand-600);
}
.btn-primary:hover { background: var(--pf-brand-800); border-color: var(--pf-brand-800); }
.btn-primary:disabled {
  background: var(--pf-ink-4);
  border-color: var(--pf-ink-4);
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-cta { width: 100%; padding: 11px 20px; font-size: 14px; font-weight: 600; }

.btn-done-state {
  width: 100%;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  background: var(--pf-brand-100);
  border-color: rgb(22 163 74 / .3);
  color: var(--pf-brand-700);
  cursor: default;
}
.btn-done-state:hover { background: var(--pf-brand-100); }

.btn-download {
  background: var(--pf-brand-900);
  border-color: var(--pf-brand-900);
  color: white;
  padding: 9px 20px;
}
.btn-download:hover { background: var(--pf-brand-800); border-color: var(--pf-brand-800); }

/* ── Drop zone ──────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--pf-line-2);
  border-radius: 8px;
  padding: 30px 20px;
  text-align: center;
  background: var(--pf-surface-muted);
  cursor: pointer;
  transition: all var(--pf-dur-fast) var(--pf-ease);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--pf-brand-600);
  background: var(--pf-bg-tint);
}
.dropzone-icon { font-size: 26px; opacity: 0.5; }
.dropzone-text { font-size: 13px; color: var(--pf-ink-2); line-height: 1.5; }
.dropzone-text strong { color: var(--pf-brand-600); font-weight: 600; }
.dropzone-hint { font-size: 11px; color: var(--pf-ink-4); font-family: var(--pf-font-mono); margin-top: 2px; }

/* ── File chip ──────────────────────────────────────────────────────── */
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  background: var(--pf-bg-tint);
  border: 1px solid rgb(22 163 74 / .3);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--pf-brand-700);
}
.file-chip-meta { font-weight: 400; color: var(--pf-ink-3); font-size: 12px; }
.file-chip-x {
  color: var(--pf-ink-4);
  cursor: pointer;
  font-size: 11px;
  margin-left: 3px;
  transition: color var(--pf-dur-fast);
}
.file-chip-x:hover { color: var(--pf-warm-700); }

/* ── Preview table ──────────────────────────────────────────────────── */
.preview-wrap { border: 1px solid var(--pf-border); border-radius: 6px; overflow: hidden; }
.preview-table { width: 100%; border-collapse: collapse; }
.preview-table th {
  background: var(--pf-bg);
  padding: 6px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pf-ink-3);
  border-bottom: 1px solid var(--pf-border);
  font-family: var(--pf-font-mono);
}
.preview-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--pf-line);
  font-size: 13px;
  color: var(--pf-ink-2);
}
.preview-table tr:last-child td { border-bottom: none; }
.skel { display: inline-block; background: var(--pf-line); border-radius: 3px; height: 10px; }
.cell-mono { font-family: var(--pf-font-mono); font-size: 12px; color: var(--pf-brand-700); }

/* ── Badge ──────────────────────────────────────────────────────────── */
.badge { padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.badge-brand { background: var(--pf-brand-100); color: var(--pf-brand-700); }
.badge-neutral { background: var(--pf-line); color: var(--pf-ink-3); }

/* ── Language chips ─────────────────────────────────────────────────── */
.langs-grid { display: flex; flex-wrap: wrap; gap: 6px; }

.lang-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border: 1px solid var(--pf-border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--pf-surface);
  color: var(--pf-ink-2);
  font-family: var(--pf-font-sans);
  transition: background var(--pf-dur-fast) var(--pf-ease), border-color var(--pf-dur-fast) var(--pf-ease), color var(--pf-dur-fast) var(--pf-ease);
  user-select: none;
}
.lang-chip:hover { background: var(--pf-bg); border-color: var(--pf-line-2); color: var(--pf-ink); }
.lang-chip.sel {
  background: var(--pf-bg-tint);
  border-color: var(--pf-brand-600);
  color: var(--pf-brand-700);
  font-weight: 600;
}
.lang-chip.sel:hover { background: #D1FAE5; }
.lang-check { font-size: 10px; color: var(--pf-brand-600); }

/* ── Accordion ──────────────────────────────────────────────────────── */
.accordion { border: 1px solid var(--pf-border); border-radius: 6px; overflow: hidden; }
.accordion-hd {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 13px;
  color: var(--pf-ink-3);
  transition: background var(--pf-dur-fast) var(--pf-ease);
}
.accordion-hd:hover { background: var(--pf-bg); }
.accordion-hd.open { border-bottom: 1px solid var(--pf-border); background: var(--pf-bg); }
.accordion-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; }

.accordion-caret { transition: transform var(--pf-dur-fast) var(--pf-ease); opacity: 0.5; }
.accordion-caret.open { transform: rotate(180deg); }

textarea.sys-prompt {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--pf-border);
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--pf-font-mono);
  color: var(--pf-ink);
  background: var(--pf-surface);
  resize: vertical;
  min-height: 110px;
  line-height: 1.65;
  outline: none;
  transition: border-color var(--pf-dur-fast) var(--pf-ease), box-shadow var(--pf-dur-fast) var(--pf-ease);
}
textarea.sys-prompt:focus { border-color: var(--pf-brand-600); box-shadow: var(--pf-shadow-focus); }

/* ── Progress ───────────────────────────────────────────────────────── */
.progress-track {
  height: 4px;
  background: var(--pf-line);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--pf-brand-600);
  border-radius: 2px;
  transition: width 350ms var(--pf-ease);
}
.progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--pf-ink-3);
}

/* ── Results ────────────────────────────────────────────────────────── */
.langs-results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 28px;
  margin-top: 10px;
}

.lang-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--pf-bg);
}
.lang-row:last-child { border-bottom: none; }
.lang-row-name { flex: 1; color: var(--pf-ink); }
.lang-done-text { font-size: 12px; color: var(--pf-brand-600); font-weight: 500; }
.lang-error-text { font-size: 12px; color: var(--pf-warm-700); font-weight: 500; }
.lang-pending-text { font-size: 12px; color: var(--pf-ink-4); }

/* ── Spinner ────────────────────────────────────────────────────────── */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--pf-line);
  border-top-color: var(--pf-brand-600);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Check circle ───────────────────────────────────────────────────── */
.check-circle {
  width: 16px;
  height: 16px;
  background: var(--pf-brand-600);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.check-circle svg { display: block; }

/* ── Error circle ───────────────────────────────────────────────────── */
.error-circle {
  width: 16px;
  height: 16px;
  background: var(--pf-warm-700);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 9px;
  color: white;
  font-weight: 700;
}

/* ── Empty state ────────────────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 20px;
  gap: 8px;
  text-align: center;
}
.empty-ico { font-size: 30px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--pf-ink); }
.empty-desc { font-size: 13px; color: var(--pf-ink-3); max-width: 280px; line-height: 1.6; }

/* ── Banners ────────────────────────────────────────────────────────── */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}
.banner-ok {
  background: var(--pf-brand-100);
  border: 1px solid rgb(22 163 74 / .2);
  color: var(--pf-brand-800);
}
.banner-ok strong { font-weight: 600; }

/* ── Alert ──────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}
.alert-error {
  background: var(--pf-warm-100);
  border: 1px solid rgba(150, 35, 5, 0.2);
  color: var(--pf-warm-700);
}

/* ── Util ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
