/* =============================================================================
   OO전자 AS 접수/조회 시스템 — 스타일
   단정하고 신뢰감 있는 한국 SMB 톤. 고객 화면 모바일 우선 / 관리자 화면 데이터 밀도.
   ========================================================================== */

:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-tint: #eff6ff;

  --page-bg: #f4f6f9;
  --card-bg: #ffffff;
  --border: #e3e7ed;
  --border-strong: #cbd2dc;

  --text: #111827;
  --text-soft: #374151;
  --muted: #6b7280;

  --danger: #dc2626;
  --danger-tint: #fef2f2;

  /* 상태 색상 (fsm STATUS.color 키와 일치) */
  --c-gray: #6b7280;
  --c-blue: #2563eb;
  --c-orange: #ea580c;
  --c-green: #16a34a;

  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.16);

  --maxw-narrow: 560px;
  --maxw-wide: 1120px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
    "Malgun Gothic", "Noto Sans KR", "맑은 고딕", sans-serif;
  color: var(--text);
  background: var(--page-bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }
.muted { color: var(--muted); }

/* ----------------------------------------------------------------- 앱바 */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  height: 58px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.appbar__brand { display: inline-flex; align-items: center; gap: 8px; font-size: 17px; }
.appbar__logo { font-size: 20px; }
.appbar__title { color: var(--text); font-weight: 500; }
.appbar__title b { font-weight: 800; }
.appbar__nav { display: flex; gap: 4px; }
.appbar__nav a {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.appbar__nav a:hover { background: var(--page-bg); color: var(--text-soft); }
.appbar__nav a.is-active { background: var(--brand); color: #fff; }

/* ----------------------------------------------------------------- 레이아웃 */
.main { flex: 1 0 auto; width: 100%; padding: 28px 20px 88px; }
.view { margin: 0 auto; }
.view--narrow { max-width: var(--maxw-narrow); }
.view--wide { max-width: var(--maxw-wide); }

.page-head { margin-bottom: 18px; }
.page-head__title { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; }
.page-head__sub { margin-top: 6px; color: var(--muted); font-size: 14.5px; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card + .card { margin-top: 16px; }

.appfoot {
  flex-shrink: 0;
  padding: 18px 20px 28px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

/* ----------------------------------------------------------------- 폼 */
.form__group { border: none; padding: 0; margin: 0 0 8px; }
.form__group + .form__group { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.form__legend { font-size: 15px; font-weight: 700; color: var(--text); padding: 0; margin-bottom: 12px; }

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field__label { display: block; font-size: 13.5px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.field__control {
  width: 100%;
  padding: 11px 12px;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.field__control::placeholder { color: #9aa3af; }
.field__control:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
textarea.field__control { resize: vertical; min-height: 92px; }
select.field__control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.field__hint { margin-top: 5px; font-size: 12px; color: var(--muted); }
.field__error { min-height: 16px; margin-top: 5px; font-size: 12.5px; color: var(--danger); }
.field.is-error .field__control { border-color: var(--danger); }
.field.is-error .field__control:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14); }
.field.is-disabled { opacity: 0.55; }
.req { color: var(--danger); }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; font-size: 14px; color: var(--text-soft); cursor: pointer; }
.checkbox-row input { width: 17px; height: 17px; accent-color: var(--brand); }

.field__file {
  width: 100%;
  font-size: 14px;
  padding: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
  background: #fbfcfe;
}

/* ----------------------------------------------------------------- 버튼 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost { background: #fff; color: var(--text-soft); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--page-bg); }
.btn--block { width: 100%; }
.btn--sm { padding: 6px 11px; font-size: 12.5px; font-weight: 600; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--block + .btn--block { margin-top: 10px; }
.form > .btn--block { margin-top: 22px; }

/* ----------------------------------------------------------------- 배지 */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge--gray   { color: var(--c-gray);   background: #f3f4f6; border-color: #e5e7eb; }
.badge--blue   { color: var(--c-blue);   background: #eff6ff; border-color: #dbeafe; }
.badge--orange { color: var(--c-orange); background: #fff7ed; border-color: #fed7aa; }
.badge--green  { color: var(--c-green);  background: #f0fdf4; border-color: #bbf7d0; }

/* ----------------------------------------------------------------- 타임라인 */
.timeline { margin: 4px 0; }
.timeline__step { position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.timeline__step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 50%;
  width: 2px;
  height: 100%;
  background: var(--border);
  z-index: 0;
}
.timeline__step.is-done::after { background: var(--dot-color); }
.timeline__marker {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  background: #fff;
  color: var(--muted);
  border: 2px solid var(--border-strong);
}
.timeline__step.is-done .timeline__marker { background: var(--dot-color); border-color: var(--dot-color); color: #fff; }
.timeline__step.is-current .timeline__marker { border-color: var(--dot-color); color: var(--dot-color); box-shadow: 0 0 0 4px color-mix(in srgb, var(--dot-color) 16%, transparent); }
.timeline__label { font-size: 14.5px; color: var(--muted); }
.timeline__step.is-done .timeline__label { color: var(--text-soft); }
.timeline__step.is-current .timeline__label { color: var(--text); font-weight: 700; }

/* ----------------------------------------------------------------- 첨부 */
.attach-list { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.attach-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: #fbfcfe;
}
.attach-item__icon { font-size: 20px; }
.attach-item__body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.attach-item__name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-item__meta { font-size: 12px; color: var(--muted); }

/* ----------------------------------------------------------------- 정보 그리드 */
.info-grid { margin-top: 6px; border-top: 1px solid var(--border); }
.info-row { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.info-row__label { font-size: 13.5px; color: var(--muted); }
.info-row__value { font-size: 14.5px; color: var(--text); word-break: break-word; }

/* ----------------------------------------------------------------- 조회 결과 */
.search-bar { display: flex; gap: 10px; align-items: center; padding: 14px; }
.search-bar .field__control { flex: 1; }
.track-result { margin-top: 16px; }

.empty { color: var(--muted); text-align: center; padding: 8px 0; }
.empty-card { text-align: center; }

.result-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.result-card__id { display: block; font-family: ui-monospace, monospace; font-size: 13px; color: var(--muted); }
.result-card__model { display: block; font-size: 18px; font-weight: 800; margin-top: 2px; }
.result-card__timeline { padding: 16px 0; }

.status-note { padding: 12px 14px; border-radius: var(--r-sm); font-size: 14px; background: var(--page-bg); border-left: 3px solid var(--c-gray); margin-bottom: 16px; }
.status-note--blue { border-left-color: var(--c-blue); background: var(--brand-tint); }
.status-note--orange { border-left-color: var(--c-orange); background: #fff7ed; }
.status-note--gray { border-left-color: var(--c-gray); }

.shipping-box { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: var(--r-sm); padding: 14px; margin-bottom: 16px; }
.shipping-box__head { font-weight: 800; color: var(--c-green); margin-bottom: 10px; }
.shipping-box__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.shipping-box__grid > div { display: flex; flex-direction: column; gap: 2px; }
.shipping-box__grid strong { font-size: 15px; }

.pick-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.pick-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.pick-item:hover { border-color: var(--brand); background: var(--brand-tint); }
.pick-item__main { display: flex; flex-direction: column; }
.pick-item__main strong { font-family: ui-monospace, monospace; font-size: 14px; }
.pick-item__side { display: flex; align-items: center; gap: 10px; }
.result-count { font-size: 14px; color: var(--text-soft); }

/* ----------------------------------------------------------------- 성공 화면 */
.success { text-align: center; }
.success__icon { font-size: 44px; }
.success__title { font-size: 21px; font-weight: 800; margin-top: 8px; }
.success__desc { color: var(--muted); margin-top: 6px; }
.success__id-box {
  margin: 20px 0 14px; padding: 18px;
  background: var(--brand-tint); border: 1px dashed var(--brand);
  border-radius: var(--r); display: flex; flex-direction: column; gap: 4px;
}
.success__id-label { font-size: 13px; color: var(--brand-dark); font-weight: 600; }
.success__id { font-family: ui-monospace, monospace; font-size: 26px; font-weight: 800; color: var(--brand-dark); letter-spacing: 0.02em; }
.success__notice { font-size: 13.5px; color: var(--text-soft); margin-bottom: 18px; }
.success__actions { display: flex; flex-direction: column; }

/* ----------------------------------------------------------------- 게이트 */
.gate { text-align: center; max-width: 380px; margin: 24px auto; }
.gate__icon { font-size: 34px; }
.gate__title { font-size: 20px; font-weight: 800; margin-top: 6px; }
.gate__desc { color: var(--muted); margin-top: 4px; font-size: 14px; }
.gate__form { display: flex; flex-direction: column; gap: 10px; margin: 18px 0 8px; }
.gate__error { min-height: 18px; color: var(--danger); font-size: 13px; }
.gate__hint { font-size: 12.5px; color: var(--muted); }
.gate__hint code { background: var(--page-bg); padding: 2px 6px; border-radius: 5px; font-size: 12px; }

/* ----------------------------------------------------------------- 관리자 목록 */
.admin-toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; padding: 14px 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 6px 13px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text-soft);
  border-radius: 999px; cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.admin-toolbar__search { flex: 1; min-width: 200px; max-width: 320px; }

.table-wrap { padding: 0; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.data-table th, .data-table td { padding: 13px 16px; text-align: left; font-size: 14px; }
.data-table thead th { font-size: 12.5px; font-weight: 700; color: var(--muted); background: #fafbfc; border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.data-table__row { border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.data-table__row:hover { background: var(--brand-tint); }
.data-table__row:last-child { border-bottom: none; }
.data-table__empty { text-align: center; color: var(--muted); padding: 28px; }

/* ----------------------------------------------------------------- 관리자 상세 */
.back-link { margin-bottom: 14px; }
.back-link a { color: var(--brand); font-size: 14px; font-weight: 600; }
.back-link a:hover { text-decoration: underline; }

.detail-grid { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
.detail-side > .card + .card { margin-top: 0; }
.detail-side { display: flex; flex-direction: column; gap: 16px; }

.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.detail-head__id { font-size: 12.5px; color: var(--muted); }
.detail-head__model { font-size: 19px; font-weight: 800; margin-top: 3px; }

.detail-section { margin-top: 18px; }
.detail-section__title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.symptom-text { background: var(--page-bg); border-radius: var(--r-sm); padding: 12px 14px; font-size: 14.5px; color: var(--text-soft); white-space: pre-wrap; }

.transition { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.transition__guide { font-size: 13.5px; color: var(--muted); margin-bottom: 10px; }
.transition__error { min-height: 18px; color: var(--danger); font-size: 13px; margin: 4px 0 8px; }
.transition-done { margin-top: 14px; padding: 12px; text-align: center; background: #f0fdf4; color: var(--c-green); font-weight: 700; border-radius: var(--r-sm); font-size: 14px; }

.history { display: flex; flex-direction: column; gap: 2px; }
.history__item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.history__item:last-child { border-bottom: none; }
.history__time { font-size: 12.5px; color: var(--muted); }

.mini-notif { display: flex; flex-direction: column; gap: 10px; }
.mini-notif__item { padding-left: 11px; border-left: 2px solid var(--border-strong); }
.mini-notif__time { font-size: 12px; color: var(--muted); }
.mini-notif__msg { font-size: 13px; color: var(--text-soft); margin-top: 2px; }

/* ----------------------------------------------------------------- 알림 패널 */
.notif-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 340px;
  max-width: calc(100vw - 36px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  z-index: 40;
  overflow: hidden;
}
.notif-panel__toggle {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; background: #fff; border: none; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--text);
}
.notif-panel__title { flex: 1; text-align: left; }
.notif-panel__count { background: var(--brand); color: #fff; font-size: 12px; padding: 1px 8px; border-radius: 999px; }
.notif-panel__chevron { color: var(--muted); transition: transform .2s; }
.notif-panel.is-collapsed .notif-panel__chevron { transform: rotate(-180deg); }
.notif-panel__body { border-top: 1px solid var(--border); max-height: 42vh; overflow-y: auto; padding: 12px 14px; }
/* 기본은 접힘: 코너의 작은 토글 바만 노출해 클릭 가능한 콘텐츠를 가리지 않는다
   (모바일에서도 접힘 상태는 우측 코너 알약 형태로 — left 앵커 해제) */
.notif-panel.is-collapsed { width: auto; left: auto; }
.notif-panel.is-collapsed .notif-panel__body { display: none; }
.notif-panel.is-bump { animation: notif-bump .6s ease; }
@keyframes notif-bump {
  0% { transform: scale(1); }
  30% { transform: scale(1.05); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18), var(--shadow-lg); }
  100% { transform: scale(1); }
}
.notif-panel__hint { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

.notif-log { display: flex; flex-direction: column; gap: 10px; }
.notif-log__empty { font-size: 13px; color: var(--muted); text-align: center; padding: 10px 0; }
.notif-log__item { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 9px 11px; background: #fbfcfe; }
.notif-log__head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.notif-log__phone { font-family: ui-monospace, monospace; font-size: 12px; color: var(--text-soft); }
.notif-log__time { font-size: 11px; color: var(--muted); margin-left: auto; }
.notif-log__msg { font-size: 12.5px; color: var(--text-soft); margin-top: 6px; line-height: 1.45; }
.notif-log__ref { display: inline-block; margin-top: 5px; font-family: ui-monospace, monospace; font-size: 10.5px; color: var(--muted); }

/* ----------------------------------------------------------------- 토스트 */
.toast-wrap {
  position: fixed;
  top: 70px;
  right: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 330px;
  max-width: calc(100vw - 36px);
  pointer-events: none;
}
.toast {
  background: #111827;
  color: #fff;
  border-radius: var(--r-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateX(16px);
  transition: opacity .3s, transform .3s;
}
.toast.is-in { opacity: 1; transform: translateX(0); }
.toast.is-out { opacity: 0; transform: translateX(16px); }
.toast__head { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.toast__title { font-weight: 700; }
.toast__phone { font-family: ui-monospace, monospace; color: #cbd5e1; margin-left: auto; font-size: 12px; }
.toast__msg { font-size: 12.5px; color: #e5e7eb; margin-top: 6px; line-height: 1.45; }
.toast__mock { display: block; margin-top: 6px; font-size: 10.5px; color: #94a3b8; }

/* ----------------------------------------------------------------- 반응형 */
@media (max-width: 920px) {
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .main { padding: 20px 16px 80px; }
  .card { padding: 18px; }
  .page-head__title { font-size: 21px; }
  .appbar { padding: 0 14px; }
  .appbar__nav a { padding: 6px 11px; }

  .notif-panel { left: 12px; right: 12px; bottom: 12px; width: auto; }
  .toast-wrap { top: 66px; left: 12px; right: 12px; width: auto; }
}
@media (max-width: 400px) {
  .shipping-box__grid { grid-template-columns: 1fr; }
  .appbar__title { font-size: 15px; }
}
