:root {
  --brand-navy: #2e2a4d;
  --brand-navy-dark: #211e38;
  --brand-red: #cd0e2e;
  --brand-red-dark: #a80b25;
}

html {
  font-size: 14px;
}

body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Malgun Gothic", sans-serif;
}

.btn-primary {
  --bs-btn-bg: var(--brand-red);
  --bs-btn-border-color: var(--brand-red);
  --bs-btn-hover-bg: var(--brand-red-dark);
  --bs-btn-hover-border-color: var(--brand-red-dark);
  --bs-btn-active-bg: var(--brand-red-dark);
  --bs-btn-active-border-color: var(--brand-red-dark);
  --bs-btn-focus-shadow-rgb: 205, 14, 46;
}

a {
  color: var(--brand-navy);
}

a:hover {
  color: var(--brand-red);
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

body.has-sidebar {
  margin-bottom: 0;
}

.brand-navbar {
  background-color: var(--brand-navy) !important;
}

.sidebar {
  width: 240px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1030;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
}

.sidebar-brand {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.main-content {
  min-width: 0;
}

@media (min-width: 992px) {
  .main-content {
    margin-left: 240px;
  }
}

.side-menu {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-top: 0.5rem;
}

.side-menu .nav-link {
  color: rgba(255, 255, 255, 0.75);
  padding: 0.6rem 1rem;
  border-left: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.side-menu .nav-link:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.08);
}

.side-menu .nav-link.active {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.1);
  border-left-color: var(--brand-red);
  font-weight: 600;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--brand-red);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
}

.stat-card {
  border-radius: 0.75rem;
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.stat-card .fs-4 {
  color: var(--brand-navy);
}

/* ── 로그인 화면 ─────────────────────────────────────────────────────── */

/* 로그인·에러 화면은 푸터가 없다 — 기본 템플릿이 남긴 하단 60px 여백 때문에
   100vh 로 잡은 로그인 화면에 스크롤바가 생기는 것을 막는다(사이드바 화면은 이미 0). */
body:not(.has-sidebar) {
  margin-bottom: 0;
}

.login-shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
  background: #fff;
}

@media (min-width: 992px) {
  .login-shell {
    grid-template-columns: 1.05fr 1fr;
  }
}

/* 왼쪽 브랜드 패널 — CI 남색 위에 붉은 광원을 얹고, 로고를 워터마크로 크게 깐다. */
.login-brand {
  display: none;
  position: relative;
  overflow: hidden;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
  padding: 3.5rem;
  color: #fff;
  background:
    radial-gradient(115% 85% at 6% 4%, rgba(205, 14, 46, 0.4) 0%, rgba(205, 14, 46, 0) 55%),
    radial-gradient(90% 70% at 98% 100%, rgba(96, 88, 160, 0.45) 0%, rgba(96, 88, 160, 0) 62%),
    linear-gradient(155deg, var(--brand-navy) 0%, var(--brand-navy-dark) 55%, #17142c 100%);
}

@media (min-width: 992px) {
  .login-brand {
    display: flex;
  }
}

/* 도트 그리드 — 위쪽만 옅게 남겨 문구를 가리지 않게 한다. */
.login-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 65%);
  mask-image: linear-gradient(to bottom, #000 0%, transparent 65%);
  pointer-events: none;
}

/* 로고 워터마크 */
.login-brand::after {
  content: "";
  position: absolute;
  right: -12%;
  bottom: -20%;
  width: 76%;
  aspect-ratio: 344 / 222;
  background: url("../images/logo-mark-dark-bg.svg") no-repeat center / contain;
  opacity: 0.07;
  pointer-events: none;
}

.login-brand > * {
  position: relative;
  z-index: 1;
}

