:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #182033;
  --muted: #69758a;
  --line: #dce3ef;
  --primary: #2457ff;
  --primary-dark: #163dcc;
  --secondary: #eef3ff;
  --danger: #c62828;
  --warning: #8a5a00;
  --success: #136f3b;
  --shadow: 0 18px 50px rgba(24, 32, 51, 0.10);
  --radius: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", Roboto, Arial, sans-serif;
  background: radial-gradient(circle at top left, #e7efff 0, #f8fbff 34%, var(--bg) 100%);
  color: var(--text);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
code { padding: 2px 6px; border-radius: 7px; background: #eef2f8; color: #253252; }

.hidden { display: none !important; }
.block { display: block; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 4px; color: var(--primary); font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.app-shell { min-height: 100vh; }
.login-layout {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  align-items: center;
  gap: 28px;
}
.brand-panel {
  padding: 48px;
  border-radius: 32px;
  background: linear-gradient(135deg, #17349d, #2457ff 56%, #5ba2ff);
  color: white;
  box-shadow: var(--shadow);
}
.brand-panel h1 { margin: 22px 0 12px; font-size: clamp(34px, 5vw, 54px); line-height: 1.05; }
.brand-panel p { color: rgba(255,255,255,.88); font-size: 18px; line-height: 1.7; }
.brand-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.3);
  font-weight: 900;
  letter-spacing: .05em;
}
.small-mark { width: 46px; height: 46px; border-radius: 15px; background: var(--primary); color: white; border: 0; font-size: 13px; }

.card {
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(220,227,239,.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.login-card h2, .card h2, .card h3 { margin-top: 0; }

label { display: grid; gap: 8px; margin-bottom: 16px; font-weight: 700; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: white;
  color: var(--text);
  outline: none;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(36,87,255,.12); }

.btn {
  border: 0;
  border-radius: 14px;
  padding: 11px 16px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
}
.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.secondary { background: var(--secondary); color: var(--primary-dark); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.full { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.check-list { margin: 22px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.check-list li { position: relative; padding-left: 28px; line-height: 1.55; }
.check-list li::before { content: "✓"; position: absolute; left: 0; font-weight: 900; }
.check-list.dense { gap: 8px; }

.app-layout { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #10182b;
  color: white;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.sidebar .muted { color: rgba(255,255,255,.62); }
.sidebar-head { display: flex; align-items: center; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid rgba(255,255,255,.12); }
.nav { display: grid; gap: 8px; }
.nav-item {
  text-align: left;
  border: 0;
  border-radius: 14px;
  padding: 13px 14px;
  color: rgba(255,255,255,.76);
  background: transparent;
  font-weight: 800;
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.11); color: white; }
.sidebar > .btn { margin-top: auto; color: white; border-color: rgba(255,255,255,.18); }

.content { padding: 28px; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar h1 { margin: 0; font-size: 32px; }
.topbar-actions { display: flex; align-items: end; gap: 10px; }
.inline-field { margin: 0; min-width: 150px; }

.panel { display: none; }
.active-panel { display: block; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.stat-card span { color: var(--muted); font-weight: 800; }
.stat-card strong { display: block; margin-top: 8px; font-size: 34px; }

.grid { display: grid; gap: 18px; }
.two-col { grid-template-columns: minmax(0, 1fr) minmax(360px, .72fr); align-items: start; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.section-head h2, .section-head h3, .section-head p { margin-bottom: 0; }
.section-head.compact { margin-top: 18px; }
.action-row, .message-tools, .excel-actions, .inline-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.action-row { justify-content: flex-end; margin-top: 18px; }
.message-tools { justify-content: space-between; margin-bottom: 14px; }

.recipient-list { display: grid; gap: 10px; }
.recipient-row { display: grid; grid-template-columns: 1fr 1fr 44px; gap: 10px; align-items: center; }
.recipient-row input { margin: 0; }
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--danger);
  font-weight: 900;
}
.helper-card { position: sticky; top: 24px; }
.notice {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #eef6ff;
  color: #17405f;
  line-height: 1.55;
  font-size: 14px;
}
.notice.warning { background: #fff7e5; color: var(--warning); }

.file-drop {
  border: 2px dashed #b9c7dd;
  border-radius: 18px;
  padding: 28px;
  text-align: center;
  background: #f8fbff;
  cursor: pointer;
}
.file-drop input { display: none; }
.file-drop strong, .file-drop span { display: block; }
.file-drop span { margin-top: 8px; color: var(--muted); font-weight: 500; }

.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; background: white; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f6f8fc; color: #344056; font-size: 13px; white-space: nowrap; }
td { font-size: 14px; }
tr:last-child td { border-bottom: 0; }
.preview-table { max-height: 470px; }
.status { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 900; }
.status.sent, .status.SENT { background: #e7f8ef; color: var(--success); }
.status.failed, .status.FAILED { background: #ffecec; color: var(--danger); }
.status.queued { background: #eef3ff; color: var(--primary-dark); }
.status.claimed { background: #fff7e5; color: var(--warning); }
.status.cancelled { background: #f1f1f1; color: #555; }
.message-cell { max-width: 320px; white-space: pre-wrap; word-break: break-word; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(440px, calc(100% - 36px));
  padding: 14px 16px;
  border-radius: 16px;
  background: #10182b;
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: .2s ease;
  line-height: 1.5;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8b1e1e; }
.toast.success { background: #14532d; }

@media (max-width: 1024px) {
  .login-layout, .two-col { grid-template-columns: 1fr; }
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .helper-card { position: static; }
}

@media (max-width: 640px) {
  .content { padding: 18px; }
  .topbar, .section-head { align-items: stretch; flex-direction: column; }
  .topbar-actions { align-items: stretch; flex-direction: column; }
  .nav { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .recipient-row { grid-template-columns: 1fr; }
  .icon-btn { width: 100%; }
  .brand-panel { padding: 28px; }
}
