/* ============================================================
   Midnight Gold — Aurora Edition
   보험 GA CRM 전용 디자인 시스템
   ============================================================ */

/* ---------- 0. 토큰 ---------- */
:root {
  /* Surfaces — 5 levels */
  --bg:           #08070c;
  --bg-elevated:  #0f0e15;
  --card:         #14131c;
  --card-hover:   #1a1925;
  --card-active:  #211f30;
  --overlay:      rgba(8, 7, 12, 0.72);

  /* Gold System */
  --gold:         #c8973a;
  --gold-light:   #e8c97a;
  --gold-deep:    #8a6624;
  --gold-grad:    linear-gradient(135deg, #e8c97a 0%, #c8973a 50%, #8a6624 100%);
  --gold-glow:    radial-gradient(ellipse at top, rgba(232,201,122,0.18), transparent 60%);
  --gold-soft:    rgba(200, 151, 58, 0.10);
  --gold-line:    rgba(200, 151, 58, 0.22);
  --gold-dim:     rgba(200, 151, 58, 0.10); /* legacy alias */

  /* Text */
  --text:         #f5f1e6;
  --text-muted:   rgba(245, 241, 230, 0.82);
  --text-dim:     rgba(245, 241, 230, 0.58);
  --text-faint:   rgba(245, 241, 230, 0.36);

  /* Compatibility aliases (legacy class names) */
  --muted:        var(--text-muted);
  --dim:          var(--text-dim);

  /* Borders */
  --border:        rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.10);
  --border-gold:   rgba(200, 151, 58, 0.28);

  /* Semantic */
  --green: #5cc28d;  --green-soft: rgba(92,194,141,0.12);
  --red:   #e87071;  --red-soft:   rgba(232,112,113,0.12);
  --amber: #f0b75a;  --amber-soft: rgba(240,183,90,0.12);
  --blue:  #6fa9e0;  --blue-soft:  rgba(111,169,224,0.12);
  --violet:#a486e0;  --violet-soft:rgba(164,134,224,0.12);

  /* Data Viz */
  --viz-1:#c8973a; --viz-2:#e8c97a; --viz-3:#5cc28d; --viz-4:#6fa9e0;
  --viz-5:#a486e0; --viz-6:#e87071; --viz-7:#f0b75a; --viz-8:#6dd0c8;

  /* Radii */
  --r-sm:6px; --r:10px; --r-md:14px; --r-lg:20px; --r-xl:28px; --r-pill:999px;

  /* Shadows */
  --shadow-xs:   0 1px 2px rgba(0,0,0,0.40);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.40);
  --shadow-md:   0 8px 24px rgba(0,0,0,0.50);
  --shadow-lg:   0 24px 64px rgba(0,0,0,0.60);
  --shadow-gold: 0 12px 40px rgba(200, 151, 58, 0.18);
  --ring-gold:   0 0 0 3px rgba(200, 151, 58, 0.22);

  /* Motion */
  --ease:     cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --spring:   cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 120ms; --t-base: 200ms; --t-slow: 320ms;

  /* Type */
  --kr:   'Pretendard Variable', -apple-system, BlinkMacSystemFont, sans-serif;
  --en:   'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'IBM Plex Mono', monospace;

  /* Layout */
  --side-w:        72px;
  --side-w-open:   240px;
  --topbar-h:      56px;
  --content-pad:   28px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 1. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--kr);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  position: relative;
}
::selection { background: var(--gold-soft); color: var(--gold-light); }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font: inherit; color: inherit; }

.num, [data-num], .c-table td.num, .c-kpi__value {
  font-family: var(--en);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(200,151,58,0.18);
  border-radius: 999px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: rgba(200,151,58,0.36); }

/* ---------- 2. Aurora background ---------- */
.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora__glow {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: 0.45; will-change: transform;
}
.aurora__glow--1 {
  width: 720px; height: 720px;
  top: -260px; left: -160px;
  background: radial-gradient(circle, rgba(200,151,58,0.30), transparent 65%);
  animation: aurora-drift-1 26s ease-in-out infinite alternate;
}
.aurora__glow--2 {
  width: 540px; height: 540px;
  bottom: -180px; right: -140px;
  background: radial-gradient(circle, rgba(164,134,224,0.16), transparent 65%);
  animation: aurora-drift-2 32s ease-in-out infinite alternate;
}
@keyframes aurora-drift-1 {
  0%   { transform: translate(0,0) scale(1); }
  100% { transform: translate(80px, 60px) scale(1.1); }
}
@keyframes aurora-drift-2 {
  0%   { transform: translate(0,0) scale(1); }
  100% { transform: translate(-60px, -40px) scale(1.15); }
}

