/* ========================================================================
   e뉴스라인 v2 · 디자인 시스템
   Bootstrap 5.3 + Pretendard + 커스텀 토큰
   ======================================================================== */

/* ---------- 1. 디자인 토큰 ---------- */
:root {
  /* Brand */
  --brand-50:  #eef7ff;
  --brand-100: #d9eeff;
  --brand-200: #b6ddff;
  --brand-300: #7dc2ff;
  --brand-400: #3fa0f5;
  --brand-500: #147fda;
  --brand-600: #0768c3;
  --brand-700: #07539e;
  --brand-800: #0a477f;
  --brand-900: #0e3d69;
  --brand-950: #092743;

  /* Neutral (slate) */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* Semantic */
  --success: #059669;
  --success-bg: #dff7ea;
  --warning: #d97706;
  --warning-bg: #fff2cc;
  --danger:  #dc2626;
  --danger-bg:  #ffe1df;
  --info:    #0891b2;
  --info-bg:    #d8f5fb;
  --rose: #e11d48;
  --rose-bg: #ffe4ea;

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-bg: var(--slate-900);
  --header-height: 64px;
  --content-padding: 28px;

  /* Radius / Shadow */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm: 0 8px 18px rgba(15, 23, 42, .06);
  --shadow:    0 14px 30px rgba(15, 23, 42, .09);
  --shadow-lg: 0 24px 50px rgba(15, 23, 42, .14);

  /* Bootstrap override */
  --bs-primary: var(--brand-600);
  --bs-primary-rgb: 7, 104, 195;
  --bs-body-bg: var(--slate-50);
  --bs-body-color: var(--slate-800);
  --bs-border-color: var(--slate-200);
  --bs-link-color: var(--brand-600);
  --bs-link-hover-color: var(--brand-700);
  --bs-font-sans-serif: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Noto Sans KR", system-ui, "Segoe UI", Roboto, sans-serif;
}

[data-bs-theme="dark"] {
  --bs-body-bg: var(--slate-950);
  --bs-body-color: var(--slate-100);
  --bs-border-color: var(--slate-800);
  --sidebar-bg: var(--slate-950);
}

/* ---------- 2. Reset / Base ---------- */
html, body {
  height: 100%;
}
body {
  font-family: var(--bs-font-sans-serif);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0;
  font-feature-settings: "ss03", "cv11";
  background:
    linear-gradient(180deg, rgba(238, 247, 255, .78), rgba(248, 250, 252, 0) 340px),
    var(--bs-body-bg);
}
*, *::before, *::after { box-sizing: border-box; }

a { text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--slate-700); }

/* ---------- 3. 레이아웃 ---------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.app-sidebar {
  background:
    linear-gradient(180deg, rgba(20, 127, 218, .14), transparent 220px),
    var(--sidebar-bg);
  color: var(--slate-300);
  border-right: 1px solid var(--slate-800);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.app-sidebar .brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--slate-800);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0;
  color: #fff;
}
.app-sidebar .brand .brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  border-radius: 7px;
  margin-right: 10px;
  font-weight: 800;
  box-shadow: 0 6px 12px rgba(20, 127, 218, .32);
}

.app-sidebar .nav-section {
  padding: 20px 14px 8px;
  font-size: 0.7rem;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0;
}
.app-sidebar .nav-link {
  color: var(--slate-300);
  padding: 10px 14px;
  border-radius: 7px;
  margin: 1px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background-color .15s, color .15s, transform .15s;
}
.app-sidebar .nav-link i {
  font-size: 1.05rem;
  width: 1.25rem;
  text-align: center;
  color: var(--slate-400);
}
.app-sidebar .nav-link:hover {
  background: rgba(255, 255, 255, .05);
  color: #fff;
  text-decoration: none;
  transform: translateX(1px);
}
.app-sidebar .nav-link.active {
  background: linear-gradient(90deg, rgba(20, 127, 218, .24), rgba(20, 127, 218, .06));
  color: #fff;
  box-shadow: inset 2px 0 0 var(--brand-500);
}
.app-sidebar .nav-link.active i { color: var(--brand-300); }
.app-sidebar .nav-badge {
  margin-left: auto;
  background: var(--brand-600);
  color: #fff;
  font-size: 0.7rem;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-header {
  height: var(--header-height);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  padding: 0 var(--content-padding);
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
[data-bs-theme="dark"] .app-header {
  background: rgba(15, 23, 42, .85);
  border-bottom-color: var(--slate-800);
}
.app-header .page-title {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0;
}
.app-header .breadcrumb-trail {
  color: var(--slate-500);
  font-size: 0.85rem;
}
.app-header .header-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.icon-btn {
  width: 38px; height: 38px;
  display: inline-grid; place-items: center;
  border-radius: 7px;
  border: 1px solid var(--slate-200);
  background: #fff;
  color: var(--slate-700);
  position: relative;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .15s;
}
.icon-btn:hover { background: var(--slate-50); border-color: var(--slate-300); transform: translateY(-1px); }
[data-bs-theme="dark"] .icon-btn { background: var(--slate-900); border-color: var(--slate-800); color: var(--slate-200); }
.icon-btn .pip {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 0 2px #fff;
}

.app-content { padding: var(--content-padding); flex: 1; }

/* ---------- 4. 대시보드 히어로 ---------- */
.dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px;
  border-radius: var(--radius-xl);
  color: #fff;
  background:
    linear-gradient(135deg, rgba(9, 39, 67, .98), rgba(7, 104, 195, .92)),
    var(--brand-900);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.dashboard-hero::after {
  content: '';
  position: absolute;
  inset: auto -8% -54% 52%;
  height: 180px;
  background: linear-gradient(135deg, rgba(255,255,255,.16), rgba(255,255,255,0));
  transform: rotate(-8deg);
}
.dashboard-hero > * { position: relative; z-index: 1; }
.dashboard-hero .eyebrow {
  font-size: .76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  color: rgba(255, 255, 255, .7);
  margin-bottom: 8px;
}
.dashboard-hero h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2.3vw, 2rem);
  font-weight: 800;
}
.dashboard-hero p {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, .72);
  max-width: 560px;
}
.hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.btn-hero-soft {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.16);
  color: #fff;
}
.btn-hero-soft:hover {
  background: rgba(255,255,255,.2);
  border-color: rgba(255,255,255,.24);
  color: #fff;
}

