:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f4f6fb;
  --sidebar-bg: #111827;
  --sidebar-active: #1f2937;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --gray: #6b7280;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { text-decoration: none; color: inherit; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
}

.login-box {
  background: var(--card-bg);
  padding: 40px;
  border-radius: 12px;
  width: 340px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.login-box h1 {
  font-size: 20px;
  margin: 0 0 4px;
  text-align: center;
}

.login-box p.sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}

.login-box input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.login-box button {
  width: 100%;
  padding: 10px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.login-box button:hover { background: var(--primary-dark); }

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 10px;
  min-height: 16px;
}

.login-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

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

.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: #d1d5db;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  padding: 20px 18px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid #1f2937;
  font-size: 15px;
}

.sidebar nav {
  flex: 1;
  padding: 10px 0;
}

.sidebar nav a {
  display: block;
  padding: 12px 20px;
  font-size: 14px;
  color: #d1d5db;
}

.sidebar nav a:hover { background: var(--sidebar-active); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }

.sidebar .logout {
  padding: 16px 20px;
  border-top: 1px solid #1f2937;
  font-size: 13px;
}

.main {
  flex: 1;
  padding: 24px 32px;
  overflow-x: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.topbar h2 { margin: 0; font-size: 20px; }
.topbar .user-chip { font-size: 13px; color: var(--text-muted); }

/* ---------- Cards / widgets ---------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

.summary-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.summary-card:hover {
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
  transform: translateY(-1px);
}

.summary-card .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}
.summary-card .value { font-size: 28px; font-weight: 700; line-height: 1; }
.summary-card.alert .value { color: var(--danger); }

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  align-items: stretch;
}

@media (max-width: 1000px) {
  .panel-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  display: flex;
  flex-direction: column;
}

.panel h3 {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.chart-box {
  position: relative;
  width: 100%;
  height: 220px;
}

.chart-box.chart-box-wide { height: 200px; }

.panel .chart-box { margin: 0 auto; }

.alert-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.alert-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}
.alert-list li:last-child { border-bottom: none; }
.alert-list .tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  color: #fff;
  background: var(--danger);
}
.alert-list .tag.warn { background: var(--warning); }
.alert-empty { color: var(--text-muted); font-size: 13px; padding: 8px 0; }

/* ---------- Table ---------- */
.table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f9fafb; color: var(--text-muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar .filters { display: flex; gap: 8px; }
.toolbar select, .toolbar input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

.btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: none;
  font-size: 13px;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #6b7280; }
.btn.secondary:hover { background: #4b5563; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 12px; margin-right: 4px; }

.badge { padding: 3px 9px; border-radius: 10px; font-size: 12px; color: #fff; display: inline-block; }
.badge.active, .badge.정상, .badge.재직 { background: var(--success); }
.badge.suspended, .badge.휴직, .badge.주의 { background: var(--warning); }
.badge.expired, .badge.퇴사, .badge.위험 { background: var(--danger); }
.badge.revoked, .badge.중지 { background: var(--gray); }

.access-yes { color: var(--success); font-weight: 700; }
.access-no { color: var(--danger); font-weight: 700; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: 10px; padding: 24px; width: 420px; max-width: 90vw;
  max-height: 85vh; overflow-y: auto;
}
.modal h3 { margin-top: 0; }
.modal label { display: block; font-size: 12px; color: var(--text-muted); margin: 10px 0 4px; }
.modal input, .modal select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- Employee dashboard ---------- */
.employee-wrap {
  max-width: 480px;
  margin: 40px auto;
  padding: 0 16px;
}

.greeting { font-size: 18px; margin-bottom: 20px; }

.id-card {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
}

.id-card .card-title { font-size: 13px; opacity: 0.8; margin-bottom: 14px; }
.id-card .card-number { font-size: 20px; font-weight: 700; letter-spacing: 1px; margin-bottom: 18px; }
.id-card .card-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.id-card .status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #4ade80; margin-right: 6px; }
.id-card .status-dot.off { background: #f87171; }

.area-list { list-style: none; padding: 0; margin: 0; }
.area-list li {
  display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.area-list li:last-child { border-bottom: none; }
