/* =====================================================================
 * 신규 통합 콘솔 — 디자인 시스템
 *  - aria-muse v1 의 토큰을 그대로 채택 (시안 3 / 미니멀 워크스페이스)
 *  - 사이드바 248px + 본문 1fr / 미니 48px
 *  - Pretendard Variable
 * ===================================================================== */

/* --- 토큰 (라이트) --- */
:root {
  --bg: #fbfbfa;
  --panel: #ffffff;
  --ink: #1f1f1f;
  --ink-2: #3a3a3a;
  --muted: #8a8a8a;
  --line: #ececea;
  --line-2: #f3f3f1;
  --hover: #f4f4f2;
  --accent: #d97706;
  --accent-soft: #fef3c7;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --info: #1d4ed8;
  --radius: 8px;
  --side-w: 248px;
  --side-w-mini: 48px;
  --top-h: 56px;
  --shadow-sm: 0 1px 2px rgba(15, 15, 15, 0.04);
  --shadow-md: 0 6px 18px rgba(15, 15, 15, 0.06);
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont,
          'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, sans-serif;
}

html[data-theme='dark'] {
  --bg: #15161a;
  --panel: #1c1d22;
  --ink: #ececec;
  --ink-2: #cfcfcf;
  --muted: #8e9098;
  --line: #2a2c33;
  --line-2: #23252b;
  --hover: #23252b;
  --accent: #fbbf24;
  --accent-soft: #3b2d12;
  --ok: #86efac;
  --warn: #fbbf24;
  --danger: #f87171;
  --info: #93c5fd;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4);
}

/* --- 폰트 --- */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.css');

/* --- 리셋 / 베이스 --- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }

/* --- 레이아웃 --- */
.app {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  grid-template-rows: var(--top-h) 1fr;
  grid-template-areas:
    'side top'
    'side main';
  min-height: 100vh;
}
.app[data-side='mini'] { grid-template-columns: var(--side-w-mini) 1fr; }

/* --- 사이드바 --- */
.side {
  grid-area: side;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side .brand {
  height: var(--top-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-weight: 700;
  font-size: 15px;
  border-bottom: 1px solid var(--line);
  letter-spacing: -0.01em;
}
.side .group { padding: 8px 0 4px; }
.side .group-title {
  padding: 6px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}
.side a.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 13.5px;
  color: var(--ink-2);
  border-left: 2px solid transparent;
}
.side a.menu-item:hover { background: var(--hover); }
.side a.menu-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}
.side a.menu-item .icon {
  width: 16px;
  display: inline-flex;
  justify-content: center;
  color: var(--muted);
}
.side a.menu-item.active .icon { color: var(--accent); }

.app[data-side='mini'] .side .group-title,
.app[data-side='mini'] .side a.menu-item .label,
.app[data-side='mini'] .side .brand .label { display: none; }
.app[data-side='mini'] .side a.menu-item { justify-content: center; padding: 8px 0; }

/* --- 상단바 --- */
.top {
  grid-area: top;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.top .toggle {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
}
.top .crumb {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.top .spacer { flex: 1; }
.top .user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.top .user .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

/* --- 본문 --- */
.main {
  grid-area: main;
  padding: 20px 24px 60px;
  overflow-x: auto;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* --- 카드 --- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 12px; }
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

/* --- KPI --- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.kpi .kpi-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi .kpi-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -0.02em;
}
.kpi .kpi-delta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* --- 테이블 --- */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
table.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.t th, table.t td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
table.t thead th {
  background: var(--line-2);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: -0.01em;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--line);
}
table.t tbody tr:hover { background: var(--hover); }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* --- pill / badge --- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--line-2);
  color: var(--ink-2);
}
.pill.ok      { background: #dcfce7; color: var(--ok);     border-color: #bbf7d0; }
.pill.warn    { background: #fef3c7; color: var(--warn);   border-color: #fde68a; }
.pill.danger  { background: #fee2e2; color: var(--danger); border-color: #fecaca; }
.pill.info    { background: #dbeafe; color: var(--info);   border-color: #bfdbfe; }
html[data-theme='dark'] .pill.ok     { background: #052e16; color: #86efac; border-color: #14532d; }
html[data-theme='dark'] .pill.warn   { background: #422006; color: #fbbf24; border-color: #78350f; }
html[data-theme='dark'] .pill.danger { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
html[data-theme='dark'] .pill.info   { background: #172554; color: #93c5fd; border-color: #1e3a8a; }

/* --- 버튼 --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(0.95); }
.btn.danger  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost   { background: transparent; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* --- 폼 --- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}
.form-grid.full > * { grid-column: 1 / -1; }
.form-row { display: flex; gap: 8px; align-items: stretch; }
label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
}
label.field > span { font-weight: 600; }
input[type='text'], input[type='email'], input[type='password'],
input[type='date'], input[type='datetime-local'], input[type='tel'],
input[type='number'], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.1s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 80px; resize: vertical; }
input[readonly] { background: var(--line-2); }

/* --- toolbar / 검색 --- */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.toolbar input[type='search'], .toolbar input[type='text'] { min-width: 240px; }

/* --- 알림(flash) --- */
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 12px;
  font-size: 13px;
}
.flash.success { background: #dcfce7; color: var(--ok);     border-color: #bbf7d0; }
.flash.warning { background: #fef3c7; color: var(--warn);   border-color: #fde68a; }
.flash.danger  { background: #fee2e2; color: var(--danger); border-color: #fecaca; }
.flash.info    { background: #dbeafe; color: var(--info);   border-color: #bfdbfe; }

/* --- 자동완성 드롭다운 --- */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-list .item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--line-2);
}
.autocomplete-list .item:last-child { border-bottom: none; }
.autocomplete-list .item:hover,
.autocomplete-list .item.active { background: var(--hover); }
.autocomplete-list .item .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* --- 로그인 화면 --- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  box-shadow: var(--shadow-md);
}
.login-card h1 {
  font-size: 18px;
  margin: 0 0 18px;
  letter-spacing: -0.02em;
}

/* --- 라벨 출력 (인쇄 전용) --- */
@media print {
  .side, .top, .toolbar, .btn-row { display: none !important; }
  .main { padding: 0; }
}
