/* ===== 디자인 토큰 / 리셋 ===== */
:root {
  --bg:        #f4f6fa;
  --bg-soft:   #eef2f7;
  --panel:     #ffffff;
  --panel-soft:#fafbfd;
  --line:      #e2e8f0;
  --line-soft: #eef1f6;
  --text:      #0f172a;
  --sub:       #64748b;
  --muted:     #94a3b8;
  --brand:     #1d4ed8;
  --brand-600: #1e40af;
  --brand-soft:#eff4ff;
  --danger:    #dc2626;
  --warn:      #d97706;
  --green:     #059669;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.03);
  --shadow-md: 0 2px 6px rgba(15,23,42,.05), 0 4px 12px rgba(15,23,42,.04);
  --shadow-lg: 0 10px 32px rgba(15,23,42,.10);
  --radius:    10px;
  --radius-lg: 14px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}
.center-wrap { max-width: 1200px; margin: 0 auto; }

/* ===== 토스트 ===== */
.toast-root {
  position: fixed; top: 18px; right: 18px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200; pointer-events: none;
}
.toast {
  min-width: 280px; max-width: 380px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px;
  display: flex; align-items: flex-start; gap: 10px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn .22s cubic-bezier(.2,.8,.2,1);
}
.toast.leaving { animation: toastOut .2s ease-in forwards; }
.toast-icon { width: 20px; height: 20px; flex-shrink: 0; }
.toast-msg  { flex: 1; font-size: 13px; line-height: 1.45; color: var(--text); }
.toast.success { border-left: 3px solid var(--green); }
.toast.success .toast-icon { color: var(--green); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.error   .toast-icon { color: var(--danger); }
.toast.info    { border-left: 3px solid var(--brand); }
.toast.info    .toast-icon { color: var(--brand); }
@keyframes toastIn  { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(-8px); } }

/* ===== 공용 폼 요소 ===== */
button, select, input, textarea {
  font-size: 14px; padding: 9px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer;
  font-family: inherit; color: var(--text);
  transition: all .15s ease;
  outline: none;
}
input, select, textarea { cursor: text; }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}
textarea { resize: vertical; width: 100%; min-height: 100px; line-height: 1.5; }

