:root {
  --bg: #f4f5f7; --card: #fff; --text: #1b1f24; --muted: #6b7280;
  --accent: #2563eb; --ok: #15803d; --okbg: #e8f5ec; --warn: #b45309; --warnbg: #fdf1e0;
  --line: #d9dde3; --err: #c62828;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --card: #1c2128; --text: #e8eaed; --muted: #9aa3ad;
    --accent: #6ea0ff; --ok: #5fd08a; --okbg: #17301f; --warn: #f0b062; --warnbg: #3a2b14;
    --line: #333b45; --err: #ff7b7b;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
.app { max-width: 520px; margin: 0 auto; padding: 16px; padding-bottom: 24px; }
.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 8px; }
h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { margin: 0 0 12px; font-size: 18px; }
.link { background: none; border: 0; color: var(--muted); font-size: 14px; padding: 8px; }
.banner { background: var(--warnbg); color: var(--warn); padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }

.search { background: var(--card); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.phone { display: flex; align-items: center; gap: 6px; }
.phone .fixed { font-size: 28px; font-weight: 700; padding: 0 4px; color: var(--muted); }
.phone .dash { font-size: 24px; color: var(--muted); }
.phone input {
  flex: 1; min-width: 0; width: 100%; font-size: 28px; font-weight: 700; text-align: center;
  letter-spacing: 2px; padding: 12px 4px; border: 2px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text);
}
.phone input:focus { outline: none; border-color: var(--accent); }
.phone.small .fixed { font-size: 20px; }
.phone.small input { font-size: 20px; padding: 10px 4px; }

button { font: inherit; cursor: pointer; }
.ghost { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px; }
.primary { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 12px; font-weight: 600; }

.status { color: var(--muted); font-size: 14px; margin: 14px 4px 8px; min-height: 20px; }
.results { display: flex; flex-direction: column; gap: 10px; }
.person { background: var(--card); border-radius: 14px; padding: 14px 16px; border-left: 5px solid var(--warn); }
.person .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.person .name { font-size: 20px; font-weight: 700; }
.person .num { color: var(--muted); font-size: 14px; }
.person .count { display: inline-block; background: var(--warnbg); color: var(--warn); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; margin: 6px 0; }
.person ul { margin: 4px 0 0; padding: 0; list-style: none; font-size: 15px; }
.person li { padding: 5px 0; border-top: 1px solid var(--line); }
.person li .l1 { display: flex; justify-content: space-between; gap: 8px; }
.person li .l2 { font-size: 13px; color: var(--muted); margin-top: 2px; word-break: keep-all; }
.person li .d { color: var(--muted); white-space: nowrap; }
.none { background: var(--okbg); color: var(--ok); border-radius: 14px; padding: 16px; font-weight: 600; }


.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; overflow: auto; }
.overlay[hidden], [hidden] { display: none !important; }
.card { background: var(--card); border-radius: 16px; padding: 20px; width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 10px; }
.card input[type=text], .card input[type=email], .card input[type=password], .card input[type=date] {
  font-size: 17px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); width: 100%;
}
.row { display: flex; gap: 8px; } .row > * { flex: 1; }
.err { color: var(--err); font-size: 14px; margin: 0; min-height: 0; }
.err:empty { display: none; }
.import { font-size: 14px; color: var(--muted); }
.hint { margin: 6px 0; font-size: 13px; }

.tools { display: flex; gap: 12px; }
.person li .l1 { align-items: center; }
.person li .del { background: none; border: 0; color: var(--err); font-size: 13px; padding: 2px 6px; margin-left: 4px; }
.person li .d { display: inline-flex; align-items: center; }
.card .row { margin-top: 4px; }
.card hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; width: 100%; }

