/* ============ 디자인 토큰 (Trevity 이식 · light/dark) ============ */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --hover-wash: rgba(11, 11, 11, 0.04);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-text: #006300;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5; --hover-wash: rgba(255, 255, 255, 0.06);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --good-text: #0ca30c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5; --hover-wash: rgba(255, 255, 255, 0.06);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --good-text: #0ca30c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 14px; line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
small { color: var(--muted); }

/* ============ 레이아웃 ============ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { font-weight: 700; font-size: 17px; margin-bottom: 2px; }
.sidebar .brand small { display: block; font-size: 11px; font-weight: 400; }
.sidebar .nav-group { margin-top: 18px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sidebar a.nav-link {
  display: block; padding: 8px 10px; margin: 2px 0; border-radius: 8px;
  color: var(--ink-2); font-size: 13.5px;
}
.sidebar a.nav-link:hover { background: var(--hover-wash); text-decoration: none; }
.sidebar a.nav-link.active { background: var(--accent); color: var(--accent-ink); }

.main { flex: 1; min-width: 0; padding: 22px 26px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.topbar h1 { font-size: 20px; margin: 0; }
.topbar .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 12.5px; }
.topbar-right a { color: var(--muted); }

/* ============ 카드 ============ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.card + .card, .grid > .card { margin-top: 0; }
.card h3 { margin: 0 0 12px; font-size: 14px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ============ KPI ============ */
.kpi { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
@media (max-width: 1100px) { .kpi { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .kpi { grid-template-columns: repeat(2, 1fr); } }
.kpi .card { padding: 14px 16px; }
.kpi .val { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.kpi .lbl { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ============ 버튼 ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border: 1px solid transparent;
  border-radius: 8px; padding: 8px 14px; font-size: 13.5px; font-weight: 500;
}
.btn:hover { text-decoration: none; opacity: .92; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--border); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.danger { background: var(--critical); }
.btn.warn { background: var(--warning); color: #3a2a00; }

/* ============ 폼 ============ */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=datetime-local], select, textarea {
  background: var(--page); border: 1px solid var(--border); color: var(--ink);
  border-radius: 8px; padding: 9px 12px; font-size: 14px; width: 100%; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea { min-height: 120px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.inline { display: flex; gap: 10px; align-items: center; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.checkbox input { width: auto; }

/* ============ 테이블 ============ */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--surface); position: sticky; top: 0; }
tbody tr:hover { background: var(--hover-wash); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ============ 배지 ============ */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; }
.badge.active { background: rgba(12,163,12,.14); color: var(--good-text); }
.badge.unsubscribed { background: rgba(208,59,59,.14); color: var(--critical); }
.badge.bounced { background: rgba(250,178,25,.18); color: #8a5a00; }
.badge.invalid { background: var(--hover-wash); color: var(--muted); }
.badge.queued { background: var(--hover-wash); color: var(--ink-2); }
.badge.sent { background: rgba(42,120,214,.14); color: var(--accent); }
.badge.sending { background: rgba(237,161,0,.16); color: #8a5a00; }
.badge.scheduled { background: rgba(74,58,167,.14); color: var(--s7); }
.badge.paused { background: rgba(250,178,25,.18); color: #8a5a00; }
.badge.done { background: rgba(12,163,12,.14); color: var(--good-text); }
.badge.failed, .badge.canceled { background: rgba(208,59,59,.14); color: var(--critical); }

/* ============ 알림 ============ */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert.ok { background: rgba(12,163,12,.10); color: var(--good-text); border: 1px solid rgba(12,163,12,.25); }
.alert.err { background: rgba(208,59,59,.10); color: var(--critical); border: 1px solid rgba(208,59,59,.25); }
.alert.warn { background: rgba(250,178,25,.12); color: #8a5a00; border: 1px solid rgba(250,178,25,.3); }

/* ============ 차트 ============ */
.chart { width: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.bar-track { background: var(--hover-wash); border-radius: 6px; height: 8px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); }

/* ============ 드롭존 (드래그앤드롭 업로드) ============ */
.dropzone {
  border: 2px dashed var(--border); border-radius: 10px; padding: 26px 18px;
  text-align: center; color: var(--muted); cursor: pointer; background: var(--page);
  transition: border-color .15s, background .15s, color .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--hover-wash); color: var(--ink-2); }
.dropzone input[type=file] { display: none; }
.dropzone .dz-title { font-size: 13.5px; }
.dropzone .dz-hint { font-size: 12px; margin-top: 4px; }
.dropzone .dz-files { margin-top: 10px; font-size: 12.5px; color: var(--ink-2); word-break: break-all; }
.attach-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.attach-item { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.attach-item .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ 칸반 (영업 보드) ============ */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.kanban .col { flex: 1 1 0; min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.kanban .col h4 { margin: 0 0 8px; font-size: 13px; display: flex; align-items: center; justify-content: space-between; }
.kanban .col h4 .count { color: var(--muted); font-weight: 400; }
.kanban .col h4 .dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; }
.kanban .col.drop { outline: 2px dashed var(--accent); outline-offset: 2px; }
.kanban .col-body { min-height: 40px; max-height: calc(100vh - 250px); overflow-y: auto; padding-right: 2px; }
.kcard { background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; cursor: grab; }
.kcard.dragging { opacity: .5; }
.kcard .co { font-weight: 600; font-size: 13px; }
.kcard .meta { color: var(--muted); font-size: 11.5px; margin-top: 3px; word-break: break-all; }
.kcard .due { font-size: 11.5px; margin-top: 4px; color: var(--ink-2); }
.kcard .due.over { color: var(--critical); }
.kcard .due.today { color: #8a5a00; }
.kcard-act { margin-top: 5px; font-size: 11.5px; }

/* 언어 스위처 */
.lang-switch a { font-size: 12px; color: var(--muted); margin: 0 5px; }
.lang-switch a.on { color: var(--accent); font-weight: 600; }

.muted { color: var(--muted); }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pill-btn { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; color: var(--ink-2); font-size: 13px; }
.pager { display: flex; gap: 6px; margin-top: 14px; }
.pager a, .pager span { padding: 5px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 12.5px; color: var(--ink-2); }
.pager .cur { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* 로그인 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .brand { text-align: center; padding-bottom: 20px; font-weight: 700; font-size: 20px; }
.login-card .brand small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 4px; }
