/*
 * 픽스사인 작업조건서 — 시각 언어.
 *
 * 이 화면은 사람이 돈을 승인하는 자리다. 그래서 목표는 인상적인 화면이 아니라
 * **오해가 없는 화면**이다. 세 가지 규칙이 그 목표를 지킨다.
 *
 * 1. 색은 뜻이다. 남색 = 픽스사인이 보증하는 사실, 초록 = 고객이 승인한 것,
 *    빨강 = 거절, 호박 = 아직 답하지 않은 것. 장식으로는 한 번도 쓰지 않는다 —
 *    초록이 한 번이라도 장식이 되면 「초록은 승인됨」이 더 이상 읽히지 않는다.
 * 2. 금액은 같은 자리에서 흔들리지 않는다. 모든 숫자는 tabular-nums 다.
 * 3. 아이콘은 이모지가 아니라 선 아이콘이다. 이모지는 기기마다 모양·색이 달라
 *    같은 화면을 두 사람이 다르게 본다. 합의 기록에서 그건 결함이다.
 */
:root {
  color-scheme: light;

  /* 사실 */
  --navy: #1b2a4a;
  --navy-deep: #101c33;
  --navy-soft: #eef2f9;
  --navy-line: #d9e1f0;

  /* 승인 */
  --green: #15803d;
  --green-ink: #14532d;
  --green-soft: #effaf3;
  --green-line: #b9e3c8;

  /* 거절 */
  --red: #c62828;
  --red-soft: #fdf2f2;
  --red-line: #f2cdcd;

  /* 대기 */
  --amber: #9a5b0a;
  --amber-soft: #fffaf0;
  --amber-line: #f0dcb8;

  --ink: #131b28;
  --ink-2: #556173;
  --ink-3: #8894a5;
  --line: #e4e8ef;
  --line-2: #eef1f6;
  --bg: #f5f7fa;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 1px rgba(16, 28, 51, .04), 0 4px 14px -4px rgba(16, 28, 51, .10);
  --shadow-lift: 0 2px 4px rgba(16, 28, 51, .06), 0 12px 28px -8px rgba(16, 28, 51, .18);

  --tap: 48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  /* Pretendard 가 깔린 기기에서는 그것을, 아니면 각 OS 의 한글 본문 글꼴을 쓴다. */
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  word-break: keep-all;          /* 한국어는 어절 단위로 끊는다 */
  overflow-wrap: break-word;
}

/* 금액·수량은 자리가 흔들리면 비교가 안 된다. */
.num, .amount-box .value, .total-box .value, .lines-table .num,
.tl .what .amt, .alt-tab .m { font-variant-numeric: tabular-nums; }

:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 모바일 우선. 데스크톱에서도 폭을 넓히지 않는다 — 한 손 화면이 기준이다. */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: 84px;
}

/* 데스크톱에서 480px 기둥이 허공에 뜨지 않도록 양옆에 경계를 준다. */
@media (min-width: 560px) {
  body { background: #eaeef4; }
  .app {
    box-shadow: 0 0 0 1px var(--line), 0 24px 60px -30px rgba(16, 28, 51, .28);
  }
}

/* ── 상단 바 ─────────────────────────────────────────── */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--navy);
  color: #fff;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -.02em;
}

.appbar h1 { font-size: 16.5px; font-weight: 700; margin: 0; flex: 1; }
.appbar .sub { font-size: 12px; opacity: .7; font-weight: 500; letter-spacing: 0; }