/* ---------- 5. 카드 ---------- */
.card {
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  background: #fff;
  overflow: hidden;
}
[data-bs-theme="dark"] .card { background: var(--slate-900); border-color: var(--slate-800); }
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--slate-200);
  padding: 15px 18px;
  font-weight: 700;
}
[data-bs-theme="dark"] .card-header { border-bottom-color: var(--slate-800); }
.card-body { padding: 18px; }

.stat-card { transition: transform .15s, box-shadow .15s, border-color .15s; }
.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.stat-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.stat-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: 1.1rem;
}
.stat-icon-blue { background: var(--brand-50); color: var(--brand-700); }
.stat-icon-amber { background: var(--warning-bg); color: #a16207; }
.stat-icon-green { background: var(--success-bg); color: #047857; }
.stat-icon-rose { background: var(--rose-bg); color: var(--rose); }
.stat-card .stat-label {
  color: var(--slate-500);
  font-size: 0.82rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 6px;
}
.stat-card .stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.1;
}
.stat-card .stat-delta {
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--slate-100);
}
.stat-card .stat-delta.up   { color: var(--success); }
.stat-card .stat-delta.down { color: var(--danger);  }
.stat-card .stat-delta.attention { color: var(--rose); }
.stat-caption {
  color: var(--slate-500);
  font-size: .8rem;
  margin-top: 8px;
}

/* ---------- 6. 버튼 ---------- */
.btn {
  border-radius: 7px;
  font-weight: 500;
  padding: 8px 14px;
  font-size: 0.92rem;
  transition: all .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary {
  background: var(--brand-600);
  border-color: var(--brand-600);
  box-shadow: 0 1px 2px rgba(7, 104, 195, .32);
}
.btn-primary:hover {
  background: var(--brand-700);
  border-color: var(--brand-700);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(7, 104, 195, .28);
}
.btn-soft {
  background: var(--slate-100);
  border-color: transparent;
  color: var(--slate-700);
}
.btn-soft:hover { background: var(--slate-200); color: var(--slate-900); }
.btn-sm { padding: 5px 10px; font-size: 0.84rem; }

/* ---------- 7. 테이블 ---------- */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.data-table thead th {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--slate-500);
  background: var(--slate-50);
  border-bottom: 1px solid var(--slate-200);
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
}
[data-bs-theme="dark"] .data-table thead th { background: var(--slate-900); color: var(--slate-400); border-bottom-color: var(--slate-800); }
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--slate-100);
  font-size: 0.92rem;
  vertical-align: middle;
}
[data-bs-theme="dark"] .data-table tbody td { border-bottom-color: var(--slate-800); }
.data-table tbody tr:hover { background: var(--slate-50); }
[data-bs-theme="dark"] .data-table tbody tr:hover { background: var(--slate-900); }
.data-table tbody tr:last-child td { border-bottom: 0; }

.col-num { font-variant-numeric: tabular-nums; text-align: right; }
.col-currency::before { content: '₩'; color: var(--slate-400); margin-right: 2px; }
.text-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.86em; }
.table-title {
  max-width: 260px;
}

