/* ══════════════════════════════════════════════════════
   디자인 토큰
══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --sidebar-w: 232px;
  --sidebar-w-rail: 76px;
  --header-h: 60px;
  --bottom-nav-h: 62px;

  --blue: #2563eb; --blue-lt: #eff6ff; --blue-dk: #1d4ed8; --blue-100: #dbeafe;
  --green: #16a34a; --green-lt: #f0fdf4;
  --red: #dc2626; --red-lt: #fef2f2;
  --orange: #d97706;

  --bg: #f6f7fa;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --border: #e5e8ec;
  --border-strong: #d8dce2;

  --gray-50: #f8fafc; --gray-100: #f1f5f9; --gray-200: #e2e8f0;
  --gray-400: #94a3b8; --gray-600: #475569; --gray-800: #1e293b;

  --text: #171a21;
  --text-2: #565f6e;
  --text-3: #8a92a1;

  --radius-sm: 7px; --radius-md: 10px; --radius-lg: 14px; --radius-full: 999px;
  --shadow-xs: 0 1px 2px rgba(16,24,40,.04);
  --shadow-sm: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.05);
  --shadow-md: 0 6px 16px rgba(16,24,40,.08);
  --shadow-lg: 0 16px 40px rgba(16,24,40,.16);

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px;

  --shadow: var(--shadow-sm); --radius: var(--radius-lg); /* 기존 코드 호환 */
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Malgun Gothic', '맑은 고딕', sans-serif;
  font-size: 14px; line-height: 1.5;
  background: var(--bg); color: var(--text);
  display: flex; height: 100vh; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; }
a { color: inherit; }

/* ══════════════════════════════════════════════════════
   사이드바 (Desktop ≥1024px: 전체 / Tablet 768–1023px: 아이콘 레일 / Mobile <768px: 오프캔버스 드로어)
══════════════════════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-w); background: #161a23; color: #a4acbb;
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: width .18s ease, transform .22s ease;
  z-index: 200;
}
#sidebar .logo { padding: 22px 18px 16px; border-bottom: 1px solid #262b38; }
#sidebar .logo h1 { font-size: 13px; color: #f4f6f9; line-height: 1.5; font-weight: 700; }
#sidebar .logo small { font-size: 11px; color: #6b7386; }
#sidebar nav { flex: 1; padding: 10px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
#sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; color: #9aa2b3;
  text-decoration: none; font-size: 13.5px; font-weight: 500; border-radius: var(--radius-sm);
  transition: background .12s, color .12s; position: relative; white-space: nowrap;
}
#sidebar nav a:hover { background: #21273350; color: #f1f5f9; }
#sidebar nav a.active { background: var(--blue); color: #fff; font-weight: 600; }
#sidebar nav a .icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
#sidebar .version { padding: 10px 14px 4px; font-size: 10.5px; color: #4b5261; }
.nav-badge {
  display: none; background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  align-items: center; justify-content: center; margin-left: auto;
}

.sidebar-footer { border-top: 1px solid #262b38; padding: 10px; }
.btn-sidebar {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: none;
  color: #9aa2b3; font-size: 12.5px; padding: 8px 12px; cursor: pointer;
  border-radius: var(--radius-sm); font-family: inherit; white-space: nowrap; overflow: hidden;
}
.btn-sidebar .icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.btn-sidebar:hover { background: #21273350; color: #f1f5f9; }

.drawer-backdrop { display: none; position: fixed; inset: 0; background: rgba(10,12,20,.5); z-index: 190; }
.hamburger-btn {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 36px; height: 36px; border: none; background: transparent; cursor: pointer; border-radius: var(--radius-sm);
  margin-right: 4px;
}
.hamburger-btn span { display: block; width: 18px; height: 2px; background: var(--text-2); border-radius: 2px; margin: 0 auto; }
.hamburger-btn:hover { background: var(--gray-100); }

.bottom-nav { display: none; }

/* ══════════════════════════════════════════════════════
   메인
══════════════════════════════════════════════════════ */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
#topbar {
  height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 var(--space-6);
  flex-shrink: 0; gap: var(--space-3);
}
#topbar h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin-right: auto; }
#topbar .date { font-size: 12px; color: var(--text-3); white-space: nowrap; }

