/*
 * View3 OPS 관리자 디자인 시스템
 *
 * 방향: 애플의 여백·타이포·부드러운 곡률 + 머티리얼의 명확한 상태 표현(엘리베이션·피드백).
 * 외부 CDN 을 쓰지 않는다(폐쇄망·오프라인에서도 동일하게 뜨도록 시스템 폰트 + 인라인 SVG).
 *
 * 토큰 → 레이아웃 → 컴포넌트 순으로 정리했다. 새 화면은 여기 있는 클래스를 조합해서 만든다.
 */

/* ─────────────────────────────  토큰  ───────────────────────────── */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fafafc;
  --border: #e5e5ea;
  --border-strong: #d2d2d7;

  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;

  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: #e8f2fe;

  --success: #34c759;
  --success-soft: #e7f8ec;
  --warning: #ff9f0a;
  --warning-soft: #fff4e5;
  --danger: #ff3b30;
  --danger-soft: #ffecea;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-full: 999px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 3px rgba(0, 0, 0, .06);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, .06), 0 2px 4px rgba(0, 0, 0, .04);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, .10), 0 4px 8px rgba(0, 0, 0, .04);

  --sidebar-w: 248px;
  --topbar-h: 60px;

  --ease: cubic-bezier(.4, 0, .2, 1);

  --font: 'Pretendard', -apple-system, BlinkMacSystemFont, 'SF Pro KR', 'SF Pro Display',
          'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --border: #38383a;
    --border-strong: #48484a;
    --text: #f5f5f7;
    --text-2: #aeaeb2;
    --text-3: #8e8e93;
    --accent: #0a84ff;
    --accent-hover: #409cff;
    --accent-soft: #0a273f;
    --success-soft: #10301a;
    --warning-soft: #3a2a0a;
    --danger-soft: #3a1512;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 4px 12px rgba(0, 0, 0, .5);
    --shadow-3: 0 12px 32px rgba(0, 0, 0, .6);
  }
}

/* ─────────────────────────────  기본  ───────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }

svg.icon { width: 20px; height: 20px; flex: 0 0 auto; stroke-width: 1.7; }

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

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

.sidebar__brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.02em;
}

.sidebar__logo {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #5856d6);
  color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 800;
}

.sidebar__nav { flex: 1; overflow-y: auto; padding: 12px 12px 24px; }

.sidebar__section {
  padding: 16px 12px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.sidebar__link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar__link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar__link.active svg { stroke: var(--accent); }

.sidebar__footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
}

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

.topbar {
  position: sticky; top: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}

.topbar__title { font-size: 17px; font-weight: 650; letter-spacing: -.02em; }
.topbar__spacer { flex: 1; }

.topbar__user {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 6px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
}
.topbar__avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #5856d6, var(--accent));
  color: #fff; display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
}

.menu-toggle {
  display: none;
  width: 36px; height: 36px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); cursor: pointer;
}

.content { padding: 28px; max-width: 1440px; }

.page-head { margin-bottom: 22px; display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; letter-spacing: -.03em; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; }

/* ─────────────────────────────  카드 · 그리드  ───────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 18px; }

.card__head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card__head h2 { font-size: 15px; }
.card__head .spacer { flex: 1; }
.card__body { padding: 20px; }
.card__body--flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 1100px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 지표 타일 */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-1);
}
.stat__label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.stat__value { font-size: 28px; font-weight: 680; letter-spacing: -.03em; margin-top: 6px; }
.stat__meta { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.stat--accent .stat__value { color: var(--accent); }
.stat--warning .stat__value { color: var(--warning); }
.stat--danger .stat__value { color: var(--danger); }
.stat--success .stat__value { color: var(--success); }

/* ─────────────────────────────  버튼  ───────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius-full);
  background: var(--accent); color: #fff;
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .18s var(--ease), transform .12s var(--ease), box-shadow .18s var(--ease);
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--danger); }
.btn--danger:hover { background: #ff5147; }
.btn--sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn--icon { width: 32px; height: 32px; padding: 0; border-radius: 50%; }
.btn--block { width: 100%; }

/* ─────────────────────────────  폼  ───────────────────────────── */
.field { margin-bottom: 16px; }
.field__label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field__label .req { color: var(--danger); margin-left: 2px; }
.field__hint { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.5; }

.input, .select, .textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit; font-size: 13.5px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.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-3); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.6; font-family: var(--font-mono); font-size: 13px; }
.input:disabled, .textarea:disabled { background: var(--surface-2); color: var(--text-3); }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%238e8e93' stroke-width='1.6' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-row { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .form-row, .form-row--3 { grid-template-columns: 1fr; } }

