:root {
  --primary: #0f766e;
  --primary-hover: #0a5c57;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #dde4ee;
  --success: #10b981;
  --soft-teal: #ecfdf5;
  --soft-orange: #fff7ed;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Pretendard', sans-serif;
  background:
    radial-gradient(circle at 12% 0%, #d8f3f0 0%, rgba(216, 243, 240, 0) 30%),
    radial-gradient(circle at 90% 20%, #ffe9d6 0%, rgba(255, 233, 214, 0) 30%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.header {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px 32px 20px;
}

.search-box {
  background: var(--surface);
  padding: 32px;
  border-radius: 22px;
  border: 1px solid var(--border);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  margin-bottom: 24px;
}

.search-box p {
  margin: 0 0 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
}

.form-group {
  display: flex;
  gap: 12px;
  max-width: 500px;
  margin: 0 auto;
}

.form-group input {
  flex: 1;
  padding: 16px;
  font-size: 1.1rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  outline: none;
  transition: all 0.2s;
  -webkit-appearance: none;
  appearance: none;
  min-height: 48px;
}

.form-group input:focus {
  border-color: var(--primary);
}

.form-group input::placeholder {
  font-size: 1rem;
}

.form-group button {
  padding: 0 28px;
  font-size: 1.1rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--primary), #115e59);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  white-space: nowrap;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
}

.form-group button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.25);
}

.form-group button:active {
  transform: translateY(0);
}

#statusMessage {
  text-align: center;
  margin-top: 16px;
  font-size: 0.95rem;
  color: var(--text-muted);
  min-height: 20px;
}

.result-section {
  display: none;
}

.result-section.active {
  display: block;
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  padding: 24px;
  margin-bottom: 24px;
}

