:root {
  --gif-mouse-bar-duration: 54s;
  --gif-mouse-bar-bg: #d66371;
  /* Ảnh nền ô dán: app.js đặt --paste-area-photo + --paste-shade */
  --pink-deep: #e91e8c;
  --pink-mid: #ff6bae;
  --pink-light: #ffc2d8;
  --pink-bg: #fff0f5;
  /* Nền kem nhạt — đỡ chói hơn #fff */
  --page-bg: #f2ede3;
  --white: #faf8f3;
  --text: #4a1530;
  --text-soft: #7a4a62;
  --border: #f5a0c8;
  --shadow: rgba(233, 30, 140, 0.12);
  --font: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  /* Dropdown / select — kiểu viền kem + xám + hồng, highlight xanh */
  --select-surface: #faf9f6;
  --select-inner-border: #6d5c62;
  --select-outer-ring: #fce4ec;
  --select-accent: #1976d2;
  /* Khung bảng ghi chú file — đỏ ngoài, hồng trong */
  --journal-frame-red: #c62828;
  --journal-frame-pink: #f48fb1;
  --login-page-photo: url("image/photo_2026-04-10_14-41-31.jpg");
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--page-bg);
}

body {
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(165deg, rgba(255, 240, 248, 0.92) 0%, rgba(255, 220, 235, 0.88) 40%, rgba(230, 245, 255, 0.75) 100%),
    radial-gradient(ellipse 120% 80% at 20% 20%, rgba(255, 200, 230, 0.5), transparent 55%),
    radial-gradient(ellipse 100% 60% at 80% 70%, rgba(200, 230, 255, 0.35), transparent 50%),
    var(--page-bg);
  pointer-events: none;
}

/* Thanh trên: GIF chuột nhảy chạy ngang (SWR Kindernetz) */
.gif-mouse-bar {
  position: relative;
  z-index: 2;
  width: 100vw;
  max-width: 100%;
  margin-left: calc(50% - 50vw);
  box-sizing: border-box;
  background: linear-gradient(
    180deg,
    #e07080 0%,
    var(--gif-mouse-bar-bg) 35%,
    #c55563 100%
  );
  box-shadow: 0 2px 12px var(--shadow);
}

.gif-mouse-bar__viewport {
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

.gif-mouse-bar__track {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  width: max-content;
  will-change: transform;
  animation: gif-mouse-bar-scroll var(--gif-mouse-bar-duration) linear infinite;
}

@keyframes gif-mouse-bar-scroll {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-50%, 0, 0);
  }
}

.gif-mouse-bar__strip {
  display: flex;
  flex-direction: row;
  flex-shrink: 0;
  align-items: center;
  gap: 2rem;
  padding: 0.4rem 1rem 0.45rem;
}

.gif-mouse-bar__img {
  display: block;
  height: 52px;
  width: auto;
  max-height: 58px;
  object-fit: contain;
  flex-shrink: 0;
  user-select: none;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .gif-mouse-bar__track {
    animation: none;
    justify-content: center;
    margin: 0 auto;
  }

  .paste-area--photo-bg {
    --paste-shade: 0.55;
  }
}

.workspace {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 0;
  min-height: calc(100vh - 5.5rem);
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1rem 1.25rem;
  align-items: stretch;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--white);
  border: 2px solid var(--border);
  box-shadow: 0 8px 28px var(--shadow);
}

.panel--input {
  border-radius: 14px 0 0 14px;
  padding: 1rem 1.1rem 0.85rem;
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

.panel--table {
  border-radius: 0 14px 14px 0;
  border-left: none;
  padding: 0.75rem 0.85rem 0.85rem;
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

@media (max-width: 900px) {
  .panel--input {
    border-radius: 14px 14px 0 0;
  }
  .panel--table {
    border-radius: 0 0 14px 14px;
    border-left: 2px solid var(--border);
    border-top: none;
  }
}

.panel-title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--pink-deep);
}