/* ---------- 3. App shell ---------- */
.crm-wrap {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--t-base) var(--ease);
}
.crm-wrap.side-open { grid-template-columns: var(--side-w-open) 1fr; }

/* ---------- 4. Sidebar ---------- */
.crm-side {
  position: sticky; top: 0;
  height: 100vh;
  width: var(--side-w);
  background: linear-gradient(180deg, rgba(20,19,28,0.92), rgba(15,14,21,0.92));
  border-right: 1px solid var(--border);
  backdrop-filter: blur(14px);
  display: flex; flex-direction: column;
  transition: width var(--t-base) var(--ease);
  z-index: 50;
  overflow: hidden;
}
.crm-side:hover, .crm-wrap.side-open .crm-side { width: var(--side-w-open); }

.crm-side__logo {
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  color: var(--gold);
}
.crm-side__logo i { font-size: 20px; flex-shrink: 0; }
.crm-side__logo-group {
  display: inline-flex; align-items: center; gap: 8px;
  opacity: 0;
  transition: opacity var(--t-base) var(--ease);
}
.crm-side:hover .crm-side__logo-group,
.crm-wrap.side-open .crm-side__logo-group { opacity: 1; }
.crm-side__logo-text {
  font-family: var(--en); font-size: 15px; font-weight: 700;
  letter-spacing: 0.06em; white-space: nowrap;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.crm-side__logo-badge {
  font-family: var(--en); font-size: 9px; font-weight: 700;
  letter-spacing: 0.10em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--gold-soft);
  color: var(--gold-light);
  border: 1px solid var(--gold-line);
  white-space: nowrap;
}

.crm-side__nav {
  flex: 1; padding: 12px 10px; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 2px;
}
.crm-side__group-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 14px 12px 6px;
  white-space: nowrap;
  opacity: 0; transition: opacity var(--t-fast) var(--ease);
}
.crm-side:hover .crm-side__group-label,
.crm-wrap.side-open .crm-side__group-label { opacity: 1; }

.crm-nav-item {
  display: flex; align-items: center; gap: 14px;
  height: 40px; padding: 0 14px;
  border-radius: var(--r);
  color: var(--text-muted);
  position: relative;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  white-space: nowrap;
}
.crm-nav-item i { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.crm-nav-item__label {
  font-size: 13px; font-weight: 500;
  opacity: 0; transition: opacity var(--t-base) var(--ease);
}
.crm-side:hover .crm-nav-item__label,
.crm-wrap.side-open .crm-nav-item__label { opacity: 1; }
.crm-nav-item:hover { background: var(--card-hover); color: var(--text); }
.crm-nav-item.active {
  background: var(--gold-soft);
  color: var(--gold-light);
}
.crm-nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px;
  background: var(--gold-grad); border-radius: 0 2px 2px 0;
}
.crm-nav-item__badge {
  margin-left: auto;
  font-size: 10px; font-family: var(--en); font-weight: 600;
  padding: 2px 6px; border-radius: var(--r-pill);
  background: var(--red); color: #fff;
  opacity: 0; transition: opacity var(--t-base) var(--ease);
}
.crm-side:hover .crm-nav-item__badge,
.crm-wrap.side-open .crm-nav-item__badge { opacity: 1; }

.crm-side__divider {
  height: 1px; background: var(--border);
  margin: 8px 8px;
}

.crm-side__bottom {
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.crm-side__avatar {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 12px; height: 44px;
  border-radius: var(--r);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.crm-side__avatar:hover { background: var(--card-hover); }
.crm-side__avatar-circle {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--gold-grad);
  color: #0d0c11; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; flex-shrink: 0;
}
.crm-side__avatar-text {
  display: flex; flex-direction: column; line-height: 1.2;
  opacity: 0; transition: opacity var(--t-base) var(--ease);
  overflow: hidden; min-width: 0;
}
.crm-side:hover .crm-side__avatar-text,
.crm-wrap.side-open .crm-side__avatar-text { opacity: 1; }
.crm-side__avatar-name { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-side__avatar-role { font-size: 10.5px; color: var(--text-dim); }

/* ---------- 5. Main / Topbar ---------- */
.crm-main { min-width: 0; display: flex; flex-direction: column; }

.crm-topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center;
  padding: 0 var(--content-pad);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(8,7,12,0.85), rgba(8,7,12,0.55));
  backdrop-filter: blur(16px);
  gap: 12px;
}
.crm-topbar__title {
  font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em; color: var(--text);
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
}
.crm-topbar__crumb { color: var(--text-dim); font-size: 12.5px; font-weight: 400; }
.crm-topbar__crumb i { font-size: 9px; margin: 0 8px; color: var(--text-faint); }
.crm-topbar__actions { display: flex; align-items: center; gap: 8px; }