/* ---------- 8. 상태 배지 ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 999px;
  background: currentColor;
}
.status-new     { background: var(--info-bg);    color: #0e7490; }
.status-progress{ background: var(--warning-bg); color: #b45309; }
.status-sent    { background: var(--success-bg); color: #047857; }
.status-done    { background: var(--slate-200);  color: var(--slate-700); }
.status-rejected{ background: var(--danger-bg);  color: #b91c1c; }
.status-hold    { background: #ede9fe;           color: #6d28d9; }

/* ---------- 9. 폼 ---------- */
.form-label {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--slate-700);
  margin-bottom: 6px;
}
[data-bs-theme="dark"] .form-label { color: var(--slate-300); }
.form-control, .form-select {
  border-radius: 7px;
  border: 1px solid var(--slate-300);
  padding: 8px 12px;
  font-size: 0.92rem;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(20, 127, 218, .14);
}
.form-help { font-size: 0.78rem; color: var(--slate-500); margin-top: 4px; }
.form-required::after { content: ' *'; color: var(--danger); }

/* ---------- 10. 빠른 작업 / 상태 ---------- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.quick-action {
  min-height: 86px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  color: var(--slate-700);
  background: var(--slate-50);
  font-weight: 700;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.quick-action i {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  color: var(--brand-700);
  box-shadow: var(--shadow-xs);
}
.quick-action:hover {
  color: var(--slate-900);
  text-decoration: none;
  transform: translateY(-1px);
  border-color: var(--brand-200);
  box-shadow: var(--shadow-sm);
}
.quick-action.primary {
  background: var(--brand-600);
  color: #fff;
  border-color: var(--brand-600);
}
.quick-action.primary i {
  color: var(--brand-700);
}
.status-list {
  padding-top: 8px;
  padding-bottom: 8px;
}
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--slate-100);
}
.status-row:last-child { border-bottom: 0; }

/* ---------- 11. 로그인/공개 페이지 ---------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(9, 39, 67, .07), rgba(20, 127, 218, .12)),
    var(--slate-50);
  padding: 32px 16px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
  border: 1px solid var(--slate-200);
}
.auth-card .brand-mark {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  border-radius: 10px;
  display: grid; place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  margin-bottom: 18px;
  box-shadow: 0 10px 20px rgba(20, 127, 218, .28);
}
.auth-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 4px;
}
.auth-card .lead { color: var(--slate-500); font-size: 0.92rem; }

/* ---------- 12. 유틸 ---------- */
.divider-y { border-left: 1px solid var(--slate-200); height: 24px; }
[data-bs-theme="dark"] .divider-y { border-left-color: var(--slate-800); }

.text-xs { font-size: 0.78rem; }
.text-muted-2 { color: var(--slate-500) !important; }

.kbd {
  display: inline-block;
  font-family: ui-monospace, monospace;
  font-size: 0.78em;
  padding: 1px 6px;
  border: 1px solid var(--slate-300);
  border-radius: 4px;
  background: var(--slate-100);
  color: var(--slate-700);
  vertical-align: 2px;
}

/* ---------- 13. 다크 모드 보정 ---------- */
[data-bs-theme="dark"] body {
  background:
    linear-gradient(180deg, rgba(7, 104, 195, .1), rgba(2, 6, 23, 0) 320px),
    var(--bs-body-bg);
}
[data-bs-theme="dark"] .stat-icon-blue,
[data-bs-theme="dark"] .stat-icon-amber,
[data-bs-theme="dark"] .stat-icon-green,
[data-bs-theme="dark"] .stat-icon-rose,
[data-bs-theme="dark"] .quick-action,
[data-bs-theme="dark"] .stat-card .stat-delta {
  background: var(--slate-800);
}
[data-bs-theme="dark"] .quick-action {
  border-color: var(--slate-800);
  color: var(--slate-200);
}
[data-bs-theme="dark"] .quick-action i {
  background: var(--slate-900);
}
[data-bs-theme="dark"] .status-row {
  border-bottom-color: var(--slate-800);
}

/* ---------- 14. 반응형 ---------- */
@media (max-width: 991.98px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar { position: fixed; left: -100%; width: 280px; z-index: 1050; transition: left .25s ease; }
  .app-sidebar.is-open { left: 0; }
  .dashboard-hero {
    align-items: flex-start;
    flex-direction: column;
  }
  .hero-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 575.98px) {
  :root {
    --content-padding: 18px;
  }
  .app-header {
    padding: 0 var(--content-padding);
  }
  .dashboard-hero {
    padding: 22px;
  }
  .hero-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
  .quick-actions {
    grid-template-columns: 1fr;
  }
}