.appbar button {
  background: rgba(255, 255, 255, .16);
  border: 0;
  color: #fff;
  border-radius: 8px;
  padding: 8px 11px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.appbar button:active { background: rgba(255, 255, 255, .26); }

/*
 * 승인 대기.
 *
 * 상단 바 전체를 주황으로 칠했더니 화면이 「경고」로 읽혔다 — 이 상태는 사고가 아니라
 * **차례**다. 그래서 바는 남색(사실)으로 두고, 그 아래 붙는 호박색 띠가 차례를 말한다.
 * 바는 sticky 라 스크롤을 내려도 띠가 따라오므로 신호는 그대로 유지된다.
 */
.appbar.hold { box-shadow: inset 0 -3px 0 #d08a2c; }
.appbar.hold::after {
  content: '내 승인을 기다리는 중';
  position: absolute;
  left: 0; right: 0; top: 100%;
  background: #fdf3e3;
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 16px;
  border-bottom: 1px solid var(--amber-line);
}
.appbar { position: sticky; }

.screen { padding: 16px; }

/* ── 아이콘 ──────────────────────────────────────────── */
/*
 * 이모지를 쓰지 않는다. `.g` 는 SVG 를 담는 상자이고, 크기는 쓰는 자리가 정한다.
 * SVG 는 currentColor 를 따르므로 색은 문맥이 정한다 — 아이콘이 스스로 색을 갖지 않는다.
 */
.g {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 0;
}
.g svg { width: 1em; height: 1em; display: block; }
.g svg [stroke] { vector-effect: non-scaling-stroke; }

/* ── 카드 ────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.card > h2 {
  margin: 0 0 4px;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.card > .lead { margin: 0 0 14px; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.card.flat { box-shadow: none; }

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: .01em;
  margin: 0 0 8px;
}

/* ── 증상 격자 ───────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }

.tile {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 14px 7px 12px;
  text-align: center;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-height: 84px;
  transition: border-color .12s ease, background .12s ease, transform .12s ease;
}
.tile:active { transform: scale(.97); }
.tile .glyph { font-size: 22px; line-height: 1; color: var(--ink-2); }
.tile .t { font-size: 12.5px; font-weight: 600; }
.tile .s { font-size: 11.5px; color: var(--ink-3); }
.tile[aria-pressed="true"] { border-color: var(--navy); background: var(--navy-soft); box-shadow: inset 0 0 0 1px var(--navy); }
.tile[aria-pressed="true"] .glyph { color: var(--navy); }
.tile:disabled { opacity: .42; cursor: not-allowed; }

/* ── 금액 ────────────────────────────────────────────── */
.amount-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
}
.amount-box .label { font-size: 13.5px; color: var(--ink-2); }
.amount-box .value { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }

/*
 * 이 화면에서 가장 큰 글자. 「승인하면 얼마가 확정되는가」는 한 번에 읽혀야 하고,
 * 다른 어떤 숫자도 이보다 크면 안 된다.
 */
.total-box {
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  border-radius: 14px;
  padding: 18px 16px;
  text-align: center;
  margin-bottom: 14px;
}
.total-box .label {
  font-size: 12.5px; color: var(--green-ink); font-weight: 700;
  letter-spacing: .01em; opacity: .85;
}
.total-box .value {
  display: block;
  font-size: 36px;
  font-weight: 800;
  color: var(--green-ink);
  letter-spacing: -.03em;
  line-height: 1.15;
  margin-top: 4px;
}

.notice {
  background: var(--amber-soft);
  border: 1px solid var(--amber-line);
  color: var(--amber);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-top: 10px;
}
.notice.plain { background: var(--navy-soft); border-color: var(--navy-line); color: #33445e; }
.notice.danger { background: var(--red-soft); border-color: var(--red-line); color: var(--red); }

/* ── 키·값 ───────────────────────────────────────────── */
.kv { display: grid; gap: 9px; }
.kv .row { display: flex; gap: 12px; align-items: baseline; }
.kv .row .k { flex: 0 0 84px; font-size: 12.5px; color: var(--ink-3); }
.kv .row .v { flex: 1; font-size: 14px; line-height: 1.5; }
.kv .row .v.strong { font-weight: 700; }

/* ── 기사 ────────────────────────────────────────────── */
.tech {
  display: flex; gap: 12px; align-items: center;
  border: 1px solid var(--line); border-radius: 12px; padding: 13px;
}
.tech .avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--navy-soft); color: var(--navy);
  display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: 0 0 auto;
}
.tech .name { font-weight: 700; font-size: 14.5px; }
.tech .meta { font-size: 12px; color: var(--ink-2); }
.tech .stats { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.tech .stats b { color: var(--ink); }

/* ── 항목별 견적 ─────────────────────────────────────── */
.items { display: grid; gap: 9px; }
.item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; }
.item.picked { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.item .head { display: flex; gap: 10px; align-items: flex-start; }
.item .head .name { flex: 1; font-size: 13.5px; font-weight: 600; }
.item .head .mark {
  width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid var(--line); background: #fff;
  display: grid; place-items: center; font-size: 11px; color: transparent; flex: 0 0 auto;
}
.item.picked .head .mark { background: var(--green); border-color: var(--green); color: #fff; }
.item .lines { margin-top: 8px; display: grid; gap: 4px; }
.item .lines div { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); }
.item .lines div.sum { color: var(--ink); font-weight: 700; border-top: 1px solid var(--line); padding-top: 6px; margin-top: 4px; }
.item .flag { font-size: 11.5px; color: var(--amber); margin-top: 6px; }

/* ── 확인 목록 ───────────────────────────────────────── */
.checklist { display: grid; gap: 10px; }
.checklist .li { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.5; }
.checklist .li .box {
  width: 20px; height: 20px; border-radius: 6px;
  background: var(--green); color: #fff;
  display: grid; place-items: center; font-size: 11px; flex: 0 0 auto; margin-top: 2px;
}
.checklist .li.warn .box { background: var(--amber); }
.checklist .li .txt b { display: block; font-weight: 700; }
.checklist .li .txt span { color: var(--ink-2); }

/* ── 진행 ────────────────────────────────────────────── */
.steps { display: grid; gap: 8px; }
.steps .s { display: flex; gap: 10px; font-size: 13.5px; align-items: center; }
.steps .s .dot { width: 18px; display: grid; place-items: center; color: var(--green); font-weight: 700; }
.steps .s.todo .dot { color: var(--ink-3); }
.steps .s.todo { color: var(--ink-2); }

/* ── 사진 ────────────────────────────────────────────── */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: var(--navy-soft); border: 1px solid var(--line);
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .tag {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(16,28,51,0), rgba(16,28,51,.82));
  color: #fff; font-size: 10px; padding: 10px 4px 3px; text-align: center;
}
.photo.pending .tag { background: linear-gradient(180deg, rgba(154,91,10,0), rgba(154,91,10,.9)); }
.photo-empty {
  border: 1px dashed var(--line); border-radius: 10px; padding: 20px;
  text-align: center; font-size: 12.5px; color: var(--ink-3);
}

