:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --line: rgba(0, 0, 0, 0.12);
  --line-soft: rgba(0, 0, 0, 0.07);
  --text: #1c1c1e;
  --text-2: #6b6b70;
  --text-3: #9a9aa0;
  --brand: #185fa5;
  --brand-soft: #e6f1fb;
  --ok: #0f6e56;
  --ok-soft: #e1f5ee;
  --warn: #854f0b;
  --warn-soft: #faeeda;
  --danger: #a32d2d;
  --danger-soft: #fcebeb;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 0.5px solid var(--line);
  padding-top: max(12px, env(safe-area-inset-top));
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--brand);
}

.topbar-actions { display: flex; gap: 8px; }

button {
  font-family: inherit;
  font-size: 14px;
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

button.primary {
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  font-weight: 500;
}
button.primary:hover { background: #12508c; }

button.ghost {
  background: transparent;
  color: var(--text-2);
  border: 0.5px solid var(--line);
}
button.ghost:hover { background: rgba(0, 0, 0, 0.04); color: var(--text); }

button.small { font-size: 13px; padding: 5px 10px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 20px 60px;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 12px 12px 48px; }
}

.panel {
  background: var(--card);
  border: 0.5px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.head-actions { display: flex; gap: 6px; align-items: center; }

.badge {
  font-size: 12px;
  font-weight: 400;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--brand-soft);
  color: var(--brand);
}

textarea, input[type="text"], input[type="date"], input[type="time"] {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 0.5px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  line-height: 1.6;
  resize: vertical;
}

textarea:focus, input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
}

#source { min-height: 320px; font-size: 14px; }

@media (max-width: 860px) {
  #source { min-height: 200px; }
}

#btnParse {
  width: 100%;
  margin-top: 12px;
  padding: 11px;
  font-size: 15px;
}

.hint {
  font-size: 12px;
  color: var(--text-3);
  margin: 8px 0 0;
}

/* ---------- 拖入区 ---------- */
.dropzone {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  transition: border-color .15s, background .15s;
  margin-bottom: 12px;
}

.dropzone:hover { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }

.dz-inner { color: var(--text-2); }
.dz-inner svg { color: var(--brand); margin-bottom: 6px; }
.dz-inner p { margin: 0; font-size: 13px; }
.dz-inner .link { color: var(--brand); text-decoration: underline; }
.dz-sub { font-size: 12px; color: var(--text-3); margin-top: 4px !important; }

.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  background: var(--bg);
  border: 0.5px solid var(--line-soft);
  border-radius: 8px;
  font-size: 12px;
}
.file-row .fname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.file-row .fstatus { flex-shrink: 0; color: var(--text-3); }
.file-row.ok .fstatus { color: var(--ok); }
.file-row.err .fstatus { color: var(--danger); }

/* ---------- 值班室信息卡 ---------- */
.duty-card {
  background: var(--brand-soft);
  border: 0.5px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.duty-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.duty-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.85;
  color: var(--text);
  word-break: break-word;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 260px;
  color: var(--text-3);
}
.empty p { font-size: 14px; margin: 0; }

.fields { display: flex; flex-direction: column; gap: 12px; }

.field { display: block; }

.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 5px;
}

.field-label .tip { font-style: normal; color: var(--text-3); }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  background: var(--bg);
  border: 0.5px solid var(--line);
  color: var(--text-2);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
}
.chip.on {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
}

.result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.result-actions button { flex: 1 1 auto; min-width: 100px; }

.preview {
  margin-top: 18px;
  background: var(--bg);
  border: 0.5px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
}

.preview-head {
  font-size: 12px;
  color: var(--text-2);
  padding: 8px 12px;
  border-bottom: 0.5px solid var(--line-soft);
}

#previewText {
  margin: 0;
  padding: 12px;
  font-family: inherit;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.75;
}

/* hidden 属性必须能压过display:flex —— 否则面板关不掉 */
[hidden] { display: none !important; }

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  max-height: 82vh;
  background: var(--card);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
  z-index: 60;
  display: flex;
  flex-direction: column;
}

@media (min-width: 861px) {
  .sheet {
    inset: 0 0 0 auto;
    width: 420px;
    max-height: none;
    border-radius: 16px 0 0 16px;
    border-top: none;
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 0.5px solid var(--line);
  font-weight: 500;
  font-size: 15px;
  padding-top: max(14px, env(safe-area-inset-top));
}

.sheet-body {
  padding: 16px 18px 40px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hist-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "t b" "m b";
  gap: 2px 10px;
  padding: 12px;
  border: 0.5px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.hist-row:hover { background: var(--bg); }
.hist-title { grid-area: t; font-size: 14px; font-weight: 500; }
.hist-meta { grid-area: m; font-size: 12px; color: var(--text-3); }
.hist-row button { grid-area: b; align-self: center; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: rgba(28, 28, 30, 0.92);
  color: #fff;
  font-size: 14px;
  padding: 9px 18px;
  border-radius: 20px;
  z-index: 90;
}