/* ============================================================
   Forecast Auto — 공통 디자인 시스템
   claude.ai/design "Forecast Auto" 이식 (SVG 아이콘 · 라이트 콘텐츠 · 다크 사이드바)
   ※ JSP가 참조하는 클래스명은 유지하고, 값(토큰·치수·컴포넌트)만 새 디자인에 맞춤.
   ============================================================ */
:root {
  --c-bg: #f4f5f7;
  --c-surface: #ffffff;
  --c-surface-2: #fafbfc;
  --c-border: #e5e8ee;
  --c-border-2: #eef0f4;
  --c-text: #141824;
  --c-text-soft: #586071;
  --c-muted: #949aa6;
  --c-primary: #2f56c9;
  --c-primary-d: #2544a6;
  --c-primary-soft: #eef2fd;
  --c-success: #177a52;
  --c-success-soft: #e6f4ec;
  --c-danger: #cf4040;
  --c-danger-soft: #fbecec;
  --c-warn: #9a6a12;
  --c-warn-soft: #fbf1de;
  --radius: 14px;
  --radius-lg: 16px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16,19,26,.05), 0 6px 22px rgba(16,19,26,.06);
  --shadow-sm: 0 1px 2px rgba(16,19,26,.07);
  --gap: 18px;
  --header-h: 62px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", Roboto, sans-serif;

  --sidebar-w: 256px;
  --sb-bg: #12151d;
  --sb-bg2: #1c2130;
  --sb-text: #cbd0de;
  --sb-muted: #828a9c;
  --sb-border: #282e3c;
  --sb-active: #22304d;
  --topbar-h: 62px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-d); text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4em; font-weight: 750; letter-spacing: -.3px; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd3db; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b6bcc7; background-clip: content-box; }
input, button, select, textarea { font-family: inherit; }

/* SVG 아이콘 기본(선 아이콘, currentColor 상속) */
.ic-svg { width: 1em; height: 1em; display: inline-block; vertical-align: -0.125em; fill: none; stroke: currentColor; }
.ic { display: inline-flex; align-items: center; justify-content: center; }
.ic .ic-svg { width: 18px; height: 18px; stroke-width: 1.7; }

/* ============================================================
   레이아웃: 다크 사이드바 + 라이트 콘텐츠
   ============================================================ */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--sb-bg); color: var(--sb-text);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--sb-border);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 20px 16px; color: #fff;
  border-bottom: 1px solid var(--sb-border);
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand .logo {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: var(--c-primary);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px; letter-spacing: -.5px;
}
.sidebar-brand .brand-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-brand .brand-name { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -.3px; }
.sidebar-brand .brand-sub { font-size: 11.5px; color: var(--sb-muted); margin-top: 1px; }