.crm-topbar__cmdk {
  display: inline-flex; align-items: center; gap: 10px;
  height: 32px; padding: 0 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-dim); font-size: 12.5px;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.crm-topbar__cmdk:hover { border-color: var(--border-gold); color: var(--text-muted); }
.crm-topbar__cmdk kbd {
  font-family: var(--en); font-size: 10.5px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
  background: var(--bg-elevated); color: var(--text-dim);
  border: 1px solid var(--border);
}
.crm-topbar__sidetoggle {
  width: 32px; height: 32px; border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all var(--t-fast) var(--ease);
}
.crm-topbar__sidetoggle:hover { background: var(--card-hover); color: var(--text); }

.crm-content {
  padding: var(--content-pad);
  animation: page-in 360ms var(--ease) both;
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 6. Page header ---------- */
.c-page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; margin-bottom: 24px; flex-wrap: wrap;
}
.c-page-head__title {
  font-size: 26px; font-weight: 700; letter-spacing: -0.02em;
  margin: 0; line-height: 1.15;
  background: linear-gradient(180deg, #f5f1e6 0%, #d6cfbb 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.c-page-head__sub { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

/* ---------- 7. Cards ---------- */
.c-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px;
  position: relative;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              transform var(--t-base) var(--ease),
              box-shadow var(--t-base) var(--ease);
}
.c-card--interactive { cursor: pointer; }
.c-card--interactive:hover {
  background: var(--card-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.c-card--glow {
  background-image: var(--gold-glow), linear-gradient(180deg, var(--card), var(--card));
  background-blend-mode: screen, normal;
}
.c-card__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 10px;
}
.c-card__title {
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------- 8. KPI Card ---------- */
.c-kpi {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px 22px;
  overflow: hidden;
  transition: all var(--t-base) var(--ease);
}
.c-kpi::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: var(--gold-grad); opacity: 0.55;
}
.c-kpi:hover {
  border-color: var(--border-gold);
  box-shadow: var(--shadow-gold);
  transform: translateY(-2px);
}
.c-kpi__head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 14px;
}
.c-kpi__label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.10em; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
}
.c-kpi__label i { font-size: 11px; color: var(--gold); }
.c-kpi__trend {
  font-family: var(--en); font-size: 11.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: var(--r-pill);
  font-variant-numeric: tabular-nums;
}
.c-kpi__trend--up   { color: var(--green); background: var(--green-soft); }
.c-kpi__trend--down { color: var(--red);   background: var(--red-soft); }
.c-kpi__trend--flat { color: var(--text-dim); background: rgba(255,255,255,0.04); }

.c-kpi__value {
  font-family: var(--en); font-weight: 700;
  font-size: 32px; line-height: 1;
  letter-spacing: -0.02em; color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}
