:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #eff6ff;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #2563eb;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --info-light: #cffafe;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  color: #e2e8f0;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform 0.25s ease;
}
.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand h1 { font-size: 17px; font-weight: 700; color: #fff; }
.sidebar-brand p { font-size: 12px; color: #94a3b8; margin-top: 2px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: #64748b; padding: 14px 12px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 8px;
  color: #cbd5e1; font-size: 14px; cursor: pointer;
  margin-bottom: 2px; transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-item i { width: 18px; text-align: center; font-size: 15px; }
.nav-item .badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600;
}
.sidebar-footer {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px; color: #94a3b8;
}

/* Main */
.main { flex: 1; margin-left: 250px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 60px; display: flex; align-items: center;
  gap: 16px; position: sticky; top: 0; z-index: 50;
}
.topbar h2 { font-size: 18px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text); }

.role-switch {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border-radius: 8px; padding: 4px;
}
.role-switch button {
  border: none; background: none; padding: 6px 12px; border-radius: 6px;
  font-size: 13px; cursor: pointer; color: var(--text-muted); font-weight: 500;
}
.role-switch button.active { background: var(--primary); color: #fff; }

.user-chip {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  padding: 6px 12px; background: var(--bg); border-radius: 20px;
}
.user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px;
}

.content { padding: 24px; flex: 1; }

/* Cards */
.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-header h3 { font-size: 15px; font-weight: 700; }
.card-header .spacer { flex: 1; }
.card-body { padding: 20px; }
.card-body.no-pad { padding: 0; }

/* Stat cards */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.stat-info .stat-label { font-size: 13px; color: var(--text-muted); }
.stat-info .stat-value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat-info .stat-sub { font-size: 12px; color: var(--text-muted); }

.i-blue { background: var(--primary-light); color: var(--primary); }
.i-green { background: var(--success-light); color: var(--success); }
.i-orange { background: var(--warning-light); color: var(--warning); }
.i-red { background: var(--danger-light); color: var(--danger); }
.i-cyan { background: var(--info-light); color: var(--info); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 9px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Filters */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; background: #fff; min-width: 120px;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.field textarea { resize: vertical; min-height: 60px; }


.select-inline {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--text);
}
.field label small { color: var(--warning); font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th, table.data td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th {
  background: #f8fafc; font-weight: 600; color: var(--text-muted);
  font-size: 12px; position: sticky; top: 0;
}
table.data tbody tr:hover { background: #f8fafc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 700; background: #f8fafc; border-top: 2px solid var(--border); }

/* Badges */
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 12px;
  font-size: 12px; font-weight: 600;
}
.tag-green { background: var(--success-light); color: var(--success); }
.tag-red { background: var(--danger-light); color: var(--danger); }
.tag-orange { background: var(--warning-light); color: var(--warning); }
.tag-gray { background: #e2e8f0; color: #475569; }
.tag-blue { background: var(--primary-light); color: var(--primary); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 200; padding: 40px 16px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow-md); animation: pop 0.15s ease;
}
.modal.lg { max-width: 780px; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-header .close { margin-left: auto; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .field input, .form-grid .field select, .form-grid .field textarea { width: 100%; min-width: 0; }

/* Empty state */
.empty {
  padding: 48px 20px; text-align: center; color: var(--text-muted);
}
.empty i { font-size: 36px; opacity: 0.4; margin-bottom: 12px; display: block; }

/* Toast */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #1e293b; color: #fff; padding: 12px 18px; border-radius: 8px;
  box-shadow: var(--shadow-md); font-size: 13px; display: flex; align-items: center; gap: 10px;
  animation: slidein 0.2s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Calendar */
.calendar {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.cal-head {
  text-align: center; font-weight: 700; font-size: 12px; color: var(--text-muted);
  padding: 8px 0;
}
.cal-head.sun { color: var(--danger); }
.cal-head.sat { color: var(--primary); }
.cal-cell {
  min-height: 92px; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 8px; background: #fff; display: flex; flex-direction: column; gap: 4px;
}
.cal-cell.empty-cell { background: transparent; border: none; }
.cal-cell.weekend { background: #f8fafc; }
.cal-cell.holiday { background: var(--danger-light); }
.cal-date { font-size: 13px; font-weight: 600; }
.cal-cell.weekend .cal-date { color: var(--text-muted); }
.cal-holiday-name { font-size: 11px; color: var(--danger); font-weight: 600; }
.cal-assignee {
  margin-top: auto; font-size: 12px; background: var(--primary-light);
  color: var(--primary); padding: 3px 6px; border-radius: 6px; font-weight: 600;
  cursor: pointer; text-align: center;
}
.cal-assignee.changed { background: var(--warning-light); color: var(--warning); }

/* Notice list */
.notice-item {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.notice-item:last-child { border-bottom: none; }
.notice-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.notice-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.notice-body { font-size: 13px; margin-top: 8px; color: #334155; white-space: pre-wrap; }

.admin-only { display: none; }
body.role-admin .admin-only { display: inline-flex; }
body.role-admin tr .admin-only.cell { display: inline-flex; }

.pill-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.pill-legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .form-grid { grid-template-columns: 1fr; }
}

/* 관리자 확인 전용 입력영역 */
.admin-confirm-field { display: none; }
body.role-admin .admin-confirm-field { display: flex; }