/* ── 버튼 ────────────────────────────────────────────── */
.actions { display: flex; gap: 10px; margin-top: 14px; }
.actions.stack { flex-direction: column; }

.btn {
  flex: 1;
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  min-height: var(--tap);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
  cursor: pointer;
  background: var(--navy);
  color: #fff;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform .1s ease, filter .12s ease;
}
.btn:active { transform: scale(.985); filter: brightness(.94); }
.btn.approve { background: var(--green); box-shadow: 0 6px 16px -8px rgba(21, 128, 61, .8); }
.btn.reject { background: #fff; color: var(--red); border: 1px solid var(--red-line); }
.btn.ghost { background: #fff; color: var(--ink-2); border: 1px solid var(--line); font-weight: 600; }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none; filter: none; }
.btn.wide { width: 100%; display: flex; }
.btn-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── 목록 ────────────────────────────────────────────── */
.list { display: grid; gap: 10px; }
.entry {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
  display: block; text-decoration: none; color: inherit; cursor: pointer;
  text-align: left; font: inherit; width: 100%;
  transition: transform .1s ease, box-shadow .15s ease;
}
.entry:active { transform: scale(.99); box-shadow: var(--shadow-lift); }
.entry .top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.entry .top .trade {
  font-size: 11.5px; color: var(--navy); background: var(--navy-soft);
  padding: 3px 8px; border-radius: 999px; font-weight: 700;
}
.entry .sym { font-size: 14.5px; font-weight: 600; }
.entry .meta { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

.pill {
  font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--navy-soft); color: #33445e; margin-left: auto; white-space: nowrap;
}
.pill.hold { background: #fdf3e3; color: var(--amber); }
.pill.done { background: var(--green-soft); color: var(--green-ink); }
.pill.dead { background: #eef0f3; color: var(--ink-3); }

/* ── 타임라인 ────────────────────────────────────────── */
.timeline { display: grid; gap: 0; }
.tl {
  display: grid; grid-template-columns: 72px 1fr; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line-2); font-size: 13.5px;
}
.tl:last-child { border-bottom: 0; }
.tl .when { font-size: 11.5px; color: var(--ink-3); }
.tl .what b { display: block; }
.tl .what span { color: var(--ink-2); font-size: 12.5px; }
.tl .what .amt { font-weight: 700; color: var(--navy); }
.tl .what .amt.neg { color: var(--red); }

/* ── 입력 ────────────────────────────────────────────── */
.field { margin-bottom: 13px; }
.field > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  font: inherit;
  font-size: 15px;               /* 16px 미만이면 iOS 가 확대한다 → 15px 유지 + 확대 방지는 viewport 가 맡는다 */
  background: #fff;
  color: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover, select:hover, textarea:hover { border-color: #ccd4e0; }
textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27, 42, 74, .12);
}
.hint { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; line-height: 1.5; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.choice { display: grid; gap: 8px; }
.choice label {
  display: flex; gap: 10px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; font-size: 13.5px; cursor: pointer; background: #fff;
  min-height: var(--tap);
}
.choice label:has(input:checked) { border-color: var(--navy); background: var(--navy-soft); box-shadow: inset 0 0 0 1px var(--navy); }
.choice input { width: auto; accent-color: var(--navy); }

/* ── 하단 탭바 ───────────────────────────────────────── */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  padding: 9px 0 10px; text-align: center; text-decoration: none;
  color: var(--ink-3); font-size: 11px; font-weight: 600;
  display: grid; gap: 3px; justify-items: center; min-height: var(--tap);
}
.tabbar a .g { font-size: 21px; }
.tabbar a[aria-current="page"] { color: var(--navy); }

/* ── 안내 ────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 24px; color: var(--ink-3); font-size: 13.5px; }
.empty .g { font-size: 34px; display: flex; margin: 0 auto 12px; color: #b6c0cd; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--navy-deep); color: #fff;
  padding: 12px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  z-index: 50; max-width: 92vw; box-shadow: 0 12px 30px -8px rgba(16, 28, 51, .5);
}
.toast.err { background: var(--red); }

/* ── 첫 화면 ─────────────────────────────────────────── */
/*
 * 브랜드를 말한다. 이전 화면은 「추가비 사전승인 플랫폼」이라는 기능 설명만 있고
 * 제품 이름이 없었다 — 고객이 카톡으로 받은 링크를 열었을 때 무엇을 여는 것인지
 * 알 수 없다는 뜻이다.
 */
.hero {
  background:
    radial-gradient(120% 100% at 85% 0%, #2c4270 0%, transparent 60%),
    var(--navy);
  color: #fff;
  padding: 30px 20px 30px;
  position: relative;
  overflow: hidden;
}

.brand { display: flex; align-items: center; gap: 9px; margin-bottom: 20px; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: #fff; color: var(--navy);
  display: grid; place-items: center; flex: 0 0 auto;
}
.brand .mark svg { width: 18px; height: 18px; }
.brand .name { font-size: 15.5px; font-weight: 800; letter-spacing: -.02em; }
.brand .name em { font-style: normal; opacity: .55; font-weight: 600; margin-left: 6px; font-size: 12.5px; letter-spacing: 0; }

.hero h1 {
  margin: 0 0 8px;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -.035em;
  line-height: 1.32;
}
.hero p { margin: 0; opacity: .76; font-size: 13.5px; line-height: 1.6; }

.roles { display: grid; gap: 10px; padding: 16px 16px 6px; }

.role {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  display: flex;
  gap: 13px;
  align-items: center;
  transition: transform .1s ease, box-shadow .15s ease;
}
.role:active { transform: scale(.99); box-shadow: var(--shadow-lift); }
.role .g {
  font-size: 20px;
  width: 42px; height: 42px; border-radius: 11px;
  background: var(--navy-soft); color: var(--navy);
}
.role .txt { flex: 1; min-width: 0; }
/* 누를 수 없는 안내 줄. 링크처럼 보이면 눌러 보고 아무 일이 없어 실망한다. */
.role.as-note { background: var(--navy-soft); border-color: var(--navy-line); box-shadow: none; }
.role.as-note .g { background: #fff; }
.role.as-note span span { color: #3c4c66; }
/* 화살표는 아이콘 상자가 아니라 글자 크기의 표식이다. */
.role .go { width: auto; height: auto; background: none; font-size: 17px; color: var(--ink-3); }
.role b { display: block; font-size: 15.5px; letter-spacing: -.02em; }
.role span { font-size: 12.5px; color: var(--ink-2); }
.role .go { color: var(--ink-3); font-size: 16px; }

.values { padding: 10px 16px 28px; display: grid; gap: 8px; }

/*
 * 반드시 `.values` 안으로 좁힌다. 그냥 `.value` 로 두면 금액의 `.total-box .value`
 * 까지 흰 상자로 칠해 버린다 — 실제로 그랬고, 승인 금액이 액자에 갇혀 보였다.
 */
.values .value {
  display: flex;
  gap: 11px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px 13px;
  font-size: 13.5px;
}
.values .value .g { font-size: 17px; color: var(--navy); }

/* 개발용 진입은 공개 화면에 두지 않는다. `?dev=1` 로 열 때만 보인다. */
.dev-only { display: none; }
body.dev .dev-only { display: grid; }

/* ── 인쇄 ────────────────────────────────────────────── */
@media print {
  body { background: #fff; }
  .app { box-shadow: none; max-width: none; }
}

/* ── 움직임을 줄이도록 설정한 사용자 ─────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