button { font-weight: 500; }
button:not(.topbar button):hover { background: var(--bg-soft); }
button.clicked { transform: scale(.97); }
button.primary, button.tab-active:not(.topbar button):not(.settings-btn):not(.stock-btn):not(.inv-period-btn) {
  background: var(--brand); color: #fff; border-color: var(--brand);
  box-shadow: var(--shadow-sm);
}
button.primary:hover  { background: var(--brand-600); border-color: var(--brand-600); }
button.danger  { background: var(--danger); color: #fff; border-color: var(--danger); box-shadow: var(--shadow-sm); }
button.danger:hover  { background: #b91c1c; border-color: #b91c1c; }
button.warn    { background: var(--warn);   color: #fff; border-color: var(--warn);   box-shadow: var(--shadow-sm); }
button.warn:hover    { background: #b45309; border-color: #b45309; }
button.success { background: var(--green);  color: #fff; border-color: var(--green);  box-shadow: var(--shadow-sm); }
button.success:hover { background: #047857; border-color: #047857; }
button:disabled { opacity: .5; cursor: not-allowed; }
.ml-auto { margin-left: auto; }

.hidden { display: none !important; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.empty-msg { color: var(--muted); margin-top: 14px; text-align: center; padding: 24px; font-size: 14px; }
label { font-size: 14px; color: var(--sub); font-weight: 500; }

/* ===== 대시보드 카드 ===== */
.dash-title { font-size: 13px; font-weight: 600; color: var(--sub); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.dash-time  { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.dash-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 4px; }
.dash-card  {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
  text-align: left;
  position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.dash-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand) 0%, #60a5fa 100%);
  opacity: .85;
}
.dash-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.dash-card .k    { color: var(--sub); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }
.dash-card .v    { font-size: 36px; font-weight: 700; color: var(--text); line-height: 1.1; }
.dash-card .unit { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* ===== 월간 결산: 클릭 가능한 숫자 & 제품별 드롭다운 ===== */
.settle-clickable { cursor: pointer; display: inline-block; border-bottom: 2px dashed var(--line); transition: color .15s; }
.settle-clickable:hover { color: var(--brand); border-bottom-color: var(--brand); }
.settle-dropdown {
  margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px;
  max-height: 240px; overflow-y: auto;
}
.settle-drop-row {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 14px; color: var(--text); padding: 6px 2px;
  border-bottom: 1px solid var(--line-soft);
}
.settle-drop-row .right { font-weight: 600; }
.settle-drop-head { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.settle-drop-head .right { font-weight: 600; }
.settle-drop-empty { color: var(--muted); font-size: 13px; padding: 8px 2px; }

/* ===== 입력/생산 카드 ===== */
.cards { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 12px; margin: 14px 0; }
.card  {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--panel-soft);
}
.card .k { color: var(--sub); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.card .v { font-size: 26px; font-weight: 700; margin-top: 6px; }

.status, .error { display: none; }
.error.login-error { display: block; color: var(--danger); min-height: 20px; font-size: 13px; font-weight: 500; }

/* ===== 테이블 ===== */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 11px 14px; white-space: nowrap; text-align: left; border-bottom: 1px solid var(--line-soft); }
th {
  background: var(--panel-soft);
  color: var(--sub);
  font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--line);
}
tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: none; }
.total-row { font-weight: 700; background: var(--brand-soft) !important; color: var(--brand-600); }
.total-row td { border-top: 1px solid var(--line); }
.neg { color: var(--danger); font-weight: 600; }

.stock-current { font-weight: 700; font-size: 22px; color: var(--brand); }
.stock-unit { font-size: 14px; color: var(--sub); }
.period-label { color: var(--sub); font-size: 13px; margin-bottom: 10px; font-weight: 500; }

/* ===== 세그먼트 버튼 (재고/기간/설정) ===== */
.stock-btn, .inv-period-btn, .settings-btn {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 16px; background: #fff;
  font-size: 14px; font-weight: 500; color: var(--sub);
}
.stock-btn:hover, .inv-period-btn:hover, .settings-btn:hover {
  background: var(--bg-soft); color: var(--text);
}
.stock-btn.tab-active, .inv-period-btn.tab-active, .settings-btn.tab-active {
  background: var(--brand); color: #fff; border-color: var(--brand);
  box-shadow: var(--shadow-sm); font-weight: 600;
}

/* ===== 설정 ===== */
.section { margin-bottom: 0; }
.section-title {
  font-size: 15px; font-weight: 600;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
}
.del-btn {
  background: transparent; border: none; cursor: pointer;
  font-size: 16px; padding: 4px 8px; border-radius: 6px;
  transition: background .15s;
}
.del-btn:hover { background: #fef2f2; }

/* ===== 메모 ===== */
.memo-write {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--panel-soft);
  margin-bottom: 16px;
}
.memo-write-title { font-weight: 600; margin-bottom: 12px; color: var(--text); font-size: 14px; }
.memo-card {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}
.memo-card:hover { box-shadow: var(--shadow-md); }
.memo-card.confirmed { border-left: 3px solid var(--green); background: #f0fdf4; }
.memo-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.memo-author { font-weight: 600; color: var(--brand); font-size: 14px; }
.memo-time { font-size: 12px; color: var(--muted); }
.memo-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.memo-content { font-size: 14px; white-space: pre-wrap; line-height: 1.6; color: var(--text); }
.memo-empty { color: var(--muted); text-align: center; padding: 30px; font-size: 14px; }
.badge-confirmed {
  background: var(--green); color: #fff;
  border-radius: 6px; padding: 3px 10px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}
.btn-check {
  font-size: 12px; padding: 5px 12px;
  background: var(--green); color: #fff;
  border: none; border-radius: 6px; cursor: pointer; font-weight: 500;
}
.btn-check:hover { background: #047857; }

/* ===== 재고 수정이력 ===== */
.adjust-row { cursor: pointer; }
.adjust-row:hover { background: var(--bg-soft); }
.cmt-badge {
  display: inline-block; margin-left: 6px;
  font-size: 11px; color: var(--brand);
  background: var(--brand-soft); border-radius: 6px; padding: 1px 6px;
}
.adjust-comment-list { display: flex; flex-direction: column; gap: 8px; max-height: 280px; overflow-y: auto; }
.adjust-comment {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; background: var(--panel-soft);
}
.adjust-comment-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.adjust-comment-author { font-weight: 600; color: var(--brand); font-size: 13px; }
.adjust-comment-time { font-size: 11px; color: var(--muted); }
.adjust-comment-head .del-btn { margin-left: auto; font-size: 13px; }
.adjust-comment-body { font-size: 14px; white-space: pre-wrap; line-height: 1.55; color: var(--text); }

/* ===== 모달 ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-box {
  background: #fff; border-radius: var(--radius-lg);
  padding: 26px; min-width: 360px; max-width: 480px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 14px;
}
.modal-box h3 { margin: 0 0 4px; font-size: 18px; font-weight: 700; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.warn-msg {
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 8px; padding: 14px;
  font-size: 14px; line-height: 1.6; color: #78350f;
}

/* ===== 로그인 ===== */
.login-box { padding: 32px 28px !important; min-width: 380px !important; }
.login-box input { width: 100%; }
.login-title { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 2px; letter-spacing: .5px; }
.login-sub   { text-align: center; color: var(--sub); font-size: 13px; margin-bottom: 14px; }
.login-error { text-align: center; }
#appRoot.hidden-before-auth { display: none; }

/* ===== Flatpickr 오버라이드 ===== */
.flatpickr-calendar { font-family: inherit; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-md); }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--brand); border-color: var(--brand); }
.flatpickr-day.today { border-color: var(--brand); }
.flatpickr-day:hover { background: var(--bg-soft); }
.flatpickr-months .flatpickr-month { color: var(--text); }

/* ===== 공통 미디어 쿼리 ===== */
@media (max-width: 700px) {
  .dash-cards { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .page-title { font-size: 18px; }
  .panel { padding: 18px; }
  .content { padding: 16px 12px; }
  body { font-size: 14px; }
}