.card.card-main {
  border-color: #b9ddd6;
  background: linear-gradient(170deg, #ffffff 0%, #f9fffd 100%);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.08);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 16px 0;
  border-bottom: 2px solid var(--border);
  padding-bottom: 12px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.metric {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  gap: 4px;
}

.metric.full-width {
  grid-column: span 3;
}

.metric span {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  min-width: unset;
}

.metric strong {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  text-align: left;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: break-word;
}

.transport-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.transport-info-item {
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.transport-info-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.transport-info-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.info-value {
  font-size: 1.05rem;
  font-weight: 600;
  word-break: break-all;
}

.detail-area {
  margin-top: 16px;
}

.detail-toggle {
  width: 100%;
  margin-top: 0;
  padding: 16px 18px;
  border: none;
  border-radius: 14px;
  background: #f1f5f9;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.detail-toggle:hover {
  background: #e2e8f0;
  color: var(--text);
}

.detail-toggle::after {
  content: '▾';
  font-size: 1rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.detail-toggle[data-open="true"]::after {
  content: '▴';
}

.detail-panel {
  display: none;
  margin-top: 16px;
  padding: 0;
  background: transparent;
  flex-direction: column;
  gap: 16px;
}

.detail-section {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.detail-section-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  color: #0f172a;
}

.status-badge {
  display: inline-block;
  padding: 6px 12px;
  background: var(--soft-teal);
  color: #065f46;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.status-badge.hold {
  background: #fee2e2;
  color: #b91c1c;
}

.hold-notice {
  margin: 12px 0 16px;
  padding: 14px 16px;
  border: 1px solid #fecaca;
  border-radius: 12px;
  background: #fff1f2;
  color: #991b1b;
  line-height: 1.5;
}

.hold-notice strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.98rem;
}

.hold-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.hold-btn {
  appearance: none;
  border: 1px solid #fecaca;
  background: #fff;
  color: #991b1b;
  font-weight: 700;
  font-size: 0.86rem;
  padding: 8px 12px;
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
}

.hold-btn.primary {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

.hold-btn.disabled {
  opacity: 0.6;
  pointer-events: none;
  cursor: not-allowed;
}

.progress-rail {
  grid-column: span 3;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.progress-step {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #475569;
  background: #f8fafc;
  white-space: nowrap;
}

.progress-step.done {
  color: #065f46;
  background: var(--soft-teal);
  border-color: #99f6e4;
}

.progress-step.active {
  color: #111827;
  background: #ffedd5;
  border-color: #fdba74;
}

.cj-tracking-box {
  margin-top: 24px;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #fff;
}

.cj-tracking-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #ff1010 0%, #cc0000 100%);
  color: white;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
}

.cj-tracking-body {
  padding: 0;
  display: grid;
  gap: 0;
}

.cj-latest-status {
  padding: 20px;
  background: #fff3f3;
  border-bottom: 2px solid #ff1010;
  display: grid;
  gap: 8px;
}

.cj-latest-label {
  color: #ff1010;
  font-size: 0.84rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cj-latest-status-text {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
}

.cj-latest-time,
.cj-latest-location {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-weight: 500;
}

.cj-tracking-summary {
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.cj-summary-item {
  padding: 0;
  border: none;
  background: transparent;
}

.cj-summary-label {
  display: block;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
}

.cj-summary-value {
  display: block;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.3;
  word-break: break-word;
  overflow-wrap: break-word;
}

.cj-tracking-timeline {
  padding: 20px;
  position: relative;
  padding-left: 24px;
}

.cj-tracking-timeline::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.cj-timeline-item {
  position: relative;
  margin-bottom: 16px;
  padding-left: 12px;
}

.cj-timeline-item:last-child {
  margin-bottom: 0;
}

.cj-timeline-dot {
  position: absolute;
  left: -16px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--border);
  top: 2px;
}

.cj-timeline-item:first-child .cj-timeline-dot {
  background: #ff1010;
  border-color: #ff1010;
  width: 16px;
  height: 16px;
  left: -18px;
  top: 0;
}

.cj-event-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}

.cj-event-status {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 700;
  line-height: 1.3;
}

.cj-event-location {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.cj-empty-state {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.timeline-container {
  position: relative;
  padding-left: 24px;
}

.timeline-container::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 7px;
  width: 2px;
  background: var(--border);
}

.timeline-stage {
  position: relative;
  margin-bottom: 28px;
}

.timeline-stage:last-child {
  margin-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: -24px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--border);
  top: 2px;
  z-index: 1;
}

.timeline-stage.active .timeline-marker {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.stage-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.stage-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.stage-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.stage-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.stage-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}

.stage-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.item-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.item-time {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.item-detail {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* 태블릿 최적화 */
@media (max-width: 768px) {
  .header {
    padding: 12px 16px;
  }
  .header h1 {
    font-size: 1.2rem;
  }
  .container {
    max-width: 100%;
    padding: 0 16px 24px 16px;
  }
  .search-box {
    padding: 24px 16px;
    border-radius: 16px;
    margin-bottom: 16px;
  }
  .form-group {
    flex-direction: column;
    gap: 10px;
  }
  .form-group input,
  .form-group button {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    min-height: 48px;
  }
  .card {
    padding: 16px;
    border-radius: 14px;
    margin-bottom: 16px;
  }
  .card-title {
    font-size: 1rem;
  }
  .result-summary {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .metric.full-width {
    grid-column: span 2;
  }
  .metric {
    padding: 10px 12px;
    border-radius: 10px;
  }
  .metric span {
    font-size: 0.75rem;
  }
  .metric strong {
    font-size: 0.9rem;
  }
  .info-grid {
    grid-template-columns: 1fr;
  }
  .timeline-container {
    padding-left: 20px;
  }
  .timeline-container::before {
    left: 5px;
  }
  .timeline-marker {
    left: -20px;
    width: 14px;
    height: 14px;
    border-width: 2px;
  }
  .stage-header {
    gap: 6px;
  }
  .stage-title {
    font-size: 1rem;
  }
  .stage-desc {
    font-size: 0.75rem;
  }
  .hold-btn {
    padding: 12px 16px;
    font-size: 0.9rem;
    min-height: 44px;
  }
  .cj-tracking-box {
    border-radius: 14px;
  }
  .cj-tracking-summary {
    grid-template-columns: 1fr;
  }
}

/* 작은 모바일 최적화 */
@media (max-width: 480px) {
  .header h1 {
    font-size: 1.1rem;
    letter-spacing: -0.01em;
  }
  .container {
    padding: 0 12px 16px 12px;
  }
  .search-box {
    padding: 16px 12px;
    margin-bottom: 12px;
  }
  .search-box p {
    font-size: 0.9rem;
    margin: 0 0 16px;
  }
  .form-group input,
  .form-group button {
    padding: 12px;
    font-size: 0.95rem;
    border-radius: 10px;
  }
  #statusMessage {
    font-size: 0.85rem;
  }
  .card {
    padding: 12px;
    margin-bottom: 12px;
  }
  .card-title {
    font-size: 0.95rem;
    margin: 0 0 12px 0;
    padding-bottom: 10px;
  }
  .result-summary {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .metric.full-width {
    grid-column: span 1;
  }
  .metric {
    padding: 8px 10px;
    gap: 3px;
  }
  .metric span {
    font-size: 0.7rem;
  }
  .metric strong {
    font-size: 0.85rem;
  }
  .transport-info-grid {
    grid-template-columns: 1fr;
  }
  .detail-toggle {
    padding: 12px 14px;
    font-size: 0.9rem;
  }
  .stage-items {
    padding: 12px;
    gap: 10px;
  }
  .stage-item {
    padding-bottom: 10px;
  }
  .stage-title {
    font-size: 0.95rem;
  }
  .stage-desc {
    font-size: 0.7rem;
  }
  .item-detail {
    font-size: 0.8rem;
  }
  .hold-btn {
    padding: 10px 14px;
    font-size: 0.85rem;
    min-height: 40px;
    border-radius: 10px;
  }
  .hold-actions {
    gap: 8px;
    margin-top: 8px;
  }
  .hold-notice {
    padding: 12px;
    font-size: 0.9rem;
  }
  .hold-notice strong {
    font-size: 0.95rem;
  }
  .cj-tracking-box {
    margin-bottom: 12px;
  }
  .cj-tracking-header {
    padding: 10px 12px;
    font-size: 0.9rem;
  }
  .cj-tracking-body {
    min-height: 50px;
  }
  .cj-tracking-summary {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .cj-summary-item {
    padding: 8px 10px;
    font-size: 0.85rem;
  }
  .cj-tracking-timeline {
    padding-left: 16px;
  }
  .cj-tracking-timeline::before {
    left: 4px;
  }
  .cj-timeline-item {
    margin-bottom: 16px;
  }
  .cj-timeline-dot {
    left: -16px;
    width: 12px;
    height: 12px;
    border-width: 2px;
  }
  .cj-timeline-item:first-child .cj-timeline-dot {
    left: -16px;
  }
  .cj-timeline-title {
    font-size: 0.9rem;
  }
  .cj-timeline-time {
    font-size: 0.75rem;
  }
  .cj-event-location {
    font-size: 0.75rem;
  }
  .cj-empty-state {
    padding: 16px;
    font-size: 0.85rem;
  }
}

/* 초소형 모바일 (340px 이하) */
@media (max-width: 340px) {
  .header h1 {
    font-size: 1rem;
  }
  .container {
    padding: 0 8px 12px 8px;
  }
  .search-box {
    padding: 12px 8px;
  }
  .form-group input,
  .form-group button {
    padding: 10px;
    font-size: 0.9rem;
  }
  .card {
    padding: 8px;
  }
  .metric span {
    font-size: 0.65rem;
  }
  .metric strong {
    font-size: 0.8rem;
  }
}
