* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: #f5f5f5; display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.card { position: relative; background: #fff; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,.08); padding: 2.5rem; width: 420px; max-width: 90vw; }
h1 { font-size: 1.4rem; margin-bottom: 1.5rem; color: #111; }
.header-row h1 { margin-bottom: 1.5rem; }
.settings-link {
  position: absolute; top: 1.1rem; right: 1.1rem; width: auto; flex-shrink: 0;
  text-decoration: none; font-size: 1.4rem; line-height: 1; color: #888; padding: .3rem; transition: .15s;
}
.settings-link:hover { color: #111; }
.settings-hint { font-size: .8rem; color: #888; margin: -.8rem 0 1.5rem; line-height: 1.4; }
.msg.success { color: #34a853; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .4rem; color: #333; }
select, .text-input {
  width: 100%; padding: .55rem .7rem; border: 1px solid #ccc; border-radius: 6px; font-size: .9rem; margin-bottom: 1.2rem;
}
.dropzone {
  border: 2px dashed #bbb; border-radius: 8px; padding: 2.5rem 1rem;
  text-align: center; color: #888; cursor: pointer; transition: .15s;
  margin-bottom: 1.2rem; position: relative;
}
.dropzone.hover { border-color: #4f8cff; background: #eef4ff; color: #4f8cff; }
.dropzone.has-file { border-color: #34a853; color: #34a853; border-style: solid; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
button {
  width: 100%; padding: .65rem; border: none; border-radius: 6px;
  background: #111; color: #fff; font-size: .95rem; font-weight: 600;
  cursor: pointer; transition: .15s;
}
button:hover { background: #333; }
button:disabled { background: #aaa; cursor: not-allowed; }
.msg { margin-top: 1rem; font-size: .85rem; text-align: center; }
.msg.error { color: #d93025; }
.spinner { display: none; margin: 1rem auto 0; width: 24px; height: 24px; border: 3px solid #ddd; border-top-color: #111; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.checkbox-row { display: flex; align-items: center; gap: .5rem; margin-bottom: 1.2rem; }
.checkbox-row input[type="checkbox"] { width: 1rem; height: 1rem; cursor: pointer; accent-color: #111; }
.checkbox-row label { margin: 0; font-size: .85rem; font-weight: 600; color: #333; cursor: pointer; }
.mapeo-link { width: auto; display: inline-block; margin: -.8rem 0 1.2rem; padding: 0; border: none; background: none; font-size: .8rem; font-weight: 600; color: #4f8cff; cursor: pointer; }
.mapeo-link:hover { background: none; text-decoration: underline; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 10; padding: 1rem; }
.overlay.open { display: flex; }
.mappings-card { width: fit-content; min-width: 420px; max-width: 90vw; padding: 1.75rem 2rem; }
.mappings-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: .25rem; }
.mappings-header h2 { font-size: 1rem; font-weight: 700; color: #111; }
.modal-close { width: auto; border: none; background: none; padding: 0 0 0 1rem; font-size: 1.3rem; line-height: 1; color: #999; cursor: pointer; }
.modal-close:hover { background: none; color: #111; }
.mappings-hint { font-size: .78rem; color: #999; margin-bottom: 1rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; background: #f0f0f2; border-radius: 8px; padding: 3px; margin-bottom: 1rem; }
.tab { flex: 1 1 auto; width: auto; white-space: nowrap; border: none; background: transparent; padding: .4rem .5rem; border-radius: 6px; font-size: .82rem; font-weight: 600; color: #777; cursor: pointer; transition: .15s; }
.tab:hover { background: transparent; color: #111; }
.tab.active { background: #fff; color: #111; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.mappings-content { max-height: 60vh; overflow-y: auto; padding-right: .9rem; scrollbar-gutter: stable; }
.mapping-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid #f2f2f2; }
.mapping-row:last-child { border-bottom: none; }
.mapping-names { font-size: .8rem; color: #333; min-width: 0; }
.mapping-names div + div { color: #a0a0a0; margin-top: .1rem; }
.mapping-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; font-weight: 600; color: #111; white-space: nowrap; }
.mapping-code::before { content: "\2192\00a0\00a0"; color: #ccc; font-weight: 400; }
#honorariosSection { margin-bottom: 1.2rem; }
#honorariosSection > .section-label { font-size: .85rem; font-weight: 600; color: #333; margin-bottom: .6rem; }
.grano-honorario { display: flex; align-items: center; gap: .7rem; margin-bottom: .6rem; }
.grano-honorario label { width: 130px; flex-shrink: 0; font-size: .85rem; font-weight: 600; color: #333; margin-bottom: 0; }
.grano-honorario .text-input { margin-bottom: 0; flex: 1; }
.observaciones {
  background: #fff8d6; border: 1px solid #f2e08a; border-left: 4px solid #f0c000;
  border-radius: 8px; padding: .8rem 1rem; margin-bottom: 1.5rem;
  font-size: .85rem; line-height: 1.4; color: #5c4a00;
}
.observaciones-title { font-weight: 700; margin-bottom: .3rem; color: #7a5c00; }

.observacion-grano { margin-top: .55rem; }
.observacion-grano-title { font-weight: 600; color: #7a5c00; margin-bottom: .15rem; }

.ctg-inline-row { position: relative; transition: outline .15s; border-radius: 6px; outline: 2px dashed transparent; outline-offset: 5px; }
.ctg-inline-row.dragover { outline-color: #4f8cff; }
.ctg-inline-actions { display: flex; align-items: center; gap: .4rem; margin-left: auto; }
.ctg-inline-status { font-size: .74rem; color: #777; white-space: nowrap; }
.ctg-icon-btn {
  width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%; border: 1px solid #ccc;
  background: #fff; display: flex; align-items: center; justify-content: center;
  font-size: .85rem; line-height: 1; color: #666; cursor: pointer; padding: 0; transition: .15s;
}
.ctg-icon-btn:hover { background: #f5f5f5; color: #111; }
.ctg-icon-btn.loading { opacity: .5; pointer-events: none; }
.ctg-icon-btn-clear { color: #d93025; border-color: #f3c6c1; }
.ctg-icon-btn-clear:hover { background: #fdf1f0; color: #d93025; }
.ctg-list-error { margin: -.8rem 0 1.2rem; font-size: .8rem; color: #d93025; }

.ctg-status-line { display: flex; align-items: center; gap: .4rem; margin: -.8rem 0 1.2rem; font-size: .8rem; color: #555; }
.ctg-count-link {
  width: auto; border: none; background: none; padding: 0; font-size: .8rem;
  font-weight: 600; color: #4f8cff; cursor: pointer;
}
.ctg-count-link:hover { background: none; text-decoration: underline; }
.ctg-clear-link {
  width: auto; flex-shrink: 0; margin-left: auto; border: none; background: none; padding: 0;
  font-size: .78rem; font-weight: 600; color: #d93025; cursor: pointer;
}
.ctg-clear-link:hover { background: none; text-decoration: underline; }

.ctg-list-modal { width: 320px; }
.ctg-list-modal-content {
  max-height: 55vh; overflow-y: auto; column-width: 105px; column-gap: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem;
  color: #333; line-height: 1.7;
}