.c-kpi__value--gold {
  background: var(--gold-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.c-kpi__sub { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.c-kpi__spark { margin-top: 14px; height: 32px; }

/* KPI as link */
a.c-kpi, .c-kpi--link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
a.c-kpi:hover, .c-kpi--link:hover {
  border-color: var(--border-gold);
  box-shadow: var(--shadow-gold);
  transform: translateY(-2px);
}
.c-kpi__more {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-faint);
  transition: transform var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
a.c-kpi:hover .c-kpi__more, .c-kpi--link:hover .c-kpi__more {
  color: var(--gold);
  transform: translateX(3px);
}

/* ---------- 9. Buttons ---------- */
.c-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 0 16px; height: 36px;
  border-radius: var(--r);
  font-size: 13px; font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              filter var(--t-fast) var(--ease);
}
.c-btn:hover { background: var(--card-hover); border-color: var(--border-strong); }
.c-btn:active { transform: scale(0.97); }
.c-btn:focus-visible { outline: none; box-shadow: var(--ring-gold); }
.c-btn i { font-size: 12px; }

.c-btn--primary {
  background: var(--gold-grad);
  border-color: transparent;
  color: #0d0b14;
  font-weight: 600;
}
.c-btn--primary:hover { background: var(--gold-grad); border-color: transparent; box-shadow: var(--shadow-gold); filter: brightness(1.08); }
.c-btn--ghost {
  background: transparent;
  border-color: var(--border-gold);
  color: var(--gold-light);
}
.c-btn--ghost:hover { background: var(--gold-soft); }
.c-btn--subtle {
  background: var(--gold-soft);
  border-color: transparent;
  color: var(--gold-light);
}
.c-btn--subtle:hover { background: rgba(200,151,58,0.18); }
.c-btn--muted {
  background: var(--card);
  color: var(--text-muted);
  border-color: var(--border);
}
.c-btn--muted:hover { color: var(--text); }
.c-btn--danger { color: var(--red); border-color: rgba(232,112,113,0.28); }
.c-btn--danger:hover { background: var(--red-soft); }

.c-btn--sm  { height: 30px; padding: 0 12px; font-size: 12px; border-radius: var(--r-sm); }
.c-btn--lg  { height: 44px; padding: 0 22px; font-size: 14px; }
.c-btn--icon { width: 36px; padding: 0; }
.c-btn--sm.c-btn--icon { width: 30px; }

/* ---------- 10. Forms ---------- */
.c-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.c-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
}
.c-input, .c-select, textarea.c-input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.c-input::placeholder { color: var(--text-dim); }
.c-input:hover, .c-select:hover { border-color: var(--border-strong); }
.c-input:focus, .c-select:focus, textarea.c-input:focus {
  outline: none;
  border-color: var(--border-gold);
  box-shadow: var(--ring-gold);
  background: var(--card-hover);
}
textarea.c-input { height: auto; padding: 10px 12px; min-height: 80px; resize: vertical; line-height: 1.5; }
.c-select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%23999'><polygon points='1,3 9,3 5,8'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}

.c-grid { display: grid; gap: 12px; }
.c-grid--2 { grid-template-columns: 1fr 1fr; }
.c-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
.c-grid--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .c-grid--2, .c-grid--3, .c-grid--4 { grid-template-columns: 1fr; }
}

.c-search {
  position: relative;
  flex: 1; min-width: 220px; max-width: 380px;
}
.c-search > i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); font-size: 13px; pointer-events: none;
}
.c-search input {
  width: 100%; height: 36px;
  padding: 0 12px 0 36px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text); font-size: 13px;
  transition: all var(--t-fast) var(--ease);
}
.c-search input:focus { outline: none; border-color: var(--border-gold); box-shadow: var(--ring-gold); }

.c-toolbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px; flex-wrap: wrap;
}

/* ---------- 11. Table ---------- */
.c-table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.c-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.c-table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
.c-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text);
}
.c-table tbody tr { position: relative; transition: background var(--t-fast) var(--ease); }
.c-table tbody tr:hover { background: var(--card-hover); }
.c-table tbody tr:hover td:first-child { box-shadow: inset 2px 0 0 var(--gold); }
.c-table tbody tr.clickable { cursor: pointer; }
.c-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.012); }
.c-table tbody tr:nth-child(even):hover { background: var(--card-hover); }

/* ---------- 12. Badge ---------- */
.c-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  font-size: 11px; font-weight: 500;
  border-radius: var(--r-pill);
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
  white-space: nowrap;
}
.c-badge--gold   { background: var(--gold-soft); color: var(--gold-light); }
.c-badge--green  { background: var(--green-soft); color: var(--green); }
.c-badge--red    { background: var(--red-soft);   color: var(--red); }
.c-badge--amber  { background: var(--amber-soft); color: var(--amber); }
.c-badge--blue   { background: var(--blue-soft);  color: var(--blue); }
.c-badge--violet { background: var(--violet-soft);color: var(--violet); }
.c-badge--dim    { background: rgba(255,255,255,0.04); color: var(--text-dim); }
.c-badge--live::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; animation: pulse-dot 1.6s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity: 1; box-shadow: 0 0 0 0 currentColor; }
  50%     { opacity: 0.55; box-shadow: 0 0 0 5px transparent; }
}

/* ---------- 13. Modal ---------- */
.c-modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity var(--t-base) var(--ease), visibility 0s linear var(--t-base);
}
.c-modal-overlay.open {
  opacity: 1; visibility: visible;
  transition: opacity var(--t-base) var(--ease);
}
.c-modal {
  width: min(560px, 92vw);
  max-height: 88vh; overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), var(--shadow-gold);
  transform: scale(0.96) translateY(8px);
  transition: transform var(--t-base) var(--ease);
  position: relative;
}
.c-modal-overlay.open .c-modal { transform: scale(1) translateY(0); }
.c-modal::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: var(--gold-grad); opacity: 0.6;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.c-modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.c-modal__title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.c-modal__close {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all var(--t-fast) var(--ease);
}
.c-modal__close:hover { background: var(--card-hover); color: var(--text); }
.c-modal__body { padding: 20px 22px; }
.c-modal__footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 22px; border-top: 1px solid var(--border);
}