.side-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.nav-section { margin: 16px 12px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--sb-muted); opacity: .8; }
.side-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin: 2px 0; border-radius: 10px;
  color: var(--sb-muted); font-weight: 600; font-size: 13.5px;
}
.side-link .ic { width: 18px; height: 18px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.side-link .ic .ic-svg { width: 18px; height: 18px; stroke-width: 1.7; }
.side-link:hover { background: var(--sb-bg2); color: #fff; text-decoration: none; }
.side-link.active { background: var(--c-primary); color: #fff; }
.side-link.active .ic { color: #fff; }
.sidebar-foot { padding: 14px 20px; color: var(--sb-muted); font-size: 11.5px; border-top: 1px solid var(--sb-border); }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* 상단바 */
.topbar {
  height: var(--topbar-h); flex-shrink: 0; background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: 14px; padding: 0 28px;
  position: sticky; top: 0; z-index: 30;
}
.topbar .hamburger {
  display: none; background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 9px; width: 38px; height: 38px; cursor: pointer; color: var(--c-text-soft);
  align-items: center; justify-content: center;
}
.topbar .hamburger .ic-svg { width: 18px; height: 18px; stroke-width: 1.8; }
.topbar-title { flex: 1; min-width: 0; font-size: 16px; font-weight: 700; letter-spacing: -.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-pill {
  display: flex; align-items: center; gap: 9px; padding: 5px 12px 5px 6px;
  border-radius: 999px; border: 1px solid var(--c-border); background: var(--c-surface);
}
.user-pill:hover { background: var(--c-bg); text-decoration: none; }
.user-pill .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--c-primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; text-transform: uppercase;
}
.user-pill .user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-pill .user-name { font-size: 12.5px; font-weight: 650; color: var(--c-text); }
.user-pill .user-role { font-size: 10.5px; color: var(--c-muted); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--c-border);
  background: var(--c-surface); color: var(--c-text-soft); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--c-bg); }
.icon-btn .ic-svg { width: 18px; height: 18px; stroke-width: 1.7; }

.sidebar-backdrop { display: none; }

/* 콘텐츠 컨테이너 */
.container { max-width: 1360px; margin: 0 auto; padding: 26px 28px 60px; width: 100%; }
.page-title { margin-bottom: 6px; }
.page-sub { color: var(--c-text-soft); margin-bottom: 22px; font-size: 13.5px; line-height: 1.6; max-width: 900px; }

.grid { display: grid; gap: var(--gap); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

/* ---- 카드 ---- */
.card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.card h2, .card h3 { margin-top: 0; }
.card .card-desc { color: var(--c-muted); font-size: 13px; margin-bottom: 16px; }

/* ---- 버튼 ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 650; font-size: 13px; cursor: pointer; font-family: inherit; white-space: nowrap;
  transition: background .13s, box-shadow .13s, border-color .13s;
}
.btn .ic-svg { width: 16px; height: 16px; stroke-width: 1.7; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-d); text-decoration: none; color: #fff; }
.btn-ghost { background: var(--c-surface); border-color: var(--c-border); color: var(--c-text); }
.btn-ghost:hover { background: var(--c-bg); text-decoration: none; color: var(--c-text); }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #b83636; color: #fff; text-decoration: none; }
.btn-block { width: 100%; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 14.5px; border-radius: 10px; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; }

/* ---- 폼 ---- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 6px; color: var(--c-text-soft); }
.input, input[type=text], input[type=password], input[type=number], input[type=email], input[type=date], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; background: var(--c-surface); color: var(--c-text);
}
textarea { min-height: 90px; resize: vertical; }
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-soft);
}
.file-drop {
  border: 1.5px dashed var(--c-border); border-radius: var(--radius); padding: 22px;
  background: var(--c-surface-2); text-align: center; color: var(--c-text-soft);
}
.file-drop input { margin-top: 10px; }
/* 파일을 끌어왔을 때 — 여기 놓으면 된다는 걸 확실히 보여준다 */
.file-drop.dragging {
  border-color: var(--c-primary); background: var(--c-primary-soft); color: var(--c-primary);
}
.file-drop .fd-list { margin-top: 10px; font-size: 13px; color: var(--c-text); text-align: left; }
.file-drop .fd-list .fd-count { font-weight: 700; margin-bottom: 4px; }
.file-drop .fd-list div { padding: 2px 0; }

/* ---- 표 ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--c-surface); }
table.tbl th, table.tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--c-border-2); white-space: nowrap; }
table.tbl th { background: var(--c-surface-2); font-weight: 600; color: var(--c-muted); font-size: 12px; letter-spacing: 0; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--c-surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- 배지 / 알림 ---- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; line-height: 1.4; }
.badge.gray { background: var(--c-surface-2); color: var(--c-text-soft); border: 1px solid var(--c-border); }
.badge.blue { background: var(--c-primary-soft); color: var(--c-primary-d); }
.badge.green { background: var(--c-success-soft); color: var(--c-success); }
.badge.red { background: var(--c-danger-soft); color: var(--c-danger); }
.badge.warn { background: var(--c-warn-soft); color: var(--c-warn); }

.alert { padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 13px; font-weight: 500; border: 1px solid transparent; }
.alert.error { background: var(--c-danger-soft); color: var(--c-danger); border-color: #f3d2d2; }
.alert.ok { background: var(--c-success-soft); color: var(--c-success); border-color: #cfe8db; }
.alert.warn { background: var(--c-warn-soft); color: var(--c-warn); border-color: #f0e0bf; }

/* ---- 로그인 ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #eef2fd 0%, var(--c-bg) 55%); }
.auth-card { width: 100%; max-width: 396px; background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius-lg); box-shadow: 0 8px 30px rgba(16,19,26,.06); padding: 28px; }
.auth-card .brand { justify-content: center; margin-bottom: 6px; font-size: 1.2rem; }
.auth-card .sub { text-align: center; color: var(--c-muted); margin-bottom: 24px; font-size: 13px; }

/* 브랜드(로그인 등 사이드바 밖) */
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.05rem; color: var(--c-text); }
.brand .logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--sb-bg); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 16px; letter-spacing: -.5px;
}

/* ---- 대시보드 타일 ---- */
.dashboard-tile {
  display: flex; flex-direction: column; gap: 12px; text-align: left;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 18px; transition: border-color .12s, box-shadow .12s;
}
.dashboard-tile .ico {
  width: 40px; height: 40px; border-radius: 11px; background: var(--c-primary-soft);
  color: var(--c-primary); display: grid; place-items: center;
}
.dashboard-tile .ico .ic-svg { width: 21px; height: 21px; stroke-width: 1.7; }
.dashboard-tile:hover { text-decoration: none; border-color: var(--c-primary); box-shadow: 0 4px 16px rgba(47,86,201,.1); }
.dashboard-tile .t-title { font-size: 14.5px; font-weight: 700; color: var(--c-text); }
.dashboard-tile .t-desc { font-size: 12px; color: var(--c-muted); margin-top: 3px; line-height: 1.4; }

