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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
    "Microsoft JhengHei", sans-serif;
  background: radial-gradient(circle at top left, #fdfbff, #f5f5ff);
  color: #1f2933;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body > .app {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.app {
  width: 100%;
  max-width: 1200px;
  padding: 24px 20px 32px;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.title-group h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.05em;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  color: #6b7280;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-upload {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(79, 70, 229, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.file-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-upload:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(79, 70, 229, 0.32);
  filter: brightness(1.03);
}

.file-upload:active {
  transform: translateY(0);
  box-shadow: 0 6px 12px rgba(79, 70, 229, 0.35);
}

.file-name {
  font-size: 13px;
  color: #4b5563;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.file-path-input {
  padding: 8px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  min-width: 250px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: white;
}

.file-path-input:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.load-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.load-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
  filter: brightness(1.03);
}

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

.app-main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr);
  gap: 16px;
}

.filters-card,
.table-card {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
  padding: 16px 18px 18px;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.filters-header,
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.filters-header h2,
.table-header h2 {
  margin: 0;
  font-size: 18px;
}

.ghost-btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(248, 250, 252, 0.85);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: #4b5563;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    transform 0.1s ease;
}

.ghost-btn:hover {
  background: #eef2ff;
  color: #4338ca;
  border-color: #818cf8;
  transform: translateY(-0.5px);
}

.filters-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.filter-field {
  flex: 1 1 45%;
  min-width: 0;
}

.filter-field label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: #6b7280;
  gap: 4px;
}

.filter-field input {
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  outline: none;
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
    background-color 0.15s ease;
  background: white;
}

.filter-field input:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.4);
  background-color: #f9fafb;
}

.keyword-row {
  margin-top: 4px;
}

.keyword-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #6b7280;
}

.keyword-row input {
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  outline: none;
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
    background-color 0.15s ease;
  background: white;
}

.keyword-row input:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.4);
  background-color: #f9fafb;
}

.table-info {
  font-size: 13px;
  color: #6b7280;
}

.table-wrapper {
  position: relative;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: white;
}

thead {
  background: linear-gradient(to right, #eef2ff, #e0f2fe);
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  white-space: nowrap;
}

th {
  font-weight: 600;
  font-size: 12px;
  color: #4b5563;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.65);
}

tbody tr:hover {
  background: #eef2ff;
}

.table-wrapper {
  max-height: 480px;
  overflow: auto;
  scrollbar-width: thin;
}

/* 表單一致性 */
.form-row select {
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  background: white;
  transition: border-color 0.2s ease;
}

.form-row select:focus {
  outline: none;
  border-color: #4f46e5;
}

/* 讓 swap 科目輸入看起來像 select */
.swap-subject {
  appearance: none;
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  background-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  padding-right: 38px;
  transition: border-color 0.2s ease;
}

.swap-subject:focus {
  outline: none;
  border-color: #4f46e5;
}

.primary-btn,
.danger-btn,
.load-btn,
.ghost-btn {
  letter-spacing: 0.02em;
}

.primary-btn:focus-visible,
.danger-btn:focus-visible,
.load-btn:focus-visible,
.ghost-btn:focus-visible,
.file-path-input:focus-visible,
.keyword-row input:focus-visible,
.filter-field input:focus-visible {
  outline: 3px solid rgba(99, 102, 241, 0.35);
  outline-offset: 2px;
}

.table-wrapper {
  max-height: 460px;
  overflow: auto;
}

.no-data {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #9ca3af;
  background: linear-gradient(
      to bottom,
      rgba(249, 250, 251, 0.8),
      rgba(249, 250, 251, 0.95)
    );
  text-align: center;
  padding: 0 16px;
}

pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.6;
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

@media (max-width: 960px) {
  .app-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .filters-card,
  .table-card {
    padding: 14px 14px 16px;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 16px 10px 24px;
  }

  .app-header {
    align-items: flex-start;
  }

  .header-actions {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }

  .file-input-group {
    width: 100%;
  }

  .file-path-input {
    width: 100%;
    min-width: 0;
  }

  .file-name {
    max-width: 180px;
  }

  .filters-container {
    flex-direction: column;
  }

  .filter-field {
    flex: 1 1 100%;
  }
}

