:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --ink-1: #1f2a44;
  --ink-2: #55627a;
  --line: #d6deed;
  --line-soft: #e9eef8;
  --brand: #2463eb;
  --brand-strong: #1f54c7;
  --ok: #1d8546;
  --warn: #9a6111;
  --danger: #cb3d2f;
  --shadow: 0 12px 28px rgba(21, 38, 71, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Pretendard', sans-serif;
  color: var(--ink-1);
  background:
    radial-gradient(circle at 10% 0%, #ffffff 0%, rgba(255, 255, 255, 0) 45%),
    radial-gradient(circle at 90% -20%, #eef4ff 0%, rgba(238, 244, 255, 0) 40%),
    var(--bg);
  min-height: 100vh;
}

.top-links {
  max-width: 1100px;
  margin: 20px auto 0;
  padding: 0 24px;
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  font-size: 12px;
}

.top-links a {
  color: #5b6476;
  text-decoration: none;
}

.top-links a:hover {
  color: var(--brand);
}

.app {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 32px;
  display: grid;
  gap: 14px;
}

.hero {
  text-align: center;
  margin-bottom: 10px;
  padding: 4px 0 2px;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid #d8e2f5;
  border-radius: 999px;
  background: #f8fbff;
  color: #4f5f83;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
}

.hero h1 {
  margin: 14px 0 0;
  font-size: clamp(2rem, 3.8vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #1a2846;
}

.hero-sub {
  margin: 11px 0 0;
  font-size: 16px;
  font-weight: 600;
  color: #556586;
}

.input-zone,
.result-zone,
.request-zone {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.section-head h2,
.result-head h2,
.request-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.section-head p,
.request-sub {
  margin: 6px 0 0;
  color: var(--ink-2);
  font-size: 13px;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.btn {
  border: 1px solid var(--line);
  background: #f8faff;
  color: var(--ink-1);
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: #bcc8e3;
  background: #f1f5ff;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-small {
  padding: 8px 12px;
  font-size: 12px;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

.progress-text {
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink-2);
  background: #f9fbff;
}

.progress-text.error {
  border-color: #efb3aa;
  color: #a12214;
  background: #fff6f5;
}

#input-table {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

#input-table:hover {
  border-color: #b8c5e4;
}

#input-table.is-clicked {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

#input-table .tabulator {
  border: 0;
  background: transparent;
}

#input-table .tabulator-header {
  background: #f4f7ff;
  border-bottom: 1px solid var(--line);
}

#input-table .tabulator-col,
#input-table .tabulator-col-title {
  color: #3d4b67;
  font-size: 12px;
  font-weight: 700;
}

#input-table .tabulator-row {
  border-bottom: 1px solid #f0f3fa;
}

#input-table .tabulator-cell {
  padding: 10px;
  border-right: 1px solid #f0f3fa;
}

#input-table .tabulator-editing {
  background: #edf3ff !important;
}

.summary-zone {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary-card {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.summary-card h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-card p {
  margin: 6px 0 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.summary-total p {
  color: #3e4e6e;
}

.summary-urgent p {
  color: var(--danger);
}

.summary-review p {
  color: var(--warn);
}

.summary-normal p {
  color: var(--ok);
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.result-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.last-updated {
  color: var(--ink-2);
  font-size: 12px;
}

.result-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 13px;
  border-top: 1px solid var(--line-soft);
}

.result-table th,
.result-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

.result-table th {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  background: #f8faff;
}

.sort-btn {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  text-align: left;
}

.sort-btn .sort-indicator {
  color: #8b97b1;
  font-size: 12px;
  line-height: 1;
}

.sort-btn.is-active .sort-indicator,
.sort-btn:hover .sort-indicator {
  color: #3f5280;
}

.result-table .col-bl {
  width: 11%;
}

.result-table .col-tracking {
  width: 11%;
}

.result-table .col-customs {
  width: 14%;
}

.result-table .col-delivery {
  width: 15%;
}

.result-table .col-risk {
  width: 8%;
}

.result-table .col-delay {
  width: 19%;
}

.result-table .col-next {
  width: 22%;
}

.cell-main {
  color: #2f3b55;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}

.cell-main-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

.customs-main-text {
  min-width: 0;
  word-break: break-word;
}

.inline-complete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin-left: 0;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e8f6ed;
  color: #1d8546;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.cell-sub {
  margin-top: 3px;
  color: #64718a;
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.cell-urgent {
  margin-top: 4px;
  color: #a63a2d;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
}

.stack {
  display: grid;
  gap: 4px;
}

.bl-detail-btn {
  border: 0;
  background: transparent;
  padding: 0;
  color: #2456c5;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.bl-detail-btn:hover {
  text-decoration: underline;
}

.bl-text {
  color: #2f3b55;
}

.tracking-link {
  color: #2456c5;
  text-decoration: none;
  word-break: break-all;
}

.tracking-link:hover {
  text-decoration: underline;
}

.tracking-detail-btn {
  border: 0;
  background: transparent;
  padding: 0;
  color: #2456c5;
  font-size: 13px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  word-break: break-all;
}

.tracking-detail-btn:hover {
  text-decoration: underline;
}

.tracking-plain {
  color: #2f3b55;
  word-break: break-all;
}

.penalty-box {
  border: 1px solid #ffdcb2;
  border-radius: 10px;
  background: #fff8ef;
}

.row-retry-btn {
  border: 1px solid #cfd9ee;
  background: #f7faff;
  color: #274686;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
  padding: 6px 8px;
  cursor: pointer;
  width: fit-content;
}

.row-retry-btn:hover {
  background: #edf3ff;
}

.penalty-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  padding: 6px 8px;
  color: #844a0f;
  font-size: 12px;
  font-weight: 700;
}

.penalty-toggle:hover {
  background: #fff2df;
}

.penalty-detail {
  border-top: 1px solid #ffe6c9;
  padding: 6px 8px;
  font-size: 12px;
  color: #63462a;
  line-height: 1.4;
  display: grid;
  gap: 3px;
}

.penalty-detail[hidden] {
  display: none;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.dot-pending {
  background: #9aa8c6;
}

.dot-running {
  background: var(--brand);
  box-shadow: 0 0 0 0 rgba(36, 99, 235, 0.45);
  animation: pulse 1.2s infinite;
}

.dot-done {
  background: var(--ok);
}

.dot-cached {
  background: #4b7ef5;
}

.dot-error {
  background: var(--danger);
}

.risk-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
}

.risk-low {
  color: var(--ok);
  background: #e8f6ed;
}

.risk-mid {
  color: var(--warn);
  background: #fff5df;
}

.risk-high {
  color: var(--danger);
  background: #feeceb;
}

.empty-row {
  text-align: center;
  color: var(--ink-2);
  padding: 26px 8px !important;
}

.request-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.request-link {
  font-size: 12px;
  color: var(--brand);
  text-decoration: none;
}

.request-link:hover {
  text-decoration: underline;
}

.request-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.request-item {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.request-item a {
  color: #2d4169;
  text-decoration: none;
  font-weight: 600;
}

.request-item a:hover {
  color: var(--brand);
}

.request-meta {
  color: var(--ink-2);
  font-size: 12px;
  white-space: nowrap;
}

.request-empty {
  margin-top: 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
}

.request-empty p {
  margin: 0;
}

.request-empty p + p {
  margin-top: 6px;
}

.request-empty a {
  color: var(--brand);
}

body.modal-open {
  overflow: hidden;
}

.bl-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
}

.bl-modal[hidden] {
  display: none;
}

.bl-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 28, 56, 0.45);
}

.bl-modal-panel {
  position: absolute;
  left: 50%;
  top: 40px;
  transform: translateX(-50%);
  width: min(640px, calc(100% - 44px));
  max-height: calc(100vh - 80px);
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
  box-shadow: 0 16px 36px rgba(12, 24, 49, 0.2);
}

.bl-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  cursor: move;
  user-select: none;
  touch-action: none;
}

