:root {
  color-scheme: only light;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --surface-soft: #f6f3ec;
  --line: #e4ddd2;
  --line-strong: #cfc6b8;
  --ink: #2c251f;
  --muted: #6b6258;
  --wine: #861b38;
  --wine-hover: #6e152d;
  --wine-soft: #fcf4f6;
  --gold: #a88752;
  --green: #2f6b47;
  --danger: #b42318;
  --radius: 10px;
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 14.5px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: var(--ink); }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--wine); outline-offset: 2px; }

.skip-link { position: fixed; left: -9999px; top: 8px; z-index: 90; background: var(--surface); border: 1px solid var(--line-strong); padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { left: 12px; }
.crm-boot, .crm-noscript { max-width: 520px; margin: 120px auto; text-align: center; color: var(--muted); padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* Header */
.crm-header { position: sticky; top: 0; z-index: 30; height: 60px; background: var(--surface); border-bottom: 1px solid var(--line); }
.crm-header-inner { max-width: 1360px; height: 100%; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.crm-brand { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.crm-brand svg { width: 22px; height: 26px; color: var(--gold); flex-shrink: 0; }
.crm-brand strong { font-size: 16px; font-weight: 650; letter-spacing: -0.03em; color: var(--ink); }
.crm-brand span { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 6px; }

.crm-tabs { display: flex; align-items: center; gap: 6px; height: 100%; }
.crm-tab { position: relative; height: 100%; border: 0; background: transparent; padding: 0 14px; font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.crm-tab:hover { color: var(--ink); }
.crm-tab.is-active { color: var(--wine); font-weight: 600; }
.crm-tab.is-active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; background: var(--wine); }

.crm-userbar { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); white-space: nowrap; }

/* Main Container */
.crm-main { max-width: 1360px; margin: 0 auto; padding: 22px 24px 56px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 13.5px; font-weight: 500; white-space: nowrap; transition: background-color 0.15s, border-color 0.15s; }
.btn:hover { background: var(--surface-soft); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--wine); border-color: var(--wine); color: #ffffff; }
.btn-primary:hover { background: var(--wine-hover); border-color: var(--wine-hover); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 12.5px; }
.btn-link { border: 0; background: transparent; color: var(--wine); padding: 4px 6px; font-size: 13px; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }

/* Login Card */
.crm-login-wrap { min-height: calc(100vh - 40px); display: flex; align-items: center; justify-content: center; padding: 24px; }
.crm-login-card { width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--line); border-top: 2px solid var(--wine); border-radius: var(--radius); padding: 32px 28px; box-shadow: 0 10px 30px rgba(44, 37, 31, 0.05); }
.crm-login-card h1 { margin: 10px 0 6px; font-size: 21px; font-weight: 650; letter-spacing: -0.03em; }
.crm-login-card p { margin: 0 0 22px; font-size: 13.5px; color: var(--muted); }

/* Single 4-Column Summary Ribbon (OCT Reference #3) */
.crm-kpi-bar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-top: 1.5px solid var(--ink); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.crm-kpi-cell { padding: 18px 22px; border-right: 1px solid var(--line); }
.crm-kpi-cell:last-child { border-right: 0; }
.crm-kpi-label { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.crm-kpi-val { font-size: 24px; font-weight: 650; letter-spacing: -0.03em; color: var(--ink); line-height: 1.2; }
.crm-kpi-val small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.crm-kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Alert Strip */
.crm-alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; margin-bottom: 18px; background: var(--wine-soft); border: 1px solid #eccfd7; border-radius: 8px; font-size: 13.5px; color: var(--ink); }

/* Panels & Split Grid */
.crm-split { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); gap: 18px; align-items: start; }
.crm-split-email { display: grid; grid-template-columns: minmax(0, 0.96fr) minmax(0, 1.04fr); gap: 18px; align-items: start; }
.crm-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.crm-panel-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.crm-panel-head h2 { margin: 0; font-size: 15.5px; font-weight: 600; letter-spacing: -0.02em; }
.crm-panel-body { padding: 16px 18px; }

/* Toolbar */
.crm-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--line); background: #fdfcfa; }
.crm-input, .crm-select, .crm-textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 7px; padding: 8px 11px; background: var(--surface); font-size: 13.5px; line-height: 1.5; }
.crm-input:focus, .crm-select:focus, .crm-textarea:focus { border-color: var(--wine); outline: none; }
.crm-toolbar .crm-input { flex: 1 1 180px; min-width: 150px; }
.crm-toolbar .crm-select { width: auto; min-width: 130px; }

