:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #e3e7ec;
  --line-strong: #cfd6de;
  --text: #1c232b;
  --muted: #6b7682;
  --accent: #1f6feb;
  --accent-weak: #e8f0fe;
  --ok: #1a7f4b;
  --ok-weak: #e3f4ea;
  --warn: #9a6200;
  --warn-weak: #fdf1d8;
  --bad: #c62f2f;
  --bad-weak: #fde8e8;
  --phone: #20262d;
  --bubble: #e9ecf0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 650; }
a { color: var(--accent); }

/* ---------- 공통 요소 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: #fff; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f6f8fa; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #195fd0; }
.btn.danger { color: var(--bad); border-color: #f0c4c4; }
.btn.danger:hover { background: var(--bad-weak); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #eef1f4; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 42px; padding: 0 22px; font-size: 15px; }

.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff;
  padding: 7px 10px; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.textarea { resize: vertical; min-height: 90px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }

.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: #eef1f4; color: var(--muted); white-space: nowrap;
}
.badge.ok { background: var(--ok-weak); color: var(--ok); }
.badge.bad { background: var(--bad-weak); color: var(--bad); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.info { background: var(--accent-weak); color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 15px; }
.panel-body { padding: 16px; }

.notice { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.notice.warn { background: var(--warn-weak); color: var(--warn); }
.notice.bad { background: var(--bad-weak); color: var(--bad); }
.notice.info { background: var(--accent-weak); color: #174ea6; }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.grid th { font-size: 12.5px; color: var(--muted); font-weight: 600; background: #fafbfc; position: sticky; top: 0; }
table.grid tbody tr.click { cursor: pointer; }
table.grid tbody tr.click:hover { background: #f7f9fb; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* ---------- 로그인 ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login { width: 340px; padding: 28px; }
.login h1 { font-size: 20px; margin-bottom: 4px; }
.login p { margin: 0 0 20px; color: var(--muted); }

/* ---------- 뼈대 ---------- */
.shell { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }
.side { background: #17202b; color: #c9d3dd; padding: 18px 12px; display: flex; flex-direction: column; }
.brand { color: #fff; font-size: 16px; font-weight: 700; padding: 4px 10px 16px; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: #8b98a6; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: inherit; text-decoration: none; margin-bottom: 2px;
}
.nav a:hover { background: rgba(255, 255, 255, .06); }
.nav a.on { background: rgba(255, 255, 255, .12); color: #fff; font-weight: 600; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.side-foot { margin-top: auto; padding: 10px; font-size: 12.5px; color: #8b98a6; }
.side-foot button { margin-top: 8px; width: 100%; background: transparent; color: #c9d3dd; border-color: #3a4756; }
.side-foot button:hover { background: rgba(255, 255, 255, .06); }
.main { padding: 22px 26px 40px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 20px; }

/* ---------- 보내기 ---------- */
.compose { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
.phone {
  background: var(--phone); border-radius: 34px; padding: 14px 12px 18px; box-shadow: var(--shadow);
  position: sticky; top: 18px;
}
.phone-top { height: 22px; display: grid; place-items: center; }
.phone-top i { width: 64px; height: 6px; border-radius: 6px; background: #3b444e; display: block; }
.phone-screen { background: #fff; border-radius: 22px; overflow: hidden; display: flex; flex-direction: column; min-height: 470px; }
.phone-bar { padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.phone-bar .from { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.phone-body { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.phone-subject { border: 0; border-bottom: 1px dashed var(--line-strong); padding: 4px 2px; outline: none; font-weight: 600; width: 100%; }
.bubble { background: var(--bubble); border-radius: 16px 16px 16px 4px; padding: 10px 12px; flex: 1; display: flex; flex-direction: column; }
.bubble textarea {
  border: 0; background: transparent; outline: none; resize: none; width: 100%; flex: 1; min-height: 240px;
  line-height: 1.5;
}
.bubble .fixed { color: var(--muted); font-size: 13px; white-space: pre-wrap; }
.phone-foot { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.bytes { font-variant-numeric: tabular-nums; font-weight: 600; }
.bytes.over { color: var(--bad); }
.meter { height: 4px; background: #eef1f4; border-radius: 4px; overflow: hidden; flex: 1; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.over i { background: var(--bad); }
.phone-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.phone-tools .btn { background: #2b343e; border-color: #3b4652; color: #dfe6ee; }
.phone-tools .btn:hover { background: #36414d; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; }
.tabs button { border: 0; background: transparent; padding: 11px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.rcpt-input { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.rcpt-list { max-height: 320px; overflow: auto; }
.rcpt-sum { padding: 10px 16px; display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 var(--radius) var(--radius); }
.rcpt-sum b { font-size: 16px; }
.drop { border: 1.5px dashed var(--line-strong); border-radius: 10px; padding: 22px; text-align: center; color: var(--muted); background: #fafbfc; }
.drop.over { border-color: var(--accent); background: var(--accent-weak); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.send-bar { margin-top: 16px; padding: 14px 16px; display: grid; grid-template-columns: 280px 1fr auto; gap: 14px; align-items: end; }
.send-bar .opts { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; }
.check.off { color: var(--muted); cursor: not-allowed; }

/* ---------- 주소록 ---------- */
.book { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: start; }
.group-list a { display: flex; align-items: center; gap: 8px; padding: 8px 12px; text-decoration: none; color: inherit; border-radius: 8px; }
.group-list a:hover { background: #f4f6f8; }
.group-list a.on { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.group-list .cnt { margin-left: auto; font-size: 12px; color: var(--muted); }

/* ---------- 문구함 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.card h3 { font-size: 14.5px; }
.card pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit; color: #3b4652; background: #f6f8fa; border-radius: 8px; padding: 10px; max-height: 150px; overflow: auto; flex: 1; }

/* ---------- 현황 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { padding: 16px; }
.stat .label { font-size: 12.5px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0 6px; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; min-width: 0; }
.bars .bar i { display: block; width: 100%; max-width: 30px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar span { font-size: 11px; color: var(--muted); }
.bars .bar em { font-style: normal; font-size: 11px; color: var(--text); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- 모달·알림 ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 520px; max-width: 100%; max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(16, 24, 40, .25); }
.modal.wide { width: 860px; }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 18px; overflow: auto; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.sample { background: var(--bubble); border-radius: 12px 12px 12px 4px; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; margin-top: 6px; }
#toast-root { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #1c232b; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; align-items: center; padding: 8px 10px; overflow-x: auto; }
  .brand { padding: 0 10px 0 4px; white-space: nowrap; }
  .brand small { display: none; }
  .nav { display: flex; }
  .nav a { margin: 0 2px 0 0; white-space: nowrap; }
  .side-foot { margin: 0 0 0 auto; padding: 0; display: flex; align-items: center; gap: 8px; }
  .side-foot button { margin: 0; width: auto; }
  .main { padding: 16px 14px 32px; }
  .compose, .book { grid-template-columns: 1fr; }
  .phone { position: static; max-width: 360px; margin: 0 auto; }
  .send-bar { grid-template-columns: 1fr; }
}