.bl-modal-title {
  margin: 0;
  font-size: 16px;
}

.bl-modal-close {
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #5d6880;
}

.bl-modal-meta {
  margin: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: #4b5871;
  font-size: 12px;
}

.bl-modal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 10px 12px 12px;
  overflow: auto;
}

.bl-modal-section {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  overflow: hidden;
  background: #fcfdff;
}

.bl-modal-subtitle {
  margin: 0;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  color: #41506d;
}

.bl-history-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11.5px;
}

.bl-history-table th,
.bl-history-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 6px 6px;
  text-align: left;
}

.bl-history-table th:first-child,
.bl-history-table td:first-child {
  width: 52px;
  text-align: center;
}

.bl-history-table th:nth-child(2),
.bl-history-table td:nth-child(2) {
  width: 15%;
}

.bl-history-table th:nth-child(3),
.bl-history-table td:nth-child(3) {
  width: 47%;
}

.bl-history-table th:nth-child(4),
.bl-history-table td:nth-child(4) {
  width: 30%;
}

.bl-history-table th {
  color: #4b5871;
  background: #f7f9fe;
}

.bl-empty {
  text-align: center;
  color: #6a7791;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(36, 99, 235, 0.45);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(36, 99, 235, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(36, 99, 235, 0);
  }
}

@media (max-width: 960px) {
  .app {
    width: min(1100px, calc(100% - 20px));
    padding-top: 44px;
  }

  .section-head {
    flex-direction: column;
  }

  .control-row {
    width: 100%;
    justify-content: flex-start;
  }

  .summary-zone {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .result-head,
  .request-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .result-head-right {
    justify-content: flex-start;
  }

  .result-table {
    font-size: 12px;
  }

  .result-table th,
  .result-table td {
    padding: 10px 7px;
  }

  .bl-modal-grid {
    grid-template-columns: 1fr;
  }

  .request-item {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 600px) {
  .top-links {
    padding: 0 12px;
    margin-top: 12px;
    gap: 10px;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .summary-zone {
    grid-template-columns: 1fr;
  }

  .control-row {
    flex-wrap: wrap;
  }

  .control-row .btn {
    flex: 1 1 auto;
  }

  .bl-modal-panel {
    width: calc(100% - 16px);
    left: 50%;
    top: 8px;
    transform: translateX(-50%);
    max-height: calc(100vh - 16px);
  }
}

.embedded-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
}

.embedded-modal.is-open {
  display: block;
}

.embedded-backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(11, 16, 32, 0.56);
  backdrop-filter: blur(2px);
}

.embedded-panel {
  position: absolute;
  inset: 20px;
  z-index: 2;
  background: #fff;
  border: 1px solid #d8e0f2;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(23, 42, 89, 0.25);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

.embedded-viewport {
  position: relative;
  overflow: hidden;
  background: #fff;
}

.embedded-head {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #e6ecf8;
  background: linear-gradient(180deg, #f8fbff 0%, #f4f7ff 100%);
}

.embedded-title {
  font-size: 15px;
  color: #1f2a44;
}

.embedded-close {
  border: 1px solid #d6dfef;
  background: #fff;
  color: #1f2a44;
  border-radius: 10px;
  padding: 6px 10px;
  font-weight: 600;
  cursor: pointer;
}

.embedded-iframe {
  display: block;
  position: relative;
  z-index: 1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

@media (max-width: 960px) {
  .embedded-panel {
    inset: 8px;
    border-radius: 12px;
  }
}