/* ── 알림 배너 ── */
.alert-banner { background: #fff7ed; border-bottom: 1px solid #fed7aa; padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0; font-size: 13px; }
#alert-content { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; }
.alert-item { background: #fed7aa; color: #c2410c; padding: 3px 10px; border-radius: var(--radius-full); font-size: 12px; font-weight: 500; }
.alert-item em { font-style: normal; font-weight: 700; }
.alert-sep { color: #d1d5db; }
#alert-content a { color: var(--blue); font-weight: 600; text-decoration: none; }
#alert-close { background: none; border: none; cursor: pointer; font-size: 15px; color: #9ca3af; padding: 4px 8px; border-radius: var(--radius-sm); }
#alert-close:hover { background: #f3f4f6; }

/* ── 콘텐츠 ── */
#content { flex: 1; overflow-y: auto; padding: var(--space-6); width: 100%; }
.page { display: none; }
.page.active { display: block; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* ── 카드 ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); padding: var(--space-5) var(--space-6); margin-bottom: var(--space-4); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-4); gap: var(--space-3); flex-wrap: wrap; }
.card-header h3 { font-size: 14.5px; font-weight: 700; letter-spacing: -0.01em; }

/* ── 통계 ── */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.stat-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); box-shadow: var(--shadow-xs); border-left: 3px solid var(--blue); }
.stat-box.green { border-left-color: var(--green); } .stat-box.orange { border-left-color: var(--orange); } .stat-box.red { border-left-color: var(--red); }
.stat-box .label { font-size: 12px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.stat-box .value { font-size: 25px; font-weight: 800; letter-spacing: -0.02em; }
.stat-box .sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ── 테이블 ── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { background: var(--gray-50); padding: 10px 12px; text-align: left; font-size: 11.5px; font-weight: 700; color: var(--text-2); border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; text-transform: uppercase; letter-spacing: .02em; }
thead th[data-sort] { cursor: pointer; }
thead th[data-sort]:hover { background: #eef1f5; }
.sort-arrow { display: inline-block; width: 12px; font-size: 10px; color: var(--text-3); }
thead th.sort-asc .sort-arrow::after { content: '▲'; color: var(--blue); }
thead th.sort-desc .sort-arrow::after { content: '▼'; color: var(--blue); }
tbody tr { border-bottom: 1px solid var(--gray-100); transition: background .1s; }
tbody tr:hover { background: var(--blue-lt); cursor: pointer; }
tbody tr.row-resigned { opacity: 0.55; }
tbody td { padding: 10px 12px; font-size: 13px; }
tbody td.right { text-align: right; } tbody td.center { text-align: center; }

/* ── 버튼 ── */
.btn-group { display: flex; gap: 4px; background: var(--gray-100); padding: 3px; border-radius: var(--radius-md); }
.btn-group .btn { border: none; background: transparent; }
.btn-group .btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.btn {
  padding: 7px 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface);
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; color: var(--text-2);
  transition: background .12s, border-color .12s, color .12s, transform .05s; white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: scale(.98); }
.btn.active, .btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.primary:hover { background: var(--blue-dk); }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-resign { background: var(--red-lt); color: #dc2626; border-color: #fecaca; font-size: 11px; padding: 3px 9px; }
.btn-resign:hover { background: #fee2e2; }

/* ── 툴바 ── */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=text] { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 13px; width: 200px; font-family: inherit; outline: none; transition: border-color .15s, box-shadow .15s; background: var(--surface); }
.toolbar input[type=text]:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-100); }

