:root {
  --ink: #18221f;
  --muted: #65716d;
  --line: #d9dfdc;
  --surface: #ffffff;
  --canvas: #f3f6f4;
  --green: #176b58;
  --green-dark: #105044;
  --green-soft: #e7f2ee;
  --coral: #d95e47;
  --coral-soft: #fbece8;
  --amber: #a56810;
  --amber-soft: #fff3db;
  --shadow: 0 12px 30px rgba(26, 46, 39, 0.08);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  min-height: 116px;
  padding: 25px clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--ink);
  color: #fff;
  border-bottom: 4px solid var(--coral);
}

.topbar h1 { margin: 2px 0 0; font-size: 30px; line-height: 1.2; font-weight: 720; }
.eyebrow { margin: 0; color: #a9c4bb; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.eyebrow.dark { color: var(--green); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.service-state { display: inline-flex; align-items: center; gap: 8px; color: #dbe5e1; font-size: 13px; }
.service-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.service-state.online i { background: #51c99f; }

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid #52615c;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}
.icon-button:hover { background: #2a3733; }

main { width: min(1500px, 100%); margin: 0 auto; padding: 30px clamp(16px, 4vw, 64px) 56px; }
section { background: var(--surface); border: 1px solid var(--line); }
.workspace { box-shadow: var(--shadow); }
.section-heading { min-height: 82px; padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.section-heading.compact { min-height: 70px; padding: 16px 24px; }
h2 { margin: 0; font-size: 18px; line-height: 1.35; }
.muted { color: var(--muted); font-size: 13px; }
.path { margin: 5px 0 0; overflow-wrap: anywhere; }
.count { padding: 5px 9px; border: 1px solid var(--line); border-radius: 4px; font-size: 12px; white-space: nowrap; }

.work-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; min-height: 320px; }
.file-panel { min-width: 0; border-right: 1px solid var(--line); }
.file-panel.drop-active { outline: 2px dashed var(--green); outline-offset: -7px; background: var(--green-soft); }
.table-toolbar { height: 48px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.toolbar-actions { display: flex; align-items: center; gap: 14px; }
.upload-button { border: 1px solid var(--green); padding: 6px 10px; border-radius: 4px; background: #fff; color: var(--green); font-size: 12px; font-weight: 700; cursor: pointer; }
.upload-button:hover:not(:disabled) { background: var(--green-soft); }
.upload-button:disabled { border-color: var(--line); color: var(--muted); cursor: not-allowed; }
.check-label { display: inline-flex; gap: 9px; align-items: center; font-size: 13px; cursor: pointer; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--green); }
.file-list { max-height: 390px; overflow-y: auto; }
.file-row { min-height: 68px; padding: 12px 20px; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; border-bottom: 1px solid #edf0ee; }
.file-row:hover { background: #f8faf9; }
.file-name { min-width: 0; font-size: 14px; font-weight: 650; overflow-wrap: anywhere; }
.file-meta { margin-top: 4px; color: var(--muted); font-size: 12px; }
.pdf-mark { width: 38px; padding: 5px 0; color: var(--coral); background: var(--coral-soft); border-radius: 4px; text-align: center; font-size: 10px; font-weight: 800; }
.file-delete { width: 28px; height: 28px; border: 1px solid #e6c7c0; border-radius: 4px; background: #fff; color: var(--coral); font-size: 19px; line-height: 1; cursor: pointer; }
.file-delete:hover:not(:disabled) { background: var(--coral-soft); }
.file-delete:disabled { border-color: var(--line); color: #aeb9b5; cursor: not-allowed; }

.run-panel { padding: 24px; background: #fafcfb; }
.run-panel h2 { margin-bottom: 20px; }
.config-list { margin: 0; }
.config-list > div { padding: 11px 0; display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 12px; border-bottom: 1px solid var(--line); }
.config-list dt { color: var(--muted); font-size: 12px; }
.config-list dd { margin: 0; font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--amber); }
.configured .status-dot { background: var(--green); }
.not-configured { color: var(--coral); }
.not-configured .status-dot { background: var(--coral); }
.switch-row { margin: 20px 0; display: flex; justify-content: space-between; align-items: center; gap: 16px; cursor: pointer; }
.switch-row strong, .switch-row small { display: block; }
.switch-row strong { font-size: 13px; }
.switch-row small { margin-top: 3px; color: var(--muted); font-size: 11px; }

.primary-button, .secondary-button { width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 5px; font-weight: 700; text-decoration: none; cursor: pointer; }
.primary-button { border: 0; background: var(--green); color: #fff; }
.primary-button:hover:not(:disabled) { background: var(--green-dark); }
.primary-button:disabled { background: #aeb9b5; cursor: not-allowed; }
.secondary-button { margin-top: 10px; border: 1px solid var(--green); background: #fff; color: var(--green); }
.secondary-button:hover { background: var(--green-soft); }

.job-section, .results-section { margin-top: 22px; }
.progress-track { height: 8px; margin: 24px 24px 0; overflow: hidden; background: #e5ebe8; border-radius: 4px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--green); transition: width 240ms ease; }
.job-message { margin: 12px 24px 20px; color: var(--muted); font-size: 13px; }
.job-files { border-top: 1px solid var(--line); }
.job-file { min-height: 44px; padding: 9px 24px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; border-bottom: 1px solid #edf0ee; font-size: 12px; }
.job-file span:first-child { overflow-wrap: anywhere; }
.file-state { color: var(--muted); white-space: nowrap; }
.file-state.completed { color: var(--green); }
.file-state.failed { color: var(--coral); }
.file-state.parsing, .file-state.extracting { color: var(--amber); }
.error-list { margin: 18px 24px; padding: 12px 14px; color: #8f3022; background: var(--coral-soft); border-left: 3px solid var(--coral); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }

.text-button { border: 0; padding: 8px 0; background: transparent; color: var(--green); font-weight: 700; cursor: pointer; }
.result-table-wrap { width: 100%; min-height: 190px; overflow: auto; position: relative; }
table { width: max(100%, 1800px); border-collapse: collapse; font-size: 12px; }
th, td { padding: 11px 12px; border-right: 1px solid #edf0ee; border-bottom: 1px solid #e4e9e6; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; background: #edf4f1; color: #29413a; font-weight: 750; white-space: nowrap; }
td { max-width: 270px; overflow-wrap: anywhere; }
tbody tr:hover { background: #f8faf9; }
.empty-state { min-height: 190px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 5px; background: var(--ink); color: #fff; box-shadow: var(--shadow); font-size: 13px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8f3022; }
.is-hidden { display: none !important; }

@media (max-width: 860px) {
  .topbar { min-height: 96px; padding: 18px 20px; }
  .topbar h1 { font-size: 25px; }
  .service-state { display: none; }
  main { padding: 18px 12px 36px; }
  .work-grid { grid-template-columns: 1fr; }
  .file-panel { border-right: 0; }
  .run-panel { border-top: 1px solid var(--line); }
  .section-heading { padding: 16px; }
  .job-file { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 520px) {
  .section-heading { align-items: flex-start; }
  .path { max-width: 230px; }
  .file-row { padding-left: 14px; padding-right: 14px; grid-template-columns: 22px minmax(0, 1fr) auto; }
  .table-toolbar { padding-left: 14px; padding-right: 14px; }
  .toolbar-actions { gap: 9px; }
  .pdf-mark { display: none; }
  .run-panel { padding: 20px 16px; }
  .toast { right: 16px; bottom: 16px; }
}
