/* AS접수_테스트 — mobile-first */
:root {
  --bg: #f4f6f9; --card: #fff; --ink: #111827; --sub: #4b5563; --muted: #8a94a3; --line: #e5e9f0;
  --pri: #0b5cab; --pri-2: #e8f1fb; --ok: #0f8a5f; --ok-2: #e6f6ef; --warn: #b45309; --warn-2: #fdf3e2;
  --bad: #c2410c; --bad-2: #fdece4; --new: #4f46e5; --new-2: #eef0fe;
  --r: 14px; --sh: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; letter-spacing: -0.01em; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
a { color: var(--pri); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }

/* header */
.top { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1180px; margin: 0 auto; height: 56px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #0b5cab, #3b82f6); color: #fff; font-weight: 800; font-size: 13px; display: grid; place-items: center; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt b { font-size: 15px; }
.brand-txt small { font-size: 12px; color: var(--muted); }
.top-nav { display: none; gap: 4px; align-items: center; }
.top-nav a, .top-nav button { padding: 8px 12px; border-radius: 10px; color: var(--sub); font-weight: 600; font-size: 14px; background: none; border: 0; cursor: pointer; }
.top-nav a.on, .top-nav a:hover { background: var(--pri-2); color: var(--pri); }
.top-nav .who { color: var(--muted); font-weight: 500; font-size: 13px; padding: 0 6px; }

/* bottom tab bar (mobile) */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 8px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--pri); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }
.loading, .empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* cards & blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); padding: 18px; }
.card + .card, .stack > * + * { margin-top: 14px; }
.card h2 { font-size: 17px; margin-bottom: 12px; }
.sec-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 22px 2px 10px; }
.sec-title h2 { font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* hero */
.hero { background: linear-gradient(140deg, #0b5cab 0%, #2563eb 60%, #60a5fa 100%); color: #fff; border-radius: 20px; padding: 26px 20px 22px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255,255,255,.12); }
.hero h1 { font-size: 24px; line-height: 1.3; }
.hero p { margin: 8px 0 18px; opacity: .9; font-size: 14.5px; }
.hero .btns { display: grid; gap: 10px; position: relative; z-index: 1; }
.hero .btn { justify-content: center; }
.hero .btn-light { background: #fff; color: var(--pri); }
.hero .btn-ghost { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.35); }

.steps4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 4px; }
.steps4 div { text-align: center; font-size: 12.5px; color: var(--sub); }
.steps4 i { display: grid; place-items: center; width: 38px; height: 38px; margin: 0 auto 6px; border-radius: 12px; background: var(--pri-2); color: var(--pri); font-style: normal; font-weight: 800; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent; background: var(--pri); color: #fff; font-weight: 700; font-size: 15.5px; cursor: pointer; transition: transform .05s, filter .15s; text-align: center; justify-content: center; }
.btn:active { transform: translateY(1px); }
.btn:hover { filter: brightness(1.05); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-line { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-soft { background: var(--pri-2); color: var(--pri); }
.btn-danger { background: #fff; color: var(--bad); border-color: #f3c6b4; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn-block { width: 100%; }
.row-btns { display: flex; gap: 10px; }
.row-btns > * { flex: 1; }

/* forms */
.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field > label em { color: var(--bad); font-style: normal; margin-left: 2px; }
.input, select.input, textarea.input { width: 100%; min-height: 48px; padding: 11px 14px; border: 1px solid #d5dbe4; border-radius: 12px; background: #fff; font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { min-height: 130px; resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(11,92,171,.15); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.grid2 { display: grid; gap: 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid #d5dbe4; background: #fff; font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--pri); border-color: var(--pri); color: #fff; }
.chip.ai { border-style: dashed; border-color: #a5b4fc; color: var(--new); background: var(--new-2); }
.chip.quick { min-height: 34px; font-size: 13px; font-weight: 500; color: var(--sub); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 700; cursor: pointer; }
.seg button.on { color: #fff; }

/* wizard */
.wiz-head { display: flex; gap: 6px; margin-bottom: 16px; }
.wiz-head div { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.wiz-head div.on { background: var(--pri); }
.wiz-title { font-size: 20px; margin-bottom: 4px; }
.wiz-sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.wiz-foot { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); padding: 14px 0 4px; display: flex; gap: 10px; }
.wiz-foot .btn { flex: 1; }

/* photos */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #eef1f5; border: 1px solid var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .pdf { display: grid; place-items: center; height: 100%; font-weight: 800; color: var(--bad); font-size: 13px; text-align: center; padding: 6px; word-break: break-all; }
.photo button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 14px; line-height: 1; }
.add-photo { aspect-ratio: 1; border-radius: 12px; border: 1.5px dashed #b8c2d0; background: #fafbfc; display: grid; place-items: center; text-align: center; color: var(--sub); font-size: 13px; font-weight: 600; cursor: pointer; }
.add-photo svg { width: 26px; height: 26px; display: block; margin: 0 auto 4px; color: var(--pri); }

/* review table */
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; white-space: pre-wrap; }

/* status badge */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-접수 { background: var(--new-2); color: var(--new); }
.st-진행 { background: var(--warn-2); color: var(--warn); }
.st-미수 { background: var(--bad-2); color: var(--bad); }
.st-완료 { background: var(--ok-2); color: var(--ok); }
.seg button.on.st-접수 { background: var(--new); border-color: var(--new); }
.seg button.on.st-진행 { background: var(--warn); border-color: var(--warn); }
.seg button.on.st-미수 { background: var(--bad); border-color: var(--bad); }
.seg button.on.st-완료 { background: var(--ok); border-color: var(--ok); }

/* request list (customer) */
.req { display: block; color: inherit; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 15px 16px; box-shadow: var(--sh); }
.req + .req { margin-top: 10px; }
.req .r1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.req .r2 { font-weight: 700; font-size: 16px; margin: 6px 0 10px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--pri); border-radius: 3px; }

/* timeline */
.tl { display: grid; grid-template-columns: repeat(4, 1fr); position: relative; margin: 8px 0 4px; }
.tl::before { content: ""; position: absolute; left: 12.5%; right: 12.5%; top: 14px; height: 3px; background: var(--line); }
.tl .fill { position: absolute; left: 12.5%; top: 14px; height: 3px; background: var(--pri); transition: width .3s; }
.tl div { text-align: center; position: relative; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tl div i { display: grid; place-items: center; width: 30px; height: 30px; margin: 0 auto 6px; border-radius: 50%; background: #fff; border: 2px solid var(--line); font-style: normal; font-size: 13px; }
.tl div.done i { background: var(--pri); border-color: var(--pri); color: #fff; }
.tl div.cur { color: var(--pri); }
.tl div.cur i { border-color: var(--pri); color: var(--pri); box-shadow: 0 0 0 4px rgba(11,92,171,.15); }

/* thread */
.thread { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 14px; background: #f1f4f8; font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.msg .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.msg.me { align-self: flex-end; background: var(--pri); color: #fff; }
.msg.me .meta { color: rgba(255,255,255,.75); }
.msg.memo { align-self: stretch; max-width: none; background: #fff8e6; border: 1px dashed #f0c36d; }
.msg .photos { margin-top: 8px; grid-template-columns: repeat(3, 72px); }
.sys { align-self: center; font-size: 12.5px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; white-space: pre-wrap; text-align: center; }
.sys.internal { border-style: dashed; }
.composer { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.composer textarea { flex: 1; min-height: 48px; max-height: 160px; }
.composer .icon-btn { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; cursor: pointer; color: var(--sub); }
.composer .icon-btn svg { width: 22px; height: 22px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--sub); margin-top: 8px; cursor: pointer; }

/* receipt done */
.done-box { text-align: center; padding: 30px 18px; }
.done-box .check { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-2); color: var(--ok); display: grid; place-items: center; margin: 0 auto 14px; }
.done-box .no { font-size: 26px; font-weight: 800; letter-spacing: .02em; margin: 6px 0 4px; color: var(--pri); }

/* admin */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 13px 14px; text-align: left; cursor: pointer; box-shadow: var(--sh); }
.stat b { display: block; font-size: 24px; line-height: 1.2; }
.stat span { font-size: 13px; color: var(--sub); font-weight: 600; }
.stat.on { outline: 2px solid var(--pri); }
.stat.alert b { color: var(--bad); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px -16px; padding: 10px 16px; position: sticky; top: 56px; z-index: 10; background: rgba(244,246,249,.96); backdrop-filter: blur(8px); }
.filters > input[type=search] { grid-column: 1 / -1; }
.filters .more { grid-column: 1 / -1; }
/* 휴대폰 카드: 과업명을 맨 위에 */
.atable tbody tr { display: flex; flex-direction: column; }
.atable td.t { order: -1; }
.atable td.num { font-variant-numeric: tabular-nums; }
.atable th.sortable { cursor: pointer; user-select: none; }
.atable th.sortable:hover { color: var(--pri); }
.atable th.sortable.on { color: var(--pri); }
.atable th .arr { font-size: 11px; opacity: .6; }
.atable th.on .arr { opacity: 1; }
.filters .sort-sel { grid-column: 1 / -1; }
.stat.mine { border-color: #bcd3f0; background: var(--pri-2); }
.atable td.act { justify-content: flex-end; padding-top: 8px; }
.atable td.act::before { content: none; }
.atable td.act:empty { display: none; }
.ai-card { border-color: #c7d2fe; background: linear-gradient(180deg, #f7f7ff, #fff 60%); }
.ai-text { white-space: pre-wrap; font-size: 14.5px; line-height: 1.65; }
.urg { display: inline-block; padding: 1px 8px; margin-right: 6px; border-radius: 6px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 700; vertical-align: 1px; }
.urg.soft { background: var(--pri-2); color: var(--pri); }
.quick { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px 0; margin-bottom: 14px; }
.quick .seg button { min-height: 48px; font-size: 15px; }
.filters .input { min-height: 44px; }
.filters .more { display: none; gap: 8px; grid-template-columns: 1fr 1fr; }
.filters.open .more { display: grid; }
.atable { width: 100%; border-collapse: separate; border-spacing: 0; }
.atable thead { display: none; }
.atable tr { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--sh); cursor: pointer; }
.atable td { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 14px; }
.atable td::before { content: attr(data-l); color: var(--muted); font-size: 13px; flex: 0 0 auto; }
.atable td.t { font-weight: 700; font-size: 15.5px; display: block; padding-bottom: 6px; }
.atable td.t::before { content: none; }
.dot-new { display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; margin-left: 6px; vertical-align: 2px; }
.admin-grid { display: grid; gap: 14px; }
.panel .field > label { font-size: 13px; color: var(--sub); }
.panel .input { min-height: 44px; font-size: 15px; }
.save-bar { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 5; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 10px; box-shadow: 0 -4px 20px rgba(0,0,0,.06); display: none; gap: 8px; align-items: center; margin-top: 12px; }
.save-bar.show { display: flex; }
.save-bar span { flex: 1; font-size: 13.5px; color: var(--sub); padding-left: 6px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--sub); font-weight: 600; font-size: 14px; margin-bottom: 10px; }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: #111827; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.notice { background: var(--pri-2); color: #0b4a8a; border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.notice.warn { background: var(--warn-2); color: #8a4b09; }

@media (min-width: 720px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .hero { padding: 40px 36px 34px; }
  .hero h1 { font-size: 30px; }
  .hero .btns { grid-template-columns: max-content max-content; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .photos { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 960px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .top-nav { display: flex; }
  .wrap { padding: 24px; }
  .wiz-foot, .save-bar { bottom: 12px; }
  .toast { bottom: 28px; }
  .narrow { max-width: 720px; margin: 0 auto; }
  .stats { grid-template-columns: repeat(7, 1fr); }
  .filters { grid-template-columns: 1fr 160px 160px auto auto; align-items: center; margin: 14px 0; padding: 10px 0; top: 56px; }
  .filters > input[type=search] { grid-column: auto; }
  .atable tbody tr { display: table-row; }
  /* PC 표: 과업명 칸도 다른 칸과 같은 줄에 (휴대폰 카드용 block 해제) */
  .atable td.t { display: table-cell; vertical-align: middle; min-width: 240px; max-width: 360px; }
  .atable td.co { min-width: 150px; max-width: 220px; }
  .atable td, .atable th { vertical-align: middle; padding-top: 10px; padding-bottom: 10px; }
  .atable td.act .btn { white-space: nowrap; }
  /* 긴 업체명·과업명은 최대 2줄, 마우스를 올리면 전체 */
  .atable .clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; word-break: keep-all; overflow-wrap: anywhere; }
  /* 관리 목록은 PC에서 넓게 써서 열이 잘리지 않게 */
  body.mode-admin .wrap { max-width: 1680px; }
  body.mode-admin .top-in { max-width: 1680px; }
  .atable td.nw, .atable th { white-space: nowrap; }
  .atable td.num { text-align: right; }
  .tbl-card { overflow-x: auto; }
  .atable td.act { display: table-cell; text-align: right; }
  .atable td.act:empty { display: table-cell; }
  .filters .more { grid-column: 1 / -1; grid-template-columns: repeat(4, 1fr); }
  .atable thead { display: table-header-group; }
  .atable tr { display: table-row; box-shadow: none; border: 0; padding: 0; margin: 0; }
  .atable th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
  .atable td { display: table-cell; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; background: #fff; }
  .atable td::before { content: none; }
  .atable td.t { font-size: 14.5px; padding-bottom: 12px; }
  .atable tbody tr:hover td { background: #f7faff; }
  .tbl-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--sh); }
  .admin-grid { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
  .admin-grid .panel { position: sticky; top: 72px; }
}
.brief summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.brief summary::-webkit-details-marker { display: none; }
.brief summary::after { content: '▾'; margin-left: auto; color: var(--muted); }
.brief[open] summary { margin-bottom: 10px; }
.brief-sec + .brief-sec { margin-top: 12px; }
.brief-h { font-weight: 700; font-size: 13.5px; margin-bottom: 4px; }
.brief-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; padding: 7px 0; border-top: 1px dashed var(--line); color: var(--ink); font-size: 14px; align-items: baseline; }
.brief-row .brief-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brief-row .muted { font-size: 12.5px; }
.tpl { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: #fbfcfe; }
@media (max-width: 480px) { .brief-row { grid-template-columns: 1fr auto; } .brief-row > :first-child { display: none; } }