:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --line: #e4e8ef;
  --soft: #eef1f6;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #2f55d4;
  --primary-soft: #a9b9ec;
  --green: #1f9254;
  --red: #d14343;
  --notice-bg: #faf3dc;
  --notice-text: #7a5f14;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 12.5px; }
.small { font-size: 12px; }

/* 위쪽 메뉴 */
.topbar { background: var(--bg); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 880px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 22px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-badge { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: #fff; font-weight: 800; font-size: 11px; display: grid; place-items: center; }
.brand-name { font-weight: 800; font-size: 14px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--muted); }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { padding: 6px 10px; border-radius: 8px; font-weight: 600; color: #3a4150; }
.nav a.active, .nav a:hover { background: var(--soft); color: var(--text); }
.top-right { display: flex; align-items: center; gap: 8px; }
.count-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.pill { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.pill.sim { background: var(--notice-bg); color: var(--notice-text); }
.pill.live { background: #e3f4ea; color: var(--green); }

main { max-width: 880px; margin: 0 auto; padding: 22px 16px 60px; }
.page-head { margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 14px; align-items: start; }
.stack { display: grid; gap: 14px; }
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; gap: 8px 12px; }
  .nav { order: 3; flex-basis: 100%; }
  .top-right { margin-left: auto; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(20, 30, 60, 0.04); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-head h2 { margin: 0; }

/* 입력 */
label.field { display: block; font-size: 12.5px; font-weight: 600; color: #4a5160; margin: 12px 0 6px; }
label.field:first-child { margin-top: 0; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=tel], textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 120px; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > .shrink { flex: 0 0 auto; width: auto; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 700; cursor: pointer; width: 100%; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.primary:disabled { background: var(--primary-soft); border-color: var(--primary-soft); cursor: not-allowed; }
.btn.danger { color: var(--red); }
.btn.small { width: auto; padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.link { width: auto; border: none; background: none; color: var(--muted); font-weight: 600; padding: 4px 8px; }
form.inline { display: inline; }

/* 칩 / 세그먼트 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 10px; font-weight: 700; font-size: 12.5px; cursor: pointer; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--soft); border-radius: 10px; padding: 3px; }
.seg input { display: none; }
.seg label { text-align: center; padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 600; color: #5a6170; }
.seg input:checked + label { background: #fff; color: var(--text); font-weight: 800; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.seg a { text-align: center; padding: 8px; border-radius: 8px; font-weight: 600; color: #5a6170; }
.seg a.on { background: #fff; color: var(--text); font-weight: 800; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* 숫자 상자 */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tiles.three { grid-template-columns: repeat(3, 1fr); }
.tile { background: var(--soft); border-radius: 10px; padding: 10px 12px; }
.tile b { display: block; font-size: 20px; line-height: 1.2; }
.tile span { font-size: 12px; color: var(--muted); }
.tile.good b { color: var(--green); }
.tile.bad b { color: var(--red); }

/* 안내 */
.notice { background: var(--notice-bg); color: var(--notice-text); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-weight: 600; }
.flash.ok { background: #e3f4ea; color: var(--green); }
.flash.error { background: #fde8e8; color: var(--red); }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

/* 목록 */
.list { max-height: 420px; overflow: auto; border-top: 1px solid var(--line); }
.list-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--soft); font-size: 13px; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .sub { color: var(--muted); font-size: 12px; }
.tag { display: inline-block; background: var(--soft); border-radius: 6px; padding: 1px 6px; font-size: 11px; margin-right: 3px; color: #4a5160; }
.state { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--soft); white-space: nowrap; }
.state.Sent, .state.Delivered { background: #e3f4ea; color: var(--green); }
.state.Failed { background: #fde8e8; color: var(--red); }
.state.Cancelled { color: var(--muted); }
.send-link { display: block; padding: 8px 10px; border-radius: 10px; }
.send-link:hover, .send-link.on { background: var(--soft); }
.empty { color: var(--muted); padding: 10px 2px; font-size: 13px; }

/* 폰 미리보기 */
.phone { width: 230px; margin: 4px auto 0; border: 6px solid #1f2430; border-radius: 30px; height: 410px; padding: 10px 12px; background: #fff; display: flex; flex-direction: column; }
.phone-status { display: flex; justify-content: space-between; font-size: 10px; font-weight: 700; }
.phone-head { text-align: center; padding: 8px 0 8px; border-bottom: 1px solid var(--soft); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; margin: 0 auto 4px; font-size: 12px; font-weight: 700; }
.phone-body { flex: 1; overflow: auto; padding: 10px 0; }
.bubble { background: #eceef2; border-radius: 14px; padding: 8px 11px; font-size: 12px; white-space: pre-wrap; word-break: break-all; max-width: 88%; }
.phone-meta { font-size: 10px; color: var(--muted); text-align: center; margin-bottom: 6px; }

/* 로그인 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