/* ---------- 14. Sheet ---------- */
.c-sheet { position: fixed; inset: 0; z-index: 180; pointer-events: none; }
.c-sheet__backdrop {
  position: absolute; inset: 0;
  background: var(--overlay); backdrop-filter: blur(4px);
  opacity: 0; transition: opacity var(--t-base) var(--ease);
}
.c-sheet__panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(520px, 92vw);
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 380ms var(--spring);
  display: flex; flex-direction: column;
}
.c-sheet.open { pointer-events: auto; }
.c-sheet.open .c-sheet__backdrop { opacity: 1; }
.c-sheet.open .c-sheet__panel { transform: translateX(0); }
.c-sheet__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.c-sheet__body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.c-sheet__foot {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ---------- 15. Toast ---------- */
.c-toast-wrap {
  position: fixed; right: 24px; bottom: 24px; z-index: 400;
  display: flex; flex-direction: column-reverse; gap: 10px;
  pointer-events: none;
}
.c-toast {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  font-size: 13px; color: var(--text);
  min-width: 240px; max-width: 420px;
  position: relative; overflow: hidden;
  animation: toast-in 360ms var(--spring);
}
.c-toast i { font-size: 14px; flex-shrink: 0; }
.c-toast--gold i, .c-toast--success i { color: var(--green); }
.c-toast--error i { color: var(--red); }
.c-toast--warn i  { color: var(--amber); }
.c-toast--info i  { color: var(--blue); }
.c-toast__msg { flex: 1; line-height: 1.4; }
.c-toast__action {
  font-size: 12px; font-weight: 600; color: var(--gold-light);
  padding: 4px 10px; border-radius: var(--r-sm);
  background: var(--gold-soft); border: 1px solid var(--gold-line);
  transition: background var(--t-fast) var(--ease);
}
.c-toast__action:hover { background: rgba(200,151,58,0.20); }
.c-toast__bar {
  position: absolute; left: 0; bottom: 0; height: 2px;
  background: var(--gold-grad); width: 100%;
  animation: toast-bar 3.2s linear forwards;
}
.c-toast--leaving { animation: toast-out 320ms var(--ease) forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(40px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px) scale(0.98); } }
@keyframes toast-bar { from { width: 100%; } to { width: 0%; } }

/* ---------- 16. Empty state ---------- */
.c-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px;
  color: var(--text-dim);
  text-align: center; gap: 6px;
}
.c-empty > i {
  font-size: 36px; color: var(--gold);
  opacity: 0.7; margin-bottom: 12px;
}
.c-empty__title { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.c-empty__sub   { font-size: 12.5px; color: var(--text-dim); }
.c-empty__cta   { margin-top: 14px; }

/* ---------- 17. Skeleton ---------- */
.skel {
  display: block;
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 0%, rgba(200,151,58,0.10) 50%, rgba(255,255,255,0.03) 100%);
  background-size: 200% 100%;
  border-radius: var(--r-sm);
  animation: skel-shine 1.5s linear infinite;
}
.skel--text  { height: 12px; width: 100%; }
.skel--line  { height: 14px; }
.skel--num   { height: 32px; width: 120px; }
.skel--card  { height: 96px; border-radius: var(--r-md); }
.skel--row   { height: 44px; }
@keyframes skel-shine {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ---------- 18. Command Palette ---------- */
.c-cmdk {
  position: fixed; inset: 0; z-index: 500;
  display: flex; justify-content: center; padding-top: 12vh;
  background: var(--overlay); backdrop-filter: blur(8px);
  opacity: 0; visibility: hidden;
  transition: opacity var(--t-base) var(--ease), visibility 0s linear var(--t-base);
}
.c-cmdk.open { opacity: 1; visibility: visible; transition: opacity var(--t-base) var(--ease); }
.c-cmdk__panel {
  width: min(640px, 92vw);
  height: fit-content; max-height: 70vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), var(--shadow-gold);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: scale(0.97) translateY(-6px);
  transition: transform var(--t-base) var(--ease);
}
.c-cmdk.open .c-cmdk__panel { transform: scale(1) translateY(0); }
.c-cmdk__input-wrap {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.c-cmdk__input-wrap > i { color: var(--gold); font-size: 14px; }
.c-cmdk__input {
  flex: 1;
  background: transparent; border: 0; outline: 0;
  font-size: 15px; color: var(--text);
}
.c-cmdk__input::placeholder { color: var(--text-dim); }
.c-cmdk__hint {
  font-family: var(--en); font-size: 10.5px;
  padding: 2px 6px; border-radius: 4px;
  background: var(--card); color: var(--text-dim);
  border: 1px solid var(--border);
}
.c-cmdk__list {
  overflow-y: auto; padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.c-cmdk__group {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.10em;
  color: var(--text-faint);
  padding: 10px 12px 4px;
}
.c-cmdk__item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  font-size: 13px;
}
.c-cmdk__item i { color: var(--gold); font-size: 13px; width: 18px; text-align: center; }
.c-cmdk__item:hover, .c-cmdk__item.active {
  background: var(--gold-soft);
  color: var(--gold-light);
}
.c-cmdk__item .c-cmdk__sub {
  margin-left: auto; font-size: 11px; color: var(--text-dim);
}
.c-cmdk__empty {
  padding: 28px; text-align: center;
  color: var(--text-dim); font-size: 13px;
}

/* ---------- 19. Activity Feed ---------- */
.c-feed { display: flex; flex-direction: column; gap: 0; }
.c-feed-item {
  display: flex; gap: 14px; padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.c-feed-item:last-child { border-bottom: 0; }
.c-feed-item__icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--gold-soft); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 13px;
}
.c-feed-item__body { flex: 1; min-width: 0; }
.c-feed-item__head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px; gap: 8px;
}
.c-feed-item__title { font-size: 13px; font-weight: 500; }
.c-feed-item__time { font-family: var(--en); font-size: 11px; color: var(--text-dim); }
.c-feed-item__text { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }

