* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(145deg, #1a1d29 0%, #252a3a 100%);
  color: #e4e6eb;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.app {
  width: 100%;
  max-width: 720px;
}

.app.has-panels {
  max-width: 1120px;
}

h1 {
  text-align: center;
  font-weight: 600;
  font-size: 1.75rem;
  margin-bottom: 2rem;
  letter-spacing: -0.02em;
}

.drop-row {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.drop-box {
  flex: 1;
  min-width: 220px;
  max-width: 320px;
  aspect-ratio: 4/3;
  border: 2px dashed #4a5164;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.drop-box:hover,
.drop-box:focus-within {
  border-color: #6b7fd7;
  background: rgba(107, 127, 215, 0.08);
}

.drop-box.drag-over {
  border-color: #8b9ef5;
  background: rgba(139, 158, 245, 0.12);
  transform: scale(1.02);
}

.drop-box.has-file {
  border-style: solid;
  border-color: #5a9f6e;
  background: rgba(90, 159, 110, 0.1);
}

.drop-label {
  font-weight: 600;
  font-size: 1rem;
  color: #a0a8b8;
}

.drop-hint {
  font-size: 0.875rem;
  color: #6b7280;
}

.drop-box.has-file .drop-hint {
  display: none;
}

.file-name {
  font-size: 0.8125rem;
  color: #8b9ef5;
  max-width: 100%;
  padding: 0 0.75rem;
  text-align: center;
  word-break: break-all;
  min-height: 1.25rem;
}

.drop-box input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-box {
  position: relative;
}

.run-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: center;
}

.run-buttons-row .run-btn {
  margin: 0;
}

.run-btn {
  display: block;
  margin: 0 auto;
  padding: 0.75rem 2.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #5a6fd6 0%, #7b5dd6 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 4px 14px rgba(90, 111, 214, 0.4);
}

.run-btn:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.run-btn:active {
  transform: translateY(0);
}

.match-btn {
  margin-top: 1.5rem;
  display: none;
}

.match-btn.visible {
  display: block;
}

.save-result-btn {
  margin: 0;
}

.save-result-row {
  display: none;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  margin-top: 1.5rem;
}

.save-result-row.visible {
  display: flex;
}

.save-result-row .save-result-btn {
  margin: 0;
}

.save-folder-note {
  font-size: 0.8125rem;
  color: #6b7280;
}

.parse-section {
  margin-top: 2rem;
  width: 100%;
}

.parse-section:has(#panels[hidden]) {
  display: none;
}

.parse-section .section-title,
.match-result-section .section-title {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 1rem 0;
  padding: 0;
  width: 100%;
  text-align: left;
  font-size: 1.125rem;
  font-weight: 600;
  color: #a0a8b8;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.section-toggle-icon {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.toggle-section.collapsed .section-content {
  display: none;
}

.toggle-section.collapsed .section-toggle-icon {
  transform: rotate(-90deg);
}

.match-result-section {
  margin-top: 2rem;
  width: 100%;
}

.match-result-section .section-content {
  position: relative;
}

.match-result-section .panels.match-panels {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  margin-top: 0;
  min-height: 280px;
}

.match-result-section .panels.match-panels .panel-aliases {
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  height: fit-content;
  max-height: 70vh;
}

.match-result-section .match-panels-row {
  display: flex;
  align-items: flex-start;
  gap: 15rem;
  flex: 1 1 auto;
  min-height: 0;
}

.match-result-section .match-panels-row .panel-left,
.match-result-section .match-panels-row .panel-right {
  flex: 0 0 auto;
  min-width: 0;
  max-width: none;
  width: auto;
  height: fit-content;
  overflow: visible;
}

.match-result-section .match-panels-row .panel-content {
  overflow: visible;
}

.alias-toolbar {
  margin-bottom: 0.5rem;
}

.alias-add-btn {
  font-size: 0.8125rem;
  padding: 0.35rem 0.6rem;
  color: #9ca3af;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid #4a5164;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}

.alias-add-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #e5e7eb;
}

.alias-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.alias-table th,
.alias-table td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #3a3f4e;
}

.alias-table th {
  color: #a0a8b8;
  font-weight: 600;
}

.alias-table .alias-actions-cell {
  width: 1%;
  padding: 0.3rem;
}

.alias-table td input {
  width: 100%;
  min-width: 20ch;
  box-sizing: border-box;
  padding: 0.25rem 0.4rem;
  font-size: inherit;
  font-family: inherit;
  color: #e5e7eb;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid #4a5164;
  border-radius: 4px;
}

.alias-table td input:focus {
  outline: none;
  border-color: #6366f1;
}

.alias-delete-btn {
  font-size: 0.75rem;
  padding: 0.2rem 0.4rem;
  color: #9ca3af;
  background: transparent;
  border: 1px solid #4a5164;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}

.alias-delete-btn:hover {
  color: #e53e3e;
  border-color: #e53e3e;
}

#matchSection .entries-table tbody tr.matched-algo td {
  color: #48bb78;
}