.login-brand-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.login-brand-name {
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.login-brand-name b {
  font-weight: 700;
}

/* 브랜드 패널에는 슬로건 하나만 둔다 — 위의 짧은 레드 라인이 CI 를 잡아주는 역할. */
.login-slogan {
  margin: 0;
  font-size: clamp(2rem, 3.2vw, 3rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
  word-break: keep-all;
}

.login-slogan::before {
  content: "";
  display: block;
  width: 2.5rem;
  height: 3px;
  margin-bottom: 1.75rem;
  border-radius: 2px;
  background: var(--brand-red);
}

.login-brand-foot {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.45);
}

/* 오른쪽 폼 패널 */
.login-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.25rem;
  background: #fff;
}

/* 브랜드 패널이 숨는 좁은 화면에서도 CI 색이 한 줄은 남도록 */
.login-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand-red), var(--brand-navy));
}

@media (min-width: 992px) {
  .login-panel {
    padding: 3rem 2rem;
  }

  .login-panel::before {
    display: none;
  }
}

.login-form {
  width: 100%;
  max-width: 24rem;
  animation: login-rise 0.45s ease-out both;
}

@keyframes login-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.login-brand-head-sm {
  justify-content: center;
  margin-bottom: 1.75rem;
  color: var(--brand-navy);
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--brand-navy);
  margin-bottom: 0.35rem;
}

.login-subtitle {
  margin-bottom: 1.75rem;
  color: #6c757d;
  font-size: 0.9rem;
}

.login-alert {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 0;
  border-radius: 0.625rem;
  padding: 0.7rem 0.9rem;
  font-size: 0.85rem;
}

/* 서버 검증 실패 메시지 — 폼 위에 붉은 카드로 한 번만 모아 보여준다. */
.login-summary:not(.validation-summary-valid) {
  border-radius: 0.625rem;
  background: rgba(205, 14, 46, 0.07);
  color: var(--brand-red-dark);
  font-size: 0.85rem;
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
}

.login-summary ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.login-field {
  margin-bottom: 1rem;
}

.login-label {
  margin-bottom: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #4a4f5a;
}

.login-input {
  position: relative;
}

.login-input > .bi {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  line-height: 1;
  color: #a2a8b4;
  pointer-events: none;
  transition: color 0.15s ease-in-out;
}

.login-input .form-control {
  height: 3rem;
  padding-left: 2.65rem;
  border-radius: 0.625rem;
  border-color: #dfe2e8;
  background-color: #fafbfc;
}

.login-input .form-control::placeholder {
  color: #b3b8c2;
}

.login-input .form-control:focus {
  background-color: #fff;
  border-color: var(--brand-navy);
  box-shadow: 0 0 0 0.2rem rgba(46, 42, 77, 0.12);
}

.login-input:focus-within > .bi {
  color: var(--brand-navy);
}

/* 서버 검증에 걸린 칸 — 메시지만 붉게 두면 어느 칸인지 한 번 더 찾아야 한다. */
.login-input .form-control.input-validation-error {
  border-color: var(--brand-red);
  background-color: rgba(205, 14, 46, 0.03);
}

.login-input .form-control.input-validation-error:focus {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 0.2rem rgba(205, 14, 46, 0.12);
}

.login-input-password .form-control {
  padding-right: 3rem;
}

.login-toggle {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  padding: 0.35rem 0.55rem;
  border-radius: 0.5rem;
  line-height: 1;
  background: transparent;
  color: #8b919c;
}

.login-toggle:hover {
  color: var(--brand-navy);
  background: rgba(46, 42, 77, 0.07);
}

.login-toggle:focus-visible {
  outline: 2px solid var(--brand-navy);
  outline-offset: 1px;
}

.login-error {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--brand-red);
}

.login-check {
  margin-bottom: 1.5rem;
}

.login-check .form-check-input {
  border-color: #cfd3db;
}

.login-check .form-check-input:checked {
  background-color: var(--brand-red);
  border-color: var(--brand-red);
}

.login-check .form-check-label {
  font-size: 0.875rem;
  color: #4a4f5a;
}

