@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;600;700&display=swap');

:root {
  --primary: #1B6FD8;
  --primary-light: #EBF3FF;
  --primary-dark: #1459B0;
  --secondary: #F7A600;
  --success: #16A34A;
  --success-light: #DCFCE7;
  --danger: #DC2626;
  --danger-light: #FEE2E2;
  --warning: #D97706;
  --warning-light: #FEF3C7;
  --text: #111827;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --bg: #F3F6FB;
  --white: #FFFFFF;
  --sidebar-w: 230px;
  --header-h: 60px;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: 'Noto Sans KR', -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ===== LAYOUT ===== */
.layout { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  position: fixed; top: 0; left: 0; height: 100vh;
  overflow-y: auto; z-index: 100;
  display: flex; flex-direction: column;
}
.sidebar-logo {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo .logo-name { font-size: 18px; font-weight: 700; color: var(--primary); }
.sidebar-logo .logo-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sidebar-company {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.company-selector {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 8px;
  background: var(--primary-light); cursor: pointer;
  border: none; width: 100%; font-family: inherit;
}
.company-selector .co-name { font-size: 13px; font-weight: 600; color: var(--primary); flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-selector .co-arrow { color: var(--primary); font-size: 12px; flex-shrink: 0; margin-left: 6px; }

.company-dropdown {
  position: absolute; top: 100%; left: 12px; right: 12px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-md); z-index: 200;
  overflow: hidden; display: none;
}
.company-dropdown.show { display: block; }
.company-dropdown-item {
  padding: 10px 12px; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
.company-dropdown-item:hover { background: var(--bg); }
.company-dropdown-item.active { color: var(--primary); font-weight: 600; }
.company-dropdown-divider { height: 1px; background: var(--border); }
.company-dropdown-add {
  padding: 10px 12px; cursor: pointer; font-size: 12px;
  color: var(--primary); display: flex; align-items: center; gap: 6px;
}
.company-dropdown-add:hover { background: var(--primary-light); }

.sidebar-nav { padding: 8px 0; flex: 1; }
.nav-section {
  padding: 10px 16px 4px;
  font-size: 10px; color: var(--text-muted);
  font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; color: var(--text);
  font-size: 13.5px; cursor: pointer; transition: all 0.15s;
  border-left: 3px solid transparent;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-muted); }
.nav-item:hover { background: var(--bg); color: var(--primary); }
.nav-item:hover svg { color: var(--primary); }
.nav-item.active { background: var(--primary-light); color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.nav-item.active svg { color: var(--primary); }

.sidebar-user {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11px; color: var(--text-muted); }
.btn-logout { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 4px; }
.btn-logout:hover { color: var(--danger); background: var(--danger-light); }

/* ===== MAIN ===== */
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }

/* ===== HEADER ===== */
.header {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.header-title { font-size: 16px; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: 12px; }

/* ===== CONTENT ===== */
.content { padding: 24px; }

/* ===== CARDS ===== */
.card { background: var(--white); border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 700; }
.card-actions { display: flex; gap: 8px; align-items: center; }

/* ===== STAT CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white); border-radius: var(--radius); padding: 18px 20px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.stat-label svg { width: 14px; height: 14px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-value.blue { color: var(--primary); }
.stat-value.green { color: var(--success); }
.stat-value.red { color: var(--danger); }
.stat-value.orange { color: var(--warning); }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ===== GRID ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--bg); padding: 10px 12px;
  text-align: left; font-weight: 600; font-size: 12px;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }
.td-right { text-align: right; font-variant-numeric: tabular-nums; }
.td-center { text-align: center; }
.td-mono { font-variant-numeric: tabular-nums; }

.tbl-summary { background: var(--primary-light) !important; }
.tbl-summary td { font-weight: 700; color: var(--primary); border-top: 2px solid var(--primary); }

/* ===== VIEWER MODE (읽기 전용) ===== */
body.viewer-mode .header-right .btn { display: none !important; }
body.viewer-mode .btn-xs:not(.viewer-allow) { display: none !important; }
body.viewer-mode td input,
body.viewer-mode td select { pointer-events: none; opacity: 0.7; }
body.viewer-mode .viewer-mode-banner {
  display: flex !important; align-items: center; gap: 8px;
  background: #FFF8E1; border: 1px solid var(--secondary); border-radius: 8px;
  padding: 8px 14px; font-size: 12px; color: #92400E; margin-bottom: 16px;
}

/* ===== TABLE ENHANCE (필터 + 리사이즈) ===== */
.col-resizer {
  position: absolute; right: -2px; top: 0; bottom: 0; width: 6px;
  cursor: col-resize; z-index: 3;
}
.col-resizer::after {
  content: ''; position: absolute; right: 2px; top: 20%; bottom: 20%;
  width: 2px; background: var(--border); border-radius: 1px; transition: background .15s;
}
.col-resizer:hover::after, .col-resizer:active::after { background: var(--primary); }
.col-filter-row th { padding: 3px 4px; background: #f0f4fb; }
.col-filter {
  width: 100%; padding: 2px 6px; font-size: 11px; height: 22px;
  border: 1px solid var(--border); border-radius: 4px;
  background: white; color: var(--text); outline: none;
}
.col-filter:focus { border-color: var(--primary); }
.col-filter:not(:placeholder-shown) { border-color: var(--secondary); background: #FFFBF0; }

/* ===== UPLOAD ===== */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 36px 20px; text-align: center; cursor: pointer;
  transition: all 0.2s; position: relative;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary); background: var(--primary-light);
}
.upload-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-zone .upload-icon { font-size: 32px; margin-bottom: 10px; }
.upload-zone .upload-title { font-weight: 600; margin-bottom: 4px; }
.upload-zone .upload-sub { font-size: 12px; color: var(--text-muted); }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-orange { background: var(--warning-light); color: var(--warning); }
.badge-gray { background: #F3F4F6; color: var(--text-muted); }
.badge-purple { background: #EDE9FE; color: #7C3AED; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; transition: all 0.15s; text-decoration: none;
  line-height: 1.4;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803D; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #B91C1C; }
.btn-outline { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 4px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; justify-content: center; }
.btn svg { width: 14px; height: 14px; }
.btn-sm svg { width: 13px; height: 13px; }

/* ===== FORMS ===== */
.form-row { display: grid; gap: 16px; margin-bottom: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-control {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 13px; outline: none; transition: border-color 0.15s;
  background: white;
}
.form-control:focus { border-color: var(--primary); }
.form-control::placeholder { color: #D1D5DB; }
select.form-control { cursor: pointer; }

/* ===== TABS ===== */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 18px; font-size: 13px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  color: var(--text-muted); transition: all 0.15s; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }

/* ===== FILTERS ===== */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar .form-control { min-width: 120px; }

/* ===== MONTH NAV ===== */
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav button {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  width: 28px; height: 28px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: var(--text-muted);
}
.month-nav button:hover { background: var(--bg); }
.month-nav .month-label { font-weight: 700; font-size: 15px; min-width: 90px; text-align: center; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  z-index: 1000; display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: white; border-radius: 14px; padding: 24px;
  width: 480px; max-width: 92vw; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-lg { width: 680px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 22px; line-height: 1; padding: 2px; }
.modal-close:hover { color: var(--danger); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1F2937; color: white; padding: 12px 20px;
  border-radius: 10px; font-size: 13px; z-index: 9999;
  opacity: 0; transform: translateY(8px); transition: all 0.25s;
  pointer-events: none; max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

/* ===== PAGINATION ===== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.page-btn {
  min-width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid var(--border); background: white;
  cursor: pointer; font-size: 12px; padding: 0 6px;
}
.page-btn:hover { background: var(--bg); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 13px; }

/* ===== UTILS ===== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.text-bold { font-weight: 700; }
.text-sm { font-size: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh; background: linear-gradient(135deg, #EBF3FF 0%, #F3F6FB 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-box {
  background: white; border-radius: 16px; padding: 40px;
  width: 400px; max-width: 90vw; box-shadow: var(--shadow-md);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 26px; font-weight: 700; color: var(--primary); }
.login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-form .form-group { margin-bottom: 14px; }
.login-btn { width: 100%; padding: 11px; font-size: 14px; font-weight: 700; margin-top: 4px; }

/* ===== AMOUNT COLORS ===== */
.amount-in { color: var(--primary); font-weight: 600; }
.amount-out { color: var(--danger); font-weight: 600; }
.amount-zero { color: var(--text-muted); }

/* ===== INFO BOX ===== */
.info-box {
  background: var(--primary-light); border: 1px solid #BFDBFE;
  border-radius: 8px; padding: 12px 14px; font-size: 12px;
  color: #1D4ED8; display: flex; gap: 8px; align-items: flex-start;
}
.info-box svg { flex-shrink: 0; margin-top: 1px; }
.info-box ul { padding-left: 14px; }
.info-box li { margin-bottom: 2px; }

/* ===== ALERT BOX ===== */
.alert-box {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden;
}
.alert-box-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; cursor: pointer; user-select: none;
}
.alert-box-header:hover { background: var(--bg); }
.alert-box-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700;
}
.alert-box-toggle {
  font-size: 11px; color: var(--text-muted);
  background: none; border: none; cursor: pointer; padding: 2px 8px;
}
.alert-box-body { padding: 0 16px 12px; }
.alert-box-body.collapsed { display: none; }
.alert-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; font-size: 12.5px; margin-bottom: 4px;
}
.alert-item:last-child { margin-bottom: 0; }
.alert-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.alert-item a {
  margin-left: auto; font-size: 11px; color: inherit;
  opacity: 0.7; white-space: nowrap;
}
.alert-item a:hover { opacity: 1; text-decoration: underline; }
.alert-item.danger { background: var(--danger-light); color: var(--danger); }
.alert-item.warning { background: var(--warning-light); color: var(--warning); }
.alert-item.info { background: var(--primary-light); color: var(--primary); }
.alert-box-ok {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; font-size: 13px; color: var(--success); font-weight: 600;
}
.alert-box-ok svg { width: 16px; height: 16px; }
.alert-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; font-size: 11px; font-weight: 700; color: white;
}
.alert-count.danger { background: var(--danger); }
.alert-count.warning { background: var(--warning); }
.alert-count.info { background: var(--primary); }

/* ===== ACCOUNT CHIP ===== */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 20px; font-size: 12px; }
.chip.active { background: var(--primary-light); border-color: #93C5FD; color: var(--primary); }

/* ===== 모바일 사이드바 오버레이 ===== */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 99; transition: opacity 0.2s;
}
.sidebar-overlay.show { display: block; }

/* ===== 햄버거 메뉴 버튼 ===== */
.btn-mobile-menu {
  display: none; background: none; border: none; cursor: pointer;
  padding: 6px 8px; border-radius: 6px; color: var(--text);
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.btn-mobile-menu:hover { background: var(--bg); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .btn-mobile-menu { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .main { margin-left: 0; }
  .header { padding: 0 12px; gap: 8px; }
  .header-title { font-size: 15px; }
  .header-right { gap: 6px; flex-wrap: wrap; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 12px; }
  .filter-bar { flex-wrap: wrap; gap: 4px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; }
  .modal { width: calc(100vw - 32px); max-width: none; margin: 16px; }
  .card { padding: 14px; }
  .card-header { flex-wrap: wrap; gap: 6px; }
}

/* ===== 인쇄 공통 (급여명세서/고용계약서) ===== */
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .sidebar, .header, .btn, .modal-overlay, #app-toast, .alert-box { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  body { background: white !important; }
}