.panel-title kbd {
  font-size: 0.8em;
  padding: 0.1em 0.35em;
  background: var(--pink-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.panel-hint {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  color: var(--text-soft);
  line-height: 1.4;
}

.paste-area {
  flex: 1;
  min-height: 160px;
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--text);
  background: var(--pink-bg);
  border: 2px solid var(--pink-light);
  border-radius: 10px;
  resize: vertical;
}

.paste-area--photo-bg {
  /* Viền 2 màu dày: trong đậm, ngoài nhạt */
  border: 4px solid var(--pink-deep);
  box-shadow: 0 0 0 4px var(--pink-light);
  border-radius: 12px;
  /* 1 = lớp phủ đậm (mờ); 0 = ảnh rõ — app.js: mờ→rõ 1s, giữ rõ đến khi đổi ảnh (10s/chu kỳ) */
  --paste-shade: 1;
  --paste-area-photo: none;
  background-image: linear-gradient(
      180deg,
      rgba(255, 252, 253, calc(0.22 + 0.32 * var(--paste-shade))) 0%,
      rgba(255, 236, 244, calc(0.30 + 0.30 * var(--paste-shade))) 50%,
      rgba(255, 240, 248, calc(0.34 + 0.30 * var(--paste-shade))) 100%
    ),
    var(--paste-area-photo);
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat;
  caret-color: var(--pink-deep);
}

.paste-area:focus {
  outline: none;
  border-color: var(--pink-mid);
  box-shadow: 0 0 0 3px rgba(255, 107, 174, 0.25);
}

.paste-area--photo-bg:focus {
  border-color: var(--pink-mid);
  box-shadow:
    0 0 0 4px var(--pink-light),
    0 0 0 8px rgba(255, 107, 174, 0.28);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.btn {
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  font-size: 0.88rem;
  transition: background 0.15s, transform 0.08s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-pink {
  padding: 0.4rem 1.15rem;
  border: none;
  background: linear-gradient(180deg, var(--pink-mid), var(--pink-deep));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px var(--shadow);
}

.btn-pink:hover {
  filter: brightness(1.06);
}

.btn-outline {
  padding: 0.38rem 0.85rem;
  border: 2px solid var(--pink-mid);
  background: var(--white);
  color: var(--pink-deep);
  font-weight: 600;
}

.btn-outline:hover {
  background: var(--pink-bg);
}

.btn-icon {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 2px solid var(--border);
  background: var(--white);
  font-size: 1rem;
  line-height: 1;
}

.btn-icon:hover {
  background: var(--pink-bg);
}

.file-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.check-inline {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}

.file-line {
  margin-top: 0.35rem;
}

.file-name {
  font-size: 0.75rem;
  color: var(--text-soft);
}

.filters-block {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.82rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.filter-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-soft);
  margin-bottom: 0.25rem;
}

.filter-hint {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  color: var(--text-soft);
  line-height: 1.35;
}

.filter-hint kbd {
  font-size: 0.85em;
  padding: 0.05em 0.3em;
  background: var(--pink-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
}

.col-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  margin-bottom: 0.5rem;
}

.col-picker .filter-label {
  margin-bottom: 0;
  width: 100%;
}

.select-pink--narrow {
  width: auto;
  min-width: 7rem;
  max-width: 100%;
}

.col-picker-hint {
  font-size: 0.72rem;
  color: var(--text-soft);
  flex: 1;
  min-width: 140px;
}

.inp-search {
  margin-bottom: 0.35rem;
}

.paste-area--province {
  min-height: 72px;
  margin-top: 0.35rem;
  font-size: 0.82rem;
}

.select-pink {
  width: 100%;
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text);
  background-color: var(--select-surface);
  border: 1px solid var(--select-inner-border);
  border-radius: 10px;
  box-shadow: 0 0 0 3px var(--select-outer-ring);
  cursor: pointer;
  accent-color: var(--select-accent);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

/* Một dòng: mũi tên tùy chỉnh (dropdown đóng) */
.select-pink:not([multiple]) {
  padding-right: 2.15rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234a1530' d='M6 8.2 1.4 3.6l.8-.8L6 6.6l3.8-3.8.8.8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 0.7rem;
}

.select-pink:not([multiple])::-ms-expand {
  display: none;
}

.select-pink[multiple] {
  padding: 0.35rem;
  cursor: default;
  min-height: 7.5rem;
  background-image: none;
}

.select-pink:hover {
  border-color: #5a4a52;
  box-shadow: 0 0 0 3px rgba(252, 228, 236, 0.9);
}

.select-pink:focus {
  outline: none;
  border-color: var(--select-accent);
  box-shadow:
    0 0 0 3px var(--select-outer-ring),
    0 0 0 6px rgba(25, 118, 210, 0.22);
}

/* Danh sách multi: dòng chọn xanh — trình duyệt hỗ trợ khác nhau */
.select-pink[multiple] option {
  padding: 0.35rem 0.45rem;
  margin: 0.1rem 0;
  border-radius: 4px;
}

.select-pink[multiple] option:checked {
  background: linear-gradient(var(--select-accent), var(--select-accent));
  color: #fff;
}

.select-pink[multiple] option:hover {
  background: #e3f2fd;
}

.select-pink[multiple]::-webkit-scrollbar {
  width: 10px;
}

.select-pink[multiple]::-webkit-scrollbar-track {
  background: #ece8e4;
  border-radius: 6px;
}

.select-pink[multiple]::-webkit-scrollbar-thumb {
  background: #7a7a7a;
  border-radius: 6px;
  border: 2px solid #ece8e4;
}

.select-pink[multiple]::-webkit-scrollbar-thumb:hover {
  background: #5c5c5c;
}

.years {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.years label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-soft);
  margin-bottom: 0.15rem;
}

.inp-pink {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 2px solid var(--pink-light);
  border-radius: 6px;
  font-size: 0.85rem;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.stats {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: #c2185b;
  line-height: 1.35;
}

.version {
  margin: 0.6rem 0 0;
  font-size: 0.68rem;
  color: var(--text-soft);
  opacity: 0.9;
}

.data-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.stat-pill {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem 0.4rem;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  border: 2px solid var(--pink-light);
  background: linear-gradient(180deg, var(--white) 0%, var(--pink-bg) 100%);
  font-size: 0.78rem;
  line-height: 1.2;
}

.stat-pill strong {
  font-size: 1.05rem;
  color: var(--pink-deep);
}

.stat-label {
  width: 100%;
  font-size: 0.68rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-unit {
  font-size: 0.72rem;
  color: var(--text-soft);
}

.stat-pill--source {
  border-color: #e1bee7;
  background: linear-gradient(180deg, #faf5fc 0%, var(--white) 100%);
}

.stat-pill--filter {
  border-color: #f8bbd0;
}

.stat-pill--export {
  border-color: #c5e1a5;
  background: linear-gradient(180deg, #f9fff5 0%, var(--white) 100%);
}

.stat-pill--session {
  border-color: #b3e5fc;
  background: linear-gradient(180deg, #f5fcff 0%, var(--white) 100%);
}

.export-meta {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  color: var(--text-soft);
  min-height: 1.1em;
}

.table-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.table-top__lead {
  display: flex;
  align-items: center;
  min-width: 0;
}

.table-top__trail {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  text-align: right;
  min-width: min(100%, 12rem);
}

.neon-brand {
  margin: 0;
  font-weight: 700;
  font-size: clamp(0.95rem, 2.5vw, 1.15rem);
  letter-spacing: 0.08em;
  color: #c51162;
  white-space: nowrap;
  text-shadow:
    0 0 1px #fff,
    0 0 6px #ff9ecf,
    0 0 12px var(--pink-mid),
    0 0 22px rgba(255, 105, 180, 0.75),
    0 0 36px rgba(233, 30, 140, 0.45);
  animation: neon-brand-pulse 2.8s ease-in-out infinite;
}

@keyframes neon-brand-pulse {
  0%,
  100% {
    filter: brightness(1);
    text-shadow:
      0 0 1px #fff,
      0 0 6px #ff9ecf,
      0 0 12px var(--pink-mid),
      0 0 22px rgba(255, 105, 180, 0.75),
      0 0 36px rgba(233, 30, 140, 0.45);
  }
  50% {
    filter: brightness(1.06);
    text-shadow:
      0 0 2px #fff,
      0 0 10px #ffb7d5,
      0 0 18px var(--pink-mid),
      0 0 30px rgba(255, 20, 147, 0.65),
      0 0 48px rgba(233, 30, 140, 0.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .neon-brand {
    animation: none;
  }
}

.total-badge {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--pink-deep);
}

.preview-note {
  font-size: 0.75rem;
  color: var(--text-soft);
}

.panel--table .table-wrap {
  flex: 1;
  overflow: auto;
  max-height: min(calc(100vh - 200px), 640px);
  border: 2px solid var(--pink-light);
  border-radius: 10px;
  background: var(--white);
}

/* Bảng ghi chú file — viền đôi giống ô dán, nền kem */
.file-journal {
  margin-top: 0.85rem;
  flex-shrink: 0;
}

.file-journal__title {
  margin: 0 0 0.25rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--pink-deep);
}

.file-journal__remind {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  color: var(--text-soft);
  line-height: 1.4;
}

.file-journal__wrap {
  border: 3px solid var(--journal-frame-pink);
  border-radius: 2px;
  box-shadow: 0 0 0 5px var(--journal-frame-red);
  overflow: auto;
  min-height: 280px;
  max-height: min(58vh, 560px);
  background: var(--select-surface);
}

.file-journal__table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.76rem;
}

.file-journal__table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.5rem 0.55rem;
  background: linear-gradient(180deg, #c2185b 0%, #e91e63 35%, #ec407a 70%, #f48fb1 100%);
  color: #fff;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
  border-bottom: 1px solid rgba(236, 64, 122, 0.5);
  white-space: nowrap;
}

.file-journal__table thead tr:first-child th:first-child {
  border-top-left-radius: 10px;
}

.file-journal__table thead tr:first-child th:last-child {
  border-top-right-radius: 10px;
}

.file-journal__table th:nth-child(1) {
  text-align: left;
  width: 42%;
}

.file-journal__table th:nth-child(2) {
  text-align: center;
}

.file-journal__table th:nth-child(3) {
  text-align: right;
}

.file-journal__table td {
  padding: 0.4rem 0.55rem;
  border-bottom: 1px dashed rgba(233, 30, 140, 0.25);
  color: var(--text);
  vertical-align: top;
  word-break: break-word;
}

.file-journal__table td:nth-child(2) {
  text-align: center;
}

.file-journal__table td:nth-child(3) {
  text-align: right;
}

.file-journal__table tbody tr:nth-child(even) {
  background: rgba(250, 248, 243, 0.65);
}

.file-journal__table tbody tr:hover {
  background: #ffe8f2;
}

.file-journal__table .file-journal__empty {
  text-align: center;
  color: var(--text-soft);
  font-style: italic;
  padding: 0.65rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

#previewTable {
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
}

#previewTable.is-resizing {
  cursor: col-resize;
}

#previewTable .row-col-labels th {
  position: relative;
  padding-right: 0.6rem;
}

#previewTable .th-text {
  display: block;
  padding-right: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

#previewTable .col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  z-index: 6;
  box-sizing: border-box;
  border-right: 2px dashed transparent;
  margin-right: -3px;
  touch-action: none;
}

#previewTable .col-resize-handle:hover {
  border-right-color: rgba(233, 30, 140, 0.85);
  background: rgba(233, 30, 140, 0.08);
}

#previewTable td,
#previewTable th {
  max-width: none;
}