.card.wide { max-width: 560px; max-height: 92vh; }
.mlist { overflow: auto; max-height: 55vh; display: flex; flex-direction: column; }
.mrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.mrow small { color: var(--muted); display: block; word-break: keep-all; }
.mrow .acts { display: flex; gap: 6px; flex-shrink: 0; }
.mrow button { border: 1px solid var(--line); background: none; color: var(--text); border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.mrow button.del { color: var(--err); }
.row input[type=text] { flex: 2; }
.msec { display: flex; flex-direction: column; gap: 8px; }
.msec h3 { margin: 0; font-size: 15px; color: var(--muted); }
.person li .l2 b { font-weight: 600; color: var(--text); margin-right: 2px; }

/* 모바일 우선: 상단 작은 알약 버튼 */
.tools { margin-left: auto; margin-bottom: 12px; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.pill { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; line-height: 1.2; min-height: 32px; }
.pill.add { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pill[hidden] { display: none; }
.overlay { align-items: flex-start; }
.overlay > .card { margin: auto; }
@media (max-width: 420px) {
  .app { padding: 12px; }
  .card { padding: 16px; }
  .phone input { font-size: 24px; }
  .phone .fixed { font-size: 24px; }
}
.err.ok { color: var(--ok); }

/* 탭 */
.tabs { display: flex; gap: 4px; background: var(--card); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.tab { flex: 1; border: 0; background: none; color: var(--muted); border-radius: 9px; padding: 10px 0; font-weight: 600; font-size: 15px; }
.tab.on { background: var(--accent); color: #fff; }

/* 파일 등록(간단) */
.filerow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filerow .hint { margin: 0; font-size: 12px; color: var(--muted); }
.filebtn { cursor: pointer; display: inline-flex; align-items: center; }
#impMsg { margin: 0; }

/* 전체 목록(게시판) */
.listbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.sorts { display: flex; gap: 6px; }
.sortbtn { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; font-size: 14px; min-height: 36px; }
.sortbtn.on { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.psize select { font-size: 14px; padding: 7px 8px; min-height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); }
.lrows { background: var(--card); border-radius: 14px; padding: 0 14px; }
.lrow { padding: 10px 0; border-top: 1px solid var(--line); }
.lrow:first-child { border-top: 0; }
.lrow .l1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.lrow .nm { font-weight: 700; }
.lrow .ph { color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }
.lrow .dt { color: var(--muted); font-size: 13px; white-space: nowrap; }
.lrow .l2 { font-size: 14px; margin-top: 2px; word-break: keep-all; }
.lrow .l3 { font-size: 13px; color: var(--muted); margin-top: 2px; word-break: keep-all; }
.lrow .l3 b { font-weight: 600; color: var(--text); }
.pager { display: flex; justify-content: center; gap: 4px; margin: 14px 0 4px; flex-wrap: wrap; }
.pager button { min-width: 38px; min-height: 38px; padding: 0 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 10px; font-size: 14px; }
.pager button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.pager button:disabled { opacity: .35; }
.pager .gap { align-self: center; color: var(--muted); padding: 0 2px; }

/* 전화번호 ↔ 날짜 구분 */
.person .num { color: var(--accent); font-weight: 700; font-size: 16px; letter-spacing: .5px; font-variant-numeric: tabular-nums; border: 1px solid var(--accent); border-radius: 8px; padding: 2px 8px; white-space: nowrap; }
.lrow .ph { color: var(--accent); font-weight: 600; }
.person li .d, .lrow .dt { color: var(--muted); font-size: 13px; background: var(--bg); border-radius: 6px; padding: 2px 8px; }
.person li .d small, .lrow .dt small { font-size: 11px; margin-right: 4px; opacity: .8; }

.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; border-radius: 10px; padding: 12px; font-weight: 600; }

/* 사용량 위젯 */
.usage { margin-top: 16px; background: var(--card); border-radius: 14px; padding: 10px 14px; font-size: 14px; }
.usage summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.usage summary::-webkit-details-marker { display: none; }
.usage summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
.usage details[open] summary::after { content: "▴"; }
#usageLine { color: var(--muted); font-size: 13px; }
.ubar { margin-top: 10px; }
.ulabel { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.track { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.track i { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 999px; transition: width .3s; }
.track i.warn { background: var(--warn); }
.track i.bad { background: var(--err); }
.usage .hint { margin: 10px 0 2px; font-size: 12px; color: var(--muted); line-height: 1.5; }

.overlay.solid { background: var(--bg); }
.denied { text-align: center; }
.denied .msg { font-size: 18px; font-weight: 600; margin: 4px 0; }
.denied .hint { word-break: break-all; margin: 0 0 6px; color: var(--muted); }

/* 사용자 관리 */
.urow { display: flex; gap: 8px; }
.urow input { flex: 1; min-width: 0; }
.urow button { flex-shrink: 0; }
.tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--accent); color: #fff; vertical-align: middle; }
.mrow .em { word-break: break-all; }

/* ---------- 설정 팝업(탭) ---------- */
.settings { gap: 8px; }
.stabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 0 -4px; padding: 0 4px; scrollbar-width: none; }
.stabs::-webkit-scrollbar { display: none; }
.stab { flex: 0 0 auto; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); font-size: 15px; padding: 10px 12px; margin-bottom: -1px; white-space: nowrap; }
.stab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.stab[hidden] { display: none; }
.spane { display: flex; flex-direction: column; gap: 8px; overflow: auto; min-height: 0; }
.spane[hidden] { display: none; }
.spane .mlist { max-height: 42vh; }

/* ---------- 로고 / 로그인 화면 ---------- */
.loginCard { align-items: stretch; text-align: center; }
.loginCard h2 { margin: 4px 0 0; }
.loginLogo { min-height: 150px; display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.logoimg { max-width: 100%; max-height: 150px; object-fit: contain; }
.logobox { min-height: 150px; border: 1px dashed var(--line); border-radius: 12px; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 12px; }
.dlogo { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dl-title { font-size: 24px; font-weight: 800; letter-spacing: -.5px; margin-top: 6px; }
.dl-sub { font-size: 13px; color: var(--muted); }
.dl-a { stop-color: var(--accent); }
.dlogo svg { filter: drop-shadow(0 6px 14px rgba(37, 99, 235, .28)); }
.dl-wave path { animation: dlpulse 2.4s ease-in-out infinite; }
.dl-wave path:nth-child(even) { animation-delay: .4s; }
@keyframes dlpulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dl-wave path { animation: none; } }