/* ── 배지 ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: var(--radius-full); font-size: 11px; font-weight: 700; }
.badge-green { background: #dcfce7; color: #15803d; } .badge-gray { background: var(--gray-100); color: var(--text-2); }

/* ── 계약 카드 ── */
.contract-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--space-3); }
.contract-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); box-shadow: var(--shadow-xs); border-left: 3px solid var(--gray-200); transition: transform .12s, box-shadow .12s; }
.contract-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.contract-card.expired { border-left-color: #dc2626; background: #fffafa; }
.contract-card.pink    { border-left-color: #ec4899; background: #fdf2f8; }
.contract-card.orange  { border-left-color: #f97316; background: #fffbf5; }
.contract-card.yellow  { border-left-color: #eab308; background: #fefce8; }
.contract-card.green   { border-left-color: #22c55e; background: #f6fdf9; }
.contract-card.normal  { border-left-color: #94a3b8; background: var(--gray-50); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; gap: 8px; }
.contract-card .name { font-size: 14.5px; font-weight: 700; }
.contract-card .pos  { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.contract-card .dates { font-size: 12px; color: var(--text-2); margin-bottom: 10px; }
.dday { font-size: 13.5px; font-weight: 700; white-space: nowrap; padding: 4px 10px; border-radius: var(--radius-full); }
.dday.expired { color: #dc2626; background: #fee2e2; }
.dday.pink    { color: #ec4899; background: #fce7f3; }
.dday.orange  { color: #ea580c; background: #ffedd5; }
.dday.yellow  { color: #a16207; background: #fef9c3; }
.dday.green   { color: #15803d; background: #dcfce7; }
.dday.normal  { color: #64748b; background: var(--gray-100); }
.urgency-tag { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-sm); margin-bottom: 8px; letter-spacing: 0.3px; }
.urgency-tag.expired { background: #fee2e2; color: #dc2626; }
.urgency-tag.pink    { background: #fce7f3; color: #be185d; }
.urgency-tag.orange  { background: #ffedd5; color: #c2410c; }
.urgency-tag.yellow  { background: #fef9c3; color: #92400e; }
.urgency-tag.green   { background: #dcfce7; color: #15803d; }
.urgency-tag.normal  { background: var(--gray-100); color: #64748b; }
.card-actions { border-top: 1px solid var(--gray-100); padding-top: 10px; display: flex; gap: 6px; }
.btn-renew { flex: 1; }
.alert-item.urgency-expired { background:#fee2e2; color:#dc2626; }
.alert-item.urgency-pink    { background:#fce7f3; color:#be185d; }
.alert-item.urgency-orange  { background:#ffedd5; color:#c2410c; }
.alert-item.urgency-yellow  { background:#fef9c3; color:#a16207; }

/* ── 비상연락망 ── */
.contact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-3); }
.contact-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; box-shadow: var(--shadow-xs); display: flex; align-items: center; gap: 12px; min-width: 0; }
.contact-card .avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--blue-lt); color: var(--blue); display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; flex-shrink: 0; }
.contact-card .info { flex: 1; min-width: 0; }
.contact-card .info .pos { font-size: 11px; color: var(--text-3); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-card .info .name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-card .info .phone { font-size: 12px; color: var(--blue); margin-top: 2px; word-break: keep-all; white-space: nowrap; }
.contact-card .card-actions { border: none; padding: 0; display: flex; gap: 5px; flex-shrink: 0; }
.contact-card .btn-sm { width: 34px; height: 30px; padding: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.contact-card .btn-del { color: #dc2626; border-color: #fecaca; background: var(--red-lt); }
.contact-card .btn-del:hover { background: #fee2e2; }

/* ── 모달 ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15,18,26,.5); z-index: 1000; align-items: center; justify-content: center; padding: var(--space-4); }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); padding: 26px; width: 560px; max-width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal.modal-sm { width: 420px; }
.modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 18px; letter-spacing: -0.01em; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.field input, .field select { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; outline: none; transition: border-color .15s, box-shadow .15s; background: var(--surface); }
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-100); }
.field input[readonly] { background: var(--gray-50); color: var(--text-2); }
.field input[type=time] { cursor: pointer; }
.field.full-width { grid-column: 1 / -1; }
.jumin-input { letter-spacing: 1.5px; font-family: monospace; font-size: 14px !important; }
.required { color: var(--red); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; align-items: center; }
.modal-info { background: var(--gray-50); border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 12px; }
.modal-info .row, .renew-info .row { display: flex; gap: 8px; margin-bottom: 6px; font-size: 13px; align-items: center; }
.modal-info .row .lbl, .renew-info .row .lbl { color: var(--text-2); min-width: 80px; }
.renew-info { background: var(--gray-50); border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 4px; }
.section-label { font-size: 12px; font-weight: 700; color: var(--text-2); margin: 12px 0 8px; }
.leave-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.leave-chip { padding: 4px 10px; background: var(--blue-lt); color: var(--blue); border-radius: var(--radius-full); font-size: 12px; }
.note-box { margin-top: 12px; font-size: 12px; color: var(--text-2); background: var(--gray-50); padding: 10px; border-radius: var(--radius-sm); line-height: 1.6; }

/* ── 급여 ── */
.salary-total { background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%); color: #fff; border-radius: var(--radius-lg); padding: 20px 24px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow-md); }
.salary-total .lbl { font-size: 13px; opacity: .85; }
.salary-total .amount { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }

/* ── 요일 선택기 ── */
.day-selector { display: flex; gap: 6px; flex-wrap: wrap; }
.day-btn { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; font-family: inherit; color: var(--text-2); }
.day-btn:hover { border-color: var(--blue); color: var(--blue); }
.day-btn.selected { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ── 색상 스와치 ── */
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: transform .15s, border-color .15s; flex-shrink: 0; }
.swatch:hover { transform: scale(1.15); }
.swatch.selected { border-color: #fff; box-shadow: 0 0 0 3px var(--blue-dk); }
.swatch-custom { display: flex; align-items: center; justify-content: center; background: var(--gray-100); font-size: 14px; }

/* ══════════════════════════════════════
   시간표 그리드
══════════════════════════════════════ */
.schedule-card { padding-bottom: 24px; }
.schedule-subtitle { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.schedule-wrap { overflow-x: auto; margin-top: 4px; }
.schedule-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.sch-table { border-collapse: collapse; min-width: 700px; width: 100%; table-layout: fixed; }
.sch-table th { background: var(--gray-50); border: 1px solid var(--border); padding: 10px 6px; text-align: center; font-size: 12.5px; font-weight: 700; color: var(--text-2); position: sticky; top: 0; z-index: 2; text-transform: none; letter-spacing: 0; }
.sch-table th.time-th { width: 70px; color: var(--text-3); font-weight: 600; font-size: 12px; }
.sch-table th.day-th { color: var(--text); }
.sch-table th.day-th.weekend { color: #2563eb; }
.sch-table td { border: 1px solid var(--gray-100); vertical-align: top; padding: 4px; min-height: 40px; }
.sch-table td.time-cell { text-align: center; font-size: 12px; color: var(--text-3); font-weight: 600; white-space: nowrap; background: var(--gray-50); vertical-align: middle; }
.sch-table td.day-cell { cursor: pointer; transition: background .1s; }
.sch-table td.day-cell:hover { background: #f0f7ff; }

.class-block { display: block; padding: 5px 8px; border-radius: 6px; margin-bottom: 3px; cursor: pointer; border-left: 3px solid; transition: filter .15s, transform .1s; min-width: 0; }
.class-block:hover { filter: brightness(0.93); transform: translateX(1px); }
.class-block:last-child { margin-bottom: 0; }
.class-block .cb-name { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.class-block .cb-sub { font-size: 10px; opacity: 0.8; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cell-add-btn { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: transparent; border: 1px dashed #cbd5e1; color: #94a3b8; font-size: 14px; cursor: pointer; opacity: 0; transition: opacity .15s, background .15s; margin: 2px auto 0; line-height: 1; }
.day-cell:hover .cell-add-btn { opacity: 1; }
.cell-add-btn:hover { background: var(--blue-lt); border-color: var(--blue); color: var(--blue); }

/* ── 스크롤바 ── */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ====================================
   대시보드
==================================== */
.dash-kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin-bottom: var(--space-5); }
.kpi-val { font-size: 34px; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -0.02em; }
.kpi-val.kpi-warn { color: #dc2626; }
.kpi-lbl { font-size: 13px; font-weight: 600; margin-top: 6px; color: var(--text); }
.kpi-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.dash-main-grid { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(280px, 1fr); gap: var(--space-4); align-items: start; }
.dash-side { display: flex; flex-direction: column; gap: var(--space-4); }

.dash-today-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.dash-sch-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--gray-50); border-radius: var(--radius-sm); font-size: 13px; }
.dash-sch-item .sch-time { font-size: 12px; font-weight: 700; color: var(--text-2); min-width: 44px; flex-shrink: 0; }
.dash-sch-item .sch-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dash-sch-item .sch-name { font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-sch-item .sch-sub { font-size: 11px; color: var(--text-3); white-space: nowrap; padding-left: 4px; }

.dash-db-desc { font-size: 12px; color: var(--text-2); margin: 0 0 10px; }
.dash-db-btns { display: flex; flex-direction: column; gap: 8px; }
.dash-db-note { font-size: 11px; color: var(--text-3); margin: 8px 0 0; }

.sub-note { font-size: 11px; font-weight: 400; color: var(--text-3); margin-left: 4px; }
.day-label { font-size: 13px; font-weight: 400; color: var(--text-3); }
.empty { text-align: center; color: var(--text-3); padding: 24px 0; font-size: 13px; }
.leave-empty { color: var(--text-3); font-size: 13px; margin: 0; }

/* ─── 순서 변경 버튼 ──────────────────────────────── */
.order-cell { white-space: nowrap; padding: 4px 6px !important; }
.btn-order { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 18px; padding: 0; background: var(--gray-100); border: 1px solid var(--border); border-radius: 3px; font-size: 9px; color: var(--text-2); cursor: pointer; line-height: 1; transition: background 0.15s, color 0.15s; }
.btn-order:hover { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-order:active { transform: scale(0.9); }
.btn-order-up { margin-bottom: 2px; }

/* ─── 연차 추가 폼 ────────────────────────────────── */
.leave-add-form { display: flex; align-items: center; gap: 6px; padding: 10px 12px; background: var(--blue-lt); border: 1.5px solid #bfdbfe; border-radius: var(--radius-md); margin-bottom: 10px; }
.leave-add-form input[type="date"], .leave-add-form input[type="number"] { height: 32px; padding: 4px 8px; border: 1.5px solid #93c5fd; border-radius: var(--radius-sm); font-size: 13px; background: var(--surface); }
.leave-add-form input[type="number"] { width: 68px; }

/* ─── 삭제 버튼 (danger) ──────────────────────────── */
.btn-danger { background: var(--surface); border: 1.5px solid #fca5a5; color: #dc2626; padding: 5px 12px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.btn-danger:hover { background: #dc2626; color: #fff; border-color: #dc2626; }

/* ─── 연차칩 삭제 ✕ 버튼 ──────────────────────────── */
.btn-chip-del { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; padding: 0; background: transparent; border: none; font-size: 11px; color: var(--text-3); cursor: pointer; border-radius: 50%; line-height: 1; margin-right: 3px; vertical-align: middle; transition: all 0.12s; }
.btn-chip-del:hover { background: #dc2626; color: #fff; }
.leave-chip { display:inline-flex; align-items:center; }

/* ══════════════════════════════════════
   로그인 화면
══════════════════════════════════════ */
.login-screen { display: none; position: fixed; inset: 0; z-index: 2000; background: radial-gradient(circle at 20% 20%, #1e2536 0%, #0d0f16 70%); align-items: center; justify-content: center; padding: var(--space-4); }
.login-screen.open { display: flex; }
.login-box { background: var(--surface); border-radius: var(--radius-lg); padding: 36px 32px; width: 340px; max-width: 100%; box-shadow: var(--shadow-lg); }
.login-logo { font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.5; text-align: center; }
.login-sub { font-size: 12px; color: var(--text-3); text-align: center; margin: 6px 0 22px; }
.login-error { background: var(--red-lt); color: #dc2626; font-size: 12px; padding: 8px 10px; border-radius: var(--radius-sm); margin-bottom: 12px; }
.pw-force-note { font-size: 12px; color: #dc2626; margin-bottom: 12px; }

/* ── 계정 관리 ── */
.user-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.user-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; background: var(--gray-50); padding: 7px 10px; border-radius: var(--radius-sm); }
.user-add-form { display: flex; gap: 6px; }
.user-add-form input { flex: 1; min-width: 0; padding: 7px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; font-family: inherit; }

/* ══════════════════════════════════════════════════════
   반응형: Tablet (768–1023px) — 사이드바 → 아이콘 레일
══════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  #sidebar { width: var(--sidebar-w-rail); }
  #sidebar .logo { padding: 18px 8px 14px; text-align: center; }
  #sidebar .logo h1 { display: none; }
  #sidebar .logo::after { content: '🏢'; font-size: 22px; }
  #sidebar .logo small { display: none; }
  #sidebar nav a { justify-content: center; padding: 11px 6px; }
  #sidebar nav a .lbl { display: none; }
  #sidebar nav a .nav-badge { position: absolute; top: 2px; right: 2px; margin-left: 0; }
  .btn-sidebar { justify-content: center; padding: 10px 4px; }
  .btn-sidebar .lbl { display: none; }
  .sidebar-footer .version { display: none; }

  .dash-main-grid { grid-template-columns: 1fr; }
  .dash-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════
   반응형: Mobile (<768px) — 오프캔버스 드로어 + 하단 탭바
══════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  /* ── 구조적 스크롤 수정 ──────────────────────────────
     데스크톱은 body를 100vh로 고정하고 #content 내부만 스크롤하는 "앱 셸" 패턴을 쓴다.
     이 패턴은 모바일 Safari/Chrome에서 중첩된 스크롤 컨테이너가 터치 스크롤을 받지 못하거나
     주소창이 자동으로 접히지 않는 문제를 일으킨다(iOS는 body/document 자체가 스크롤될 때만
     주소창을 자동으로 숨긴다). 그래서 모바일에서는 앱 셸을 풀고 문서 자체가 스크롤되는
     일반적인 모바일 웹 레이아웃으로 전환한다. */
  html { height: auto; }
  body {
    display: block; height: auto; min-height: 100vh; min-height: 100dvh;
    overflow-x: hidden; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #main { display: block; height: auto; overflow: visible; }
  #topbar { position: sticky; top: 0; z-index: 120; }
  #content { overflow: visible; height: auto; }

  .hamburger-btn { display: flex; width: 44px; height: 44px; }

  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 260px; max-width: 82vw;
    transform: translateX(-100%); box-shadow: var(--shadow-lg);
  }
  /* #sidebar의 열림 transform은 app.js에서 인라인 스타일로 직접 제어한다 */
  #app-shell.drawer-open .drawer-backdrop { display: block; }
  #sidebar .logo h1 { display: block; }
  #sidebar .logo::after { content: none; }
  #sidebar .logo small { display: block; }
  #sidebar nav a { justify-content: flex-start; padding: 12px; min-height: 44px; }
  #sidebar nav a .lbl { display: inline; }
  .btn-sidebar { justify-content: flex-start; padding: 10px 12px; min-height: 44px; }
  .btn-sidebar .lbl { display: inline; }
  .sidebar-footer .version { display: block; }

  #topbar { padding: 0 var(--space-4); }
  #topbar .date { display: none; }
  #content { padding: var(--space-4); padding-bottom: calc(var(--bottom-nav-h) + var(--space-6)); }

  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: var(--bottom-nav-h);
    background: var(--surface); border-top: 1px solid var(--border); z-index: 150;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 10px rgba(16,24,40,.06);
  }
  .bn-link {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-decoration: none; color: var(--text-3); font-size: 10px; font-weight: 600; position: relative;
    min-width: 0; min-height: 48px;
  }
  .bn-link .icon { font-size: 18px; }
  .bn-link .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .bn-link.active { color: var(--blue); }
  .bn-link .nav-badge { position: absolute; top: 2px; right: calc(50% - 20px); }

  .dash-kpi-row { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
  .dash-main-grid { grid-template-columns: 1fr; }
  .contract-grid, .contact-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .modal {
    padding: 20px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; width: 100%;
    max-height: 92vh; max-height: 92dvh; align-self: flex-end;
  }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .toolbar input[type=text] { width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar > div { display: flex; }
  .card { padding: var(--space-4); }

  /* 터치 영역 최소 44px 확보 + iOS 자동 확대 방지(입력창 폰트 16px 미만이면 포커스 시 확대됨) */
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-sm { min-height: 40px; padding: 8px 12px; }
  .contact-card .btn-sm { width: 40px; height: 40px; }
  .day-btn { width: 44px; height: 44px; }
  .swatch { width: 36px; height: 36px; }
  .btn-order { width: 30px; height: 26px; font-size: 11px; }
  input, select, textarea { font-size: 16px !important; }
  .jumin-input { font-size: 16px !important; }

  /* 테이블 → 카드 뷰 */
  .tbl-wrap table, .tbl-wrap thead, .tbl-wrap tbody, .tbl-wrap th, .tbl-wrap td, .tbl-wrap tr { display: block; }
  .tbl-wrap thead { display: none; }
  .tbl-wrap tbody tr {
    margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 4px 12px; background: var(--surface);
  }
  .tbl-wrap tbody td {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 0; border-bottom: 1px solid var(--gray-100); text-align: right; font-size: 13px;
    flex-wrap: wrap; overflow-wrap: anywhere;
  }
  .tbl-wrap tbody td:last-child { border-bottom: none; }
  .tbl-wrap tbody td::before {
    content: attr(data-label); font-weight: 600; color: var(--text-3); font-size: 11.5px;
    text-align: left; flex-shrink: 0;
  }
  .tbl-wrap tbody td.order-cell { justify-content: center; gap: 12px; }
  .tbl-wrap tbody td.order-cell::before { content: none; }
}

/* 아주 좁은 화면(≤380px) 하단 탭 라벨 축소 */
@media (max-width: 380px) {
  .bn-link .lbl { font-size: 9px; }
}