/* Vạch phân cột nét đứt (toàn bộ header + phần dữ liệu) */
#previewTable thead th:not(:last-child),
#previewTable tbody td:not(:last-child) {
  border-right: 1px dashed rgba(233, 30, 140, 0.42);
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #ffb3d4, var(--pink-mid));
  color: #fff;
}

thead tr.row-col-letters th.th-col-letter {
  background: linear-gradient(180deg, #fff8fc 0%, #ffe0ef 100%);
  color: #ad1457;
  text-align: center;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.4rem;
  text-shadow: none;
  border-bottom: 1px solid #f48fb1;
  vertical-align: middle;
}

thead tr.row-col-labels th {
  background: linear-gradient(180deg, #ffb3d4, var(--pink-mid));
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

thead th {
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

th,
td {
  padding: 0.4rem 0.45rem;
  text-align: left;
  border-bottom: 1px solid #ffd6e8;
  vertical-align: top;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: rgba(250, 248, 243, 0.85);
}

tbody tr:hover {
  background: #ffe8f2;
}

/* Trang đăng nhập — nền ảnh rõ, không phủ mờ */
.login-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--page-bg);
  background-image: var(--login-page-photo);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.login-body > .bg {
  display: none;
}

.login-main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
  margin-top: clamp(3.5rem, 14vh, 9rem);
  padding: 1.5rem 1.35rem 1.4rem;
  background: var(--white);
  border: 4px solid var(--pink-deep);
  border-radius: 14px;
  box-shadow:
    0 0 0 4px var(--pink-light),
    0 12px 36px var(--shadow);
}

.login-brand {
  margin: 0 0 0.35rem;
  font-size: clamp(1.05rem, 3vw, 1.25rem);
  text-align: center;
}

.login-sub {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: var(--text-soft);
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.login-label {
  font-size: 0.76rem;
  color: var(--text-soft);
  margin-top: 0.35rem;
}

.login-label:first-of-type {
  margin-top: 0;
}

.login-input {
  width: 100%;
}

.login-error {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: #c62828;
  min-height: 1.2em;
}

.login-submit {
  margin-top: 0.65rem;
  width: 100%;
  padding: 0.5rem 1rem;
}

.version-logout {
  margin-left: 0.5rem;
  padding: 0.15rem 0.45rem;
  font-size: 0.65rem;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--pink-bg);
  color: var(--pink-deep);
  vertical-align: middle;
}

.version-logout:hover {
  background: #ffe0ef;
}

/* Lớp tuyết (snow.js) — không chặn click */
#snow-overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;
}
