/* ===================================================================
   밀코 안심진행 알림 - 공통 스타일
   컬러: 네이비(신뢰) / 화이트(정갈) / 레드(경고,강조)
=================================================================== */

:root {
  --navy-900: #0b1f3a;
  --navy-800: #10294d;
  --navy-700: #163461;
  --navy-600: #1f4179;
  --navy-100: #e7ecf5;
  --red-600: #d61f2c;
  --red-500: #e6394a;
  --red-100: #fde8ea;
  --white: #ffffff;
  --gray-50: #f6f7fb;
  --gray-100: #eef0f5;
  --gray-200: #dfe3ec;
  --gray-400: #9aa3b5;
  --gray-600: #5c6579;
  --gray-800: #2b3142;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(11,31,58,0.06), 0 1px 6px rgba(11,31,58,0.05);
  --shadow-md: 0 6px 20px rgba(11,31,58,0.10);
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--gray-50); color: var(--gray-800); }
body { font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; }

.hidden { display: none !important; }

/* ---------- 로그인 화면 ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy-900) 0%, var(--navy-700) 55%, var(--navy-600) 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--white);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  padding: 36px 32px 30px;
  text-align: center;
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.login-logo {
  width: 140px; height: auto;
  display: flex; align-items: center; justify-content: center;
}
.login-logo img {
  width: 100%; height: auto; object-fit: contain;
}
.login-title { font-size: 20px; font-weight: 800; color: var(--navy-900); }
.login-sub { font-size: 13px; color: var(--gray-600); }
.login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-form label { font-size: 13px; font-weight: 600; color: var(--gray-600); margin-bottom: 4px; display: block; }
.field-group { margin-bottom: 4px; }
.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--gray-200);
  background: var(--gray-50);
  font-size: 15px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.input:focus { border-color: var(--navy-600); background: var(--white); }
.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 15px;
  transition: transform .05s, opacity .15s, background .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--navy-900); color: var(--white); }
.btn-primary:hover { background: var(--navy-700); }
.btn-red { background: var(--red-600); color: var(--white); }
.btn-red:hover { background: var(--red-500); }
.btn-outline { background: var(--white); color: var(--navy-900); border: 1.5px solid var(--navy-900); }
.btn-outline:hover { background: var(--navy-100); }
.logout-btn-dark { background: #000; color: #fff; border: 1.5px solid #000; }
.logout-btn-dark:hover { background: #1a1a1a; }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.login-error { color: var(--red-600); font-size: 13px; min-height: 18px; }
.login-hint {
  margin-top: 18px; font-size: 12px; color: var(--gray-400); line-height: 1.6;
  background: var(--gray-50); border-radius: 8px; padding: 10px 12px;
}

/* ---------- 앱 셸 ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--navy-900);
  color: var(--white);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: transform .2s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo {
  width: 84px; height: 34px; border-radius: 8px; background: var(--white);
  display:flex; align-items:center; justify-content:center; padding: 4px 8px;
}
.sidebar-logo img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-title { font-size: 15px; font-weight: 800; line-height: 1.3; }
.sidebar-title small { display:block; font-size: 11px; font-weight: 400; color: var(--gray-400); }
.nav-menu { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 9px; font-size: 14px; font-weight: 600;
  color: rgba(255,255,255,0.75);
  cursor: pointer; border: none; background: transparent; text-align: left; width: 100%;
}
.nav-item i { width: 18px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.nav-item.active { background: var(--red-600); color: var(--white); }
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 8px; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--navy-600); display:flex;align-items:center;justify-content:center; font-weight:700; font-size:13px; }
.role-badge { font-size: 10px; padding: 2px 6px; border-radius: 5px; background: var(--red-600); margin-left: 4px; }
.role-badge.staff { background: var(--navy-600); }

.main-area { flex: 1; margin-left: 220px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; background: var(--white); border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 17px; font-weight: 800; color: var(--navy-900); }
.hamburger { display: none; background: none; border: none; font-size: 20px; color: var(--navy-900); }
.content { padding: 20px 22px 60px; flex: 1; }

/* ---------- 카드/그리드 공통 ---------- */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px; }
.section-title { font-size: 16px; font-weight: 800; color: var(--navy-900); margin: 0 0 14px; display:flex; align-items:center; gap:8px;}
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-4, .grid-2 { grid-template-columns: 1fr; } }

.stat-card { padding: 16px 18px; border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow-sm); border-left: 4px solid var(--navy-700); }
.stat-card.accent-red { border-left-color: var(--red-600); }
.stat-label { font-size: 12.5px; color: var(--gray-600); font-weight: 600; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--navy-900); }
.stat-value.red { color: var(--red-600); }
.stat-sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-general { background: var(--navy-100); color: var(--navy-700); }
.badge-accident { background: var(--red-100); color: var(--red-600); }
.badge-status { background: var(--gray-100); color: var(--gray-800); }
.badge-warn { background: var(--red-600); color: var(--white); }