/* ---- 유틸 ---- */
.muted { color: var(--c-muted); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 10px; } .mt-2 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack > * + * { margin-top: 14px; }
.hint { font-size: 12px; color: var(--c-muted); }

/* ---- 목록 페이저 / 정렬 헤더 (공용) ---- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--c-border-2); }
.pager .pg-info { font-size: .82rem; color: var(--c-text-soft); }
.pager .pg-btns { display: flex; gap: 4px; align-items: center; margin-left: auto; }
.pager .pg-b { min-width: 32px; height: 32px; padding: 0 9px; border: 1px solid var(--c-border); background: var(--c-surface); border-radius: 8px; font-size: .82rem; cursor: pointer; color: var(--c-text); }
.pager .pg-b:hover:not(:disabled) { border-color: var(--c-primary); background: var(--c-primary-soft); }
.pager .pg-b.on { background: var(--c-primary); color: #fff; border-color: var(--c-primary); font-weight: 700; }
.pager .pg-b:disabled { opacity: .4; cursor: default; }
.pager .pg-dots { color: var(--c-muted); padding: 0 2px; }
table.tbl th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.tbl th.sortable:hover { color: var(--c-primary); }
table.tbl th.sortable::after { content: '↕'; font-size: .7em; opacity: .35; margin-left: 4px; }
table.tbl th.sort-asc::after { content: '↑'; opacity: 1; color: var(--c-primary); }
table.tbl th.sort-desc::after { content: '↓'; opacity: 1; color: var(--c-primary); }

/* ============================================================
   마스터-디테일 (그룹 좌 / 항목 우)
   ============================================================ */
.master-detail { display: grid; grid-template-columns: 232px 1fr; gap: 16px; align-items: start; }
.md-left { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; }
.md-left .md-head { padding: 12px 16px; font-weight: 600; font-size: 12px; color: var(--c-muted); border-bottom: 1px solid var(--c-border-2); }
.md-group { display: flex; align-items: center; justify-content: space-between; padding: 11px 16px; cursor: pointer; color: var(--c-text-soft); font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--c-border-2); }
.md-group:hover { background: var(--c-surface-2); text-decoration: none; color: var(--c-text); }
.md-group.active { background: var(--c-primary-soft); color: var(--c-primary-d); box-shadow: inset 3px 0 0 var(--c-primary); }
.md-group .cnt { font-size: 11px; background: var(--c-surface-2); color: var(--c-muted); border-radius: 999px; padding: 1px 8px; }
.md-right { min-width: 0; }

/* ---- 모달 (드래그 이동) ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(16,19,26,.4); z-index: 100; display: none; }
.modal-overlay.open { display: block; animation: ov .12s ease; }
@keyframes ov { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: absolute; top: 12%; left: 50%; transform: translateX(-50%);
  width: 560px; max-width: 94vw; background: var(--c-surface); border-radius: var(--radius-lg);
  box-shadow: 0 24px 70px rgba(16,19,26,.28); overflow: hidden; animation: pop .14s ease;
}
@keyframes pop { from { opacity: 0; transform: translateX(-50%) translateY(8px) scale(.98); } to { opacity: 1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 15px 20px; border-bottom: 1px solid var(--c-border-2);
  cursor: move; user-select: none;
}
.modal-header h3 { margin: 0; font-size: 15px; font-weight: 700; }
.modal-header .grip { color: var(--c-muted); font-size: 12px; margin-left: auto; margin-right: 8px; }
.modal-close { background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--c-muted); }
.modal-close:hover { color: var(--c-text); }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--c-border-2); display: flex; justify-content: flex-end; gap: 8px; }

/* 모든 전체화면 모달은 콘텐츠 영역(사이드바 제외) 기준으로 가운데 정렬 — 사이드바에 가려지지 않게.
   데스크톱만 적용(모바일은 사이드바가 숨겨짐). 각 모달의 인라인 스타일보다 우선하도록 !important. */
@media (min-width: 901px) {
  .modal-overlay, .pm-overlay, .blkp-overlay, .pc-overlay, .pwc-overlay, .pv-overlay {
    left: var(--sidebar-w) !important;
  }
}

/* ============================================================
   반응형
   ============================================================ */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.4);
  }
  .sidebar.open { transform: none; }
  .topbar .hamburger { display: inline-flex; }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; }
}
@media (max-width: 760px) {
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .container { padding: 20px 16px 50px; }
  .topbar { padding: 0 16px; }
  .topbar-title { font-size: 15px; }
  .user-pill .user-meta { display: none; }
  h1 { font-size: 1.25rem; }
  .master-detail { grid-template-columns: 1fr; }
  .md-left { display: flex; overflow-x: auto; }
  .md-left .md-head { display: none; }
  .md-group { border-bottom: none; border-right: 1px solid var(--c-border-2); white-space: nowrap; }
  .modal { top: 6%; }
}