#matchSection .entries-table tbody tr.matched-user td {
  color: #3182ce;
}

#matchSection .match-lines-svg {
  z-index: 1;
}

#matchSection .match-arrow-group:hover line:not([stroke="transparent"]) {
  stroke-width: 2;
}

#matchSection .match-arrow-delete:hover circle {
  fill: #dd6b20;
  opacity: 0.9;
}

#matchSection .row-dot-cell {
  width: 0.1%;
  min-width: 20px;
  padding: 0 6px;
  vertical-align: middle;
  text-align: center;
}

#matchSection .panel-left .row-dot-cell {
  text-align: right;
}

#matchSection .panel-right .row-dot-cell {
  text-align: left;
  min-width: 32px;
  padding-left: 12px;
  cursor: move;
}

#matchSection .row-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4a5164;
  flex-shrink: 0;
}

.panels {
  display: none;
  gap: 1rem;
  margin-top: 2rem;
  width: 100%;
  min-height: 280px;
}

.panels.visible {
  display: flex;
}

.panel {
  flex: 1;
  min-width: 0;
  border: 1px solid #4a5164;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-left {
  flex: 1.2 1 0;
  min-width: 720px;
}

.panel-left .entries-table td {
  white-space: nowrap;
}

.qb-editable-toolbar {
  margin-bottom: 0.75rem;
}

.qb-add-row-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  margin: 0;
}

.qb-editable-table .qb-actions-cell {
  width: 1%;
  white-space: nowrap;
  padding: 0.35rem 0.5rem;
  vertical-align: middle;
}

.qb-editable-table .qb-row-del-btn,
.qb-editable-table .qb-row-swap-btn,
.qb-editable-table .qb-row-edit-btn {
  font-size: 0.6875rem;
  padding: 0.2rem 0.4rem;
  margin-right: 0.25rem;
  color: #9ca3af;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid #4a5164;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}

.qb-editable-table .qb-row-edit-btn {
  margin-right: 0.35rem;
}

.qb-editable-table .qb-row-edit-btn:hover,
.qb-editable-table .qb-row-edit-btn:focus {
  color: #6366f1;
  border-color: #6366f1;
}

.qb-editable-table .qb-row-del-btn:hover {
  color: #e53e3e;
  border-color: #e53e3e;
}

.qb-editable-table .qb-row-swap-btn:hover {
  color: #8b9ef5;
  border-color: #8b9ef5;
}

.qb-editable-table input.qb-edit {
  width: 100%;
  min-width: 4ch;
  box-sizing: border-box;
  padding: 0.25rem 0.4rem;
  font-size: inherit;
  font-family: inherit;
  color: #e4e6eb;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid #4a5164;
  border-radius: 4px;
}

.qb-editable-table input.qb-edit:focus {
  outline: none;
  border-color: #6366f1;
}

.qb-editable-table td.num input.qb-edit {
  text-align: right;
}

.panel-right {
  flex: 1.8 1 0;
  min-width: 880px;
  max-width: 65%;
}

.panel-title-context-menu {
  position: fixed;
  z-index: 10000;
  background: #252a3a;
  border: 1px solid #4a5164;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  padding: 0.25rem 0;
  min-width: 160px;
}

.panel-title-context-menu button.panel-export-raw-option {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  text-align: left;
  font-size: 0.875rem;
  color: #e4e6eb;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.panel-title-context-menu button.panel-export-raw-option:hover {
  background: rgba(107, 127, 215, 0.2);
  color: #8b9ef5;
}

.statement-table td:nth-child(2),
.statement-table td:nth-child(3) {
  word-break: break-word;
  white-space: pre-line;
  vertical-align: top;
}

.statement-table td:nth-child(4) {
  white-space: nowrap;
  vertical-align: top;
}

.panel-title {
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #a0a8b8;
  border-bottom: 1px solid #4a5164;
}

#matchSection .panel-title {
  cursor: move;
  user-select: none;
}

.panel-content {
  flex: 1;
  padding: 1rem;
  overflow: auto;
  color: #9ca3af;
  font-size: 0.875rem;
}

.entries-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.entries-table th,
.entries-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #3a3f4e;
}

.entries-table .copy-cell {
  width: 1%;
  white-space: nowrap;
  padding: 0.35rem 0.5rem;
  vertical-align: middle;
}

.panel-left .entries-table .copy-cell {
  text-align: left;
}

.panel-right .entries-table .copy-cell {
  text-align: right;
}

.row-copy-btn {
  font-size: 0.6875rem;
  padding: 0.2rem 0.4rem;
  color: #9ca3af;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid #4a5164;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}

.row-copy-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #e5e7eb;
}

.row-copy-btn:disabled {
  opacity: 0.8;
  cursor: default;
}

.entries-table th {
  color: #a0a8b8;
  font-weight: 600;
  white-space: nowrap;
}

.entries-table td {
  color: #e4e6eb;
}

.entries-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.entries-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