/* Clean 5-Column Table */
.crm-table-wrap { width: 100%; overflow-x: auto; }
.crm-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.crm-table th { text-align: left; padding: 10px 14px; font-size: 12px; font-weight: 500; color: var(--muted); background: #faf8f4; border-bottom: 1px solid var(--line); white-space: nowrap; }
.crm-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; font-weight: 400; }
.crm-table tbody tr { transition: background-color 0.12s; }
.crm-table tbody tr.is-clickable { cursor: pointer; }
.crm-table tbody tr.is-clickable:hover { background: #faf7f1; }
.crm-table tbody tr.is-selected { background: var(--wine-soft); }
.crm-cell-main { font-weight: 500; color: var(--ink); display: block; }
.crm-cell-sub { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }

/* Status Dot (7px circle + plain text — Charter #11) */
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); white-space: nowrap; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.status-dot.dot-new::before { background: var(--wine); }
.status-dot.dot-active::before { background: var(--gold); }
.status-dot.dot-ok::before { background: var(--green); }
.status-dot.dot-err::before { background: var(--danger); }
.status-dot.dot-muted::before { background: #8c847a; }

/* Forms */
.crm-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.crm-field label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.crm-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.crm-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; }
.crm-check input { width: 16px; height: 16px; accent-color: var(--wine); }
.crm-form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* Detail Timeline */
.crm-meta-box { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; font-size: 13px; line-height: 1.65; }
.crm-meta-box p { margin: 0 0 6px; }
.crm-meta-box p:last-child { margin-bottom: 0; }
.crm-timeline { list-style: none; margin: 10px 0 0; padding: 0; }
.crm-timeline li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.crm-timeline li:last-child { border-bottom: 0; }
.crm-timeline-time { font-size: 11.5px; color: var(--muted); display: block; margin-bottom: 3px; }
.crm-empty { padding: 36px 18px; text-align: center; color: var(--muted); font-size: 13.5px; }
.crm-error { padding: 10px 12px; border-radius: 7px; background: #fef2f2; border: 1px solid #f4c7c3; color: var(--danger); font-size: 13px; margin-bottom: 12px; }

/* Settings & Links Grid */
.crm-info-dl { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; margin: 0; font-size: 13.5px; }
.crm-info-dl dt { color: var(--muted); font-weight: 500; }
.crm-info-dl dd { margin: 0; color: var(--ink); word-break: break-word; }
.crm-link-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.crm-link-card { display: block; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color 0.15s; }
.crm-link-card:hover { border-color: var(--wine); }
.crm-link-card strong { display: block; font-size: 14.5px; font-weight: 600; margin-bottom: 6px; }
.crm-link-card p { margin: 0; font-size: 13px; color: var(--muted); }
.crm-details { margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.crm-details summary { cursor: pointer; font-weight: 500; font-size: 13.5px; color: var(--ink); }
.crm-details ol { margin: 12px 0 4px; padding-left: 20px; font-size: 13px; color: var(--muted); line-height: 1.75; }

/* Toast & Modal */
.crm-toast { position: fixed; right: 20px; bottom: 20px; z-index: 80; max-width: 380px; padding: 12px 16px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-left: 3px solid var(--wine); border-radius: 8px; box-shadow: 0 8px 24px rgba(44, 37, 31, 0.12); font-size: 13.5px; }
.crm-modal { width: min(620px, calc(100vw - 24px)); border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: 0 18px 48px rgba(44, 37, 31, 0.16); }
.crm-modal::backdrop { background: rgba(44, 37, 31, 0.35); }
.crm-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.crm-modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.crm-icon-btn { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 18px; line-height: 1; }
.crm-modal-body { padding: 18px; max-height: 75vh; overflow-y: auto; }
.crm-pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; padding: 14px; font-size: 13px; line-height: 1.7; margin: 10px 0 0; }

/* 067호: 전용메일함 · 관리자 계정 · 임시비밀번호 강제변경 UI */
.crm-subtabs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.crm-subtab { border: 1px solid transparent; background: transparent; padding: 7px 13px; border-radius: 7px; font-size: 13.5px; font-weight: 500; color: var(--muted); }
.crm-subtab:hover { color: var(--ink); background: var(--surface-soft); }
.crm-subtab.is-active { background: var(--wine-soft); border-color: #eccfd7; color: var(--wine); font-weight: 600; }
.crm-mailbox-strip { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 11px 16px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 8px; font-size: 13px; color: var(--muted); }
.crm-mailbox-strip strong { color: var(--ink); font-weight: 600; }
.crm-mail-unread { font-weight: 600; color: var(--ink); }
.crm-btn-danger { border-color: #f4c7c3; color: var(--danger); background: #fffafa; }
.crm-btn-danger:hover { background: #fef2f2; border-color: var(--danger); }
.crm-temp-pw-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; margin: 12px 0; background: #fffbeb; border: 1px solid #f2d08a; border-radius: 8px; }
.crm-temp-pw-code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 17px; font-weight: 600; letter-spacing: 0.04em; color: var(--ink); user-select: all; }
.crm-security-card { max-width: 560px; margin: 0 auto; }
.crm-must-banner { padding: 14px 18px; margin-bottom: 18px; background: #fffbeb; border: 1px solid #f2d08a; border-left: 3px solid #d97706; border-radius: 8px; font-size: 13.5px; color: var(--ink); }
.crm-must-banner strong { display: block; margin-bottom: 4px; color: #92400e; }
.crm-role-tag { display: inline-block; font-size: 12px; font-weight: 600; color: var(--wine); }
.crm-role-tag.is-normal { color: var(--muted); font-weight: 500; }
.crm-attach-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.crm-attach-list li { font-size: 12.5px; padding: 4px 10px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; color: var(--ink); }

/* 068호: 공개 DB 발굴 · DB 발송 캠페인 · 원클릭 수신거부 확인 화면 */
.crm-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.crm-preview-box { padding: 12px 14px; margin: 10px 0 14px; background: var(--surface-soft); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 8px; font-size: 13px; color: var(--ink); }
.crm-file-input { padding: 8px 10px; background: var(--surface-soft); border: 1px dashed var(--line-strong); border-radius: 7px; font-size: 13px; color: var(--ink); width: 100%; }
.unsub-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.unsub-card { width: min(520px, 100%); background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--wine); border-radius: 12px; padding: 30px 28px; box-shadow: 0 8px 24px rgba(44, 37, 31, 0.06); }
.unsub-brand { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.unsub-title { margin: 0 0 12px; font-size: 20px; font-weight: 600; color: var(--ink); }
.unsub-desc { margin: 0 0 14px; font-size: 14.5px; line-height: 1.65; color: var(--ink); }
.unsub-email { margin: 0 0 18px; padding: 10px 12px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 7px; font-size: 13.5px; }
.unsub-actions { display: flex; justify-content: flex-end; }
.crm-btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 7px; font-size: 13.5px; font-weight: 500; background: var(--surface); color: var(--ink); text-decoration: none; }
.crm-btn:hover { background: var(--surface-soft); }

/* Responsive (Mobile) */
@media (max-width: 960px) {
  .crm-header { height: auto; }
  .crm-header-inner { padding: 10px 14px; flex-wrap: wrap; }
  .crm-tabs { order: 3; width: 100%; height: 42px; border-top: 1px solid var(--line); overflow-x: auto; }
  .crm-main { padding: 16px 14px 48px; }
  .crm-kpi-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-kpi-cell:nth-child(2) { border-right: 0; }
  .crm-kpi-cell:nth-child(1), .crm-kpi-cell:nth-child(2) { border-bottom: 1px solid var(--line); }
  .crm-split, .crm-split-email, .crm-grid-2, .crm-grid-3, .crm-link-grid { grid-template-columns: 1fr; }
  .crm-info-dl { grid-template-columns: 1fr; gap: 4px; }
  .crm-input, .crm-select, .crm-textarea { font-size: 16px; }
  .btn { min-height: 44px; }
}