/* 폼 안 구분선 — 성격이 다른 묶음 사이에만 쓴다(자주 쓰면 줄만 많아진다). */
hr.divider { margin: 20px 0; border: 0; border-top: 1px solid var(--border); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  width: 42px; height: 25px; border-radius: var(--radius-full);
  background: var(--border-strong); position: relative;
  transition: background .22s var(--ease);
}
.switch__track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 21px; height: 21px; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-1);
  transition: transform .22s var(--ease);
}
.switch input:checked + .switch__track { background: var(--success); }
.switch input:checked + .switch__track::after { transform: translateX(17px); }

/* 검색 바 */
.toolbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; height: 34px; }

/* ─────────────────────────────  테이블  ───────────────────────────── */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th, table.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.table th {
  font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-3); background: var(--surface-2); white-space: nowrap;
}
table.table tbody tr { transition: background .15s var(--ease); }
table.table tbody tr:hover { background: var(--surface-2); }
table.table td.num,
table.table th.num { text-align: right; }
table.table td.num { font-variant-numeric: tabular-nums; }
table.table td.actions { text-align: right; white-space: nowrap; }
.table__empty { padding: 56px 20px; text-align: center; color: var(--text-3); }

.mono { font-family: var(--font-mono); font-size: 12.5px; }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─────────────────────────────  뱃지 · 알림  ───────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2);
}
.badge--success { background: var(--success-soft); color: #1d8a3a; }
.badge--warning { background: var(--warning-soft); color: #a76500; }
.badge--danger { background: var(--danger-soft); color: #c9241a; }
.badge--accent { background: var(--accent-soft); color: var(--accent); }

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--warning-soft); color: #8a5400;
  font-size: 13px; line-height: 1.6;
}
.notice--danger { background: var(--danger-soft); color: #c9241a; }
.notice--success { background: var(--success-soft); color: #1c7c3a; }
.notice--info { background: var(--accent-soft); color: var(--accent); }
.notice + .notice { margin-top: 10px; }

/* ─────────────────────────────  페이지네이션  ───────────────────────────── */
.pagination { display: flex; gap: 4px; justify-content: center; padding: 16px; }
.pagination a, .pagination span {
  min-width: 32px; height: 32px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-2);
}
.pagination a:hover { background: var(--surface-2); text-decoration: none; }
.pagination .is-current { background: var(--accent); color: #fff; font-weight: 600; }

/* ─────────────────────────────  모달  ───────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, .38);
  backdrop-filter: blur(3px);
}
.modal.is-open { display: flex; animation: fade .18s var(--ease); }
.modal__dialog {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  animation: pop .22s var(--ease);
}
.modal__dialog--wide { max-width: 820px; }
.modal__head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal__head h2 { font-size: 16px; flex: 1; }
.modal__body { padding: 22px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px; border-top: 1px solid var(--border); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* ─────────────────────────────  토스트  ───────────────────────────── */
.toast-stack {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  min-width: 260px; max-width: 400px;
  padding: 13px 16px;
  border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-3);
  font-size: 13px; font-weight: 500;
  animation: slide-in .24s var(--ease);
}
.toast--success { border-left: 3px solid var(--success); }
.toast--error { border-left: 3px solid var(--danger); }
.toast--info { border-left: 3px solid var(--accent); }
.toast.is-leaving { animation: slide-out .2s var(--ease) forwards; }

@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } }
@keyframes slide-out { to { opacity: 0; transform: translateX(24px); } }

/* ─────────────────────────────  로그인  ───────────────────────────── */
.login {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), var(--bg) 60%);
}
.login__card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-3);
  padding: 36px 32px 30px;
}
.login__logo {
  width: 46px; height: 46px; margin: 0 auto 18px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), #5856d6);
  color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 16px;
}
.login h1 { font-size: 20px; text-align: center; letter-spacing: -.02em; }
.login__sub { text-align: center; color: var(--text-2); font-size: 13px; margin: 6px 0 26px; }
.login__error { display: none; margin-bottom: 14px; }

/* ─────────────────────────────  유틸  ───────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row--between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; }
.hidden { display: none !important; }

.copy-field { display: flex; gap: 6px; }
.copy-field .input { font-family: var(--font-mono); font-size: 12.5px; }

/* ─────────────────────────────  반응형  ───────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-3); }
  .sidebar.is-open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: grid; place-items: center; }
  .content { padding: 18px; }
  .grid--4, .grid--3, .grid--2 { grid-template-columns: 1fr; }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.3); display: none; }
  .sidebar-scrim.is-open { display: block; }
}
