/* 생활관 민원 웹앱 - 휴대폰 우선 */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #667085;
  --line: #e3e6eb;
  --brand: #1f4e8c;
  --brand-dark: #173c6c;
  --ok: #1e7a46;
  --ok-bg: #e5f4ec;
  --doing: #9a5b00;
  --doing-bg: #fff3dc;
  --new: #b42318;
  --new-bg: #fde8e7;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 16px; line-height: 1.55;
  word-break: keep-all; overflow-wrap: break-word;
}
img, svg, video { max-width: 100%; }
a { color: var(--brand); }
header.top {
  background: var(--brand); color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 12px calc(16px + env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
header.top a { color: #fff; text-decoration: none; }
header.top .title { font-weight: 700; font-size: 17px; }
header.top nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 15px; }
header.top nav form { margin: 0; }
header.top nav button { background: none; border: 1px solid rgba(255,255,255,.6); color: #fff;
  border-radius: 6px; padding: 8px 12px; min-height: 40px; font-size: 14px; cursor: pointer; }
header.top nav a { display: inline-flex; align-items: center; min-height: 40px; white-space: nowrap; }
header.top nav .user { opacity: .85; }
.demo-banner { background: #fff3dc; color: #7a4a00; text-align: center; font-size: 13px; padding: 4px 8px; }
main { max-width: 760px; margin: 0 auto;
  padding: 16px calc(16px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
main.wide { max-width: 1100px; }
h1 { font-size: 21px; margin: 4px 0 14px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; }
.muted { color: var(--muted); font-size: 14px; }
.flash { background: #e8f0fb; border: 1px solid #c6d7f1; color: #173c6c; padding: 10px 12px;
  border-radius: 8px; margin-bottom: 12px; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }
label .req { color: var(--new); }
label .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input[type=text], input[type=tel], input[type=search], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #c9ced6; border-radius: 8px; background: #fff;
  min-width: 0; min-height: 46px;
}
input[type=file] { font: inherit; width: 100%; max-width: 100%; min-width: 0; }
textarea { min-height: 110px; resize: vertical; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
.row > div label { margin-top: 14px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 5px; }
.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 8px;
  padding: 11px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center; }
.btn:hover { background: var(--brand-dark); }
.btn.block { display: block; width: 100%; }
.btn.light { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.small { padding: 8px 14px; min-height: 42px; font-size: 14px; }

.badge { display: inline-block; font-size: 13px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge.s-접수 { background: var(--new-bg); color: var(--new); }
.badge.s-처리중 { background: var(--doing-bg); color: var(--doing); }
.badge.s-완료 { background: var(--ok-bg); color: var(--ok); }
.tag { display: inline-block; font-size: 12px; background: #eef1f5; color: #475467; padding: 1px 8px; border-radius: 6px; }

ul.items { list-style: none; padding: 0; margin: 0; }
ul.items li { border-bottom: 1px solid var(--line); }
ul.items li:last-child { border-bottom: 0; }
ul.items a { display: block; padding: 12px 2px; color: inherit; text-decoration: none; }
.line1 { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.line1 > :first-child { min-width: 0; }
.line1 .badge { flex: none; }
ul.items .where { font-weight: 600; }

dl.info { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 6px 10px; margin: 0; }
dl.info dt { color: var(--muted); font-size: 14px; }
dl.info dd { margin: 0; }
.content { white-space: pre-wrap; }
.content, .url, dl.info dd, .where { overflow-wrap: anywhere; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.photos img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.thread .msg { border-left: 3px solid var(--line); padding: 6px 0 6px 12px; margin: 10px 0; }
.thread .msg.office { border-color: var(--brand); }
.thread .msg.internal { border-color: #b08400; background: #fffaf0; }
.thread .who { font-size: 14px; font-weight: 700; }
.thread .who span { font-weight: 400; color: var(--muted); }

table.list { width: 100%; border-collapse: collapse; background: #fff; font-size: 15px; }
table.list th, table.list td { border-bottom: 1px solid var(--line); padding: 9px 8px; text-align: left; vertical-align: top; }
table.list th { background: #f0f2f5; font-size: 14px; color: #475467; white-space: nowrap; }
table.list tr:hover td { background: #f9fafb; }
table.list td.num, table.list th.num { text-align: right; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters select, .filters input { width: auto; max-width: 100%; padding: 7px 10px; min-height: 42px; }
.table-wrap { max-width: 100%; overflow-x: auto; }
.counts { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.counts a { flex: 1 1 120px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; text-decoration: none; color: inherit; }
.counts b { display: block; font-size: 24px; }
.pager { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.pager a, .pager span { padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; text-decoration: none; }
.pager span { background: var(--brand); color: #fff; border-color: var(--brand); }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.bar { display: grid; grid-template-columns: 90px minmax(0, 1fr) 40px; gap: 8px; align-items: center; margin: 6px 0; font-size: 14px; }
.bar .track { background: #eef1f5; border-radius: 4px; height: 16px; overflow: hidden; }
.bar .fill { background: var(--brand); height: 100%; }
.bar .n { text-align: right; font-variant-numeric: tabular-nums; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpis div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpis b { display: block; font-size: 24px; }

.qr-sheet { text-align: center; }
.qr-sheet svg { display: block; width: min(320px, 100%); height: auto; aspect-ratio: 1; margin: 0 auto; }
/* 휴대폰과 세로 태블릿: 넓은 표를 카드로 바꾼다 */
@media screen and (max-width: 900px) {
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack { background: none; }
  table.stack thead { display: none; }
  table.stack tr { background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 8px 14px; margin-bottom: 10px; }
  table.stack td { border: 0; padding: 4px 0; }
  table.stack td[data-label] { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px; overflow-wrap: anywhere; }
  table.stack td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 14px; }
  table.stack td > .badge, table.stack td > .tag { justify-self: start; align-self: center; }
}
@media (max-width: 480px) {
  .row { grid-template-columns: minmax(0, 1fr); }
  .counts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters select, .filters input { width: 100%; }
  .filters input[type=search], .filters a.btn.light { grid-column: 1 / -1; }
  .filters > a:not(.btn) { align-self: center; text-align: center; }
  table.list:not(.stack) th { white-space: normal; }
  table.list:not(.stack) th, table.list:not(.stack) td { padding: 8px 4px; font-size: 13px; }
}

@media print {
  header.top, .demo-banner, .noprint { display: none !important; }
  body { background: #fff; }
  .card { border: 0; }
}

/* 넓은 화면의 표: 띄어쓰기 없는 긴 글도 칸 안에서 줄바꿈 */
@media screen and (min-width: 901px) {
  table.stack td > div { min-width: 100px; overflow-wrap: anywhere; }
  table.stack td:not(:has(> div)) { white-space: nowrap; }
}