/* ---------- 20. Stagger ---------- */
.stagger > * { opacity: 0; animation: stagger-in 360ms var(--ease) forwards; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 50ms; }
.stagger > *:nth-child(3) { animation-delay: 100ms; }
.stagger > *:nth-child(4) { animation-delay: 150ms; }
.stagger > *:nth-child(5) { animation-delay: 200ms; }
.stagger > *:nth-child(6) { animation-delay: 250ms; }
.stagger > *:nth-child(7) { animation-delay: 300ms; }
.stagger > *:nth-child(8) { animation-delay: 350ms; }
@keyframes stagger-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 21. Pagination ---------- */
.c-pagination {
  display: flex; justify-content: center; gap: 4px;
  margin-top: 18px;
}
.c-pagination button {
  min-width: 32px; height: 32px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 12.5px; font-family: var(--en); font-variant-numeric: tabular-nums;
  transition: all var(--t-fast) var(--ease);
}
.c-pagination button:hover { background: var(--card-hover); color: var(--text); }
.c-pagination button.active {
  background: var(--gold-soft); color: var(--gold-light);
  border-color: var(--gold-line);
}

/* ---------- 22. Utility ---------- */
.u-row { display: flex; align-items: center; gap: 8px; }
.u-col { display: flex; flex-direction: column; gap: 8px; }
.u-spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.u-num { font-family: var(--en); font-variant-numeric: tabular-nums; }
.u-muted { color: var(--text-muted); }
.u-dim { color: var(--text-dim); }
.u-gold { color: var(--gold); }
.u-mt-1 { margin-top: 8px; }
.u-mt-2 { margin-top: 16px; }
.u-mt-3 { margin-top: 24px; }
.u-mb-1 { margin-bottom: 8px; }
.u-mb-2 { margin-bottom: 16px; }
.u-mb-3 { margin-bottom: 24px; }
.u-cap {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
}
.u-divider { height: 1px; background: var(--border); margin: 16px 0; }

/* Avatar */
.c-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold-light);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; flex-shrink: 0;
}
.c-avatar--lg { width: 56px; height: 56px; font-size: 18px; }
.c-avatar--gold { background: var(--gold-grad); color: #0d0b14; }

/* Mini bar (progress / capacity) */
.c-bar { width: 100%; height: 6px; border-radius: var(--r-pill); background: rgba(255,255,255,0.05); overflow: hidden; }
.c-bar__fill { height: 100%; background: var(--gold-grad); border-radius: var(--r-pill); transition: width var(--t-slow) var(--ease); }

/* Chip / Tag */
.c-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  font-size: 11.5px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text-muted);
}

/* ============================================================
   ---------- Mobile / Tablet Adaptive Layer ----------
   Phase 1: 기반 (사이드바 드로어 / 토픽바 / KPI / Sheet / Table)
   ≤1024px : 태블릿+ (드로어 모드 시작)
   ≤ 640px : 폰 (단일 컬럼·풀스크린 시트·테이블 카드화)
============================================================ */