/* ---------- 테이블 ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 900px; }
table.data-table th, table.data-table td { padding: 11px 10px; border-bottom: 1px solid var(--gray-100); text-align: left; white-space: nowrap; }
table.data-table th { color: var(--gray-600); font-weight: 700; font-size: 12.5px; background: var(--gray-50); position: sticky; top: 0; }
table.data-table tbody tr { cursor: pointer; transition: background .1s; }
table.data-table tbody tr:hover { background: var(--navy-100); }
table.data-table tbody tr.row-alert { background: var(--red-100); }
table.data-table tbody tr.row-alert:hover { background: #fbd3d7; }
.empty-row td { text-align: center; color: var(--gray-400); padding: 30px; }

/* ---------- 폼 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 13px; font-weight: 700; color: var(--gray-600); }
.form-field.full { grid-column: 1 / -1; }
textarea.input { resize: vertical; min-height: 70px; }
.required-mark { color: var(--red-600); margin-left: 2px; }
.radio-group { display: flex; gap: 10px; }
.radio-pill { flex: 1; text-align: center; padding: 10px; border-radius: 10px; border: 1.5px solid var(--gray-200); font-weight: 700; font-size: 13.5px; cursor: pointer; }
.radio-pill input { display: none; }
.radio-pill.selected-general { border-color: var(--navy-700); background: var(--navy-100); color: var(--navy-700); }
.radio-pill.selected-accident { border-color: var(--red-600); background: var(--red-100); color: var(--red-600); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.reserve-toggle {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px; border-radius: 10px; border: 1.5px solid var(--gray-200);
  font-weight: 700; font-size: 13.5px; cursor: pointer; height: 100%;
}
.reserve-toggle.selected-general { border-color: var(--navy-700); background: var(--navy-100); color: var(--navy-700); }
.reserve-toggle-checkbox { width: 16px; height: 16px; margin: 0; accent-color: var(--navy-700); cursor: pointer; }

/* ---------- 검색바 ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: flex-end;}
.filter-bar .form-field { min-width: 150px; flex: 1; }
.filter-bar .form-field.grow2 { flex: 1.6; }

/* ---------- 모달 ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(11,31,58,0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  z-index: 100;
}
.modal-box {
  background: var(--white); border-radius: 16px; width: 100%; max-width: 720px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-md);
}
.modal-box.modal-sm { max-width: 480px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--gray-100); position: sticky; top:0; background: var(--white); z-index: 1;}
.modal-header h3 { margin: 0; font-size: 17px; font-weight: 800; color: var(--navy-900); }
.modal-close { background: none; border: none; font-size: 20px; color: var(--gray-400); }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- 진행단계 타임라인 ---------- */
.timeline { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.timeline-step {
  padding: 8px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 700;
  background: var(--gray-100); color: var(--gray-600); border: 1.5px solid transparent; cursor: pointer;
}
.timeline-step.done { background: var(--navy-100); color: var(--navy-700); }
.timeline-step.current { background: var(--navy-900); color: var(--white); }
.timeline-step.current.accident { background: var(--red-600); }

.msg-preview {
  background: var(--gray-50); border: 1.5px dashed var(--gray-200); border-radius: 10px;
  padding: 14px; font-size: 13.5px; white-space: pre-wrap; line-height: 1.6; color: var(--gray-800);
  margin-top: 8px;
}
.tag-test { display: inline-block; background: var(--red-600); color: var(--white); font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 6px; margin-left: 6px; }

/* ---------- 발송 기록 리스트 ---------- */
.log-item { border-bottom: 1px solid var(--gray-100); padding: 12px 0; }
.log-item:last-child { border-bottom: none; }
.log-top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 6px; }
.log-result { font-weight: 800; font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.log-result.success { background: #e5f6ea; color: #1c8a3c; }
.log-result.fail { background: var(--red-100); color: var(--red-600); }
.log-msg { font-size: 13px; color: var(--gray-600); white-space: pre-wrap; background: var(--gray-50); border-radius: 8px; padding: 10px; }

/* ---------- 토스트 ---------- */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--navy-900); color: var(--white); padding: 12px 18px; border-radius: 10px;
  font-size: 13.5px; box-shadow: var(--shadow-md); opacity: 1; transition: opacity .3s;
  max-width: 320px;
}
.toast-success { background: #1c8a3c; }
.toast-error { background: var(--red-600); }
.toast-hide { opacity: 0; }

/* ---------- 반응형: 태블릿/모바일 ---------- */
@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 39; }
  .sidebar-overlay.show { display: block; }
}
@media (max-width: 640px) {
  .content { padding: 14px 12px 50px; }
  .topbar { padding: 0 12px; }
  table.data-table { min-width: 720px; font-size: 12.5px; }
  .modal-body, .modal-header, .modal-footer { padding-left: 14px; padding-right: 14px; }
}

.helper-text { font-size: 12px; color: var(--gray-400); }
.divider { height: 1px; background: var(--gray-100); margin: 16px 0; }
.settings-tab-bar { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.settings-tab { padding: 9px 16px; border-radius: 9px; font-weight: 700; font-size: 13.5px; background: var(--gray-100); color: var(--gray-600); border: none; }
.settings-tab.active { background: var(--navy-900); color: var(--white); }
.mode-flag { display:inline-flex; align-items:center; gap:6px; padding: 6px 12px; border-radius: 8px; background: var(--red-100); color: var(--red-600); font-weight: 800; font-size: 13px; }
.mode-flag.production { background: #e5f6ea; color: #1c8a3c; }