.login-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 3rem;
  border: 0;
  border-radius: 0.625rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--brand-red) 0%, var(--brand-red-dark) 100%);
  box-shadow: 0 6px 16px rgba(205, 14, 46, 0.25);
  transition: transform 0.15s ease-in-out, box-shadow 0.15s ease-in-out, filter 0.15s ease-in-out;
}

.login-submit .bi {
  font-size: 0.9rem;
  transition: transform 0.15s ease-in-out;
}

.login-submit:hover {
  filter: brightness(1.05);
  box-shadow: 0 10px 22px rgba(205, 14, 46, 0.32);
  transform: translateY(-1px);
}

.login-submit:hover .bi {
  transform: translateX(2px);
}

.login-submit:active {
  transform: translateY(0);
}

.login-help {
  margin: 1.5rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid #eceef1;
  font-size: 0.8rem;
  color: #8b919c;
  text-align: center;
}

.login-foot {
  margin: 1.25rem 0 0;
  font-size: 0.75rem;
  color: #b3b8c2;
  text-align: center;
}

/* 한글은 어절 중간에서 줄이 바뀌면 읽기 나쁘다 — 문구는 어절 단위로 끊는다. */
.login-subtitle,
.login-help {
  word-break: keep-all;
}

@media (prefers-reduced-motion: reduce) {
  .login-form {
    animation: none;
  }

  .login-submit,
  .login-submit .bi,
  .login-input > .bi {
    transition: none;
  }

  .login-submit:hover,
  .login-submit:hover .bi {
    transform: none;
  }
}

/* ── 대시보드 지연 로드 패널 ─────────────────────────────────────────── */

/* 로딩 자리표시자 — 높이를 인라인으로 받아 실제 패널과 비슷하게 잡아두고, 채워질 때 아래가 밀리지 않게 한다. */
.panel-skeleton {
  border-radius: 0.5rem;
  background: linear-gradient(90deg, #f2f3f5 25%, #e9ebee 37%, #f2f3f5 63%);
  background-size: 400% 100%;
  animation: panel-skeleton-shimmer 1.4s ease-in-out infinite;
}

@keyframes panel-skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .panel-skeleton { animation: none; }
}

/* 전월 동기 대비 증감 배지 */
.delta {
  font-weight: 600;
  font-size: 0.95rem;
}

.delta-up { color: #0d7a3e; }
.delta-down { color: var(--brand-red); }
.delta-flat { color: #6c757d; }

.delta .bi {
  font-size: 0.7rem;
  vertical-align: 1px;
}

/* 오늘 배차 현황 타일 */
.dispatch-tile {
  border-radius: 0.5rem;
  background: #f5f6f8;
  padding: 0.5rem 0.25rem;
  color: #6c757d;
}

.dispatch-tile .fs-5 { color: var(--brand-navy); }

/* 미배차가 남아 있으면 눈에 띄어야 한다 — 이 화면에서 유일하게 조치가 필요한 숫자다. */
.dispatch-tile-alert {
  background: rgba(205, 14, 46, 0.08);
  color: var(--brand-red);
}

.dispatch-tile-alert .fs-5 { color: var(--brand-red); }

/* 최근 6개월 추이 막대 */
.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
}

.trend-col {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
}

.trend-bar-area {
  height: 110px;
  display: flex;
  align-items: flex-end;
}

.trend-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 0.25rem 0.25rem 0 0;
  background: var(--brand-navy);
}

/* 진행 중인 달 — 아직 한 달이 다 담기지 않은 값이라는 표시 */
.trend-bar-partial {
  background: repeating-linear-gradient(
    45deg,
    var(--brand-navy),
    var(--brand-navy) 4px,
    rgba(46, 42, 77, 0.45) 4px,
    rgba(46, 42, 77, 0.45) 8px
  );
}

.trend-value {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand-navy);
  margin-bottom: 0.25rem;
}