/* 가시성 유틸 */
.u-show-sm { display: none !important; }
@media (max-width: 640px) {
  .u-hide-sm { display: none !important; }
  .u-show-sm { display: revert !important; }
}
@media (min-width: 1025px) {
  .u-mobile-only { display: none !important; }
}

/* 백드롭은 항상 고정 위치(그리드 흐름에서 제외). 데스크탑에선 늘 숨김. */
.crm-side__backdrop {
  position: fixed; inset: 0;
  background: var(--overlay); backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden; pointer-events: none;
  z-index: 199;
  transition: opacity var(--t-base) var(--ease), visibility 0s linear var(--t-base);
}

/* ─── ≤1024px : 드로어 사이드바 + 토픽바 컴팩트 ─── */
@media (max-width: 1024px) {
  :root {
    --content-pad: 16px;
    --topbar-h: 52px;
  }

  .crm-wrap { grid-template-columns: 1fr; }
  .crm-wrap.side-open { grid-template-columns: 1fr; }

  /* 사이드바: 화면 밖 → .side-open 시 슬라이드 인 */
  .crm-side {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--side-w-open);
    transform: translateX(-100%);
    transition: transform var(--t-base) var(--ease);
    z-index: 200;
  }
  .crm-side:hover { width: var(--side-w-open); }
  .crm-wrap.side-open .crm-side { transform: translateX(0); }

  /* 드로어 모드는 라벨 항상 노출 */
  .crm-side__logo-group,
  .crm-side__group-label,
  .crm-nav-item__label,
  .crm-side__avatar-text,
  .crm-nav-item__badge { opacity: 1 !important; }

  /* 백드롭은 모바일 드로어 열렸을 때만 보이게 */
  .crm-wrap.side-open .crm-side__backdrop {
    opacity: 1; visibility: visible; pointer-events: auto;
    transition: opacity var(--t-base) var(--ease);
  }

  /* 토픽바 컴팩트 */
  .crm-topbar { padding: 0 14px; gap: 8px; }
  .crm-topbar__cmdk { display: none; }
  .crm-topbar__crumb { display: none; }
  .crm-topbar__title { font-size: 14px; }
  .crm-topbar__title > span:not(.crm-topbar__crumb) {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }

  /* KPI 4열 → 2열 */
  .c-grid--4 { grid-template-columns: 1fr 1fr; }

  /* 페이지 헤더 압축 */
  .c-page-head { gap: 12px; }
  .c-page-head__title { font-size: 22px; }
}

