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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f5f5;
  color: #333;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ── */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 10px 20px;
  font-size: 13px;
  color: #888;
}

/* ── Layout ── */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 230px;
  min-width: 230px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-title {
  padding: 18px 18px 10px;
  font-weight: 700;
  font-size: 18px;
  color: #2d6a4f;
  cursor: pointer;
  user-select: none;
}
.sidebar-title:hover { color: #1a4030; }

.sidebar-nav { padding: 4px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  font-size: 15px;
  cursor: pointer;
  color: #444;
  transition: background 0.15s;
}
.nav-item:hover { background: #f0faf4; }
.nav-item.active { background: #e8f5ee; color: #2d6a4f; font-weight: 600; }
.nav-item svg { flex-shrink: 0; opacity: 0.7; }
.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}
.nav-icon-import {
  width: 14px;
  height: 14px;
  -webkit-mask-image: url('../images/import.svg');
  mask-image: url('../images/import.svg');
}
.nav-icon-export {
  width: 14px;
  height: 14px;
  -webkit-mask-image: url('../images/export.svg');
  mask-image: url('../images/export.svg');
}
.nav-icon-history {
  -webkit-mask-image: url('../images/history.svg');
  mask-image: url('../images/history.svg');
}

.sidebar-section-label {
  padding: 14px 16px 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #aaa;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 13px;
  cursor: pointer;
  color: #555;
  transition: background 0.15s;
}
.file-item:hover { background: #f5f5f5; }
.file-item.active { background: #e8f5ee; color: #2d6a4f; }

.file-item-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.file-item-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.file-item:hover .file-item-actions { opacity: 1; }

.icon-btn {
  background: none; border: none; cursor: pointer; padding: 2px;
  color: #999; border-radius: 3px;
  display: flex; align-items: center;
}
.icon-btn:hover { color: #e53935; background: #ffeeed; }

/* ── Main content ── */
.main {
  flex: 1;
  overflow: auto;
  padding: 24px 28px;
}

.page { display: none; }
.page.active { display: block; }

.page-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  color: #222;
}

/* ── Import / Intelligent Extractor ── */
.import-drop-zone {
  background: #fff;
  border: 2px dashed #c8e6d4;
  border-radius: 14px;
  padding: 80px 40px;
  text-align: center;
  width: 100%;
  min-height: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 20px 0;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.import-drop-zone:hover { border-color: #2d6a4f; background: #f7fdf9; }
.import-drop-zone.drag-over { border-color: #2d6a4f; background: #edf7f1; }
.import-frog { margin-bottom: 20px; }

/* ── Upload queue ── */
#upload-queue-wrap { margin: 0 0 24px; }
.queue-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #f6faf7; border: 1px solid #d4e9db;
  border-radius: 8px 8px 0 0; font-size: 13px; color: #444;
}
.queue-list { list-style: none; margin: 0; padding: 0; border: 1px solid #d4e9db; border-top: none; border-radius: 0 0 8px 8px; overflow: hidden; }
.queue-item {
  display: grid; grid-template-columns: 24px 1fr 70px 1fr auto;
  align-items: center; gap: 8px;
  padding: 8px 14px; font-size: 13px; background: #fff;
  border-bottom: 1px solid #eef4f0;
}
.queue-item:last-child { border-bottom: none; }
.queue-item.q-uploading { background: #eef5ff; }
.queue-item.q-done     { background: #f2faf4; }
.queue-item.q-error    { background: #fff5f5; }
.q-icon { font-size: 14px; text-align: center; }
.q-uploading .q-icon { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.q-done .q-icon { color: #2d6a4f; font-weight: 700; }
.q-error .q-icon { color: #b91c1c; font-weight: 700; }
.q-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.q-size { color: #888; font-size: 12px; text-align: right; }
.q-msg  { color: #888; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-error .q-msg { color: #b91c1c; }
.q-done .q-msg  { color: #2d6a4f; }
.q-remove-btn { background: none; border: none; color: #aaa; cursor: pointer; font-size: 20px; line-height: 1; padding: 0 5px; display: flex; align-items: center; justify-content: center; }
.q-remove-btn:hover { color: #b91c1c; }
#upload-all-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-upload {
  background: #222;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 10px 28px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 14px;
  display: inline-block;
}
.btn-upload:hover { background: #444; }
.import-hint { font-size: 16px; color: #aaa; margin-top: 4px; }

/* ── Buttons ── */
.btn-primary {
  background: #2d6a4f;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 22px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: #245a42; }

.btn-secondary {
  background: #fff;
  color: #2d6a4f;
  border: 1px solid #2d6a4f;
  border-radius: 6px;
  padding: 9px 22px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { background: #f0faf4; }

.btn-ghost {
  background: none;
  border: none;
  color: #2d6a4f;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 5px;
}
.btn-ghost:hover { background: #f0faf4; }

/* ── Table View ── */
.table-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.table-view-subtitle {
  font-size: 13px;
  color: #888;
  margin-top: 2px;
}

.table-match-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 12px;
}

.table-match-label {
  font-size: 12px;
  font-weight: 700;
  color: #6d7f74;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table-match-value {
  font-size: 13px;
  color: #7f8d84;
}

.table-match-value.active {
  color: #2d6a4f;
  font-weight: 600;
}

.spreadsheet-wrap {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #ddd;
  overflow: auto;
  max-height: calc(100vh - 180px);
}

.spreadsheet {
  border-collapse: collapse;
  font-size: 13px;
  width: 100%;
  min-width: 900px;
}

.spreadsheet col.row-num { width: 40px; }

.spreadsheet thead tr:first-child th {
  background: #f0faf4;
  color: #5a9e7a;
  font-weight: 400;
  padding: 8px 10px;
  border: 1px solid #d4edda;
  text-align: center;
  font-size: 11px;
  position: sticky;
  top: 0;
  z-index: 2;
}
.spreadsheet thead tr:first-child th.row-num-th {
  background: #e8f5ee;
}

.spreadsheet thead tr:first-child th.main-key-col {
  background: #e7f4ec;
}

.spreadsheet thead tr:first-child th.alternate-key-col {
  background: #f5faf7;
}

.col-letter {
  display: block;
}

.spreadsheet tbody tr:hover td { background: #f9fffc; }

.spreadsheet td {
  border: 1px solid #e8e8e8;
  padding: 0;
  min-width: 100px;
  max-width: 180px;
  height: 32px;
  vertical-align: middle;
  position: relative;
}

/* Editable column name */
.col-name {
  display: block;
  font-weight: 700;
  font-size: 13px;
  color: #2d6a4f;
  cursor: text;
  padding: 2px 4px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.col-name:hover { background: #d0ead9; color: #2d6a4f; }

.main-key-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #9ab7a6;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}

.main-key-btn:hover {
  background: #d6eadf;
  color: #2d6a4f;
}

.main-key-btn.active {
  background: #2d6a4f;
  color: #fff;
}

.main-key-btn svg {
  width: 14px;
  height: 14px;
}

.main-key-chip {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #2d6a4f;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.alternate-key-chip {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dcefe4;
  color: #2d6a4f;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.match-key-menu {
  position: absolute;
  top: calc(100% - 6px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 160px;
  background: #fff;
  border: 1px solid #d7e7dd;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(34, 62, 48, 0.12);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
}

.match-key-menu-item {
  border: none;
  background: transparent;
  color: #335846;
  text-align: left;
  font-size: 12px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
}

.match-key-menu-item:hover:not(:disabled) {
  background: #edf7f1;
}

.match-key-menu-item:disabled {
  color: #a8b7ae;
  cursor: not-allowed;
}

.match-key-menu-item.danger {
  color: #a94442;
}
.col-name-input {
  font-size: 13px;
  font-family: inherit;
  color: #2d6a4f;
  background: #fff;
  border: 1px solid #2d6a4f;
  border-radius: 3px;
  padding: 1px 5px;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  outline: none;
}

/* Row num + delete button */
.spreadsheet td.row-num-cell {
  background: #fafafa;
  color: #bbb;
  text-align: center;
  font-size: 11px;
  width: 40px;
  min-width: 40px;
  user-select: none;
  position: relative;
}
.row-num-label { display: block; }
.delete-row-btn {
  display: none;
  position: absolute;
  inset: 0;
  margin: auto;
  width: 20px;
  height: 20px;
  background: #ffeeed;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: #e53935;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.spreadsheet tbody tr:hover td.row-num-cell .row-num-label { visibility: hidden; }
.spreadsheet tbody tr:hover td.row-num-cell .delete-row-btn { display: flex; }

/* column-range selection */
#spreadsheet td { user-select: none; }
#spreadsheet td.cell-selected { background: #d0ead9 !important; outline: 1px solid #2d6a4f; }

/* save status badge */
.save-status { font-size: 12px; padding: 3px 10px; border-radius: 12px; white-space: nowrap; transition: opacity 0.2s; }
.save-status:empty { display: none; }
.save-unsaved { background: #fff8e1; color: #a67c00; border: 1px solid #ffe082; }
.save-saving  { background: #e8f0fe; color: #1a56db; border: 1px solid #93b4fb; }
.save-saved   { background: #e6f4ea; color: #2d6a4f; border: 1px solid #a8d5b5; }
.save-error   { background: #fdecea; color: #b91c1c; border: 1px solid #fca5a5; }
.save-retry-btn { background: none; border: none; color: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; font-size: inherit; }

/* sum row */
#spreadsheet tfoot tr { border-top: 2px solid #b0c4b1; }
#spreadsheet tfoot td { position: sticky; bottom: 0; z-index: 2; background: #f0f7f1; font-weight: 600; color: #2d6a4f; font-size: 13px; padding: 0 8px; height: 34px; line-height: 34px; user-select: none; }
#spreadsheet tfoot td.sum-label-cell { text-align: center; color: #888; font-weight: 700; font-size: 15px; }
#spreadsheet tfoot td.sum-empty { color: #ccc; font-weight: 400; font-style: italic; }

.cell-display {
  padding: 0 8px;
  height: 32px;
  line-height: 32px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: cell;
  display: block;
  color: #333;
}
.cell-display.null-val { color: #ccc; font-style: italic; }

.cell-input {
  position: absolute;
  inset: 0;
  border: 2px solid #2d6a4f;
  outline: none;
  padding: 0 7px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(45,106,79,0.15);
}

td.editing { outline: 2px solid #2d6a4f; z-index: 5; }

/* ── Template Selector ── */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 14px;
  align-items: stretch;
}

.template-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 14px;
  min-height: 190px;
  padding: 24px 20px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  color: #333;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
}
.template-card:hover {
  border-color: #2d6a4f;
  box-shadow: 0 10px 24px rgba(45,106,79,0.12);
  transform: translateY(-3px);
}
.template-card .card-icon {
  width: 72px; height: 72px;
  background: #e8f5ee;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
}
.template-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.template-card-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  color: #1f2937;
}
.template-card-subtitle {
  font-size: 12px;
  line-height: 1.5;
  color: #6b7280;
  max-width: 18ch;
  text-align: center;
}
.template-card.disabled { opacity: 0.4; cursor: not-allowed; }
.template-card.disabled:hover { transform: none; box-shadow: none; border-color: #e0e0e0; }

/* ── Template Editor ── */
.editor-layout {
  display: flex;
  gap: 15px;
  align-items: stretch;
}

.editor-left {
  flex: 0 0 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.editor-panel {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
}

.panel-header {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 13px;
  background: #fafafa;
  border-bottom: 1px solid #eee;
  color: #444;
}

.source-cols {
  display: flex;
  height: 420px;
}

.source-col {
  flex: 1;
  border-right: 1px solid #eee;
  overflow-y: auto;
}
.source-col:last-child { border-right: none; }

.source-col-header {
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #f9f9f9;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
}

.source-table-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: #555;
  transition: background 0.1s;
}
.source-table-item:hover { background: #f5f5f5; }
.source-table-item.active { background: #e8f5ee; color: #2d6a4f; font-weight: 600; }

.source-field-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: grab;
  color: #555;
  transition: background 0.1s;
  user-select: none;
}
.source-field-item:hover { background: #f0faf4; color: #2d6a4f; }
.source-field-item:active { cursor: grabbing; }

.panel-footer {
  padding: 10px 14px;
  border-top: 1px solid #eee;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.add-btn {
  width: 100%;
  padding: 7px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}
.add-btn.primary { background: #2d6a4f; color: #fff; }
.add-btn.primary:hover { background: #245a42; }
.add-btn.secondary { background: #f0faf4; color: #2d6a4f; border: 1px solid #b7dfca; }
.add-btn.secondary:hover { background: #d8f0e4; }
.add-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Formula Builder ── */
.formula-panel {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
}

.formula-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px;
  min-height: 120px;
  align-items: flex-start;
  border-bottom: 1px solid #eee;
  transition: background 0.15s, border-color 0.15s;
}
.formula-tokens.drag-over {
  background: #edf7f1;
  border: 2px dashed #2d6a4f;
  border-radius: 6px;
}

.formula-token {
  background: #e8f5ee;
  color: #2d6a4f;
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: grab;
  user-select: none;
  transition: opacity 0.15s;
}
.formula-token.dragging { opacity: 0.35; }
.formula-token.drop-before { box-shadow: -3px 0 0 #2d6a4f; }
.formula-token:active { cursor: grabbing; }
.formula-token .remove-token {
  background: none; border: none; cursor: pointer;
  color: #aaa; font-size: 13px; padding: 0; line-height: 1;
}
.formula-token .remove-token:hover { color: #e53935; }

.formula-op {
  background: #f0f0f0;
  color: #555;
  border-radius: 14px;
  padding: 3px 9px;
  font-size: 13px;
  font-weight: 700;
  cursor: grab;
  user-select: none;
  transition: opacity 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.formula-op .remove-token { color: #999; background: none; border: none; cursor: pointer; padding: 0; line-height: 1; font-size: 13px; }
.formula-op .remove-token:hover { color: #e53935; }
.formula-op.dragging { opacity: 0.35; }
.formula-op.drop-before { box-shadow: -3px 0 0 #2d6a4f; }

.formula-number-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid #eee;
}
.formula-number-input {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
  min-width: 0;
}
.formula-number-input:focus { border-color: #2d6a4f; }
.formula-number-add-btn {
  padding: 5px 10px;
  background: #cfebdb;
  color: #2d4a3e;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.formula-number-add-btn:hover { background: #96cab2; }

.formula-number-token {
  background: #e8f0fb;
  color: #1a56a0;
  font-weight: 600;
}

.formula-keypad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid #eee;
}

.keypad-btn {
  padding: 10px;
  font-size: 22px;
  background: #fff;
  border: none;
  border-right: 1px solid #eee;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background 0.1s;
  color: #444;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.keypad-btn svg {
  width: 13x;
  height: 13px;
  display: block;
  flex-shrink: 0;
}
.keypad-btn:hover { background: #f0faf4; color: #2d6a4f; }
.keypad-btn:last-child { border-right: none; }

.formula-footer {
  padding: 10px 14px;
  border-top: 1px solid #eee;
}

/* ── Editor Arrow ── */
.editor-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #3eb36b;
}

/* ── Destination Field ── */
.editor-right {
  flex: 1;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  --dest-preview-head-height: 78px;
  --dest-preview-row-height: 30px;
}

.dest-header {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 13px;
  background: #fafafa;
  border-bottom: 1px solid #eee;
  color: #444;
}

.dest-spreadsheet-wrap {
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dest-spreadsheet {
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
  height: 100%;
  table-layout: fixed;
}
.dest-spreadsheet thead tr {
  height: var(--dest-preview-head-height);
}
.dest-spreadsheet tbody { height: 100%; }
.dest-spreadsheet tbody tr {
  height: var(--dest-preview-row-height);
}

.dest-spreadsheet th {
  padding: 8px 28px 8px 10px;
  border: 1px solid #d4edda;
  background: #e8f5ee;
  color: #2d6a4f;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  min-width: 130px;
  user-select: none;
  text-align: center;
  height: var(--dest-preview-head-height);
  vertical-align: middle;
  position: relative;
}
.dest-spreadsheet th:hover { background: #d0ead9; }
.dest-spreadsheet th.drag-over {
  background: #b7dfca !important;
  outline: 2px dashed #2d6a4f;
  outline-offset: -2px;
}

.dest-th-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}
.dest-th-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: center;
  min-height: 0;
}

.dest-col-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 3px;
  flex-shrink: 0;
  transition: color 0.1s, background 0.1s;
  position: absolute;
  top: 8px;
  right: 8px;
}
.dest-col-clear:hover { color: #e53935; background: rgba(229,57,53,0.1); }
th.selected-dest .dest-col-clear { color: #a8d5bc; }
th.selected-dest .dest-col-clear:hover { color: #fff; background: rgba(255,255,255,0.15); }

.dest-spreadsheet th.selected-dest {
  background: #2d6a4f;
  color: #fff;
  box-shadow: inset 0 -3px 0 #1a4231;
}

.dest-col-label {
  font-size: 11px;
  font-weight: 400;
  color: #6aab8a;
  display: block;
  margin-bottom: 4px;
  line-height: 1;
}
th.selected-dest .dest-col-label { color: #a8d5bc; }

.dest-col-title {
  display: block;
  line-height: 1.2;
}

.dest-spreadsheet td {
  border: 1px solid #eee;
  padding: 0 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  color: #555;
  font-size: 13px;
  text-align: center;
  height: var(--dest-preview-row-height);
  line-height: 1.2;
}

.dest-spreadsheet td.mapped { color: #2d6a4f; background: #f7fdf9; }
.dest-spreadsheet td.empty { color: #ddd; }

.dest-mapping-tag {
  font-size: 11px;
  background: #e8f5ee;
  color: #2d6a4f;
  border-radius: 10px;
  padding: 1px 7px;
  font-weight: 400;
  white-space: nowrap;
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

.editor-title-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

.editor-title-input {
  display: block;
  width: 100%;
  min-width: 680px;
  max-width: 1040px;
  padding: 6px 10px;
  margin-left: -10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #222;
  font-family: inherit;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  outline: none;
  box-shadow: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.editor-title-input::placeholder {
  color: #aab3ad;
}

.editor-title-input:hover {
  background: #fff;
  border-color: #d9e7df;
}

.editor-title-input:focus {
  background: #fff;
  border-color: #2d6a4f;
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.1);
}

/* ── Export History ── */
.history-table-wrap {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.history-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: #888;
  border-bottom: 1px solid #eee;
  background: #fafafa;
}
.history-table tbody tr { transition: background 0.1s; }
.history-table tbody tr:hover { background: #f9f9f9; }
.history-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f0f0f0;
  color: #444;
}
.history-table tr:last-child td { border-bottom: none; }

.history-table td.task-name {
  font-weight: 600;
  color: #222;
  cursor: pointer;
}
.history-table td.task-name:hover { color: #2d6a4f; text-decoration: underline; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}
.badge.completed { background: #e8f5ee; color: #2d6a4f; }
.badge.draft     { background: #f0f4ff; color: #4a6cf7; }
.badge.processing { background: #fff8e1; color: #f57c00; }
.badge.failed { background: #ffeeed; color: #e53935; }

.time-primary { font-weight: 600; color: #333; }
.time-secondary { font-size: 11px; color: #aaa; }

/* ── Misc ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #bbb;
  font-size: 14px;
}

.back-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  color: #2d6a4f; font-size: 13px; padding: 4px 0; margin-bottom: 14px;
  font-weight: 600;
}
.back-btn:hover { text-decoration: underline; }

/* ── Tooltip ── */
.tooltip-wrap { position: relative; display: inline-block; }
.tooltip-wrap .tooltip {
  display: none; position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: #333; color: #fff; font-size: 11px; padding: 4px 8px;
  border-radius: 4px; white-space: nowrap; pointer-events: none; z-index: 100;
}
.tooltip-wrap:hover .tooltip { display: block; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f5f5f5; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #2d6a4f; color: #fff;
  padding: 10px 18px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  opacity: 0; transform: translateY(10px);
  transition: all 0.25s; pointer-events: none; z-index: 9999;
}
#toast.show { opacity: 1; transform: translateY(0); }
