#box_main {
  flex: 1;
  min-width: 0;
  min-height: 800px;
  padding-top: 14px;
  padding-left: 20px;
}

#box_title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

#box_filter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

#input_date {
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--color-greyLight);
  border-radius: 10px;
  background: #ffffff;
  font-family: "Poppins", "Noto Sans TC", sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: var(--color-black);
  outline: none;
  flex: 1;
  min-width: 120px;
  transition: border-color 0.15s ease;
}
#input_date:focus {
  border-color: var(--color-primary);
}

#btn_query {
  height: 44px;
  padding: 0 24px;
  outline: none;
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}
#btn_query:hover {
  background: var(--color-primaryDark);
}
#btn_query:disabled {
  background: var(--color-greyMedium);
  cursor: default;
}

/* ── Range buttons ── */
#box_range {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#box_range::-webkit-scrollbar {
  display: none;
}

.btn_range {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--color-greyLight);
  border-radius: 8px;
  background: transparent;
  font-size: 12px;
  color: var(--color-greyDark);
  cursor: pointer;
  outline: none;
  flex-shrink: 0;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.btn_range:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.btn_range.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
}

/* ── Summary cards ── */
#box_summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.summary_card {
  flex: 1;
  min-width: 140px;
  background: #ffffff;
  border: 1px solid var(--color-greyLight);
  border-radius: 12px;
  padding: 16px 20px;
}
.summary_card .label {
  font-size: 12px;
  color: var(--color-greyMedium);
  margin-bottom: 4px;
}
.summary_card .value {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  color: var(--color-black);
}
.summary_card .value.green {
  color: var(--color-greenBlack);
}
.summary_card .value.red {
  color: var(--color-redBlack);
}

/* ── Content card ── */
.content_card {
  background: #ffffff;
  border: 1px solid var(--color-greyLight);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
}
.content_card h6 {
  font-size: 13px;
  color: var(--color-greyDark);
  margin-bottom: 16px;
}

/* ── Table ── */
#box_table {
  overflow: auto;
  max-height: 600px;
}

table {
  width: 100%;
  min-width: 240px;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

thead th {
  position: sticky;
  top: 0;
  background: #ffffff;
  color: var(--color-greyMedium);
  font-weight: 600;
  font-size: 12px;
  text-align: right;
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--color-greyLight);
  z-index: 1;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
thead th:hover {
  color: var(--color-greyDark);
}
thead th.th_active {
  color: var(--color-black);
}
thead th:first-child {
  text-align: left;
}

.sort_arrow {
  margin-left: 3px;
  font-size: 11px;
  color: var(--color-primary);
}

tbody tr {
  transition: background 0.15s ease;
}
tbody tr:last-child {
  border-bottom: none;
}
tbody tr:hover {
  background: var(--color-white);
}
tbody td {
  padding: 8px;
  text-align: right;
  color: var(--color-black);
}
tbody td:first-child {
  text-align: left;
}
tbody td.green {
  color: var(--color-greenBlack);
  font-weight: 600;
}
tbody td.red {
  color: var(--color-redBlack);
  font-weight: 600;
}

/* ── Accordion ── */
.tr_summary:hover td {
  background: var(--color-white);
}
.tr_summary.tr_active td {
  background: var(--color-primaryLight);
}
.tr_detail td {
  padding: 0 !important;
}
.detail_wrap {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease, padding 0.28s ease;
  padding: 0 12px;
  background: var(--color-white);
}
.detail_wrap.open {
  max-height: 400px;
  padding: 8px 12px 12px;
  border-top: 1px solid var(--color-greyLight);
  overflow-y: auto;
}
.detail_loading {
  padding: 8px 0;
  font-size: 12px;
  color: var(--color-greyMedium);
}
.detail_table {
  width: auto;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.detail_table thead th {
  position: static;
  background: transparent;
  color: var(--color-greyMedium);
  font-size: 11px;
  font-weight: 600;
  padding: 0 8px 4px;
  border-bottom: 1px solid var(--color-greyLight);
  text-align: right;
  cursor: default;
  user-select: none;
  white-space: nowrap;
  z-index: auto;
}
.detail_table thead th:first-child {
  text-align: left;
}
.detail_table tbody td {
  padding: 4px 8px;
  text-align: right;
  color: var(--color-black);
  border-bottom: 1px solid var(--color-greyLight);
}
.detail_table tbody tr {
  border-bottom: none;
}
.detail_table tbody tr:last-child td {
  border-bottom: none;
}
.detail_table tbody tr:hover td {
  background: var(--color-white);
}
.detail_table tbody td:first-child {
  text-align: left;
}
.detail_table td.green {
  color: var(--color-greenBlack);
}
.detail_table td.red {
  color: var(--color-redBlack);
}

@media (max-width: 768px) {
  .detail_table thead th {
    padding: 0 6px 4px;
  }
  .detail_table tbody td {
    padding: 4px 6px;
  }
}

/* ── Loading / empty ── */
.loader_wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px 0;
  color: var(--color-greyMedium);
  font-size: 14px;
}

/* ── Tablet + Mobile (≤1300px) ── */
@media (max-width: 1300px) {
  #box_container {
    padding-top: 60px !important;
  }
  #box_main {
    padding-left: 0;
  }
  #box_title {
    display: none;
  }
  #box_filter {
    gap: 8px;
    margin-bottom: 16px;
  }

  #box_summary {
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--color-greyLight);
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    margin-bottom: 16px;
  }
  .summary_card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border: none;
    border-radius: 0;
    border-bottom: 1px solid var(--color-greyLight);
    background: transparent;
    min-width: 0;
    flex: none;
  }
  .summary_card:last-child {
    border-bottom: none;
  }
  .summary_card .label {
    margin-bottom: 0;
    color: var(--color-greyDark);
  }
  .summary_card .value {
    font-size: 16px;
  }
}

/* ── Mobile only ── */
@media (max-width: 768px) {
  #box_filter {
    flex-wrap: wrap;
  }
  #btn_query {
    height: 40px;
    padding: 0 16px;
  }
  .content_card {
    width: 350px;
  }
}
