/* ============================================================
   DKLabs Admin — dark console
   ============================================================ */

:root {
  --bg:          #0a0d13;
  --surface:     #111621;
  --surface-2:   #161c29;
  --surface-3:   #1d2534;
  --border:      #222b3b;
  --border-soft: #1a2130;

  --text:        #e7ebf3;
  --text-dim:    #9aa5bb;
  --text-faint:  #67728a;

  --accent:      #4c8dff;
  --accent-soft: rgba(76, 141, 255, .14);
  --success:     #35c07f;
  --success-soft:rgba(53, 192, 127, .14);
  --warn:        #f0b429;
  --warn-soft:   rgba(240, 180, 41, .14);
  --danger:      #f0616d;
  --danger-soft: rgba(240, 97, 109, .14);
  --violet:      #a476ff;

  --radius:    10px;
  --radius-sm: 7px;
  --radius-lg: 14px;

  --shadow:    0 8px 28px rgba(0, 0, 0, .45);
  --sidebar-w: 224px;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo",
          "Malgun Gothic", "Noto Sans KR", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2b3547; }

/* ── 로그인 ───────────────────────────────────────────────── */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(76, 141, 255, .12), transparent 70%),
    var(--bg);
}

.login__card {
  width: min(100%, 380px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

.login__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login__brand h1 { font-size: 18px; }
.login__brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-dim); }

.login__mark, .sidebar__mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  flex: 0 0 38px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--accent), #7b5bff);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .02em;
}

.login__error {
  margin: 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: #ff97a0;
  font-size: 12.5px;
}

/* ── 폼 요소 ──────────────────────────────────────────────── */
.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.field--inline { display: flex; align-items: center; gap: 8px; }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}