/* ─── ≤640px : 폰 — 단일 컬럼 + 풀스크린 시트/모달 ─── */
@media (max-width: 640px) {
  :root { --content-pad: 14px; }

  /* 모든 그리드 단일 컬럼 */
  .c-grid--2,
  .c-grid--3,
  .c-grid--4 { grid-template-columns: 1fr !important; }

  /* Aurora 정적화 (배터리/성능) */
  .aurora__glow--1, .aurora__glow--2 { animation: none; }

  /* 사이드바 폭 (작은 폰에서) */
  .crm-side { width: min(86vw, 320px); }

  /* 모달 풀스크린 */
  .c-modal {
    width: 100vw; max-width: 100vw;
    height: 100vh; max-height: 100vh;
    border-radius: 0;
  }
  .c-modal::before { border-radius: 0; }

  /* 시트 풀스크린 (오른쪽에서 → 아래에서 올라오는 느낌) */
  .c-sheet__panel {
    width: 100vw; max-width: 100vw;
    top: auto; bottom: 0; height: 92vh;
    border-left: 0; border-top: 1px solid var(--border-strong);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    transform: translateY(100%);
  }
  .c-sheet.open .c-sheet__panel { transform: translateY(0); }

  /* 페이지 헤더 */
  .c-page-head { flex-direction: column; align-items: flex-start; }
  .c-page-head__title { font-size: 20px; }
  .c-page-head__sub { font-size: 12.5px; }

  /* 카드 패딩 축소 */
  .c-card { padding: 14px 16px; }

  /* iOS 폼 자동확대 방지 */
  .c-input, .c-select, .c-textarea, input, select, textarea {
    font-size: 16px !important;
  }

  /* 터치 타겟 ≥40px */
  .c-btn, .c-btn--sm { min-height: 40px; }
  .crm-nav-item { height: 44px; }
  .c-modal__close,
  .crm-topbar__sidetoggle { min-width: 40px; min-height: 40px; }

  /* 토픽바 액션: 모든 페이지에서 자동으로 아이콘 전용으로 압축
     (텍스트 노드든 span이든 font-size: 0 으로 숨김, 아이콘만 14px 복원) */
  .crm-topbar__actions { gap: 6px; }
  .crm-topbar__actions .c-btn {
    width: 36px; height: 36px; min-height: auto;
    padding: 0; gap: 0;
    font-size: 0;
    justify-content: center;
  }
  .crm-topbar__actions .c-btn i { font-size: 14px; }

  /* 툴바 가로 스크롤 (필터 칩) */
  .c-toolbar {
    flex-wrap: nowrap; overflow-x: auto;
    margin: 0 calc(-1 * var(--content-pad)) 14px;
    padding: 0 var(--content-pad) 4px;
    scrollbar-width: none;
  }
  .c-toolbar::-webkit-scrollbar { display: none; }
  .c-toolbar > * { flex-shrink: 0; }

  /* 검색은 풀폭 차지 */
  .c-search { max-width: none; flex: 1 1 100%; }

  /* ─── 테이블 → 카드 변환 (opt-in: .c-table--mobile-cards) ─── */
  .c-table--mobile-cards thead { display: none; }
  .c-table--mobile-cards,
  .c-table--mobile-cards tbody,
  .c-table--mobile-cards tr,
  .c-table--mobile-cards td { display: block; width: 100%; }
  .c-table--mobile-cards tbody tr {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 12px 14px;
    margin-bottom: 8px;
  }
  .c-table--mobile-cards tbody tr:nth-child(even) { background: var(--card); }
  .c-table--mobile-cards tbody tr:hover { background: var(--card); }
  .c-table--mobile-cards tbody tr:hover td:first-child { box-shadow: none; }
  .c-table--mobile-cards tbody td {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; border: 0;
    font-size: 13px; gap: 12px;
  }
  .c-table--mobile-cards tbody td::before {
    content: attr(data-label);
    color: var(--text-dim); font-size: 11.5px; font-weight: 500;
    flex-shrink: 0;
  }
  .c-table--mobile-cards tbody td:first-child {
    font-weight: 600; font-size: 14.5px;
    padding: 0 0 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
  }
  .c-table--mobile-cards tbody td:first-child::before { display: none; }

  /* 차트 wrapper 자동 축소 */
  .c-card canvas { max-height: 200px !important; }

  /* 테이블 컴팩트 (남은 컬럼이 비좁은 폰 폭에 들어가도록) */
  .c-table { font-size: 12px; }
  .c-table thead th {
    padding: 9px 8px;
    font-size: 9.5px; letter-spacing: 0.04em;
  }
  .c-table tbody td {
    padding: 11px 8px;
    font-size: 12px;
  }
  /* 셀 인라인 style 의 font-size 도 강제 축소 */
  .c-table tbody td[style*="font-size"] { font-size: 11.5px !important; }
  .c-table-wrap { border-radius: var(--r); }

  /* 마지막 컬럼(상태/등록일) 우측 정렬 + 콘텐츠 폭으로 압축
     실제 :last-child 가 모바일에서 숨겨지는 경우(예: 편집 버튼)에는
     상태 셀에 .c-cell--end 클래스를 부여해 같은 효과를 얻음 */
  .c-table thead th:last-child,
  .c-table tbody td:last-child,
  .c-table thead th.c-cell--end,
  .c-table tbody td.c-cell--end {
    width: 1px;
    text-align: right;
    padding-right: 12px;
    letter-spacing: normal;
    white-space: normal;
  }
  .c-table thead th:last-child,
  .c-table thead th.c-cell--end { white-space: nowrap; }

  /* 상태 셀 안의 D-N 배지(c-badge--live)는 줄바꿈해서 2행으로 */
  .c-table tbody td:last-child .c-badge--live,
  .c-table tbody td.c-cell--end .c-badge--live {
    display: block;
    margin-left: auto !important;
    margin-top: 4px;
    width: fit-content;
  }

  /* 활동 피드 head: 타이틀과 시간을 2행으로 stack */
  .c-feed-item__head {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .c-feed-item__time { font-size: 10.5px; }

  /* 카드 헤더: 좁아지면 우측 chip 그룹/액션이 다음 줄로 떨어지도록 */
  .c-card__head { flex-wrap: wrap; row-gap: 8px; }

  /* 인라인 style로 grid-template-columns 가 박힌 경우(예: analytics) 모바일에선 단일 컬럼 강제 */
  .crm-main .c-grid[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
}