.trend-label {
  font-size: 0.75rem;
  margin-top: 0.35rem;
}

.trend-sub {
  font-size: 0.7rem;
  line-height: 1.35;
  color: #6c757d;
}

.trend-sub .bi {
  font-size: 0.65rem;
  margin-right: 0.1rem;
  opacity: 0.8;
}

/* 카드 헤더 범례 — 좁은 화면에서는 제목 아래로 접힌다. */
.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.6rem;
}

/* 진행 중인 달 표시는 글자로 설명하는 것보다 같은 무늬 조각을 보여주는 편이 바로 이어진다. */
.trend-legend-swatch {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 0.15rem;
  vertical-align: -0.03rem;
}

/* ── 거래처 증감 분석 스파크라인 ─────────────────────────────────────── */

.sparkline {
  display: block;
  margin: 0 auto;
  overflow: visible;
}

.sparkline polyline {
  fill: none;
  stroke: var(--brand-navy);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* 진행 중인 마지막 기간으로 향하는 구간 — 아직 덜 쌓인 값이라는 표시 */
.sparkline .sparkline-partial {
  stroke-dasharray: 3 2;
  opacity: 0.55;
}

/* 거래처 증감 분석 — 기간별 상세내역 토글 */
.trend-detail-toggle-cell {
  width: 2rem;
  text-align: center;
}

.trend-detail-toggle {
  color: #6c757d;
  text-decoration: none;
  line-height: 1;
}

.trend-detail-toggle .bi {
  transition: transform 0.15s ease-in-out;
  display: inline-block;
}

.trend-detail-toggle.is-open .bi {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .trend-detail-toggle .bi { transition: none; }
}

.trend-detail > td {
  padding: 0.5rem 0.75rem;
}

/* 상세내역: 왼쪽 기간별 표 + 남는 폭을 채우는 큰 차트 */
.trend-detail-body {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

.trend-detail-table-wrap {
  flex: 0 1 auto;
}

.trend-detail-chart {
  flex: 1 1 300px;
  min-width: 260px;
}

.trend-detail-table {
  max-width: 26rem;
  background: transparent;
}

.trend-detail-table th,
.trend-detail-table td {
  font-size: 0.8rem;
  background: transparent;
}

/* 증감 분석 표 맨 아래 합계 행 */
.trend-total-row > td {
  border-top: 2px solid rgba(46, 42, 77, 0.35);
  background: #f5f6f8;
  font-weight: 600;
}

/* 스파크라인에 겹쳐 그리는 추세선(회귀 직선) */
.sparkline .sparkline-trend {
  stroke: var(--brand-red);
  stroke-width: 1;
  stroke-dasharray: 2 2;
  opacity: 0.55;
}

/* 설명력(R²)이 낮은 추세선은 흐리게 — 진동을 추세로 읽지 않도록 */
.sparkline .sparkline-trend-weak {
  opacity: 0.22;
}

/* 상세내역 큰 차트 (site.js 가 펼칠 때 그린다) */
.trend-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.trend-chart-axis {
  stroke: rgba(0, 0, 0, 0.15);
  stroke-width: 1;
}

.trend-chart-bar {
  fill: var(--brand-navy);
}

/* 진행 중인 마지막 기간 — 스파크라인의 점선과 같은 의미 */
.trend-chart-bar-partial {
  fill: rgba(46, 42, 77, 0.4);
}

/* viewBox 가 실제 픽셀과 1:1 이라 확대 보정 없이 보이는 크기 그대로 지정한다. */
.trend-chart-value {
  font-size: 11px;
  fill: var(--brand-navy);
}

.trend-chart-label {
  font-size: 11px;
  fill: #6c757d;
}

.trend-chart-trend {
  stroke: var(--brand-red);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  opacity: 0.65;
}

.trend-chart-trend-weak {
  opacity: 0.25;
}

.trend-chart-bar-group:hover .trend-chart-bar {
  fill: var(--brand-red);
}