textarea { resize: vertical; min-height: 70px; line-height: 1.55; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:disabled, select:disabled { opacity: .5; cursor: not-allowed; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%239aa5bb' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 28px;
}

input[type=checkbox] {
  accent-color: var(--accent);
  width: 15px; height: 15px;
  cursor: pointer;
}

/* ── 버튼 ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, border-color .14s, opacity .14s;
}

.btn:hover:not(:disabled) { background: var(--surface-3); border-color: #2c374a; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: #5f9bff; border-color: #5f9bff; }
.btn--danger { background: transparent; border-color: rgba(240,97,109,.4); color: #ff8d96; }
.btn--danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--block { width: 100%; padding: 10px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background .14s, color .14s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ── 레이아웃 ─────────────────────────────────────────────── */
.shell { display: flex; min-height: 100dvh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.sidebar__mark { width: 32px; height: 32px; flex-basis: 32px; font-size: 12.5px; border-radius: 9px; }
.sidebar__name { font-weight: 650; font-size: 14px; letter-spacing: -.01em; }

.nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: grid; gap: 2px; align-content: start; }

.nav__group {
  padding: 14px 8px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .14s, color .14s;
}
.nav__item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav__item.is-active { background: var(--accent-soft); color: #a9c8ff; font-weight: 600; }
.nav__item svg { flex: 0 0 17px; opacity: .85; }

.sidebar__foot { padding: 12px 12px 14px; border-top: 1px solid var(--border-soft); display: grid; gap: 8px; }
.whoami { display: flex; align-items: center; gap: 7px; min-width: 0; }
.whoami__name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__actions { display: flex; gap: 4px; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: rgba(10, 13, 19, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar__menu { display: none; }
.topbar__title { flex: 1; min-width: 0; }
.topbar__title h2 { font-size: 17px; }
.topbar__title p { margin: 1px 0 0; font-size: 12.5px; color: var(--text-dim); }
.topbar__right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.content { flex: 1; padding: 22px 24px 56px; display: grid; gap: 18px; align-content: start; }

.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.5); }

/* ── 카드 / 그리드 ────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}

.card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.card__head h3 { font-size: 13.5px; }
.card__head p { margin: 0; font-size: 12px; color: var(--text-dim); }
.card__head .spacer { flex: 1; }
.card__body { padding: 16px; }
.card__body--flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(172px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ── 스탯 타일 ────────────────────────────────────────────── */
.stat {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  gap: 5px;
  align-content: start;
}
.stat__label { font-size: 11.5px; color: var(--text-dim); font-weight: 500; letter-spacing: .01em; }
.stat__value { font-size: 25px; font-weight: 680; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat__value small { font-size: 13px; font-weight: 500; color: var(--text-dim); margin-left: 3px; }
.stat__note { font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.stat--accent .stat__value { color: #8fb8ff; }
.stat--success .stat__value { color: var(--success); }
.stat--warn .stat__value { color: var(--warn); }
.stat--danger .stat__value { color: var(--danger); }

/* ── 테이블 ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

.tbl th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  text-align: left;
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th .arrow { opacity: .55; font-size: 9px; margin-left: 3px; }

.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.tbl tbody tr:hover td { background: rgba(255, 255, 255, .022); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }
.tbl .wrap { white-space: normal; min-width: 200px; }
.tbl .dim { color: var(--text-dim); }
.tbl .row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.tbl input[type=checkbox] { vertical-align: middle; }

.truncate { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }

.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* ── 배지 / 칩 ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.badge--accent  { background: var(--accent-soft);  color: #8fb8ff; }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warn    { background: var(--warn-soft);    color: var(--warn); }
.badge--danger  { background: var(--danger-soft);  color: #ff8d96; }
.badge--violet  { background: rgba(164,118,255,.14); color: #c4a6ff; }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ── 필터바 ───────────────────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
}
.filters input, .filters select { width: auto; min-width: 130px; }
.filters .search { min-width: 210px; flex: 1 1 210px; max-width: 340px; }
.filters .spacer { flex: 1; }

/* ── 진행바 ───────────────────────────────────────────────── */
.meter {
  position: relative;
  height: 6px;
  min-width: 74px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.meter > span { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--accent); }
.meter--success > span { background: var(--success); }
.meter--warn > span { background: var(--warn); }
.meter--danger > span { background: var(--danger); }
.meter-cell { display: flex; align-items: center; gap: 8px; }
.meter-cell > span.val { font-family: var(--mono); font-size: 12px; color: var(--text-dim); min-width: 42px; text-align: right; }

/* ── 페이지네이션 ─────────────────────────────────────────── */
.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-top: 1px solid var(--border-soft);
  font-size: 12.5px;
  color: var(--text-dim);
}
.pager .spacer { flex: 1; }

/* ── 차트 ─────────────────────────────────────────────────── */
.chart { width: 100%; display: block; }
.chart text { font-family: var(--sans); fill: var(--text-faint); font-size: 10px; }
.chart .grid-line { stroke: var(--border-soft); stroke-width: 1; }
.chart .axis-line { stroke: var(--border); stroke-width: 1; }
.chart .dot-pt { fill: var(--accent); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 0 16px 14px; font-size: 12px; color: var(--text-dim); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 58px 1fr 46px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-row .label { color: var(--text-dim); }
.bar-row .val { text-align: right; font-family: var(--mono); font-size: 12px; }

/* ── 토스트 ───────────────────────────────────────────────── */
.toasts {
  position: fixed;
  z-index: 90;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  justify-items: end;
}
.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 340px;
  animation: toast-in .18s ease-out;
}
.toast--success { border-color: rgba(53,192,127,.45); color: #7ee0ad; }
.toast--error   { border-color: rgba(240,97,109,.45); color: #ff9aa2; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ── 모달 ─────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.modal__scrim { position: absolute; inset: 0; background: rgba(0,0,0,.62); backdrop-filter: blur(2px); }
.modal__panel {
  position: relative;
  width: min(100%, 620px);
  max-height: min(86dvh, 820px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  animation: modal-in .16s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } }

.modal__head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border-soft); }
.modal__head h3 { flex: 1; font-size: 15px; }
.modal__body { padding: 18px; overflow-y: auto; display: grid; gap: 14px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 18px; border-top: 1px solid var(--border-soft); }

.form-grid { display: grid; gap: 13px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
.hint { margin: 0; font-size: 12px; color: var(--text-faint); line-height: 1.5; }
.notice {
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: #ffd479;
  font-size: 12.5px;
  line-height: 1.55;
}

/* ── 로딩 ─────────────────────────────────────────────────── */
.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.loading { display: grid; gap: 14px; }
.loading .skeleton { height: 74px; }

/* ── 반응형 ───────────────────────────────────────────────── */
@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .shell.is-open .sidebar { transform: none; }
  .main { margin-left: 0; }
  .topbar__menu { display: grid; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 48px; }
}

@media (max-width: 560px) {
  .grid--stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .stat__value { font-size: 21px; }
  .filters { padding: 10px 12px; }
  .filters .search { max-width: none; }
  .topbar__title h2 { font-size: 15.5px; }
  .modal__panel { max-height: 92dvh; }
}
